-
Notifications
You must be signed in to change notification settings - Fork 22
Description
From dan:
The current get_preset_for_preset_number returns the memorypcm_preset_t by value (i.e., 28 bytes on the stack or something). The modified code returns a pointer to struct, which is cool, except when the preset is built-in, not memorypcm, we have to expand the pcm_map_t of the built-in sample to the full memorypcm struct, which we're now going to return as a pointer. So this code has a static alloc hidden in the middle which is pulls out, fills in, and returns the address of, if you're looking at a "rom" built-in structure. This probably works, but the client gets a pointer to a structure which is really kinda temporary, valid until the next time get_preset_for_preset_number needs to use it.
Instead, we should probably have a single pcm descriptor which is used for both memorypcm and built-in presets i.e. we make pcm_map_t the same as memorypcm_preset_t. This will involve some kind of run-time setup so the current offset value can be added to the base of the pcm[] array set up in pcm_samples_* to get an actual pointer to a memory location. Maybe write this up as an issue so we can come back and clean it up in the future?