# Midi / Cabbage/ print values

**URL:** <https://forum.cabbageaudio.com/t/midi-cabbage-print-values/730>\
**Category:** Csound Noobs\
**Created:** [26 September 2017 13:17 UTC](https://forum.cabbageaudio.com/t/midi-cabbage-print-values/730 "2017-09-26T13:17:26Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Karamel1](https://forum.cabbageaudio.com/user_avatar/forum.cabbageaudio.com/karamel1/32/1680_2.png) [@Karamel1](https://forum.cabbageaudio.com/u/Karamel1)\
**Post date:** [26 September 2017 13:17 UTC](https://forum.cabbageaudio.com/t/midi-cabbage-print-values/730/1 "2017-09-26T13:17:26Z")

</div>

Hello,

I would like to monitor some midi events :just the key pressed and particularly when a key is released for a bug tracking.  
printk2 p4  
printk2 p5  
show the velocity and the note but does not show when the key is release.  
How can I do that in cabbage in order to get an output like showing that the key has been released ? :  
p4 : 60  
p5 : 0.8

```
p4 : 60 
p5 : 0

```

Thanks for help

---

<div class="post-metadata">

**Author:** ![rorywalsh](https://forum.cabbageaudio.com/user_avatar/forum.cabbageaudio.com/rorywalsh/32/165_2.png) [@rorywalsh](https://forum.cabbageaudio.com/u/rorywalsh)\
**Post date:** [26 September 2017 14:50 UTC](https://forum.cabbageaudio.com/t/midi-cabbage-print-values/730/2 "2017-09-26T14:50:52Z")

</div>

You can use the [release](https://csound.github.io/docs/manual/release.html) opcode ala:

```
instr 1
prints "\nNote on. Freq:%4.f, Amp:%f", p4, p5

kNoteOff release
if changed:k(kNoteOff)==1 then
	printks "\nNote off", 0
endif

endin
```

---

<div class="post-metadata">

**Author:** ![Karamel1](https://forum.cabbageaudio.com/user_avatar/forum.cabbageaudio.com/karamel1/32/1680_2.png) [@Karamel1](https://forum.cabbageaudio.com/u/Karamel1)\
**Post date:** [26 September 2017 14:52 UTC](https://forum.cabbageaudio.com/t/midi-cabbage-print-values/730/3 "2017-09-26T14:52:27Z")

</div>

Thank you a lot !

---

<div class="post-metadata">

**Author:** ![rorywalsh](https://forum.cabbageaudio.com/user_avatar/forum.cabbageaudio.com/rorywalsh/32/165_2.png) [@rorywalsh](https://forum.cabbageaudio.com/u/rorywalsh)\
**Post date:** [26 September 2017 14:57 UTC](https://forum.cabbageaudio.com/t/midi-cabbage-print-values/730/4 "2017-09-26T14:57:06Z")

</div>

No problem, thanks for building the latest source on Windows. I’ve uploaded it and it is now available from the beta releases page.

---

<div class="post-metadata">

**Author:** ![Karamel1](https://forum.cabbageaudio.com/user_avatar/forum.cabbageaudio.com/karamel1/32/1680_2.png) [@Karamel1](https://forum.cabbageaudio.com/u/Karamel1)\
**Post date:** [26 September 2017 15:01 UTC](https://forum.cabbageaudio.com/t/midi-cabbage-print-values/730/5 "2017-09-26T15:01:57Z")

</div>

Great !  
People will be happy I hope.

About the midi bug : Somehow, all key when pressed and release indeed send a note on / note off message… but my synth from time to time continue sending audi, as if the note off was not received… this is really weird. I can’t see where this comes from.

Do you have any idea how I could debug this ?

---

<div class="post-metadata">

**Author:** ![Karamel1](https://forum.cabbageaudio.com/user_avatar/forum.cabbageaudio.com/karamel1/32/1680_2.png) [@Karamel1](https://forum.cabbageaudio.com/u/Karamel1)\
**Post date:** [26 September 2017 15:07 UTC](https://forum.cabbageaudio.com/t/midi-cabbage-print-values/730/6 "2017-09-26T15:07:02Z")

</div>

Mmmmhhh… I don’t see the link.  
Did you put it in the following post [Latest beta packages available here (updated links)](http://forum.cabbageaudio.com/t/latest-beta-packages-available-here-new-release/114/8) ?  
Maybe should you also update the text ?

---

<div class="post-metadata">

**Author:** ![gsenna](https://forum.cabbageaudio.com/letter_avatar_proxy/v4/letter/g/a88e4f/32.png) [@gsenna](https://forum.cabbageaudio.com/u/gsenna)\
**Post date:** [26 September 2017 21:54 UTC](https://forum.cabbageaudio.com/t/midi-cabbage-print-values/730/7 "2017-09-26T21:54:10Z")

</div>

Hey @Karamel1,

Couldn’t it be something similar to this: [Cabbage missing "note off" messages - notes stay open](http://forum.cabbageaudio.com/t/cabbage-missing-note-off-messages-notes-stay-open/248) ?

---

<div class="post-metadata">

**Author:** ![rorywalsh](https://forum.cabbageaudio.com/user_avatar/forum.cabbageaudio.com/rorywalsh/32/165_2.png) [@rorywalsh](https://forum.cabbageaudio.com/u/rorywalsh)\
**Post date:** [27 September 2017 07:32 UTC](https://forum.cabbageaudio.com/t/midi-cabbage-print-values/730/8 "2017-09-27T07:32:15Z")

</div>

The link is there, I replaced the old binary with the one you created. And the text is updated, from v2.20 to v2.21.

Re the MIDI bug. You could step through the following methods with the VS debugger.

> <https://github.com/rorywalsh/cabbage/blob/master/Source/Audio/Plugins/CsoundPluginProcessor.cpp#L680-L717>

  
That’s where the MIDI information is passed to Csound. Looks like certain note-offs are not making it through?

@gsenna, thanks for pointing to that thread, hopefully that might do the trick.

---

<div class="post-metadata">

**Author:** ![Karamel1](https://forum.cabbageaudio.com/user_avatar/forum.cabbageaudio.com/karamel1/32/1680_2.png) [@Karamel1](https://forum.cabbageaudio.com/u/Karamel1)\
**Post date:** [27 September 2017 13:28 UTC](https://forum.cabbageaudio.com/t/midi-cabbage-print-values/730/9 "2017-09-27T13:28:45Z")

</div>

Hello,

Well, I tried the @gsenna 's trick on real key board with no result.  
Concerning the VS debugging : i tried but this really goes over my programming skills.  
However, I manage to reproduce the bug very easily using debugger :  
Start debugging, launch the instrument, load a preset.on keyboard  
Play a few note to check if this woks  
Then  
just put any breakpoint into the `CsoundPluginProcessor::ReadMidiData` function (i.e. at the return line)  
play a note on the real keyboard.  
remove the breakpoint and continue execution with F5… The note plays for ever. ( whene ever in the process the key has been release long time ago)

I really need help on that …  
Thank you

---

<div class="post-metadata">

**Author:** ![rorywalsh](https://forum.cabbageaudio.com/user_avatar/forum.cabbageaudio.com/rorywalsh/32/165_2.png) [@rorywalsh](https://forum.cabbageaudio.com/u/rorywalsh)\
**Post date:** [27 September 2017 15:22 UTC](https://forum.cabbageaudio.com/t/midi-cabbage-print-values/730/10 "2017-09-27T15:22:41Z")

</div>

I think that just proves what we already know, i.e, somehow, somewhere, a note off message is not getting through. I apologise for not being able to look into this at the moment. Once things settle down a little at work I should have more free time to delve into the dark world of MIDI messages!

---

<div class="post-metadata">

**Author:** ![gsenna](https://forum.cabbageaudio.com/letter_avatar_proxy/v4/letter/g/a88e4f/32.png) [@gsenna](https://forum.cabbageaudio.com/u/gsenna)\
**Post date:** [27 September 2017 15:52 UTC](https://forum.cabbageaudio.com/t/midi-cabbage-print-values/730/11 "2017-09-27T15:52:02Z")

</div>

Oh, sorry it didn’t work. This is with a real keyboard, right? Can you trigger this behavior with the virtual keyboard also? If no, then how about midi monitoring with MIDI-OX to see if the note off is there?

Could you post a minimal .csd? I can install latest Cabbage in a virtual machine after coming back from Montevideo next week and try with my Casio keyboard if you like.

---

<div class="post-metadata">

**Author:** ![Karamel1](https://forum.cabbageaudio.com/user_avatar/forum.cabbageaudio.com/karamel1/32/1680_2.png) [@Karamel1](https://forum.cabbageaudio.com/u/Karamel1)\
**Post date:** [27 September 2017 16:10 UTC](https://forum.cabbageaudio.com/t/midi-cabbage-print-values/730/12 "2017-09-27T16:10:58Z")

</div>

Many thanks to you.  
@rorywalsh : no worries, things will find a solution.

@gsenna : My keyboard is a ALESIS VI-49, I did indeed monitor with MIDI-OX . All notes are sent with a note on and a note off message. So the keyboard is not buggy.  
Once I have triggered the bug with the real midi keyboard, then I can repeat it with the virtual keyboard, on the same note.

When printing all messages received by the instrument, it indeed receive all note on and note off.  
I also changed the computer from my tablet to my big Tower (core i7) .. I get the same trouble after a while.  
It seems to me that, Cabbage forgets from time to time to send a note off to Csound. (I discovered today that there can be a residual sound with all previously played notes, as if some buffer was never cleaned, despite the fact that I clear all audio variable at the end of the instrument).

The csd and the howto are in this post : [New synth beta : Morpheur - #3 by Karamel1](http://forum.cabbageaudio.com/t/new-synth-beta-morpheur/727/3)  
Even if it seems to be big… in fact all audio is in instr 1, the rest is for GUI and keyboard management and effects. I also tried to comment a lot.. for further maintenance 😄

Please feel to try it and thank you a lot for your help.
