Odd Behaviour with Midi Out to Synth

Have an interesting problem with midi out …

This code

30.times do
  midi_note_on 36
  sleep 0.25
  midi_note_on 38
  sleep 0.25
end
midi_all_notes_off
print "finished"

will play the analogue synth up to about 20 notes – then all you can hear is a continuous single note until the piece is finished

This code

30.times do
  midi 36, tick
  sleep 0.25
  midi 38, tick
  sleep 0.25
end
midi_all_notes_off
print "end"

plays fine - any ideas?? Thanks

Hi Riggar,

one thing to realise is that midi_note_on and midi are quite different functions.

  • midi_note_on just sends a single ‘note on’ MIDI message. This is equivalent to pressing a key on a piano and holding it down and not releasing.
  • midi sends two MIDI messages - midi_note_on and then after a delay midi_note_off. This is equivalent to pressing a key on a piano, holding it down and then releasing it. You can change the duration of time between note on and off using the sustain: opt.

This should be enough to explain why you’re observing different behaviour.

However, the precise behaviour you observe will be down to how your particularly external synth handles multiple concurrent note on events without any note offs. I’ve seen very different behaviour across different synths. The best thing to do is to experiment and play around. Often surprise behaviour is the best!

Sam,

Thanks for getting back.
I didn’t realise they were different functions. I had also tried the ‘not working’ code with midi_note_offs but got the same result. I think the answer lies in what you are saying towards the end. I had the opportunity to try another synth (this time a Roland TB-3) and both sets of code worked fine. In fact, you could pump out midi data at lighting speed and the Roland responded well with no issues - so I think it’s the oringal synth’s midi handling.
If I discover more I’ll report back here. That said having great fun with the midi.

1 Like

Ok found the culprit.

The ‘jamming’ up of the 1st lot of code problem was eliminated by putting in midi_note_off N - where N is the same number as the corresponding midi_note_on instruction.

The reason I went down this path is that I was experimenting with random notes and I didn’t know what note was played - and so couldn’t construct a valid midi_note_off line.

QUESTION - I play random midi note - how can I detect what note it was so I can make the mid_note_off command valid

many thanks!

Store the note in a variable first:

n = (scale :e3, :minor).choose
midi_note_on n
sleep 1
midi_note_off n

Got it! - many thanks

1 Like