Plug-ins, Hosts, Apps,
Hardware, Soundware
Developers
(Brands)
Videos Groups
Whats's in?
Banks & Patches
Download & Upload
Music Search
KVR
   
KVR Forum » DSP and Plug-in Development
Thread Read
help with csound code
Goto page 1, 2  Next
tuz
DC TC
- profile
- pm
PostPosted: Wed May 02, 2012 2:58 pm reply with quote
<CsoundSynthesizer>
<CsOptions>
; Select audio/midi flags here according to platform
-odac      ;;;realtime audio out
;-iadc    ;;;uncomment -iadc if realtime audio input is needed too
; For Non-realtime ouput leave only the line below:
; -o lorismorph.wav -W ;;; for file output any platform
</CsOptions>
<CsInstruments>

sr = 44100
ksmps = 32
nchnls = 2
0dbfs  = 1
; clarinet.sdif and meow.sdif can be found in /manual/examples

; Morph the partials in meow.sdif into the partials in clarinet.sdif over the duration of
; the sustained portion of the two tones (from .2 to 2.0 seconds in the meow, and from
; .5 to 2.1 seconds in the clarinet). The onset and decay portions in the morphed sound are
; specified by parameters p4 and p5, respectively. The morphing time is the time between the
; onset and the decay. The meow partials are shfited in pitch to match the pitch of the clarinet
; tone (D above middle C).

instr 1

ionset   = p4
idecay   = p5
itmorph = p3 - (ionset + idecay)
ipshift   = cpspch(8.02)/cpspch(8.08)
   
ktme   linseg   0, ionset, .2, itmorph, 2.0, idecay, 2.1    ; meow time function, morph from .2 to 2.0 seconds
ktcl   linseg   0, ionset, .5, itmorph, 2.1, idecay, 2.3    ; clarinet time function, morph from .5 to 2.1 seconds
kmurph   linseg   0, ionset, 0, itmorph, 1, idecay, 1
   lorisread  ktme, "meow.sdif", 1, ipshift, 2, 1, .001
   lorisread  ktcl, "clarinet.sdif", 2, 1, 1, 1, .001
   lorismorph 1, 2, 3, kmurph, kmurph, kmurph
asig   lorisplay  3, 1, 1, 1
   outs      asig, asig
endin

; Morph the partials in clarinet.sdif into the partials in meow.sdif. The start and end times
; for the morph are specified by parameters p4 and p5, respectively. The morph occurs over the
; second of four pitches in each of the sounds, from .75 to 1.2 seconds in the flutter-tongued
; clarinet tone, and from 1.7 to 2.2 seconds in the cat's meow. Different morphing functions are
; used for the frequency and amplitude envelopes, so that the partial amplitudes make a faster 
; transition from clarinet to cat than the frequencies. (The bandwidth envelopes use the same         
; morphing function as the amplitudes.)

instr 2

ionset    = p4
imorph    = p5 - p4
irelease = p3 - p5
   
ktclar   linseg   0, ionset, .75, imorph, 1.2, irelease, 2.4
ktmeow   linseg   0, ionset, 1.7, imorph, 2.2, irelease, 3.4
   
kmfreq   linseg   0, ionset, 0, .75*imorph, .25, .25*imorph, 1, irelease, 1
kmamp   linseg   0, ionset, 0, .75*imorph, .9, .25*imorph, 1, irelease, 1
   
   lorisread  ktclar, "clarinet.sdif", 1, 1, 1, 1, .001
   lorisread  ktmeow, "meow.sdif", 2, 1, 1, 1, .001
   lorismorph 1, 2, 3, kmfreq, kmamp, kmamp
asig   lorisplay  3, 1, 1, 1
   outs      asig, asig
endin

</CsInstruments>   
<CsScore>
;     strt   dur   onset   decay
i 1    0      3     .25     .15
i 1    +      1     .10     .10
i 1    +      6    1.      1.

;    strt   dur  morph_start   morph_end
 i 2    9    4     .75           2.75

e
</CsScore> 
</CsoundSynthesizer>


i have a few questions. any help is appreciated

1 if i generically name a sound clarinet and another sound meow (although they might not be those sounds), where do i save them so csound can see the sounds?


2 how do i hear the sound that is created ?

