[Csnd] how to record a midi file
Date | 2010-12-16 22:07 |
From | Stefan Thomas |
Subject | [Csnd] how to record a midi file |
Dear community, I would like to create a midi-file from a live session. I tried it with the following code. It produces only silent midifiles. <CsoundSynthesizer> ;<CsOptions> -odevaudio -Ma -b2048 -B 4096 -m0d --midioutfile=test.mid ;</CsOptions> ; ============================================== <CsInstruments> sr = 48000 ksmps = 100 nchnls = 2 0dbfs = 1 gisine ftgen 0,0,2^10, 10, 1 instr 1 inote notnum ilaut veloc iamp ampmidi 1 icps cpsmidi iend = 0 iaus = 7 irel = 0.1 asig poscil iamp, icps, gisine outs asig, asig endin </CsInstruments> ; ============================================== <CsScore> f 0 10 i1 0 10 </CsScore> </CsoundSynthesizer> |
Date | 2010-12-16 22:40 |
From | Oeyvind Brandtsegg |
Subject | [Csnd] Re: how to record a midi file |
Hello Stefan You need to generate some midi data. For example, use an instrument that writes midi notes, like this: ;********************************************************************* ; midi out instrument instr 201 ichn = 1 inum = p5 ivel = p4 idur = p3 noteondur ichn, inum, ivel, idur endin ;********************************************************************* Then inside your instrument 1, put this: ; trigger midi out event_i "i", 201, 0, p3, ilaut , inote (assuming your variable names ilaut for velocity and inote not note number) all best Oeyvind 2010/12/16 Stefan Thomas |
Date | 2010-12-17 18:48 |
From | Stefan Thomas |
Subject | [Csnd] Re: Re: how to record a midi file |
Dear Oeyvind, I've tried to realize Your suggestion, unfortunately without sucess. I can't see the mistake in the below quoted code. It produces a sound when I play on the midi-keyboard, it also generates a midifile, but the midi-file doesn't contain any note. Here is my code: <CsoundSynthesizer> <CsOptions> -odevaudio -Ma -b2048 -B 4096 -m0d --midioutfile=test.mid </CsOptions> ; ============================================== <CsInstruments> sr = 48000 ksmps = 100 nchnls = 2 0dbfs = 1 gisine ftgen 0,0,2^10, 10, 1 instr 1 inote notnum ilaut veloc iamp ampmidi 1 icps cpsmidi idur =12 asig poscil iamp, icps, gisine outs asig, asig event_i "i", 102, 0, p3, iamp, inote endin instr 102 ichn = 1 inum = p5 ivel = p4 idur = p3 noteondur ichn, inum, ivel, idur endin </CsInstruments> ; ============================================== <CsScore> f 0 30 i1 0 30 i102 0 30 </CsScore> </CsoundSynthesizer> 2010/12/16 Oeyvind Brandtsegg <oyvind.brandtsegg@ntnu.no> Hello Stefan |
Date | 2010-12-17 23:47 |
From | Victor Lazzarini |
Subject | [Csnd] Re: Re: Re: how to record a midi file |
I think it is because p3 in instrument 1 is 0 for realtime events (like playing from the midi keyboard) On 17 Dec 2010, at 18:48, Stefan Thomas wrote: Dear Oeyvind, |
Date | 2010-12-17 23:55 |
From | Victor Lazzarini |
Subject | [Csnd] Re: Re: Re: Re: how to record a midi file |
I this will work: <CsoundSynthesizer> <CsOptions> -odevaudio -Ma -b2048 -B 4096 -d --midioutfile=test.mid </CsOptions> ; ============================================== <CsInstruments> sr = 48000 ksmps = 100 nchnls = 2 0dbfs = 1 gisine ftgen 0,0,2^10, 10, 1 instr 1 kdur init 0 kdur = kdur + 1/kr inote notnum ilaut veloc iamp ampmidi 1 icps cpsmidi idur =12 asig poscil iamp, icps, gisine outs asig, asig krel release if krel == 1 then event "i", 102, 0, kdur, iamp*127, inote endif endin instr 102 ichn = 1 inum = p5 ivel = p4 idur = p3 noteondur ichn, inum, ivel, idur endin </CsInstruments> ; ============================================== <CsScore> f 0 300 ;i1 0 30 ;i102 0 30 </CsScore> </CsoundSynthesizer> On 17 Dec 2010, at 23:47, Victor Lazzarini wrote:
|
Date | 2010-12-18 08:23 |
From | Stefan Thomas |
Subject | [Csnd] Re: Re: Re: Re: Re: how to record a midi file |
Dear Victor, thanks for Your help. Your code works. What I don't understand: why do You write iamp*127 ? 2010/12/18 Victor Lazzarini <Victor.Lazzarini@nuim.ie>
|
Date | 2010-12-18 08:34 |
From | Victor Lazzarini |
Subject | [Csnd] Re: Re: Re: Re: Re: Re: how to record a midi file |
Because iamp is between 0 and 1, and midi velocities are 0 - 127 On 18 Dec 2010, at 08:23, Stefan Thomas wrote: Dear Victor, |
Date | 2010-12-18 09:18 |
From | Stefan Thomas |
Subject | [Csnd] Re: Re: Re: Re: Re: Re: Re: how to record a midi file |
Dear Victor, thanks for Your explanation. I would like to ask You two more questions: I've noticed, that when I play back the midifile with timidity, it plays a little faster. Is it possible to "say" the midifile, which tempo it should use? Now I've created a csd-file, where You can choose between tow sounds via the modwheel and can record a midi-file. Everything works beside one exception: When I move the modwheel, the sound doesn't change when I play the next note. It changes only when I play the next but one. Here is my code: <CsoundSynthesizer> ; ============================================== ; choose different sounds via the modwheel <CsOptions> -odevaudio -Ma -b2048 -B 4096 -d --midioutfile=onemoretest.mid </CsOptions> <CsInstruments> sr = 48000 ksmps = 100 nchnls = 2 0dbfs = 1 gisine ftgen 0,0,2^10, 10, 1 gkmodwheel init 0 instr 1 kdur init 0 kdur = kdur + 1/kr ichannelinstrumentone = 1 icontrollerinstrumentone = 1 gkmodwheel ctrl7 ichannelinstrumentone, icontrollerinstrumentone, 0, 1 ; controller 1 is the modwheel imodwheel = i(gkmodwheel) imidinot notnum iamp ampmidi 1 idur = 10 if imodwheel >0 then isubinstr = 100+imidinot/1000 else isubinstr = 101+imidinot/1000 endif icps cpsmidi event_i "i", isubinstr, 0, idur, iamp, icps krelease release if krelease == 1 then turnoff2 isubinstr, 4, 1 krel release if krel == 1 then event "i", 102, 0, kdur, iamp*127, imidinot endif endif ichn = 1 endin instr 100 imidinot notnum idur = p3 iamp = p4 icps = p5 asig poscil iamp, icps, gisine outs asig, asig endin instr 101 imodwheel = i(gkmodwheel) imidinot notnum idur = p3 iamp = p4 icps = p5 kndx = 2 asig foscil iamp, icps, 1, 3, kndx, gisine outs asig, asig endin instr 102 idur = p3 iamp = p4 imidinot = p5 ichn = 1 noteondur ichn, imidinot, iamp, idur endin </CsInstruments> <CsScore> f 0 30 </CsScore> </CsoundSynthesizer> 2010/12/18 Victor Lazzarini <Victor.Lazzarini@nuim.ie>
|