Csound Csound-dev Csound-tekno Search About

Failing to display MIDI information in output console

Date2016-02-13 14:30
FromAndrea Crespi <4ndr34cr35p1@GMAIL.COM>
SubjectFailing to display MIDI information in output console
Hi, I am quite new to Csound and I am having a little issue with a project I am trying to develop. I thought this might be the right place to ask for a little help. Please let me know if this is cool.
In a few words, I would like to fill a few arrays with data coming from a MIDI stream (being it a live performance on a keyboard or information coming from a MIDI file). Then, I am planning to analyze this data and translate it into performance data of some kind. Actually, I do not need to "record" the whole performance, just data regarding a certain time window (the last bar for example).
To begin with, I have started from a very simple program that reads a MIDI file and prints note-on and note-off events to the output console.
This i what I wrote:




-F test.mid




sr = 44100
ksmps = 32
nchnls = 2
0dbfs = 1

massign 0, 1	; make sure that all channels
pgmassign 0, 1	; and programs are assigned to test instr

instr 1
  
  kstatus, kchan, kdata1, kdata2 midiin
  
  if (kstatus == 144) then
    knoteontime times
    printks "status= %d\\n",0, kstatus
    printks "note = %d\\n",0, kdata1
    printks "at: %f\\n",0, knoteontime
  elseif (kstatus == 128) then
    knoteofftime times
    printks "status= %d\\n",0, kstatus
    printks "note = %d\\n",0, kdata1
    printks "at: %f\\n",0, knoteofftime 
  endif
  
endin




i 1 0 10
e




(I rearranged the example reported in the opcode help of "midiin" to my needs.)
It seems to work quite well, except for the fact that it actually does not print the very first note-on message and the very last note-off message, and in the case of a MIDI file containing a single note nothing gets printed.
Could you please advise me about what could be the problem here? It seems to me that the problem is not in the printing, as I have also tried storing note numbers in a variable and the same problem seems to persist.
Hope you can help me find a solution! 

Cheers

Andrea

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

Date2016-02-13 14:51
Fromjpff
SubjectRe: Failing to display MIDI information in output console
Platform?

On Sat, 13 Feb 2016, Andrea Crespi wrote:

> Hi, I am quite new to Csound and I am having a little issue with a project I am trying to develop. I thought this might be the right place to ask for a little help. Please let me know if this is cool.
> In a few words, I would like to fill a few arrays with data coming from a MIDI stream (being it a live performance on a keyboard or information coming from a MIDI file). Then, I am planning to analyze this data and translate it into performance data of some kind. Actually, I do not need to "record" the whole performance, just data regarding a certain time window (the last bar for example).
> To begin with, I have started from a very simple program that reads a MIDI file and prints note-on and note-off events to the output console.
> This i what I wrote:
>
> 
>
> 
> -F test.mid
> 
>
> 
>
> sr = 44100
> ksmps = 32
> nchnls = 2
> 0dbfs = 1
>
> massign 0, 1	; make sure that all channels
> pgmassign 0, 1	; and programs are assigned to test instr
>
> instr 1
>
>  kstatus, kchan, kdata1, kdata2 midiin
>
>  if (kstatus == 144) then
>    knoteontime times
>    printks "status= %d\\n",0, kstatus
>    printks "note = %d\\n",0, kdata1
>    printks "at: %f\\n",0, knoteontime
>  elseif (kstatus == 128) then
>    knoteofftime times
>    printks "status= %d\\n",0, kstatus
>    printks "note = %d\\n",0, kdata1
>    printks "at: %f\\n",0, knoteofftime
>  endif
>
> endin
>
> 
>
> 
> i 1 0 10
> e
> 
>
> 
>
> (I rearranged the example reported in the opcode help of "midiin" to my needs.)
> It seems to work quite well, except for the fact that it actually does not print the very first note-on message and the very last note-off message, and in the case of a MIDI file containing a single note nothing gets printed.
> Could you please advise me about what could be the problem here? It seems to me that the problem is not in the printing, as I have also tried storing note numbers in a variable and the same problem seems to persist.
> Hope you can help me find a solution!
>
> Cheers
>
> Andrea
>
> 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

