Cabbage Logo
Back to Cabbage Site

Loading sound from full path string at command line

Hello,

I probably have missed something obvious, but I was looking to load a sound (.wav) by passing the full path as a string as a command line argument and I’m a bit lost on how to do this.

The goal is to run the .csd from command line and would like to pass in the full path to the .wav to load it in.

Thanks!

You can pass a string to Csound from the command line using --strset:

csound ... --strset1="file.wav"

And you can access it in Csound using the strget opcode:

SFilename  strget  1
a1 diskin2  SFilename, ...

That should do the trick, although I can’t recall ever using it…

Hey Rory - thanks for a speedy reply!
That did indeed do the trick :slight_smile:

I meant to say the end goal was to running the .exe from command line (not the .csd, sorry!) and pass in the sound file path as a string. I also ran into some troubles here and not sure the correct way to pass in arguments to the executable.

I tried just doing “nameofapp”.exe -odac --strset1=“soundpath” but this didn’t work…

So you’re outputing a standalone app, and you want to pass a sound file to it wen you launch it from the command line? Currently there is no out-of-the-box solution for this. The arguments you pass to the standalone app do not get sent to Csound at all.

What you can do however is write a batch file that will add the sound file name to the .csd file. So instead of

nameofapp.exe --strset1="soundpath"

You might do something like this:

launchApp.bat mySoundFile.wav