Cabbage Logo
Back to Cabbage Site

How to load a .wav file by code

Using the example of “Grain3FilePlayer.csd”
I just want to load the .wav file from code, so when the "“Grain3FilePlayer.csd” starts to have it preloaded. (and after I can change it if I want and Load a new one).
What I am missing? Thank you in advance.

I just had a look. It’s possible, but that’s not how the instrument was designed. Anyway, one way to do it, would be to call instrument 99 after a few second. Place this code after the giTrangle line…

schedule(99, 2, 0, 1)

It passes a p4 value of 1 to instr 99. The in instr 99 do this after the very start:

if p4 == 1 then
gSfilepath = "C:\\Users\\rory\\OneDrive\\Csoundfiles\\Cellos\\42239__corsica-s__c-s-cello-a3-001.wav"
endif

You obviously need to pass your own file name there :slight_smile: This will work, but like I said, it’s not how the instrument was built and might lead to other issues down the line.

1 Like