how do I create a NoteOff event?

136 views
Skip to first unread message

Simone Baracchi

unread,
Dec 17, 2012, 4:45:33 PM12/17/12
to midi...@googlegroups.com
I wrote this simple script:

from mididings import *
from mididings.engine import *
from mididings.event import *

run(Filter(NOTE) >> KeyFilter(36) >> [
       Print("test"),
       NoteOff(37, 10),
       NoteOff(38, 0),
       NoteOn(55, 100),
    ]
)


my idea is that it should mute instrument #37 and #38 when #36 is struck (#36 being the hi-hat foot sound, and #37 and #38 being the hi-hat cymbal sound).
However, it doesn't create the NoteOff events.
The NoteOn event which I placed there just for testing is played fine. Why aren't my NoteOff events being played?

Also, my previous attempt was to use some python code and a "for" cycle:

from mididings import *
from mididings.engine import *
from mididings.event import *

class HiHatController:
    def __call__(self, ev):
        if ev.type_ == NOTEON and ev.note == 36:
            for i in range(37, 50):
               # this is wrong:
               NoteOffEvent(ev.port, ev.channel, i, 0) >> Output(ev.port, ev.channel)
        return ev

run(Process(HiHatController()))



How should I create midi events and how should I route them to output?

Thank you for reading this
Simone

Egor Sanin

unread,
Dec 17, 2012, 7:41:21 PM12/17/12
to midi...@googlegroups.com
Hi Simone

On 12/17/12, Simone Baracchi <simoneb...@gmail.com> wrote:
> I wrote this simple script:
>
> from mididings import *
> from mididings.engine import *
> from mididings.event import *
>
> run(Filter(NOTE) >> KeyFilter(36) >> [
> Print("test"),
> NoteOff(37, 10),
> NoteOff(38, 0),
> NoteOn(55, 100),
> ]
> )
>
> my idea is that it should mute instrument #37 and #38 when #36 is struck
> (#36 being the hi-hat foot sound, and #37 and #38 being the hi-hat cymbal
> sound).
> However, it doesn't create the NoteOff events.
> The NoteOn event which I placed there just for testing is played fine. Why
> aren't my NoteOff events being played?
Running the script here and checking with aseqdump shows that the
NoteOffs are played:

$ aseqdump -p mididings:1
Waiting for data. Press Ctrl+C to end.
Source Event Ch Data
128:1 Note on 0, note 36, velocity 127
128:1 Note off 0, note 37, velocity 10
128:1 Note off 0, note 38, velocity 0
128:1 Note on 0, note 55, velocity 100
128:1 Note off 0, note 36, velocity 127
128:1 Note off 0, note 37, velocity 10
128:1 Note off 0, note 38, velocity 0
128:1 Note on 0, note 55, velocity 100

The above is the output of a single hit followed by a release of key 36.
So all the notes get generated on release as well. Considering that
this is a supposed to be a footpedal (if I understand correctly) I'm
not sure this is the right behaviour.

Also, why are you using such low velocities for note offs? Just set
both to 127 velocity.


> How should I create midi events and how should I route them to output?
You're doing it right in your script.

Simone Baracchi

unread,
Dec 18, 2012, 5:10:36 PM12/18/12
to midi...@googlegroups.com
Hi Egor,

Thank you for your answer!
I did some further testing and discovered that the NoteOffs are NOT played if the channel is 10.
I don't know why it should do this, or if it is the intended behaviour, anyway for now I just switched everything to channel 9.

Just for the record, I found out the good way to create multiple midi events is to return an array of them, like this:
return [ NoteOffEvent(ev.port, ev.channel, 37, 0), NoteOffEvent(ev.port, ev.channel, 38, 0) ]

while I'm here: why should I use velocity 127 in NoteOffs? They look the same to me. Excuse me if I'm a MIDI noob, I stumbled in mididings recently while trying to find a continuous hi-hat control in Hydrogen...


Reply all
Reply to author
Forward
0 new messages