On 12/20/2022 at 10:23 AM, Ed Minchau said:
I don't think you can do that. Sure, you can VLOAD into VRAM, but PCM audio has its own register. Right now, best we can do is load into RAM and then push one byte at a time into the PCMAudio register.
For my video demos I've been breaking up the audio files into separate 1/10th of a second clips, about 2574 bytes each (can't recall the exact numbers off the top of my head). That's more than enough time for a snare, kick, or high hat (or tom, probably not enough time for a cymbal).
For about 10kb of ROM we could have samples of various drum sounds. The problem then becomes combining two or more PCM sounds that happen at the same time. Perhaps an 8 bit sample could be enough for various drum sounds, to make the necessary math faster.
Ah, so the PCM buffer is separate from VERA's VRAM? I was not aware of that. That's actually good news... although it does make it harder to use from BASIC, since it's not really possible to push data into the register fast enough:
BASIC can handle roughly 500 transactions per second to VERA, and to keep an audio buffer full, you'd need to at least match your sample rate in terms of bytes per second. I guess you could use a machine language routine to drive the PCM buffer from a RAM bank, but you'd still only fit something like 1-2 seconds of audio in there. Having said that.. perhaps that's the best way to use PCM audio from BASIC:
PCMPLAY Bank, Address, Length, [other setup parameters]
The catch would be that you can only play a sample that you can fit in memory (no streaming from disk), and if you play from a bank, then the sample must fit in one bank.