< Back to IRCAM Forum

Reading a list from a text file

Hi everyone,

I’m trying to make my rhythm trees more “legible” by writing them in a text file
but there is a strange behavior when trying to load the file opened
using the ‘infile’ and ‘File’ objects, the latter in eval-mode = list. A simple example follows.

The text file:

(?
(
(4//4 (1 1 1 1))
(3//4 (-1 1 -1))
)
)

gets evaluated by ‘File’ as:

OM => ((? ((|4//4| (1 1 1 1)) (|3//4| (-1 1 -1)))))

Note the vertical bars added, and unreadable by a voice object but I don’t think that is the issue;
when using the notation ((4 4) (1 1 1 1)) instead of (4//4 (1 1 1 1)), there is nothing added but the voice object complains with the same error:
“Error while evaluating the box VOICE : In abs of ((4 4)) arguments should be of type number”
Shouldn’t the text file be evaluated as a list (ignoring line breaks) in eval-mode = list ?
Perhaps there is another way to do this or I’m missing some fundamental concept (?)

Thanks in advance

Hi Clusters,

First of all try not to use |4//4| syntax for time signature, but instead this one (4 4). It is far more easier to work with.
In fact , |4//4| is supposed to be theoretically a fraction 4/4. But as you know once you use a fraction it will automatically be computed (in this case = 1) which is really bad for tree notation. So it has been transformed into 4//4 which is also not that great if you need to change the denom or numerator. So Better use the list syntax (4 4).

Now concerning the textfile object, yes indeed, it appends the content automatically in a list. So either, strip the first parenthesis level, or best , use car from the output of textfile. In that way you will have the correct tree.

Last but not least, you are right to use textfile to edit trees. That’s what i do since putting a tree in a numbox is really un-editable.

Your last error comes from the parenthesis problem.
So if you need to save the file I suggest to use the first method :

Writing the tree as follows :

;;;;;;;
?
(
((4 4) (1 1 1 1))
((3 4) (-1 1 -1))
)
;;;;;;
Best
K
PS: Hope i was clear. If not don’t hesitate to write back.