Csound Csound-dev Csound-tekno Search About

[Csnd] first trial with realtime midi

Date2009-03-22 21:41
FromStefan Thomas
Subject[Csnd] first trial with realtime midi
Dear csound-community,
I'm currently making my first steps with csound. I succesfully made my
first very simple trial with additive synthesis. Now I would like to
play with the sound live on a midi Keyboard, but I don't know how to
do it.
 Here is the short csd-file, some comments are in german, for myself
to understand better what's going on.



-+rtaudio=jack -i adc -o dac -+rtmidi=alsa -M hw:1; this option seems
to work, I get no error messages on the linux-shell
;but nothing happens, when I play notes on the midi keyboard


sr = 44100
kr = 4410
ksmps = 10
nchnls = 1
instr 1 ;unser erstes Instrument!!!!!!!!!
  k1  linen   p4, 0.01, p3, p3*0.99     ;p4=Amplitude, 0.1 =
Anschlagszeit, p3*0.99 = ReleaseZeit, also 99 %der Tondauer
  a1  oscil k1, p5, p6, 1
  ;p4 ist die Amplitude, p5 sei  die Frequenz, 1 ist die Wellenform
(Sinus), in diesem Fall eben ein Sinus
 ; k2  linen   p4, 0.01, p3, p3*0.99
  a2  oscil  k1,  p5 *1.375, 1
  amix     =        a1  +a2   ; MIX

	out      amix

endin




f1	0	4096 10 1 ; use GEN10 to compute a sine wave,

; P1     P2     P3     P4       P5       P6
; INS    STRT   DUR    AMP      FREQ     WAVESHAPE
i 1    0      	3600   10000 	440      1	


e			;das ist das Ende der "Partitur"



Date2009-03-22 21:56
FromOeyvind Brandtsegg
Subject[Csnd] Re: first trial with realtime midi
Welcome, Stefan.

Everything looks correct to me, maybe you have several midi input
ports and have selected one where there is no midi coming in? I'm not
sure about the "-M hw:1" part (as I always forget the details of
device selection under Linux, someone else will be able to guide you
there). Just a shot in the dark:
you could try hw:0 instead,
or simply -M0 (without the hw device selection),
or -+rtmidi=portmidi -M0

Do you have a midi monitor application?, as this would help you
determine on which midi port you are receiving data from the keyboard.

best
Oeyvind

2009/3/22 Stefan Thomas :
> Dear csound-community,
> I'm currently making my first steps with csound. I succesfully made my
> first very simple trial with additive synthesis. Now I would like to
> play with the sound live on a midi Keyboard, but I don't know how to
> do it.
>  Here is the short csd-file, some comments are in german, for myself
> to understand better what's going on.
>
> 
> 
> -+rtaudio=jack -i adc -o dac -+rtmidi=alsa -M hw:1; this option seems
> to work, I get no error messages on the linux-shell
> ;but nothing happens, when I play notes on the midi keyboard
> 
> 
> sr = 44100
> kr = 4410
> ksmps = 10
> nchnls = 1
> instr 1 ;unser erstes Instrument!!!!!!!!!
>  k1  linen   p4, 0.01, p3, p3*0.99     ;p4=Amplitude, 0.1 =
> Anschlagszeit, p3*0.99 = ReleaseZeit, also 99 %der Tondauer
>  a1  oscil k1, p5, p6, 1
>  ;p4 ist die Amplitude, p5 sei  die Frequenz, 1 ist die Wellenform
> (Sinus), in diesem Fall eben ein Sinus
>  ; k2  linen   p4, 0.01, p3, p3*0.99
>  a2  oscil  k1,  p5 *1.375, 1
>  amix     =        a1  +a2   ; MIX
>
>        out      amix
>
> endin
>
>
> 
> 
> f1      0       4096 10 1 ; use GEN10 to compute a sine wave,
>
> ; P1     P2     P3     P4       P5       P6
> ; INS    STRT   DUR    AMP      FREQ     WAVESHAPE
> i 1    0        3600   10000    440      1
>
>
> e                       ;das ist das Ende der "Partitur"
> 
> 
>
>
> Send bugs reports to this list.
> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"
>


