Csound Csound-dev Csound-tekno Search About

[Csnd] trying to record midi to a score file

Date2018-12-22 23:38
FromRichard
Subject[Csnd] trying to record midi to a score file
I have a midi recording instrument (10) that also passes the midi data 
on to another instrument (11).
This used to work, but for some reason I see messages like:

Closing file 'scores/record11.sco'...
   rtevent:       T  6.032 TT  6.032 M:  0.12147  0.00268
   rtevent:       T  6.243 TT  6.243 M:  0.40268  0.10099
   rtevent:       T  6.243 TT  6.243 M:  0.00633  0.00419

   rtevent:       T  6.367 TT  6.367 M:  0.39045  0.13598
Closing file 'scores/record11.sco'...

Instrument 10 is closing the file everytime, therefore only the last 
midi data is written to it.
How can I prevent the file from being closed in instr 10? It only gets 
allocated once, so I don't think it is a matter of
multiple instances...

Here is the code for instr 10:

instr 10    ; midi recorder and trigger
;   p4=key, p5=vel
mididefault   60, p3
midinoteonkey p5, p4
inote    init p5
ivel    init p4

instrnum = girecordto + inote/100 + ivel/100000
event_i "i", instrnum, 0, -1, inote, ivel ;call with indefinite duration
kend release ;get a "1" if instrument is turned off
if kend == 1 then
event "i", -instrnum, 0, 1 ;then turn this instance off
endif

istrt times
krel release
if (krel == 0) kgoto nothing
kendt times
kdur =  kendt - istrt
;prints to file
if girecord==1 then
     Sscore sprintf "scores/record%01d.sco", girecordto
     ;Sscore    strcpy "scores/record1.sco"
     fprintks Sscore, "i %2.0f\\t%15.6f\\t%15.6f\\t%d\\t%d\\n", 
girecordto, istrt, kdur, inote, ivel
endif
turnoff
nothing:
endin


Richard

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2018-12-23 00:11
Fromzappfinger
SubjectRe: [Csnd] trying to record midi to a score file
BTW, I have several csd's that record midi to file. They all used to work,
but not anymore in Csound 6.12!




--
Sent from: http://csound.1045644.n5.nabble.com/Csound-General-f1093014.html

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2018-12-23 09:23
FromVictor Lazzarini
SubjectRe: [Csnd] trying to record midi to a score file
I would have thought that fprintks opens a file at init time and closes it when the instance is killed. So it looks like every midi note triggers that cycle in your code.

Incidentally there is a midi to score file
example in the manual page for fprintks.
It should run lonly one instance of the instrument to do the writing. 

Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy
Maynooth University
Ireland

> On 22 Dec 2018, at 23:38, Richard  wrote:
> 
> I have a midi recording instrument (10) that also passes the midi data on to another instrument (11).
> This used to work, but for some reason I see messages like:
> 
> Closing file 'scores/record11.sco'...
>   rtevent:       T  6.032 TT  6.032 M:  0.12147  0.00268
>   rtevent:       T  6.243 TT  6.243 M:  0.40268  0.10099
>   rtevent:       T  6.243 TT  6.243 M:  0.00633  0.00419
> 
>   rtevent:       T  6.367 TT  6.367 M:  0.39045  0.13598
> Closing file 'scores/record11.sco'...
> 
> Instrument 10 is closing the file everytime, therefore only the last midi data is written to it.
> How can I prevent the file from being closed in instr 10? It only gets allocated once, so I don't think it is a matter of
> multiple instances...
> 
> Here is the code for instr 10:
> 
> instr 10    ; midi recorder and trigger
> ;   p4=key, p5=vel
> mididefault   60, p3
> midinoteonkey p5, p4
> inote    init p5
> ivel    init p4
> 
> instrnum = girecordto + inote/100 + ivel/100000
> event_i "i", instrnum, 0, -1, inote, ivel ;call with indefinite duration
> kend release ;get a "1" if instrument is turned off
> if kend == 1 then
> event "i", -instrnum, 0, 1 ;then turn this instance off
> endif
> 
> istrt times
> krel release
> if (krel == 0) kgoto nothing
> kendt times
> kdur =  kendt - istrt
> ;prints to file
> if girecord==1 then
>     Sscore sprintf "scores/record%01d.sco", girecordto
>     ;Sscore    strcpy "scores/record1.sco"
>     fprintks Sscore, "i %2.0f\\t%15.6f\\t%15.6f\\t%d\\t%d\\n", girecordto, istrt, kdur, inote, ivel
> endif
> turnoff
> nothing:
> endin
> 
> 
> Richard
> 
> Csound mailing list
> Csound@listserv.heanet.ie
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> Send bugs reports to
>       https://github.com/csound/csound/issues
> Discussions of bugs and features can be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2018-12-23 10:02
FromRichard van Bemmelen
SubjectRe: [Csnd] trying to record midi to a score file
Well, I tried the second example (midi file to score) and the output file size is 0.
This is csound 6.11 on Windows...