Date2016-02-13 14:54
Fromjpff
SubjectRe: Failing to display MIDI information in output console
Also could you provide your test.mid?

On Sat, 13 Feb 2016, Andrea Crespi wrote:

> Hi, I am quite new to Csound and I am having a little issue with a project I am trying to develop. I thought this might be the right place to ask for a little help. Please let me know if this is cool.
> In a few words, I would like to fill a few arrays with data coming from a MIDI stream (being it a live performance on a keyboard or information coming from a MIDI file). Then, I am planning to analyze this data and translate it into performance data of some kind. Actually, I do not need to "record" the whole performance, just data regarding a certain time window (the last bar for example).
> To begin with, I have started from a very simple program that reads a MIDI file and prints note-on and note-off events to the output console.
> This i what I wrote:
>
> 
>
> 
> -F test.mid
> 
>
> 
>
> sr = 44100
> ksmps = 32
> nchnls = 2
> 0dbfs = 1
>
> massign 0, 1	; make sure that all channels
> pgmassign 0, 1	; and programs are assigned to test instr
>
> instr 1
>
>  kstatus, kchan, kdata1, kdata2 midiin
>
>  if (kstatus == 144) then
>    knoteontime times
>    printks "status= %d\\n",0, kstatus
>    printks "note = %d\\n",0, kdata1
>    printks "at: %f\\n",0, knoteontime
>  elseif (kstatus == 128) then
>    knoteofftime times
>    printks "status= %d\\n",0, kstatus
>    printks "note = %d\\n",0, kdata1
>    printks "at: %f\\n",0, knoteofftime
>  endif
>
> endin
>
> 
>
> 
> i 1 0 10
> e
> 
>
> 
>
> (I rearranged the example reported in the opcode help of "midiin" to my needs.)
> It seems to work quite well, except for the fact that it actually does not print the very first note-on message and the very last note-off message, and in the case of a MIDI file containing a single note nothing gets printed.
> Could you please advise me about what could be the problem here? It seems to me that the problem is not in the printing, as I have also tried storing note numbers in a variable and the same problem seems to persist.
> Hope you can help me find a solution!
>
> Cheers
>
> Andrea
>

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

Date2016-02-13 15:15
FromAndrea Crespi <4ndr34cr35p1@GMAIL.COM>
SubjectRe: Failing to display MIDI information in output console
Attachmentstest.mid  test2.mid  
OK, here they are:

2016-02-13 14:54 GMT+00:00 jpff <jpff@codemist.co.uk>:
Also could you provide your test.mid?

On Sat, 13 Feb 2016, Andrea Crespi wrote:

Hi, I am quite new to Csound and I am having a little issue with a project I am trying to develop. I thought this might be the right place to ask for a little help. Please let me know if this is cool.
In a few words, I would like to fill a few arrays with data coming from a MIDI stream (being it a live performance on a keyboard or information coming from a MIDI file). Then, I am planning to analyze this data and translate it into performance data of some kind. Actually, I do not need to "record" the whole performance, just data regarding a certain time window (the last bar for example).
To begin with, I have started from a very simple program that reads a MIDI file and prints note-on and note-off events to the output console.
This i what I wrote:

<CsoundSynthesizer>

<CsOptions>
-F test.mid
</CsOptions>

<CsInstruments>

sr = 44100
ksmps = 32
nchnls = 2
0dbfs = 1

massign 0, 1    ; make sure that all channels
pgmassign 0, 1  ; and programs are assigned to test instr

instr 1

 kstatus, kchan, kdata1, kdata2 midiin

 if (kstatus == 144) then
   knoteontime times
   printks "status= %d\\n",0, kstatus
   printks "note = %d\\n",0, kdata1
   printks "at: %f\\n",0, knoteontime
 elseif (kstatus == 128) then
   knoteofftime times
   printks "status= %d\\n",0, kstatus
   printks "note = %d\\n",0, kdata1
   printks "at: %f\\n",0, knoteofftime
 endif

endin

</CsInstruments>

<CsScore>
i 1 0 10
e
</CsScore>

<CsoundSynthesizer>

