More on Midi Input

Hi,

I have a midi mixer (AkaiMidiMix) that I want to use to change values on certain loops or code parts I have in a buffer.

I saw the tutorial with the note on/off but that’s about all of the information I get from it. I don’t know how to assign a sustain or amp value the midi hardware?

Or is this not possible.

Hi @dewildequinten,

all incoming MIDI events go straight into the time state system. You should see them in the cue log in the bottom right hand corner of the screen. This isn’t just note on/off events but CC changes too.

You can use get to retrieve the last seen matching event or sync to wait for the next event. This is explained in more detail in section 10 of the tutorial: http://sonic-pi.net/tutorial.html#section-10

Once you have obtained your value, you can do whatever you want with it - including using it as an amp: opt to a synth/sample call or to control an existing synth by sending it a new value (see section 7 http://sonic-pi.net/tutorial.html#section-7).

I hope that this helps!

Sorry it seems that I’m still not getting it.

I receive these

/midi/midi_mix/0/1/control_change [3,0]

in my cues log.

But how to I get them?

set :intensity, /midi/midi_mix/0/1/control_change [3,0] is not an option because this is a string of some sorts?

I think you’ll need to do something like this (but see the correction in the reply).

1 Like

Hey this example got me understanding it.

But is the if states necessary ?

I have something like this now.

`# midi in

live_loop :midikey do
use_real_time
key, value = sync “/midi/mpk_mini/1/1/note_on”
if key == 24
set :key1, value
end
end
live_loop :midicc do
use_real_time
knob, value = sync “/midi/midi_mix/0/1/control_change”

if knob == 3
set :knob1, value
end
end

live_loop :midisleep do
use_real_time
sleep1, value = sync “/midi/midi_mix/0/1/control_change”

if sleep1 == 2
set :sleep1, value
end
end

live_loop :midi_piano do
synth :piano, note: get(:key1), amp: get(:knob1) / 25.0
sleep get(:sleep1) / 127.0
end`

The if statements after the syncs are necessary because there are different CC messages that arrive on the same OSC address, so we can pick out which one(s) we are interested in, and react in the appropriate way. Otherwise it would always react to all CC messages, even if they come from a different knob.