Forums > MaxMSP

list / text files and numbers – beginner

July 27, 2013 | 5:00 am

Ok,
I have been experimenting a little more. I have many questions but will try to keep things straight to the necessary.

My goal is to be able to import text files with numbers and plot them in various ways, similarly to what I was used to do with OpenDX.

Moving data into Max is very different from what I am used to do, so few issues came out:

-1- how to eliminate white lines / blank end lines from a list? I am trying to be error safe so checking all files may be an issue and I would prefer Max to do this. Do I need to use Javascript?

-2- I am using ‘thresh’ to create a list from ‘text’. How to I change the max size of 256? interestingly ‘average’ sees the full text, is this a bug?

-3- when I have ‘text’e dumping the data I get the ‘set’ word for each line. I found that using ‘route set’ takes that away. But why? And if I use ‘prepend set’ the print does not happen.

Could anybody with more experience help? Much appreciated :-)
See below the simple map.
Thanks
G>

<code>

– Pasted Max Patch, click to expand. –

</code>


July 27, 2013 | 11:39 am

A few thoughts:

-1- how to eliminate white lines / blank end lines from a list? I am trying to be error safe so checking all files may be an issue and I would prefer Max to do this. Do I need to use Javascript?

No, you can put the line through [zl len] and if it’s 0, there’s nothing there, so skip it (or do whatever you want when you encounter a blank line). The [zl] help file has a ton of modes which will help you down the road I’m sure, so take some time to see what you can do with lists…a LOT, and IMO, often much easier to use than code-based approaches.

-2- I am using ‘thresh’ to create a list from ‘text’. How to I change the max size of 256? interestingly ‘average’ sees the full text, is this a bug?

I don’t know about using [thresh], can’t you just use the "line" message to [text]? If there are multiple values per line, look to [zl slice] or [unpack] (if you know how many there will be); if you want to group items from several lines into a list, use [zl group]. Again, the [zl] help file is your friend, and you can up the default size with a number argument: [zl 4096 group].

-3- when I have ‘text’e dumping the data I get the ‘set’ word for each line. I found that using ‘route set’ takes that away. But why? And if I use ‘prepend set’ the print does not happen.

The "set" coming from [text] is intentional, as it makes putting the lines into objects like message boxes easier (legacy message boxes had no right inlet and you needed to have "set" before the message to set them). [route set] is expected behavior, you use [route] to match the index of a list (or the first symbol in a message, as in this case) and get rid of it. The new [routepass] will keep the value at the head of the list/symbol, but still route it to the respective outlet.

Hope these help a bit!


July 27, 2013 | 2:41 pm

Definitely helpful, thanks!
I find difficult to learn Max as there is not a manual but a massive amount of tutorial, but none is really doing what I would like to, so it is a very hard job :-)

zl is really an interesting tool and I am getting there.
I have tried the ‘zl group’ approach but with no success…
see here:

<code>

– Pasted Max Patch, click to expand. –

</code>

Anyway, without the full map may be difficult to see what is the purpose of this.
See enclosed for reference.

I have been trying few things today and it looks ok as a start.
The chart is working 50%. The red dot (when you press start you read the data) follows the data, but for some weird reason is not overlapping to the line. Not sure why… may need to investigate more for this. Not a big deal for now.

The sound part is very basic as a fried of mine will develop that more later.

Once more thanks,
G>

Attachments:
  1. Archive.zip

July 27, 2013 | 5:01 pm

A couple tweaks, with comments. Especially look to [trigger] or [t], one of the most important Max objects to ensure proper order of operations (especially if doing open-ended processes like dumping [text] which could take a few moments). Also check how [zl group] is used.

Should work, but depends on what’s in your text file: does each line just have numbers? How many? etc. If there are non-numbers as well, this might cause issues. Best to clean the data beforehand for easier parsing, though there are ways to use [route] to channel overall data types:

[route int float list]

for example…this could clean up "mixed" data. ints, floats, and lists (which are lists of numbers and/or symbols that must START with a number) will get routed; the rightmost outlet will dump anything else, which in this case would be any symbols. That way you could get rid of any non-numbers in your data, if you have them.

<code>

– Pasted Max Patch, click to expand. –

</code>


July 27, 2013 | 5:50 pm

James,
thanks!
I have tried with the map, but seems not working.
The modified file is below:

<code>

– Pasted Max Patch, click to expand. –

</code>

and the text enclosed
Any ideas?
I am sure that there is something basic that is wrong, but what?
G

Attachments:
  1. test1.txt

July 29, 2013 | 11:55 am

Anybody with some suggestion?
Note that the list going to a matrix is full…
but going to a selector is not.
is this a bug?
Thanks
G


July 30, 2013 | 9:47 am

Pretty much there. Here are some ways to tweak the output list. You just needed the length argument for your [zl] objects and a bit of reordering.

<code>

– Pasted Max Patch, click to expand. –

</code>


July 30, 2013 | 2:06 pm

WOW! A lot to learn. Very kind of you of putting this together :-)
Thanks!
Thanks again,
G

Attachments:
  1. Archive1.zip

July 30, 2013 | 2:34 pm

Ok,
I think I know where the issue is.
see here:

<code>

– Pasted Max Patch, click to expand. –

</code>

The problem is with zl.mth or zl.nth.
But why?
Thanks
G


August 4, 2013 | 2:09 am

Ok,
after looking at the problem a friend of mine explained the solution.
The solution is that ALL zl commands require to set the maximum number of elements.
So for example if I use ‘zl 4096 group’ and I connect it to ‘zl len’ the value will be wrong.
It is important that all zl are 4096. So as per James example.
Thanks to James for his help, this was a great learning exercise.
G


August 4, 2013 | 1:51 pm

Glad to help. The [zl] length argument has bitten me before as well, because it works up to 256 without an argument (default length). So in some cases I had a variable length list, and it would work sometimes but not others…it would only process the first 256, which sometimes was tricky to track down… ;)


Viewing 11 posts - 1 through 11 (of 11 total)