Get values from midi keyboard

I want to control parameters like up with a midi keyboard, but so far, I can only get the velocity value from one note at a time.

I've looked through the list of midi functions (in Control.hs), and I'm not sure what to do.
Is there any way to do this in the current version of tidal?

1 Like

Hi, can you explain the problem a bit more please?

Basically, I want the tidal code to be a sort of instrument I can control with a keyboard, more like how in a traditional daw you can select a synth and play it with a keyboard.

I want to do that by changing the up parameter of a pattern with a midi keyboard. So far, I've found ways to get the velocity values of individual midi keys to control parameters, but I don't want the velocity. I want the midi value of the actual key I'm pressing.

Currently, is there any way to do that?

Hi @CUSTOM_ROBO

I've managed to do this following these instructions

I slightly edited the SC code to get it to do what I wanted:

MIDI IN

//To accept MIDI in to Tidal we need to run a bit more code - this lets SuperCollider convert MIDI inputs from your controller into OSC messages

// Evaluate the block below to start the mapping MIDI -> OSC.

(
var on, off, cc;
var osc;

osc = NetAddr.new("127.0.0.1", 6010);

MIDIClient.init;
MIDIIn.connectAll;

on = MIDIFunc.noteOn({ |val, num, chan, src|

osc.sendMsg("/ctrl", "n", num); // if I remember correctly this was the bit I changed to get notes in!

});

off = MIDIFunc.noteOff({ |val, num, chan, src|
osc.sendMsg("/ctrl", "n", 0);
});

cc = MIDIFunc.cc({ |val, num, chan, src|
osc.sendMsg("/ctrl", num.asString, val/127);

});

if (~stopMidiToOsc != nil, {
~stopMidiToOsc.value;
});

~stopMidiToOsc = {
on.free;
off.free;
cc.free;
};
)

And then using code in Tidal like this:

d4 $ sound "arpy" # up (cF 1 "n")

Depending on the pitch of your samples etc you will probably need to transform the midinote to a lower number, as up maps to semitones, rather than midinotes.

Something like:

d4 $ sound "arpy" # up ((cF 1 "n")-60)

And you might need to have a play around with noteon/noteoff (I used this in a kind of drone/noise setting so wasn't such a big deal for me, but this setup will still play the tidal pattern even when a note isn't being pressed - you could try mapping noteon/noteoff to #gain to help with this).

Hopefully this will get you started - shout back if you need any help.

2 Likes

Sorry I haven't replied, been off the forum for a while.

The script you posted as exactly what I was looking for. I'll keep toying with it, and if I find something SuperDirt worthy, I'll put in a pull request.

Since I helped someone out with this topic today, I would like to append something to this topic for the sake of completeness. It is also possible to send a list of notes to TidalCycles (e.g. to send whole chords). My SuperCollider code looks like this:

(
var on, off;
var osc;

osc = NetAddr.new("127.0.0.1", 6010);

~notes=[];

MIDIClient.init;
MIDIIn.connectAll;

on = MIDIFunc.noteOn({ |val, num, chan, src|
	~notes=~notes.add(num);
	~notes=~notes.sort({|a,b| a>b}).reverse;
	osc.sendMsg("/ctrl", "notes", format("%", ~notes-60));
});

off = MIDIFunc.noteOff({ |val, num, chan, src|
	~notes=~notes.takeThese({|x| x ==num});
	osc.sendMsg("/ctrl", "notes", format("%", ~notes-60));
});


if (~stopMidiToOsc != nil, {
	~stopMidiToOsc.value;
});

~stopMidiToOsc = {
	on.free;
	off.free;
};
)

In TidalCycles there is a (undocumented?) function cP, which accepts whole lists. So with the code above you could do something like this:

d1 $ s "superpiano" <| n (arp "converge" $ cP "notes")

So maybe this is useful for someone...

3 Likes

This is great thank you!

Nice!
Note that cP actually accepts mininotation. So when you send a 'list' like "[40,43,50]" to get a chord, you could also send "[40,43,<50 60>]" or whatever..

I haven't even thought about it, but sure, why not. The controls are basically nothing else than patterns. But that offers endless possibilities in exchange with other systems. I do not know yet where this will end but I like it.

1 Like