Hello everyone,
I was wondering if anyone with more experience had a recommendation for memory management for me. I am making a synth/multi-fx unit. Probably the closest comparison would be something like the Empress Zoia, though I’m not so proud as to assume it will be anywhere near as ambitious or cool as that. Heh – but something kind of modular with both FX and synth components that can make lots of ambient weirdness for both internal synth sounds and guitar/mic inputs.
So one of the key hurdles I am currently facing is SDRAM management. SRAM runs out really quickly, and even something like the daisysp library’s reverb algorithm might need to go to SDRAM when running a full synth alongside. All audio buffers will need to go there too – so anything delay related.
I’m doing a few weird things with delay though, so there might possibly be multiple delay buffers running concurrently. For example, there could be a heavily modulated “FX” type of delay running into a more standard multi-tap delay, and all of that could be feeding into a looper buffer. That’s just an example but shows how three different delays could be running at once. I have some ideas for multiple simultaneous looper buffers too, and that could get pretty SDRAM intensive. Since I want it to be modular, at compile time I do not know how many delays will be running at a given time, nor of what type, but all of them probably need the buffers stored in SDRAM.
That brings us to the lack of dynamic memory allocation for SDRAM. I have read an earlier thread where people seemed pretty united in feeling like dynamic allocation is bad for this type of programming, and it’s not available anyway, so now I need to come up with a flexible memory system to manage this kind of modular setup. Some options:
-
Statically allocate a really large chunk of SDRAM as a general delay buffer, and write my own code to manage allocating chunks of this to various algorithms as needed. There is a lot of potential for some really ugly errors, issues with available memory fragmentation etc. Ultimately just having malloc/delete available for SDRAM in the first place would probably be a lot better than this option. This seems like a total headache.
-
Statically allocate separate buffers for various effects and only allow each effect to be used one-at-a-time. The drawback here is I am wasting a lot of memory on effects that aren’t being used and I might eventually hit limits on what type and how many algorithms I can add to the unit as the pre-allocated memory uses up all of the available SDRAM. Something like a stereo looper could eat up a lot by itself, for example. This seems both wasteful and limiting.
-
Statically allocate a number of delay buffers of fixed sizes, and “loan” them out to various effects on request. Maybe there would be three different sizes: small for stuff like chorus, detune and slapbacks; medium for typical delay type fx, and a larger one (or ones) for looper or Frippertronic type applications. So there would be three arrays storing N of each of these buffers, and if someone wants to load a certain effect, it will only succeed if one of the required buffers is available. This certainly simplifies memory management but it still wastes available memory on allocated buffers that aren’t being used, creating artificial ceilings on how many fx of a given type are available. In all it might be the most workable compromise though.
Anyways, I wasn’t sure if there were some people with experience with this kind of thing who might have some good solutions or advice for handling this situation. Maybe there is a better way to do it that I haven’t thought of?
Many thanks in advance for any advice…
-Kenji