(I rearranged the example reported in the opcode help of "midiin" to my needs.)
It seems to work quite well, except for the fact that it actually does not print the very first note-on message and the very last note-off message, and in the case of a MIDI file containing a single note nothing gets printed.
Could you please advise me about what could be the problem here? It seems to me that the problem is not in the printing, as I have also tried storing note numbers in a variable and the same problem seems to persist.
Hope you can help me find a solution!

Cheers

Andrea


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

Date2016-02-13 15:25
Fromjpff
SubjectRe: Failing to display MIDI information in output console
I get for test2.mid

SECTION 1:
new alloc for instr 1:
   rtevent:         T  0.250 TT  0.250 M:  0.00000  0.00000
new MIDI alloc for instr 1:
status= 144
note = 60
%f

at: 0.251066
   rtevent:         T  1.125 TT  1.125 M:  0.00000  0.00000
end of midi track in 'test2.mid'
0 forced decays, 0 extra noteoffs
status= 128
note = 60
%f

at: 1.125442
B  0.000 .. 10.000 T 10.000 TT 10.000 M:  0.00000  0.00000

Is that what you get?
==John ff

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

Date2016-02-13 15:35
FromVictor Lazzarini
SubjectRe: Failing to display MIDI information in output console
I think the midi triggering needs to be disabled with 

massign 0,0

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

> On 13 Feb 2016, at 15:25, jpff  wrote:
> 
> I get for test2.mid
> 
> SECTION 1:
> new alloc for instr 1:
>  rtevent:         T  0.250 TT  0.250 M:  0.00000  0.00000
> new MIDI alloc for instr 1:
> status= 144
> note = 60
> %f
> 
> at: 0.251066
>  rtevent:         T  1.125 TT  1.125 M:  0.00000  0.00000
> end of midi track in 'test2.mid'
> 0 forced decays, 0 extra noteoffs
> status= 128
> note = 60
> %f
> 
> at: 1.125442
> B  0.000 .. 10.000 T 10.000 TT 10.000 M:  0.00000  0.00000
> 
> Is that what you get?
> ==John ff
> 
> 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

Date2016-02-13 15:55
FromAndrea Crespi <4ndr34cr35p1@GMAIL.COM>
SubjectRe: Failing to display MIDI information in output console
That is not what I get in CsoundQt using test2.mid. I just do not get any message printed.
Using test.mid I get everything printed except for the very first note-on and the very last note-off.
Trying to use massign 0, 0 did not help, unfortunately.

Maybe this issue has to do with CsoundQt?

2016-02-13 15:35 GMT+00:00 Victor Lazzarini <Victor.Lazzarini@nuim.ie>:
I think the midi triggering needs to be disabled with

massign 0,0

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

> On 13 Feb 2016, at 15:25, jpff <jpff@CODEMIST.CO.UK> wrote:
>
> I get for test2.mid
>
> SECTION 1:
> new alloc for instr 1:
>  rtevent:         T  0.250 TT  0.250 M:  0.00000  0.00000
> new MIDI alloc for instr 1:
> status= 144
> note = 60
> %f
>
> at: 0.251066
>  rtevent:         T  1.125 TT  1.125 M:  0.00000  0.00000
> end of midi track in 'test2.mid'
> 0 forced decays, 0 extra noteoffs
> status= 128
> note = 60
> %f
>
> at: 1.125442
> B  0.000 .. 10.000 T 10.000 TT 10.000 M:  0.00000  0.00000
>
> Is that what you get?
> ==John ff
>
> 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

Date2016-02-13 18:03
FromVictor Lazzarini
SubjectRe: Failing to display MIDI information in output console
Try "run on terminal" in CsoundQT to see if it makes any difference

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

On 13 Feb 2016, at 15:55, Andrea Crespi <4ndr34cr35p1@GMAIL.COM> wrote:

That is not what I get in CsoundQt using test2.mid. I just do not get any message printed.
Using test.mid I get everything printed except for the very first note-on and the very last note-off.
Trying to use massign 0, 0 did not help, unfortunately.

Maybe this issue has to do with CsoundQt?

2016-02-13 15:35 GMT+00:00 Victor Lazzarini <Victor.Lazzarini@nuim.ie>:
I think the midi triggering needs to be disabled with

massign 0,0

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

