Create a sample pack

Hello
Is it possible to create a sample pack with a single csd file. Make an instrument that would write a wav file per musical note for example? Could you tell me which way I should look?

Hi!

Sure! you could use sprintf for ceating the file name and fout to save the file.
a simplified sketch (not the real code):

instr 1
iNote = p4 ; or some other way

aSignal

SFilename sprintf “%d.wav”, iNote
fout SFilename, 4, aSignal

endin

  • consult the manual and change it as you need.
    Hope it helps!

tarmo

Kontakt NotSure via The Csound Community (<noreply@forum.csound.com>) kirjutas kuupäeval E, 3. märts 2025 kell 06:08:

Hi Johannes,

perhaps I have expressed myself badly,
I want to create multiple samples with different frequencies of the same sound in order to feed a software sampler.
The csd file will have to provide 7 wav files:
A3_sound.wav, B3_sound.wav, C3_sound.wav, D3_sound.wav, E3_sound.wav, F3_sound.wav, G3_sound.wav.

Yes, this is exactly what you can do with that instrument if you develop it further:

-odac

sr = 44100

ksmps = 32

nchnls = 2

0dbfs = 1

instr 1

iNote = p4 ; or some other way

iFreq cpsmidinn iNote

iCutoff random iFreq2, iFreq8

aSignal moogladder vco2:a(0.1,iFreq), iCutoff, 0.8

aSignal *= adsr:a(0.1, 0.1, 0.6, p3/2)

outall aSignal

SFilename sprintf “%d.wav”, iNote

fout SFilename, 4, aSignal

endin

i 1 0 1 48 ; C3

i 1 + 1 50 ; D3

; etc

Maybe I still got you wrong…

tarmo

Kontakt NotSure via The Csound Community (<noreply@forum.csound.com>) kirjutas kuupäeval E, 3. märts 2025 kell 10:20:

demo.csd (758 Bytes)

1 Like

Thank you Johannes,
it’s exactly what I was looking for.
I imagined something with loops, very dirty.
I’m very bad at English, mathematics and algorithmics.
Thanks to you, I just discovered that there are a lot of "*out*" opcodes, and your solution is elegant.

Hello,
in the expression "adsr:a(0.1, 0.1, 0.6, p3/2)", I couldn’t find in the manual what the colon between "adsr" and "a" mean. Is this the way to write the conversion of i-rate parameters to a-rate? Same for "vco2:a(0.1,iFreq)", k-rate in a-rate?

Hi,
I finally found the answer in the flosmanual.
Sorry for the inconvenience.