[Csnd] Rendering multiple instrument calls into one file / interative rendering

Hello Everybody!

I was wondering if there is a better solution to render audio, then muting instruments and do another run of my csound-code.

For example:
I have a csound-code, which is based on multiple calls of different instruments (100 instances of instr 20 and 20 instances of instr 30).
Now i want all calls from instr 20 in one .wav file to be rendered and all calls of instr 30 in another .wav file.
I thought about collecting the output of each instrument into a global audio variable and render them i another instrument, which only exists for rendering, via ‚fout‘. But i can’t get it working.
How i know Csound by now there must be an easy solution for this.

Also i was wondering if there is a solution for another problem.
For example i’m working with an instrument, which should create variations of one sound-event. And every variation should be rendered in a seperate .wav file.
I can call the instrument via ‚event‘ and have an ‚fout‘ opcode inside the called instrument. But i want to find a way to iterative go through numbers which makes the created .wav file unique and doesn’t get replace, like „Super-Sound-001.wav“, „Super-Sound-002.wav“ and so on.
How can i solve this?

Maybe you have some tipps für me.
All the best,
Philipp
Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        Issues · csound/csound · GitHub
Discussions of bugs and features can be posted here

I’m lost on the question - is it that you can’t get fout to work? Why the need for a seperate recording instrument as you can use fout from inside the instrument.

For what it’s worth, it’s easy to set up fout from either inside the instr or using a seperate rendering instr by passing the audio using a global audio variable, I’ve done both.

If you can explain a little better that would help.

Scott

This is a simple example, 2 instr sent via global audio to record instruments. Uncomment fout lines and set your own variables.

-odac ;-o/sdcard/*******.wav ;================================

sr = 48000
ksmps = 32
nchnls = 2
0dbfs = 1

gaAud1L init
gaAud1R init
gaAud2L init
gaAud2R init

instr 1
iFreq ftgen 1, 0, 0, 2, 220, 440, 880
aSig = oscil:a(line:k(.4,p3,0),tab:k(lfo(randomh:k(0,2.9,4),4,3),1))
;outs(aSig, aSig)
gaAud1L += aSig
gaAud1R += aSig
endin

instr 2
aSig = vco2:a(line:k(.2,p3,0),110)
;outs(aSig, aSig)
gaAud2L += aSig
gaAud2R += aSig
endin

instr 3, Record_1
outs(gaAud1L, gaAud1R)
; 14 = wav, 16 bit (p2)
; 16 = wav, 32 bit float
;fout “/sdcard/instr1.wav”, 16, gaAud1L, gaAud1R
clear gaAud1L, gaAud1R
endin

instr 4, Record_2
outs gaAud2L, gaAud2R
;fout “/sdcard/instr2.wav”, 16, gaAud2L, gaAud2R
clear gaAud2L, gaAud2R
endin

;================================

i1 0 4
i. + .
i. + .
i. + .

i2 0 4
i. + .
i. + .
i. + .

i3 0 16

i4 0 16

Scott

The answer to your second question is to use sprintf to generate a unique name

[

sprintf
csounds.com

favicon.ico

](sprintf)

Prof. Victor Lazzarini
Maynooth University
Ireland

this is the correct link to the latest released manual btw

[

sprintf
csound.com

](sprintf)

Prof. Victor Lazzarini
Maynooth University
Ireland

favicon.png

Thanks, Scott! This works perfectly fine. I don’t know what i did wrong in my tests.