• Audio
  • write to and read from bela ram for preset retention

Hi, I'm designing a guitar pedal that requires some calibration without a computer being attached. When that calibration is achieved, I'd like to store it say on the SD card so that the pedal can access it next time it boots up. Is this possible? I'm using PD and a bela mini with the multichannel expander card, Cheers

I use the [text] object for this. I send a list of symbol/float to [text set], which looks for an existing [symbol/float] in a text file and either writes a new line or updates its value. [text sequence] then outputs all the values from that list and updates the respective destinations. The text file is saved and recalled on demand with dedicated buttons. I think from here it should be trivial to make selecting the text file dynamic and so using different presets, but I haven't yet implemented this.

So far, this simple system has worked well for my needs. All comments on this are much welcome!

Since it's easier to look at PD code than to explain it, here's an example:

presets.pd
2kB

    dvvi Thanks for the info. So even if the pd patch is shut down without saving, the variables are updated?

    Hi! I hope it’s useful. This implementation does not save automatically until the [write< message is sent, but one could use a [metro] to save it automatically every so often.

    5 days later

    Thanks again. I'm struggling with this a bit. I have some arrays that I'd like to tweak when running on Bela in standalone mode so that when it reboots, those tweaks are retained. I'm sure I'm missing something obvious. What I really need is a save function that works from within PD running on Bela. Is this possible?

    Try this. You have to bang the left bang when you are ready to save.
    Notes:

    • uploading a patch to Bela with a [text] object in it will break the visualisation. That won't affect the behaviour of the patch
    • write or read will cause a dropout on the audio thread, so don't do it repeatedly, but only when necessary.

    main.pd
    2kB

    Thanks for this Giulio! All I need to know now is will the text file be automatically created or do I have to insert it along with the _main file? I tried it out and can't see a txt file in the IDE