Op zo 23 dec. 2018 om 10:23 schreef Victor Lazzarini <Victor.Lazzarini@mu.ie>:
I would have thought that fprintks opens a file at init time and closes it when the instance is killed. So it looks like every midi note triggers that cycle in your code.

Incidentally there is a midi to score file
example in the manual page for fprintks.
It should run lonly one instance of the instrument to do the writing.

Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy
Maynooth University
Ireland

> On 22 Dec 2018, at 23:38, Richard <zappfinger@gmail.com> wrote:
>
> I have a midi recording instrument (10) that also passes the midi data on to another instrument (11).
> This used to work, but for some reason I see messages like:
>
> Closing file 'scores/record11.sco'...
>   rtevent:       T  6.032 TT  6.032 M:  0.12147  0.00268
>   rtevent:       T  6.243 TT  6.243 M:  0.40268  0.10099
>   rtevent:       T  6.243 TT  6.243 M:  0.00633  0.00419
>
>   rtevent:       T  6.367 TT  6.367 M:  0.39045  0.13598
> Closing file 'scores/record11.sco'...
>
> Instrument 10 is closing the file everytime, therefore only the last midi data is written to it.
> How can I prevent the file from being closed in instr 10? It only gets allocated once, so I don't think it is a matter of
> multiple instances...
>
> Here is the code for instr 10:
>
> instr 10    ; midi recorder and trigger
> ;   p4=key, p5=vel
> mididefault   60, p3
> midinoteonkey p5, p4
> inote    init p5
> ivel    init p4
>
> instrnum = girecordto + inote/100 + ivel/100000
> event_i "i", instrnum, 0, -1, inote, ivel ;call with indefinite duration
> kend release ;get a "1" if instrument is turned off
> if kend == 1 then
> event "i", -instrnum, 0, 1 ;then turn this instance off
> endif
>
> istrt times
> krel release
> if (krel == 0) kgoto nothing
> kendt times
> kdur =  kendt - istrt
> ;prints to file
> if girecord==1 then
>     Sscore sprintf "scores/record%01d.sco", girecordto
>     ;Sscore    strcpy "scores/record1.sco"
>     fprintks Sscore, "i %2.0f\\t%15.6f\\t%15.6f\\t%d\\t%d\\n", girecordto, istrt, kdur, inote, ivel
> endif
> turnoff
> nothing:
> endin
>
>
> Richard
>
> Csound mailing list
> Csound@listserv.heanet.ie
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> Send bugs reports to
>       https://github.com/csound/csound/issues
> Discussions of bugs and features can be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2018-12-23 10:43
FromRichard van Bemmelen
SubjectRe: [Csnd] trying to record midi to a score file
AttachmentsmidiFile2score.csd  bossa.mid  
Ok, confirmed. I tried the same csd with csound 6.08 on my Raspberry Pi and there it worked.
So somewhere between this version and 6.11 something went wrong...
Here are the files I used.

Op zo 23 dec. 2018 om 11:02 schreef Richard van Bemmelen <zappfinger@gmail.com>:
Well, I tried the second example (midi file to score) and the output file size is 0.
This is csound 6.11 on Windows...

Op zo 23 dec. 2018 om 10:23 schreef Victor Lazzarini <Victor.Lazzarini@mu.ie>:
I would have thought that fprintks opens a file at init time and closes it when the instance is killed. So it looks like every midi note triggers that cycle in your code.