Date2009-03-22 22:01
FromIain McCurdy
Subject[Csnd] RE: first trial with realtime midi
Hello and welcome Stefan,

You don't need any note events in your score because notes will be triggered via MIDI. Instead, create what is referred to as a 'dummy' score event such as:
f 0 3600
this will sustain realtime performance for 3600 seconds, during which time Csound will listen for MIDI events. P-fields beyond p1 no longer have any meaning as we are not passing values from the score. You can replace these with realtime midi opcodes such as 'cpsmidi', 'ampmidi' veloc' etc.
In your example when instr 1 is triggered via MIDI p4 and p5 are not assigned and are instead given values of zero.

Here is an example for playing notes from a MIDI keyboard:

instr    1
;READ RT-MIDI NOTE NUMBERS, CONVERT TO CPS
icps    cpsmidi
;READ RT-MIDI VELOCITY, CONVERT TO AMP VALUES WITHIN THE RANGE 0-10000 
iamp    ampmidi    10000
;CREATE A SINE TONE
asig    oscili    iamp, icps, 1
;SEND AUDIO TO OUTPUTS
outs    asig, asig
endin



;SCORE
;A SINE WAVE
f 1 1025 10 1
;DUMMY SCORE EVENT
f 0 3600


I hope this works for you. Let me know if it doesn't.
Iain

> Date: Sun, 22 Mar 2009 22:41:39 +0100
> From: kontrapunktstefan@googlemail.com
> To: csound@lists.bath.ac.uk
> Subject: [Csnd] first trial with realtime midi
>
> Dear csound-community,
> I'm currently making my first steps with csound. I succesfully made my
> first very simple trial with additive synthesis. Now I would like to
> play with the sound live on a midi Keyboard, but I don't know how to
> do it.
> Here is the short csd-file, some comments are in german, for myself
> to understand better what's going on.
>
> <CsoundSynthesizer>
> <CsOptions>
> -+rtaudio=jack -i adc -o dac -+rtmidi=alsa -M hw:1; this option seems
> to work, I get no error messages on the linux-shell
> ;but nothing happens, when I play notes on the midi keyboard
> </CsOptions>
> <CsInstruments>
> sr = 44100
> kr = 4410
> ksmps = 10
> nchnls = 1
> instr 1 ;unser erstes Instrument!!!!!!!!!
> k1 linen p4, 0.01, p3, p3*0.99 ;p4=Amplitude, 0.1 =
> Anschlagszeit, p3*0.99 = ReleaseZeit, also 99 %der Tondauer
> a1 oscil k1, p5, p6, 1
> ;p4 ist die Amplitude, p5 sei die Frequenz, 1 ist die Wellenform
> (Sinus), in diesem Fall eben ein Sinus
> ; k2 linen p4, 0.01, p3, p3*0.99
> a2 oscil k1, p5 *1.375, 1
> amix = a1 +a2 ; MIX
>
> out amix
>
> endin
>
>
> </CsInstruments>
> <CsScore>
> f1 0 4096 10 1 ; use GEN10 to compute a sine wave,
>
> ; P1 P2 P3 P4 P5 P6
> ; INS STRT DUR AMP FREQ WAVESHAPE
> i 1 0 3600 10000 440 1
>
>
> e ;das ist das Ende der "Partitur"
> </CsScore>
> </CsoundSynthesizer>
>
>
> Send bugs reports to this list.
> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"


Get quick access to your favorite MSN content with Internet Explorer 8. Download FREE now!

Date2009-03-22 22:41
FromIain McCurdy
Subject[Csnd] RE: RE: first trial with realtime midi
Sorry, I was too fast, a mistake in that function table, it should be:
f 1 0 1025 10 1


