Csound Csound-dev Csound-tekno Search About

[Csnd] midinoteoff broken?

Date2007-11-23 22:54
Fromjoachim heintz
Subject[Csnd] midinoteoff broken?
I think the opcode midinoteoff is broken. It gives in fact note-on  
messages, not note-off. Please test this:

instr 1
;receiving note-on or note-off messages via midiin
kstatus, kchan, kdata1, kdata2 midiin
if	kstatus==144		then
	printks	"NOTE ON: key = %d vel = %d%n", 0, kdata1, kdata2
endif
if	kstatus==128		then
	printks	"NOTE OFF: key = %d vel = %d%n", 0, kdata1, kdata2
endif
;receiving messages via midinoteoff
kkey init 0
kvel init 0
midinoteoff	kkey, kvel
printk2		kkey
printk2		kvel
endin

(i1 0 9999)

The printout is, for example:
new alloc for instr 1:
  i1     0.00000
  i1     0.00000
   rtevent:	   T  5.556 TT  5.556 M:      0
new alloc for instr 1:
NOTE ON: key = 60 vel = 93
  i1    60.00000
  i1    93.00000
   rtevent:	   T  9.500 TT  9.500 M:      0
NOTE OFF: key = 60 vel = 64
   rtevent:	   T 21.281 TT 21.281 M:      0
NOTE ON: key = 62 vel = 80
  i1    62.00000
  i1    80.00000
   rtevent:	   T 25.829 TT 25.829 M:      0
NOTE OFF: key = 62 vel = 64
inactive allocs returned to freespace
end of score.		   overall amps:      0
0 errors in performance

I took a look in the code. Didn't understand all, but I saw that the  
code for midinoteoff and midinoteonkey are exactly the same:
    33 int midinoteoff(CSOUND *csound, MIDINOTEON *p)
    34 {
    35     if (!p->h.insdshead->m_chnbp) {
    36       return OK;
    37     }
    38     *p->xkey = p->h.insdshead->m_pitch;
    39     *p->xvelocity = p->h.insdshead->m_veloc;
    40     return OK;
    41 }
    42
    43 int midinoteonkey(CSOUND *csound, MIDINOTEON *p)
    44 {
    45     if (!p->h.insdshead->m_chnbp) {
    46       return OK;
    47     }
    48     *p->xkey = p->h.insdshead->m_pitch;
    49     *p->xvelocity = p->h.insdshead->m_veloc;
    50     return OK;
    51 }

Perhaps a typo?

Best -

	joachim