3 where does the output (lorismorph.wav) get saved?

and last but not least which audio setting should i choose? HiHi
----
^ Joined: 29 May 2004  Member: #27533  
bbell
KVRer
- profile
- pm
PostPosted: Wed May 02, 2012 7:19 pm reply with quote
It depends on quite a lot of circumstances. It depends what Csound interface youre using (if any... Csound can be run in the terminal/dos). I suggest getting the QuteCsound interface (others you might want to look into are Blue and older versions of Cecilia).

In order for Csound to find the samples they must be placed in the same folder as the .csd

You could use arbitrary samples that have been renamed but you might want to be aware that Csound treats mono files and stereo files differently.

In QuteCsound you can direct where you want to the files to be saved in the Configure menu.


Hope this helps
^ Joined: 02 Oct 2011  Member: #265906  
tuz
DC TC
- profile
- pm
PostPosted: Wed May 02, 2012 9:41 pm reply with quote
thanks. Smile i have the qutecsound interface: csoundqt. makes sense about the samples being in the same folder as the csd.

is anybody able to use this code and make any sound come out? i
----
^ Joined: 29 May 2004  Member: #27533  
tuz
DC TC
- profile
- pm
PostPosted: Thu May 03, 2012 8:17 am reply with quote
a little bump. i need help....

assuming i want the output to write to a file called lorismorph.wav i will have to get rid of the semi colon in front of line:

; -o lorismorph.wav -W ;;; for file output any platform


and put a semi colon in front of line:

-odac ;;;realtime audio out


the whole program opens with <CsoundSynthesizer> and ends with </CsoundSynthesizer>

everything in between is code necessary to write to output lorismorph.wav

assuming i put the .csd file and the sdif files meow and clarinet in the same folder when i run the program, it should produce a wav file and dump it in the folder that i selected from the configuration menu.


i don't understand some things here. there's an instr 1 and instr 2 in the code. when i run the program what do those instr x's represent and how do they write to the wav file.

i'm just trying to understand what's going on here in general because i'm getting errors and no sound. could somebody please help me?
----
^ Joined: 29 May 2004  Member: #27533  
whyterabbyt
Beware the Quoth
- profile
- pm
PostPosted: Thu May 03, 2012 8:44 am reply with quote
There's two parts to the code you've got. Okay 3 with the CsOptions block but that's instructions to csound itself.

The first defines the two instruments instr1 and instr2. The instruments are the processing units and the code for them is between the two parts of the csInstruments block.
The start of the instrument definitioon is the instr command, the end is the endin command. Parameters are named For use in the instrument in the
X = p4
Type lines
Where the 4 means its the 4th parameter sent to it from the score lines,


The second part is the score, ie the parameters sent to the instruments. There instr1 gets called via i 1 lines and instr2 gets called via i 2 lines. Everything after the I on a line is the parameters sent to the instrument, so there Are 3 lines of pArameters sent to instr 1then one line of parameters sent to instr 2
This is between the csScore block.

Apologies for typos etc, iPad ain't great for typing code on.
----
To laymen, software development is something akin to wizardry. Neither time, nor effort are involved. If software is missing features they want, or has bugs, it is solely because someone has been too lazy to wave their magic wand.
^ Joined: 03 Sep 2001  Member: #1041  
cron
KVRAF
- profile
- pm
- e-mail
- www
PostPosted: Thu May 03, 2012 8:51 am reply with quote
I can't help with the code I'm afraid, but if you're curious to hear the kinds of sounds Loris can create, there are a few examples here: http://www.cerlsoundgroup.org/Kelly/soundmorphing.html

I've been curious about Loris too, as its morphing seems superior to that in CDP. Loris uses the McAulay/Quatieri method which can track moving partials, whereas I think CDP's phase vocoder analysis is nowhere near as good at tracking partials - it certainly expects both sounds to be the same pitch to get an acceptable result. Sadly, I can't be arsed to put the effort into learning CSound. Memories of how long I spent learning Max/MSP only to never use it...
^ Joined: 27 Dec 2002  Member: #5154  Location: London
whyterabbyt
Beware the Quoth
- profile
- pm
PostPosted: Thu May 03, 2012 8:52 am reply with quote
Csound just tries to output numbers representing audio, btw. the difference between sending it to a file and sending it to a sound card is pretty much set in the options block.

