Open maks opened 11 months ago
So I tried looking this up and it seems there is no agreed upon standard for how many samples should be in a single cycle waveform file, but I did find this:
There is a lot of variation in the numbers of samples that are used to represent a single cycle waveform. In Max (and MaxForLive), the ~cycle object originally defaulted to using 512 samples of a single cycle of a cosine wave. But it wasn't fixed - you could replace the default waveform by using any other set of 512 samples, or you could change the number of samples: more recent versions of Max use 16,000 64-bit samples. A lot of the single cycle waveforms that you find on the InterWeb are 337 samples long, whilst others have 256, 1024, 2048 or 4096.
So given a 44 byte header for RIFF format, in the case of AKWF he used 600 samples each, so 600 * 2 + 44 = 1244 bytes so I'm not sure where the other 100 bytes comes from but I think we could just have some preset file sizes (for specific number of samples) that we could look for to determine if a file is likely a single cycle waveform?
@maks couln't the heuristic just be a sample under X ms in length?
@maks couln't the heuristic just be a sample under X ms in length?
Yes I think that will work. Actually now I think about it some more, I think something very simple like "< 2048 bytes" should probably handle all the reasonable single cycle files and then not false match on very short, lofi one-shot samples (eg. in tardline the bassdrum one-shot is 3.4kB).
Does that sound ok?
It would be nice to be able to audition single cycle files in the Import Dialog. Current behaviour is just to play samples as a single shot, streamed from the sdcard.
Instead what should happen is that single cycle files should be detected and then played back in a loop using existing code.
We need some sort of heuristic to detect single cycle files, looking at the "AKWF" collection I have they are all exactly 1344 bytes so that seems like a good starting point.
For playback, it might be a bit tight ram wise, but since all the AKWFs are only 1344 bytes, we could just load them into a ram buffer and play from there just as the lgpt code did for all samples prior to the changes that load samples now into flash on the pico.