From: i_mccurdy@hotmail.com
To: csound@lists.bath.ac.uk
Date: Sun, 22 Mar 2009 22:01:50 +0000
Subject: [Csnd] RE: first trial with realtime midi

Hello and welcome Stefan,

You don't need any note events in your score because notes will be triggered via MIDI. Instead, create what is referred to as a 'dummy' score event such as:
f 0 3600
this will sustain realtime performance for 3600 seconds, during which time Csound will listen for MIDI events. P-fields beyond p1 no longer have any meaning as we are not passing values from the score. You can replace these with realtime midi opcodes such as 'cpsmidi', 'ampmidi' veloc' etc.
In your example when instr 1 is triggered via MIDI p4 and p5 are not assigned and are instead given values of zero.

Here is an example for playing notes from a MIDI keyboard:

instr    1
;READ RT-MIDI NOTE NUMBERS, CONVERT TO CPS
icps    cpsmidi
;READ RT-MIDI VELOCITY, CONVERT TO AMP VALUES WITHIN THE RANGE 0-10000 
iamp    ampmidi    10000
;CREATE A SINE TONE
asig    oscili    iamp, icps, 1
;SEND AUDIO TO OUTPUTS
outs    asig, asig
endin



;SCORE
;A SINE WAVE
f 1 1025 10 1
;DUMMY SCORE EVENT
f 0 3600


I hope this works for you. Let me know if it doesn't.
Iain

> Date: Sun, 22 Mar 2009 22:41:39 +0100
> From: kontrapunktstefan@googlemail.com
> To: csound@lists.bath.ac.uk
> Subject: [Csnd] first trial with realtime midi
>
> Dear csound-community,
> I'm currently making my first steps with csound. I succesfully made my
> first very simple trial with additive synthesis. Now I would like to
> play with the sound live on a midi Keyboard, but I don't know how to
> do it.
> Here is the short csd-file, some comments are in german, for myself
> to understand better what's going on.
>
> <CsoundSynthesizer>
> <CsOptions>
> -+rtaudio=jack -i adc -o dac -+rtmidi=alsa -M hw:1; this option seems
> to work, I get no error messages on the linux-shell
> ;but nothing happens, when I play notes on the midi keyboard
> </CsOptions>
> <CsInstruments>
> sr = 44100
> kr = 4410
> ksmps = 10
> nchnls = 1
> instr 1 ;unser erstes Instrument!!!!!!!!!
> k1 linen p4, 0.01, p3, p3*0.99 ;p4=Amplitude, 0.1 =
> Anschlagszeit, p3*0.99 = ReleaseZeit, also 99 %der Tondauer
> a1 oscil k1, p5, p6, 1
> ;p4 ist die Amplitude, p5 sei die Frequenz, 1 ist die Wellenform
> (Sinus), in diesem Fall eben ein Sinus
> ; k2 linen p4, 0.01, p3, p3*0.99
> a2 oscil k1, p5 *1.375, 1
> amix = a1 +a2 ; MIX
>
> out amix
>
> endin
>
>
> </CsInstruments>
> <CsScore>
> f1 0 4096 10 1 ; use GEN10 to compute a sine wave,
>
> ; P1 P2 P3 P4 P5 P6
> ; INS STRT DUR AMP FREQ WAVESHAPE
> i 1 0 3600 10000 440 1
>
>
> e ;das ist das Ende der "Partitur"
> </CsScore>
> </CsoundSynthesizer>
>
>
> Send bugs reports to this list.
> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"


Get quick access to your favorite MSN content with Internet Explorer 8. Download FREE now!

Internet Explorer 8 – Now Available. Faster, safer, easier. Download FREE now!

Date2009-03-24 10:38
FromStefan Thomas
Subject[Csnd] Re: RE: RE: first trial with realtime midi
Dear Ian,
thanks! It worked.
Next step will be to give each "partials" an individaul envelope.

