How can one object trigger MIDI notes assigned to another object?

Discuss Lemur and share techniques.
Post Reply
simspace
Newbie
Posts: 6
Joined: 05 Apr 2017 15:48
Location: Franklin, TN
Contact:

How can one object trigger MIDI notes assigned to another object?

Post by simspace »


I have created this layout (Pads and a Multiball) where each red button on the right triggers a specific note when pressed.

Image

The problem I need to solve:

I need the ability to press and hold a pad's button, but not trigger that buttons note until I tap (or press and hold) the XY Pad Ball. That is, the XY Pad Ball needs to trigger the note on/off midi message for the selected note.

The buttons and XY pad should function like the MIDI controller seen in this video: https://youtu.be/vjKZ-hflbQA?t=12

For example, let's say pad number 10 is assigned the "C" note. What I need to do is:
  • Select the note I want to trigger (in this case "C") by pressing and holding a pad (in this case "10").
  • However the note for pad 10 should not be triggered yet, not until I press the XY Pad ball.
  • Now, when I press and hold the XY Pad ball, that is when the selected note (pad 10) is triggered and sustained (sends note on).
  • Now while pressing and holding the XY Pad ball, I can drag the ball around and change other midi parameters for the currently sustained note (in this case "C") (pad "10").
  • When I release the XY Pad ball, the note turns off (sends note off).
  • I can then repeat the process for a different note by pressing and holding another pad and then pressing, holding and dragging the XY Pad ball.

I think scripts and variables may enable me to do this, but I can't figure out how to capture the "note on" midi data in a variable when a pad is pressed.

I am a professional software engineer, but a newb to MIDI programming. I am learning how to script Lemur, but it's not clear to me how to capture MIDI data when an object is pressed and use that data in another object.

In case this helps, the red pad on the right is defined as follows.

Image

midikinetics
Newbie
Posts: 41
Joined: 15 May 2015 17:46
Contact:

Re: How can one object trigger MIDI notes assigned to another object?

Post by midikinetics »

You can check if a ball is touched/not touched by checking its `z` expression. It's just an array, so `z[finger]`.
simspace
Newbie
Posts: 6
Joined: 05 Apr 2017 15:48
Location: Franklin, TN
Contact:

Re: How can one object trigger MIDI notes assigned to another object?

Post by simspace »

midikinetics wrote: 02 Nov 2019 17:23 You can check if a ball is touched/not touched by checking its `z` expression. It's just an array, so `z[finger]`.
Thanks for the reply. That's a helpful start.

However, how do I get the ball to trigger a note that is assigned to another object ... in this case one of the numbered pad buttons being held down.

I think that's going to be the tricky part.
midikinetics
Newbie
Posts: 41
Joined: 15 May 2015 17:46
Contact:

Re: How can one object trigger MIDI notes assigned to another object?

Post by midikinetics »

Check the Lemur User Guide, chapter 10.2., Script Execution.
You can define precisely when a script will be executed, similar to the Observer Pattern.
So just execute when `x` or `y` changes.
simspace
Newbie
Posts: 6
Joined: 05 Apr 2017 15:48
Location: Franklin, TN
Contact:

Re: How can one object trigger MIDI notes assigned to another object?

Post by simspace »

midikinetics wrote: 02 Nov 2019 18:20 Check the Lemur User Guide, chapter 10.2., Script Execution.
You can define precisely when a script will be executed, similar to the Observer Pattern.
So just execute when `x` or `y` changes.

Thanks @midikinetics, this helped. I'm almost there!

My current challenge is that the noteout() method is not producing notes. I am using MidiMonitor and there are no midi messages being produced by noteout().

I defined expressions so that each note button will set an XYPad note variable to the selected note number (on press) and 0 (on release) as follows:

Image
Image

My XYPad has an expression script that watches the XYPad.note variable:

Image

I see the note values changing in the monitor. But noteout() is not producing the notes. Even a when I hardcode note values such as noteout(0, 50, 127, 0); the method is not producing notes.

I did try midiout(0,{0x00, 0x50, 0x07F}); and that did work. MidiMonitor shows the message sent by midiout(). But since Lemur variables are only in Decimal format, I can't use the variables in the midiout() method. I am thinking about writing a method to convert the decimal values to hex and use midiout(), if that is possible in Lemur scripts.

Before I attempt that, do you have any ideas why the noteout() method is not working?

Once noteout() is working, I'll update the XY Pad Ball to trigger the selected sound using noteout().
midikinetics
Newbie
Posts: 41
Joined: 15 May 2015 17:46
Contact:

Re: How can one object trigger MIDI notes assigned to another object?

Post by midikinetics »

Even a when I hardcode note values such as noteout(0, 50, 127, 0); the method is not producing notes.
Looks like the channel argument, 0, is out of range.
Strictly by historical convention, user-facing MIDI components represent channels from 1-16.
The helper functions `noteout` & `ctlout` follow this convention too.

I did try midiout(0,{0x00, 0x50, 0x07F}); and that did work.
Not sure how a MIDI command with status byte of 0x00 should even be received? That is out of MIDI spec.
https://www.midi.org/specifications-old ... di-message
Post Reply