I've managed to get individual arrays to save to a .txt file, but am trying to save multiple arrays of varying lengths in an abstraction. So when I load up a .txt file it will load the length of the array also. I think it's something really simple, but I just can't crack it, I've been trying all day and getting very frustrated! I think I get the basics of [textfile], but am finding the help file for the [text] object quite confusing... have tried combining everything into lists (below), but struggling to get that to save in a .txt file. Any help would be greatly appreciated!
-
Saving multiple arrays to .txt file
-
@RT-Chris Maybe save them as audio files..... "wav"...... using [writesf~] and then load them with [soundfiler] with a -resize message?
I suppose you would have to stay within the value range -1 to 1 but you could scale that before and after.
Don't try to play the file as audio though......
I am sure it can be done with [text] though and someone will help...... but I am not absolutely joking......
David. -
@whale-av Thanks David. I have .wav's working also, but was under the impression they can cause audio dropping when loading or changing them, so figured .txt would be more efficient (although I haven't actually experienced audio dropping yet tbh, just trying to anticipate bigger files in the future!). Maybe for such short arrays wav's are okay though!
-
@RT-Chris This is how it can be done with [text]:
-
@ingox Thank you so much!! Have it working and have updated it to allow multiple saves as separately numbered array files.
Although it's working perfectly, I think I still don't fully understand what's happening with the buffer. The only differentiation in the .txt file seems to be the semi-colon, does that carriage break occur when the list number is changed? Does the saved text discount the rest of the buffer size when it is set @1e+06? I have other values I was using savestate to also save, but maybe I can force them into some kind of arbitrary array that can be included as a third array also, would be great to keep them all together.
Anyway, much appreciated. I need to learn a lot more about [text] but this has really helped for now.
-
Realised the patch I just posted for multiple array saves of varying sizes didn't adjust the arrays sizes when they were loaded, so have amended that now for anyone searching in the future (didn't realise the order of setting the array size should come first). The patch currently loads the length of the first array, but this can be adapted.
Combining Arrays_MultipleSaves.pd
-
@RT-Chris Yes, i forgot setting the array size. See here: savearrays.pd.
[text set highnumber] just adds the line to the end of the text. Doesn't matter if it is 1000000 or 100000000.
It adds a line and the semicolon marks the end of the line. So each array in one line of the text and reverse. No magic here. -
@RT-Chris [savestate] is very similar to [text] in that it just saves lists in lines.
You can as well put other values in then lists from arrays. I would prepend the values / lists by a signifier and use [route] to sort them afterwards.
-
@ingox Brilliant, thanks so much for clarifying and all your help with this. Good to know that's how savestate works, I was using it before, but needed the arrays to be dynamically sized (which I'm sure is possible), but this has allowed me to see how those lists are constructed, which for me is a big part of working with Pure data. Will explore the Route object in the future, I've seen it in quite a few of others patches, and looks useful once lists start scaling up.
-
@RT-Chris Here is an example for [savestate] using [route] to sort the values (in the subpatch): savestate_demo2.zip. You can use the same method with [text].