save multiline text in preset

For general discussion related FlowStone
User avatar
gvalletto
Posts: 117
Joined: Fri Jul 09, 2010 10:15 pm
Location: Argentina
Contact:

save multiline text in preset

Post by gvalletto »

Hi all,
I want to save multiline text in preset, for example:

hello,
how are You,
I´m Gustavo


Whether I use the typical Preset Manager to save that text and then I load it on another preset, I will view only:

hello,


... although the whole text is saved in the preset text file. I saw that the cause is that the syntax of the preset files implies that the usage of Carriage Return/Line Feed is interpreted as "end of preset".
Here is attached a scheme.
save multiline text in preset.fsm
(31.35 KiB) Downloaded 1116 times

Any idea to solve it?
tulamide
Posts: 2714
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Re: save multiline text in preset

Post by tulamide »

The VST preset definition doesn't allow texts to be stored. You can have a string of 255 ASCII characters, that's all. So the only way to deal with it is to store the (preferably relative) path to a text file and then load the text from that file after the preset is loaded.
"There lies the dog buried" (German saying translated literally)
User avatar
Spogg
Posts: 3368
Joined: Thu Nov 20, 2014 4:24 pm
Location: Birmingham, England
Contact:

Re: save multiline text in preset

Post by Spogg »

Yes indeed! You can’t have a carriage return (new line).

The reason is the way FS stores the preset text string in the preset text file. If you open the preset in notepad you’ll see the carriage return causes the string to be saved with the text after the CR on a new line. Then when you try to reload it, the text file is parsed and the text on the new line is interpreted as a new preset parameter.

It might be possible for someone with excellent Ruby skills to substitute the text string with an allowed character (for the CR) then replace it when loaded, to re-insert the carriage return.

Now, if only we knew somebody who was good with Ruby… ;)

Cheers

Spogg
User avatar
gvalletto
Posts: 117
Joined: Fri Jul 09, 2010 10:15 pm
Location: Argentina
Contact:

Re: save multiline text in preset

Post by gvalletto »

Spogg wrote:Yes indeed! You can’t have a carriage return (new line).

The reason is the way FS stores the preset text string in the preset text file. If you open the preset in notepad you’ll see the carriage return causes the string to be saved with the text after the CR on a new line. Then when you try to reload it, the text file is parsed and the text on the new line is interpreted as a new preset parameter.

It might be possible for someone with excellent Ruby skills to substitute the text string with an allowed character (for the CR) then replace it when loaded, to re-insert the carriage return.

Now, if only we knew somebody who was good with Ruby… ;)

Cheers

Spogg


Hi Spogg!
Yes, I have tried using the primitives "find" and "replace" but these only work with the first character found. In that case I can only use 1 carriage return ...
User avatar
gvalletto
Posts: 117
Joined: Fri Jul 09, 2010 10:15 pm
Location: Argentina
Contact:

Re: save multiline text in preset

Post by gvalletto »

tulamide wrote:The VST preset definition doesn't allow texts to be stored. You can have a string of 255 ASCII characters, that's all. So the only way to deal with it is to store the (preferably relative) path to a text file and then load the text from that file after the preset is loaded.


Hi Tulamide,
I already made a scheme that uses separated text files, but I don´t like it because it is too much complex. A lot of primitives (I am not use Ruby), and it is more complex whether I save/load banks or when I implement the "copy-paste" feature to the Preset Manager...
it would be very simple and solid to replace characters as Spogg says, but I do not find a method for a multiple replacement, that is, throughout the text, not just the first character found.
tulamide
Posts: 2714
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Re: save multiline text in preset

Post by tulamide »

It is not as easy as you think. The preset format only allows for a C-string. A string is not a text. It is a chain of 255 human-readable characters terminated by a NULL byte. No control chars are possible in such a string, not only CR or NL, but also TAB, print and others.

The only way to fake a text into a string therefore is to remove all control chars. Which then ends in the issue you described (which is that they are interpreted if not removed). Another possibility would be to use a human-readable char as a NL indicator, but that would reduce the usable number of chars for the text. For example, if you'd use a space " " as indicator, you couldn't write normal sentences, butonlysuchsnakesofchars. Also, the text is not allowed to exceed the 255 chars limit. That makes them short notices at most (less than 2 Tweets on Twitter). I really think the external text file solution is the best.
"There lies the dog buried" (German saying translated literally)
Youlean
Posts: 176
Joined: Mon Jun 09, 2014 2:49 pm

Re: save multiline text in preset

Post by Youlean »

Can you save array in preset? (Haven't used a Flowstone for a while). If so, just cast every char to int and save is as int array...
User avatar
Spogg
Posts: 3368
Joined: Thu Nov 20, 2014 4:24 pm
Location: Birmingham, England
Contact:

Re: save multiline text in preset

Post by Spogg »

Youlean wrote:Can you save array in preset? (Haven't used a Flowstone for a while). If so, just cast every char to int and save is as int array...


I also thought about that. No, really!! :lol:

Arrays in presets can be HUGE, like every wavetable entry for an oscillator for example. So it would be a matter of conversion both ways from and to ASCII.
Sounds like a task for Ruby...

Cheers

Spogg
tulamide
Posts: 2714
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Re: save multiline text in preset

Post by tulamide »

Youlean wrote:Can you save array in preset? (Haven't used a Flowstone for a while). If so, just cast every char to int and save is as int array...
That also is not a solution. While you can indeed save an array in a preset, it again is limited. This time to a single precision float and only in the range 0-1. So, even if you'd convert the ints to floats in that range, due to the imprecise single precision floats it would come to decryption errors.

As I said, external text files are the only serious option. And by automating the saving and loading whenever a preset is saved/loaded, there isn't really a drawback.
"There lies the dog buried" (German saying translated literally)
adamszabo
Posts: 667
Joined: Sun Jul 11, 2010 7:21 am

Re: save multiline text in preset

Post by adamszabo »

The easiest and most simplest solution is to convert your multiline string to hexadecimal then convert it back. The problem is that the string preset only holds 255 (i think) characters and you can only write a small description, but it does the job
Attachments
preset text.fsm
(7.07 KiB) Downloaded 1073 times
Post Reply