> On 13 Feb 2016, at 15:25, jpff <jpff@CODEMIST.CO.UK> wrote:
>
> I get for test2.mid
>
> SECTION 1:
> new alloc for instr 1:
>  rtevent:         T  0.250 TT  0.250 M:  0.00000  0.00000
> new MIDI alloc for instr 1:
> status= 144
> note = 60
> %f
>
> at: 0.251066
>  rtevent:         T  1.125 TT  1.125 M:  0.00000  0.00000
> end of midi track in 'test2.mid'
> 0 forced decays, 0 extra noteoffs
> status= 128
> note = 60
> %f
>
> at: 1.125442
> B  0.000 .. 10.000 T 10.000 TT 10.000 M:  0.00000  0.00000
>
> Is that what you get?
> ==John ff
>
> 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

Date2016-02-13 18:14
FromAndrea Crespi <4ndr34cr35p1@GMAIL.COM>
SubjectRe: Failing to display MIDI information in output console
I tried but it does not help either.
In the meantime, I noticed that I get this message:

end of midi track in 'test2.mid'
0 forced delays, 1 extra noteoffs

just before the "inactive allocs returned to freespace".

(Thanks for all these replies!)

2016-02-13 18:03 GMT+00:00 Victor Lazzarini <Victor.Lazzarini@nuim.ie>:
Try "run on terminal" in CsoundQT to see if it makes any difference

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

On 13 Feb 2016, at 15:55, Andrea Crespi <4ndr34cr35p1@GMAIL.COM> wrote:

That is not what I get in CsoundQt using test2.mid. I just do not get any message printed.
Using test.mid I get everything printed except for the very first note-on and the very last note-off.
Trying to use massign 0, 0 did not help, unfortunately.

Maybe this issue has to do with CsoundQt?

2016-02-13 15:35 GMT+00:00 Victor Lazzarini <Victor.Lazzarini@nuim.ie>:
I think the midi triggering needs to be disabled with

massign 0,0

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

> On 13 Feb 2016, at 15:25, jpff <jpff@CODEMIST.CO.UK> wrote:
>
> I get for test2.mid
>
> SECTION 1:
> new alloc for instr 1:
>  rtevent:         T  0.250 TT  0.250 M:  0.00000  0.00000
> new MIDI alloc for instr 1:
> status= 144
> note = 60
> %f
>
> at: 0.251066
>  rtevent:         T  1.125 TT  1.125 M:  0.00000  0.00000
> end of midi track in 'test2.mid'
> 0 forced decays, 0 extra noteoffs
> status= 128
> note = 60
> %f
>
> at: 1.125442
> B  0.000 .. 10.000 T 10.000 TT 10.000 M:  0.00000  0.00000
>
> Is that what you get?
> ==John ff
>
> 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
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

Date2016-02-13 18:37
FromVictor Lazzarini
SubjectRe: Failing to display MIDI information in output console
I think the problem is that your CSD is not terminated properly (you have  
 instead of  ). If you put the backslash, it
should work (I only noticed it when I tried your example and noticed instr 1 was not being
instantiated by the score).

========================
Dr Victor Lazzarini
Dean of Arts, Celtic Studies and Philosophy,
Maynooth University,
Maynooth, Co Kildare, Ireland
Tel: 00 353 7086936
Fax: 00 353 1 7086952 