Also, sr sets the sample rate.
----
To laymen, software development is something akin to wizardry. Neither time, nor effort are involved. If software is missing features they want, or has bugs, it is solely because someone has been too lazy to wave their magic wand.
^ Joined: 03 Sep 2001  Member: #1041  
whyterabbyt
Beware the Quoth
- profile
- pm
PostPosted: Thu May 03, 2012 11:05 am reply with quote
Ah, finally on a proper keyboard.

Okay; your code above defines two instruments using the loris opcodes, and some other related opcodes. an opcode is a command in csound, with certain parameters passed to it.

One, instr1, is used in the score to morph one way (meow->clarinet) in 3 'steps' (hence 3 lines of parameters being sent to i1).

The second, instr2, is used, after that, to morph the other way (clarinet->meow) in 1 step.
----
To laymen, software development is something akin to wizardry. Neither time, nor effort are involved. If software is missing features they want, or has bugs, it is solely because someone has been too lazy to wave their magic wand.
^ Joined: 03 Sep 2001  Member: #1041  
tuz
DC TC
- profile
- pm
PostPosted: Thu May 03, 2012 11:37 am reply with quote
thank you so much whyterabbyt. this was very very helpful. so this is what i'm going to do.... for the sake of ease i'm taking out instr 1 and leaving only instr 2 (while renaming it instr 1 assuming that things need to be in sequence)
i will then save the csd in a folder. in the same folder i will then save 2 sound files of sufficient length in sdif format: one named clarinet and one meow. These will be done using the program Spear. in the end, it should run fine hopefully. unfortunatly, i can't try it now to see results cause i don't have csound running on this computer. the only thing i'm worried about is the options block settings and my configuration in qutecsound. i have factory state laptop and i haven't really installed anything on it other than spear and csound. can't figure out what i need to set my options and configurations to. any (more) help would be greatly appreciated and i will forever be in debt.


<CsoundSynthesizer>
<CsOptions>
; Select audio/midi flags here according to platform
-odac      ;;;realtime audio out
;-iadc    ;;;uncomment -iadc if realtime audio input is needed too
; For Non-realtime ouput leave only the line below:
; -o lorismorph.wav -W ;;; for file output any platform
</CsOptions>
<CsInstruments>

sr = 44100
ksmps = 32
nchnls = 2
0dbfs  = 1
; clarinet.sdif and meow.sdif can be found in /manual/examples




; Morph the partials in clarinet.sdif into the partials in meow.sdif. The start and end times
; for the morph are specified by parameters p4 and p5, respectively. The morph occurs over the
; second of four pitches in each of the sounds, from .75 to 1.2 seconds in the flutter-tongued
; clarinet tone, and from 1.7 to 2.2 seconds in the cat's meow. Different morphing functions are
; used for the frequency and amplitude envelopes, so that the partial amplitudes make a faster 
; transition from clarinet to cat than the frequencies. (The bandwidth envelopes use the same         
; morphing function as the amplitudes.)

instr 1

ionset    = p4
imorph    = p5 - p4
irelease = p3 - p5
   
ktclar   linseg   0, ionset, .75, imorph, 1.2, irelease, 2.4
ktmeow   linseg   0, ionset, 1.7, imorph, 2.2, irelease, 3.4
   
kmfreq   linseg   0, ionset, 0, .75*imorph, .25, .25*imorph, 1, irelease, 1
kmamp   linseg   0, ionset, 0, .75*imorph, .9, .25*imorph, 1, irelease, 1
   
   lorisread  ktclar, "clarinet.sdif", 1, 1, 1, 1, .001
   lorisread  ktmeow, "meow.sdif", 2, 1, 1, 1, .001
   lorismorph 1, 2, 3, kmfreq, kmamp, kmamp
asig   lorisplay  3, 1, 1, 1
   outs      asig, asig
endin

</CsInstruments>   
<CsScore>


;    strt   dur  morph_start   morph_end
 i 1    9    4     .75           2.75

