Csound sample memory issues?

https://www.dropbox.com/s/ok0u0fhonb2x3 … k.zip?dl=0

I’ve uploaded a zip file to the dropbox link here with 5 audio tracks and
three csound files. “MyPerform.csd” is the file that executes the program.

When I launch the program its takes a long time to load the samples into the
f-tables the RPI doesnt manage to load all the files i dont think and certainly doesnt manage to playback?
The sample rates are correct. I’m not sure why this is happing, perhaps something to do
with ram? Something inefficient with the way I’m loading the samples maybe?

I’ve tested the program on OSX it it works successfully. But
on raspbian lite i get the following errors im not sure what they mean?

"memory allocate failure for 134371680

Early return from csoundPerform() "

and I’m of course running pi sound with this

Many thanks

This sounds like it tries to allocate a single 128MB memory block. It’s a lot of memory in a single block, and can easily fail, especially if paging / swap is disabled in the OS (not sure whether Raspbian Lite has it disabled by default or how large it is if it’s enabled)

The dropbox link seems broken, what are the file sizes and what is the format you’re using? If the audio files are compressed (like mp3), usually software first uncompresses the audio data into some raw audio format which can take a lot of memory.

For long duration files, it makes sense to open them in streaming mode, where only a small buffer is kept in memory for playback, and it gets updated as playback goes, so maybe there’s some alternative way you have to open samples with (I don’t know much about Csound to help you there)

What is the output of:

cat /proc/meminfo

just after trying to run your patch?

I’ll attempt the link again here (let me know if its successful?: https://www.dropbox.com/s/ok0u0fhonb2x3k2/Csoundsampleplayback.zip?dl=0

the audio are .wav files.

I’m going to try cat /proc/meminfo now

because i dont have internet on the pi i’ve typed out what i thought might be the most relevant information from meminfo:

MemTotal: 949452
MemFree: 21884
Memavailable: 11556
Buffers: 1700

Active: 441336
Inactive: 452208


interestingly i ran this script for ecasound to playback the tracks which did play the tracks back. If you have the audio files you may want to try the following:

Ecasound -c
-a1:1 -f:16,2,48000 -I Compos0002atrack1.wav
-a2:1 -f:16,2,48000 -I Compos0002atrack2.wav
-a3:1 -f:16,2,48000 -I Compos0002atrack3.wav
-a4:1 -f:16,2,48000 -I Compos0002atrack4.wav
-a5:1 -f:16,2,48000 -I Compos0002atrack5.wav
-a:all -o alsa

Theres however a little distortion happening?
Also im curious as to why ecasound can playback the audio and not csound -odac “filename”?

Looks like you only have 20MB of available RAM, the audio files themselves are ~64MB each, so they don’t really fit in memory.

Try and see which process is using that much memory.

Ecasound may be able to play if it’s using the streaming method I described before. Try searching for ‘Csound streaming player’, maybe you can find info or some sample on how to do that with Csound.

1 Like

Csound as an object (opcode) called diskin which reads from disk which should hopefully not require RAM? or as much a least…thats what ill try next