2009/3/22 Iain McCurdy :
> Sorry, I was too fast, a mistake in that function table, it should be:
> f 1 0 1025 10 1
>
> ________________________________
> From: i_mccurdy@hotmail.com
> To: csound@lists.bath.ac.uk
> Date: Sun, 22 Mar 2009 22:01:50 +0000
> Subject: [Csnd] RE: first trial with realtime midi
>
> Hello and welcome Stefan,
>
> You don't need any note events in your score because notes will be triggered
> via MIDI. Instead, create what is referred to as a 'dummy' score event such
> as:
> f 0 3600
> this will sustain realtime performance for 3600 seconds, during which time
> Csound will listen for MIDI events. P-fields beyond p1 no longer have any
> meaning as we are not passing values from the score. You can replace these
> with realtime midi opcodes such as 'cpsmidi', 'ampmidi' veloc' etc.
> In your example when instr 1 is triggered via MIDI p4 and p5 are not
> assigned and are instead given values of zero.
>
> Here is an example for playing notes from a MIDI keyboard:
>
> instr    1
> ;READ RT-MIDI NOTE NUMBERS, CONVERT TO CPS
> icps    cpsmidi
> ;READ RT-MIDI VELOCITY, CONVERT TO AMP VALUES WITHIN THE RANGE 0-10000
> iamp    ampmidi    10000
> ;CREATE A SINE TONE
> asig    oscili    iamp, icps, 1
> ;SEND AUDIO TO OUTPUTS
> outs    asig, asig
> endin
>
>
>
> ;SCORE
> ;A SINE WAVE
> f 1 1025 10 1
> ;DUMMY SCORE EVENT
> f 0 3600
>
>
> I hope this works for you. Let me know if it doesn't.
> Iain
>
>> Date: Sun, 22 Mar 2009 22:41:39 +0100
>> From: kontrapunktstefan@googlemail.com
>> To: csound@lists.bath.ac.uk
>> Subject: [Csnd] first trial with realtime midi
>>
>> Dear csound-community,
>> I'm currently making my first steps with csound. I succesfully made my
>> first very simple trial with additive synthesis. Now I would like to
>> play with the sound live on a midi Keyboard, but I don't know how to
>> do it.
>> Here is the short csd-file, some comments are in german, for myself
>> to understand better what's going on.
>>
>> 
>> 
>> -+rtaudio=jack -i adc -o dac -+rtmidi=alsa -M hw:1; this option seems
>> to work, I get no error messages on the linux-shell
>> ;but nothing happens, when I play notes on the midi keyboard
>> 
>> 
>> sr = 44100
>> kr = 4410
>> ksmps = 10
>> nchnls = 1
>> instr 1 ;unser erstes Instrument!!!!!!!!!
>> k1 linen p4, 0.01, p3, p3*0.99 ;p4=Amplitude, 0.1 =
>> Anschlagszeit, p3*0.99 = ReleaseZeit, also 99 %der Tondauer
>> a1 oscil k1, p5, p6, 1
>> ;p4 ist die Amplitude, p5 sei die Frequenz, 1 ist die Wellenform
>> (Sinus), in diesem Fall eben ein Sinus
>> ; k2 linen p4, 0.01, p3, p3*0.99
>> a2 oscil k1, p5 *1.375, 1
>> amix = a1 +a2 ; MIX
>>
>> out amix
>>
>> endin
>>
>>
>> 
>> 
>> f1 0 4096 10 1 ; use GEN10 to compute a sine wave,
>>
>> ; P1 P2 P3 P4 P5 P6
>> ; INS STRT DUR AMP FREQ WAVESHAPE
>> i 1 0 3600 10000 440 1
>>
>>
>> e ;das ist das Ende der "Partitur"
>> 
>> 
>>
>>
>> Send bugs reports to this list.
>> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe
>> csound"
>
> ________________________________
> Get quick access to your favorite MSN content with Internet Explorer 8.
> Download FREE now!
> ________________________________
> Internet Explorer 8 – Now Available. Faster, safer, easier. Download FREE
> now!