I’ve been trying to play a sample with CSound without a frontend in multiple ways but failed. The output says this:
INIT ERROR in instr 1 (opcode diskin) line 16: diskin2: samples/snaredrum
.wav: failed to open file: Format not recognised.
from file .\main.csd (1),aRead diskin "samples/snaredrum.wav" kSpeed i
Skip iLoop 0 0 0 0 0
B 0.000 - note deleted. i1 (snare) had 0 init errors
I downloaded or played different wave and ogg files but I get the same result. Also, I copied the exact code from different tutorial but same luck. I even install Cabbage and open my csd file and still didn’t get anything. This is my code taken from the official tutorial.
I’m currently coding inside WSL NixOs although I run csound.exe from powershell to avoid setting up a pulseaudio server on Windows which is frankly a pain in the back.
Why I know this is related to samples only? Because I succesfully played a note from the osc opcode so it has to do with samples.
your output always uses the backslash. did you try to use backslash
in your own code, instead of slash?
can you play the sound files with another application?
did you install csound with libsndfile? actually when you use a
normal installer, it should be included.
instead of using diskin, you can also try to load your .wav into a
function table via GEN01, just to see if there is the same issue. you
can try this code in the global space (outside any instrument):
gitable ftgen 0,0,0,1,“samples/snaredrum.wav”,0,0,1
My output has backslashes because I’m running csound from powershell. To get sound out from Windows Subsytem Linux I would have to use routing in a weird way that never worked for me
Bingo! That was the problem. For some reason I believed that my file was ok, it actually wasn’t though.
I installed csound with the normal installer so it had to include lbsndfile
Thanks! I tried to do that with my “snaredrum.wav” sample (corrupted file) so I had the same output. Code is right sample is not
Key lesson here is to check sample file first before working with them. I did a lot of things before doing that. One of them was to install csound on my desktop computer.
Your example was really useful as well thanks for that Joachim