> On 13 Feb 2016, at 15:15, Andrea Crespi <4ndr34cr35p1@GMAIL.COM> wrote:
> 
> OK, here they are:
> 
> 2016-02-13 14:54 GMT+00:00 jpff :
> Also could you provide your test.mid?
> 
> On Sat, 13 Feb 2016, Andrea Crespi wrote:
> 
> Hi, I am quite new to Csound and I am having a little issue with a project I am trying to develop. I thought this might be the right place to ask for a little help. Please let me know if this is cool.
> In a few words, I would like to fill a few arrays with data coming from a MIDI stream (being it a live performance on a keyboard or information coming from a MIDI file). Then, I am planning to analyze this data and translate it into performance data of some kind. Actually, I do not need to "record" the whole performance, just data regarding a certain time window (the last bar for example).
> To begin with, I have started from a very simple program that reads a MIDI file and prints note-on and note-off events to the output console.
> This i what I wrote:
> 
> 
> 
> 
> -F test.mid
> 
> 
> 
> 
> sr = 44100
> ksmps = 32
> nchnls = 2
> 0dbfs = 1
> 
> massign 0, 1    ; make sure that all channels
> pgmassign 0, 1  ; and programs are assigned to test instr
> 
> instr 1
> 
>  kstatus, kchan, kdata1, kdata2 midiin
> 
>  if (kstatus == 144) then
>    knoteontime times
>    printks "status= %d\\n",0, kstatus
>    printks "note = %d\\n",0, kdata1
>    printks "at: %f\\n",0, knoteontime
>  elseif (kstatus == 128) then
>    knoteofftime times
>    printks "status= %d\\n",0, kstatus
>    printks "note = %d\\n",0, kdata1
>    printks "at: %f\\n",0, knoteofftime
>  endif
> 
> endin
> 
> 
> 
> 
> i 1 0 10
> e
> 
> 
> 
> 
> (I rearranged the example reported in the opcode help of "midiin" to my needs.)
> It seems to work quite well, except for the fact that it actually does not print the very first note-on message and the very last note-off message, and in the case of a MIDI file containing a single note nothing gets printed.
> Could you please advise me about what could be the problem here? It seems to me that the problem is not in the printing, as I have also tried storing note numbers in a variable and the same problem seems to persist.
> Hope you can help me find a solution!
> 
> Cheers
> 
> Andrea
> 
> 
> 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

Date2016-02-13 22:11
FromAndrea Crespi <4ndr34cr35p1@GMAIL.COM>
SubjectRe: Failing to display MIDI information in output console
It works, thanks a lot!
I was not expecting something like this could be the bug because I thought Csound would have displayed some kind of warning.
Anyways, thanks again and I am sorry it was such a dumb question in the end!

Regards

2016-02-13 18:37 GMT+00:00 Victor Lazzarini <Victor.Lazzarini@nuim.ie>:
I think the problem is that your CSD is not terminated properly (you have
<CsoundSynthesizer> instead of  </CsoundSynthesizer>). If you put the backslash, it
should work (I only noticed it when I tried your example and noticed instr 1 was not being
instantiated by the score).

========================
Dr Victor Lazzarini
Dean of Arts, Celtic Studies and Philosophy,
Maynooth University,
Maynooth, Co Kildare, Ireland
Tel: 00 353 7086936
Fax: 00 353 1 7086952

> On 13 Feb 2016, at 15:15, Andrea Crespi <4ndr34cr35p1@GMAIL.COM> wrote:
>
> OK, here they are:
>
> 2016-02-13 14:54 GMT+00:00 jpff <jpff@codemist.co.uk>:
> Also could you provide your test.mid?
>
> On Sat, 13 Feb 2016, Andrea Crespi wrote:
>
> Hi, I am quite new to Csound and I am having a little issue with a project I am trying to develop. I thought this might be the right place to ask for a little help. Please let me know if this is cool.
> In a few words, I would like to fill a few arrays with data coming from a MIDI stream (being it a live performance on a keyboard or information coming from a MIDI file). Then, I am planning to analyze this data and translate it into performance data of some kind. Actually, I do not need to "record" the whole performance, just data regarding a certain time window (the last bar for example).
> To begin with, I have started from a very simple program that reads a MIDI file and prints note-on and note-off events to the output console.
> This i what I wrote:
>
> <CsoundSynthesizer>
>
> <CsOptions>
> -F test.mid
> </CsOptions>
>
> <CsInstruments>
>
> sr = 44100
> ksmps = 32
> nchnls = 2
> 0dbfs = 1
>
> massign 0, 1    ; make sure that all channels
> pgmassign 0, 1  ; and programs are assigned to test instr
>
> instr 1
>
>  kstatus, kchan, kdata1, kdata2 midiin
>
>  if (kstatus == 144) then
>    knoteontime times
>    printks "status= %d\\n",0, kstatus
>    printks "note = %d\\n",0, kdata1
>    printks "at: %f\\n",0, knoteontime
>  elseif (kstatus == 128) then
>    knoteofftime times
>    printks "status= %d\\n",0, kstatus
>    printks "note = %d\\n",0, kdata1
>    printks "at: %f\\n",0, knoteofftime
>  endif
>
> endin
>
> </CsInstruments>
>
> <CsScore>
> i 1 0 10
> e
> </CsScore>
>
> <CsoundSynthesizer>
>
> (I rearranged the example reported in the opcode help of "midiin" to my needs.)
> It seems to work quite well, except for the fact that it actually does not print the very first note-on message and the very last note-off message, and in the case of a MIDI file containing a single note nothing gets printed.
> Could you please advise me about what could be the problem here? It seems to me that the problem is not in the printing, as I have also tried storing note numbers in a variable and the same problem seems to persist.
> Hope you can help me find a solution!
>
> Cheers
>
> Andrea
>
>
> 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 <test.mid><test2.mid>

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