e
</CsScore> 
</CsoundSynthesizer>
----
^ Joined: 29 May 2004  Member: #27533  
whyterabbyt
Beware the Quoth
- profile
- pm
PostPosted: Thu May 03, 2012 1:55 pm reply with quote
Apart from commenting out -odac and uncommenting the -o lorismorph.wav line, I think that looks right.
----
To laymen, software development is something akin to wizardry. Neither time, nor effort are involved. If software is missing features they want, or has bugs, it is solely because someone has been too lazy to wave their magic wand.
^ Joined: 03 Sep 2001  Member: #1041  
tuz
DC TC
- profile
- pm
PostPosted: Thu May 03, 2012 8:16 pm reply with quote
grrr. i'm getting errors and writing 0 byte wav files.
----
^ Joined: 29 May 2004  Member: #27533  
whyterabbyt
Beware the Quoth
- profile
- pm
PostPosted: Fri May 04, 2012 1:56 am reply with quote
Bugger. Digging around it looks like the loris opcodes were taken out of CSound at v5.03.01. They should be in earlier versions of V5, but there's nothing downloadable for windows from Sourceforge earlier than about 5.08.
The loris source code will build the opcodes though.

They were deprecated in favour of opcodes for ATS which seemingly does the same thing.

http://www.csounds.com/manual/html/SpectralATS.html

The options would seemingly be

1) Try and find an earlier version of CSound5 with the loris opcodes
2) Try and compile the loris opcodes from the source and add them into your CSound 5.17 install.
3) Use ATS instead
----
To laymen, software development is something akin to wizardry. Neither time, nor effort are involved. If software is missing features they want, or has bugs, it is solely because someone has been too lazy to wave their magic wand.
^ Joined: 03 Sep 2001  Member: #1041  
tuz
DC TC
- profile
- pm
PostPosted: Fri May 04, 2012 6:00 am reply with quote
oh man. what a bummer! thanks for letting me know, i was losing my mind. i'll try your options in order. ANYBODY GOT CSOUND 5.02? HiHi
----
^ Joined: 29 May 2004  Member: #27533  
tuz
DC TC
- profile
- pm
PostPosted: Mon May 07, 2012 2:33 pm reply with quote
whyterabbyt wrote:

1) Try and find an earlier version of CSound5 with the loris opcodes
2) Try and compile the loris opcodes from the source and add them into your CSound 5.17 install.
3) Use ATS instead


alright. so i tried to find an earlier version of csound5 with no luck.

i have the loris opcode sources but can't figure out how to add them to the install. it's too complicated. i don't know where to start. i have an h file and a c file. i tried doing #include but that didn't work either (which apparently helps include files that are in the same folder as your .csd) can somebody please help me get loris opcodes inside csound? i'm begging you!!!!
----
^ Joined: 29 May 2004  Member: #27533  
whyterabbyt
Beware the Quoth
- profile
- pm
PostPosted: Tue May 08, 2012 2:44 am reply with quote
tuz wrote:
whyterabbyt wrote:

1) Try and find an earlier version of CSound5 with the loris opcodes
2) Try and compile the loris opcodes from the source and add them into your CSound 5.17 install.
3) Use ATS instead


alright. so i tried to find an earlier version of csound5 with no luck.

i have the loris opcode sources but can't figure out how to add them to the install. it's too complicated. i don't know where to start. i have an h file and a c file. i tried doing #include but that didn't work either (which apparently helps include files that are in the same folder as your .csd) can somebody please help me get loris opcodes inside csound? i'm begging you!!!!


I had a look at this, and it looked like it need the full build chain for CSound, which is not in any way particularly trivial.

http://csounds.com/manual/html/BuildingCsound.html

I actually think your best bet might be to hit up the Csound mailing list and see if someone there already has this built, or builds CSound from source themselves and is willing to build it with loris included for you.

edit:

Here's another page with build instructions, including the loris opcodes


http://www.csounds.com/node/1373
----
To laymen, software development is something akin to wizardry. Neither time, nor effort are involved. If software is missing features they want, or has bugs, it is solely because someone has been too lazy to wave their magic wand.
^ Joined: 03 Sep 2001  Member: #1041  
All times are GMT - 8 Hours

Printable version
Page 1 of 2
Goto page 1, 2  Next
Display posts from previous:   
ReplyNew TopicPrevious TopicNext Topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Username: Password:  
KVR Developer Challenge 2012