Incidentally there is a midi to score file
example in the manual page for fprintks.
It should run lonly one instance of the instrument to do the writing.

Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy
Maynooth University
Ireland

> On 22 Dec 2018, at 23:38, Richard <zappfinger@gmail.com> wrote:
>
> I have a midi recording instrument (10) that also passes the midi data on to another instrument (11).
> This used to work, but for some reason I see messages like:
>
> Closing file 'scores/record11.sco'...
>   rtevent:       T  6.032 TT  6.032 M:  0.12147  0.00268
>   rtevent:       T  6.243 TT  6.243 M:  0.40268  0.10099
>   rtevent:       T  6.243 TT  6.243 M:  0.00633  0.00419
>
>   rtevent:       T  6.367 TT  6.367 M:  0.39045  0.13598
> Closing file 'scores/record11.sco'...
>
> Instrument 10 is closing the file everytime, therefore only the last midi data is written to it.
> How can I prevent the file from being closed in instr 10? It only gets allocated once, so I don't think it is a matter of
> multiple instances...
>
> Here is the code for instr 10:
>
> instr 10    ; midi recorder and trigger
> ;   p4=key, p5=vel
> mididefault   60, p3
> midinoteonkey p5, p4
> inote    init p5
> ivel    init p4
>
> instrnum = girecordto + inote/100 + ivel/100000
> event_i "i", instrnum, 0, -1, inote, ivel ;call with indefinite duration
> kend release ;get a "1" if instrument is turned off
> if kend == 1 then
> event "i", -instrnum, 0, 1 ;then turn this instance off
> endif
>
> istrt times
> krel release
> if (krel == 0) kgoto nothing
> kendt times
> kdur =  kendt - istrt
> ;prints to file
> if girecord==1 then
>     Sscore sprintf "scores/record%01d.sco", girecordto
>     ;Sscore    strcpy "scores/record1.sco"
>     fprintks Sscore, "i %2.0f\\t%15.6f\\t%15.6f\\t%d\\t%d\\n", girecordto, istrt, kdur, inote, ivel
> endif
> turnoff
> nothing:
> endin
>
>
> Richard
>
> Csound mailing list
> Csound@listserv.heanet.ie
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> Send bugs reports to
>       https://github.com/csound/csound/issues
> Discussions of bugs and features can be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2018-12-23 11:34
Fromzappfinger
SubjectRe: [Csnd] trying to record midi to a score file
Correction: The csd file DOES work on OS X with version 6.12, but NOT on
Windows with version 6.11



--
Sent from: http://csound.1045644.n5.nabble.com/Csound-General-f1093014.html

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2018-12-23 12:03
FromVictor Lazzarini
SubjectRe: [Csnd] trying to record midi to a score file
What about 6.12 on Windows?

Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy
Maynooth University
Ireland

> On 23 Dec 2018, at 11:35, zappfinger  wrote:
> 
> Correction: The csd file DOES work on OS X with version 6.12, but NOT on
> Windows with version 6.11
> 
> 
> 
> --
> Sent from: http://csound.1045644.n5.nabble.com/Csound-General-f1093014.html
> 
> Csound mailing list
> Csound@listserv.heanet.ie
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> Send bugs reports to
>        https://github.com/csound/csound/issues
> Discussions of bugs and features can be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2018-12-23 12:17
FromRichard van Bemmelen
SubjectRe: [Csnd] trying to record midi to a score file
AttachmentsmidiRecord2.csd  
I installed csound 6.12 on Windows and the midiFile2score.csd seems to work.
However, there are a handfull of other oddities occuring now with another csd (will attach)
When I run this csd in the command prompt, I get this error:

Loading SoundFont : ..\samples\003.3mg GS Roland Sound Set 16 bit Bank.SF2.
fluidSynth: 0x0000024848BCEDC0  soundFontId: 1.
0: iCON iKEY V1.02 (portmidi)
PortMIDI: Activated input device 0: 'iCON iKEY V1.02' (MMSystem)
 *** PortMIDI: error opening input device 0: PortMidi: `Host error'
 *** error opening MIDI in device: -1 (Unknown MIDI error)

When I run the csd in CsoundQt (no options checked, so it should be the same) it sort of works, but not quite:
there is no midi error or audio error (see my other post), but the csd does not finish, although there is a duration macro of 30 seconds. Therefore the score file written has size 0.

Also, when I play the midi keyboard it sounds very bad, a soft, cracking sound and not the GM soundfont I expect.

Op zo 23 dec. 2018 om 12:34 schreef zappfinger <zappfinger@gmail.com>:
Correction: The csd file DOES work on OS X with version 6.12, but NOT on
Windows with version 6.11



--
Sent from: http://csound.1045644.n5.nabble.com/Csound-General-f1093014.html

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2018-12-23 12:25
FromRichard van Bemmelen
SubjectRe: [Csnd] trying to record midi to a score file
The sound was a matter of not having the buffer sizes checked in CsoundQt. Now (strangely) the csd does finish after 30 seconds, but the output score file size is still 0, unfortunately.

Op zo 23 dec. 2018 om 13:17 schreef Richard van Bemmelen <zappfinger@gmail.com>:
I installed csound 6.12 on Windows and the midiFile2score.csd seems to work.
However, there are a handfull of other oddities occuring now with another csd (will attach)
When I run this csd in the command prompt, I get this error:

Loading SoundFont : ..\samples\003.3mg GS Roland Sound Set 16 bit Bank.SF2.
fluidSynth: 0x0000024848BCEDC0  soundFontId: 1.
0: iCON iKEY V1.02 (portmidi)
PortMIDI: Activated input device 0: 'iCON iKEY V1.02' (MMSystem)
 *** PortMIDI: error opening input device 0: PortMidi: `Host error'
 *** error opening MIDI in device: -1 (Unknown MIDI error)

When I run the csd in CsoundQt (no options checked, so it should be the same) it sort of works, but not quite:
there is no midi error or audio error (see my other post), but the csd does not finish, although there is a duration macro of 30 seconds. Therefore the score file written has size 0.

Also, when I play the midi keyboard it sounds very bad, a soft, cracking sound and not the GM soundfont I expect.

Op zo 23 dec. 2018 om 12:34 schreef zappfinger <zappfinger@gmail.com>:
Correction: The csd file DOES work on OS X with version 6.12, but NOT on
Windows with version 6.11



--
Sent from: http://csound.1045644.n5.nabble.com/Csound-General-f1093014.html

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2018-12-23 12:32
FromRichard van Bemmelen
SubjectRe: [Csnd] trying to record midi to a score file
This is strange because 'Ignore CsOptions' is not checked, so it should use the buffer sizes defined in the csd.
And what is the relation between buffer sizes and the lenght of the score? Baffles me.

Op zo 23 dec. 2018 om 13:25 schreef Richard van Bemmelen <zappfinger@gmail.com>:
The sound was a matter of not having the buffer sizes checked in CsoundQt. Now (strangely) the csd does finish after 30 seconds, but the output score file size is still 0, unfortunately.

Op zo 23 dec. 2018 om 13:17 schreef Richard van Bemmelen <zappfinger@gmail.com>:
I installed csound 6.12 on Windows and the midiFile2score.csd seems to work.
However, there are a handfull of other oddities occuring now with another csd (will attach)
When I run this csd in the command prompt, I get this error:

Loading SoundFont : ..\samples\003.3mg GS Roland Sound Set 16 bit Bank.SF2.
fluidSynth: 0x0000024848BCEDC0  soundFontId: 1.
0: iCON iKEY V1.02 (portmidi)
PortMIDI: Activated input device 0: 'iCON iKEY V1.02' (MMSystem)
 *** PortMIDI: error opening input device 0: PortMidi: `Host error'
 *** error opening MIDI in device: -1 (Unknown MIDI error)

When I run the csd in CsoundQt (no options checked, so it should be the same) it sort of works, but not quite:
there is no midi error or audio error (see my other post), but the csd does not finish, although there is a duration macro of 30 seconds. Therefore the score file written has size 0.

Also, when I play the midi keyboard it sounds very bad, a soft, cracking sound and not the GM soundfont I expect.

Op zo 23 dec. 2018 om 12:34 schreef zappfinger <zappfinger@gmail.com>:
Correction: The csd file DOES work on OS X with version 6.12, but NOT on
Windows with version 6.11



--
Sent from: http://csound.1045644.n5.nabble.com/Csound-General-f1093014.html

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here