Date2016-02-14 09:20
FromVictor Lazzarini
SubjectRe: Failing to display MIDI information in output console
you are right, it should have given out an error.

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

On 13 Feb 2016, at 22:11, Andrea Crespi <4ndr34cr35p1@GMAIL.COM> wrote:

It works, thanks a lot!
I was not expecting something like this could be the bug because I thought Csound would have displayed some kind of warning.
Anyways, thanks again and I am sorry it was such a dumb question in the end!

Regards

2016-02-13 18:37 GMT+00:00 Victor Lazzarini <Victor.Lazzarini@nuim.ie>:
I think the problem is that your CSD is not terminated properly (you have
<CsoundSynthesizer> instead of  </CsoundSynthesizer>). If you put the backslash, it
should work (I only noticed it when I tried your example and noticed instr 1 was not being
instantiated by the score).

========================
Dr Victor Lazzarini
Dean of Arts, Celtic Studies and Philosophy,
Maynooth University,
Maynooth, Co Kildare, Ireland
Tel: 00 353 7086936
Fax: 00 353 1 7086952

> On 13 Feb 2016, at 15:15, Andrea Crespi <4ndr34cr35p1@GMAIL.COM> wrote:
>
> OK, here they are:
>
> 2016-02-13 14:54 GMT+00:00 jpff <jpff@codemist.co.uk>:
> Also could you provide your test.mid?
>
> On Sat, 13 Feb 2016, Andrea Crespi wrote:
>
> Hi, I am quite new to Csound and I am having a little issue with a project I am trying to develop. I thought this might be the right place to ask for a little help. Please let me know if this is cool.
> In a few words, I would like to fill a few arrays with data coming from a MIDI stream (being it a live performance on a keyboard or information coming from a MIDI file). Then, I am planning to analyze this data and translate it into performance data of some kind. Actually, I do not need to "record" the whole performance, just data regarding a certain time window (the last bar for example).
> To begin with, I have started from a very simple program that reads a MIDI file and prints note-on and note-off events to the output console.
> This i what I wrote:
>
> <CsoundSynthesizer>
>
> <CsOptions>
> -F test.mid
> </CsOptions>
>
> <CsInstruments>
>
> sr = 44100
> ksmps = 32
> nchnls = 2
> 0dbfs = 1
>
> massign 0, 1    ; make sure that all channels
> pgmassign 0, 1  ; and programs are assigned to test instr
>
> instr 1
>
>  kstatus, kchan, kdata1, kdata2 midiin
>
>  if (kstatus == 144) then
>    knoteontime times
>    printks "status= %d\\n",0, kstatus
>    printks "note = %d\\n",0, kdata1
>    printks "at: %f\\n",0, knoteontime
>  elseif (kstatus == 128) then
>    knoteofftime times
>    printks "status= %d\\n",0, kstatus
>    printks "note = %d\\n",0, kdata1
>    printks "at: %f\\n",0, knoteofftime
>  endif
>
> endin
>
> </CsInstruments>
>
> <CsScore>
> i 1 0 10
> e
> </CsScore>
>
> <CsoundSynthesizer>
>
> (I rearranged the example reported in the opcode help of "midiin" to my needs.)
> It seems to work quite well, except for the fact that it actually does not print the very first note-on message and the very last note-off message, and in the case of a MIDI file containing a single note nothing gets printed.
> Could you please advise me about what could be the problem here? It seems to me that the problem is not in the printing, as I have also tried storing note numbers in a variable and the same problem seems to persist.
> Hope you can help me find a solution!
>
> Cheers
>
> Andrea
>
>
> 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 <test.mid><test2.mid>

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