Cabbage Logo
Back to Cabbage Site

Choose sound files from folders for convolution plugin

Hi there,

I’m making a very simple convolution plugin to mix an input with an uploaded sound files, but I’d like to insert an “Open File” button to have the possibility to change sounds when the patch is running.

I’ve look at others plugins, but I’m still confused.
Do you have any suggestion?

Convolution_03.csd (1.1 KB)

You could try something like this…
Convolution_03.csd (1.3 KB)

Thanks a lot!
I had tried using schedkwhen without results…with event works fine! :smile:
Now I’ve also and idea on how to update a waveform viewer.

Another way to do this would be to use reinit. Then you wouldn’t even need to use the event opcode. You could simply reinitialise the instrument each time the filename changes.

p.s. Nice avatar, I wonder should we make it compulsory for users to have avatars of Cabbage heads :wink:

If you spend a lots of time on Cabbage you become a Cabbage head… :sweat_smile:
Maybe I’m not doin’ it right…Can I use an If statement with reinit? Probably, I’m wrong, the Csound manual isn’t clear about how to use it.

instr 1
gSFilename chnget "filename"
kGain chnget "gain"
kMix	chnget "mix"

conv:

if changed:k(gSFilename) == 1 then

	reinit conv
	
	endif

a1 inch 1
aConv	pconvolve a1, gSFilename
aOut	ntrpol	a1, aConv*0.1, kMix

outs aOut*kGain, aOut*kGain

rireturn

endin

That reason why this won’t work is that the pconvolve opcode is expecting a valid filename. The filename is not valid at the start so the instrument produces an init error. I guess in the case where you want to let the user open a file of their choice it might better to use the first approach. You can always turn an instrument off using the turnoff opcode.

That’s true, if the instrument can’t work reinit won’t work too…Thanks again!