Beginner - midi note to float/integer ('select' pure data)


#1

Hello, sorry to ask a beginner question - I've been doing some tutorials and searching the forum for a while, but still no luck.

I'm coming from a pure data and max background, and finding it hard work switching to the axo. I'd forgotten what's its like learning a new language and not knowing the most basic things....

I would like to take a midi note and convert it to a float (so I can send it to the phase input of factotum). I want to hit a key, e.g. 60, and I want the object to output 0.25, then for key 61, I'd like 0.50, etc.

I've looked through the midi objects, math, and other categories of objects, but I've still not found a selection of objects to help build this.

I did find this note to cc converter - I just couldn't find a float object that I could bang the output of (based on a condition)

So, here's some specific questions:
1) what's the simplest way to trigger/output a float based on a midi note a) some existing objects (like the above note to cc converter) if so which objects would I need? b) case select within a patch/object or the midi/in/script object, c) using a table , I will need 6 mappings in total.

2) are there any guides or tips for anyone from a pd background?


#2

Axoloti mostly uses fixed point math to communicate signals between objects.
E.g. midi notes (pitch) are sent as a krate q11.21 values.

They are also offset. Midi notes are 0..127 per the protocol. Axoloti offsets them by -64, so you end up with a -64..63 range for midi notes converted to pitch values.

It sounds like you want to do a linear transformation of the pitch value.

That is: out = A * pitch + B

So that:
midi 60 -> pitch -4 -> output 0.25
midi 61 -> pitch -3 -> out 0.5
etc...

which is: out = 0.25 * pitch + 1.25

and you can do that using the factory math objects.

Note: the result would be a fixed point quantity - not a float. I haven't seen any objects using floating point values for inter-object communication.


#3

as @deadsy said the midi note value is converted to a 'float' (blue) already.
from here you have 2 choices.

a) derive the phases mathematically
b) convert the note to an integer (green) , then a bit of maths an use it as input into a mux8 to select the appropriate value, which you can set on each of the i0 to i8 inputs

(a) works well when you want to do lots of values
(b) is a bit easier then its a limited set of notes you want to do (which seems to be the case here)

note: there may be objects in the community library that help you do this, especially things like scaling - but I do not use, so perhaps someone else can suggest, or you'll need to dig a bit :slight_smile:


experience in PD will help you a lot for how to patch, especially in structuring patches.

however, the first thing to recognise is Axoloti patching is different in the way it works

pure data is event driven, i.e. objects fire message from one to the next.

axoloti is data driven, so data constantly flows between objects.

think of a physical modular synth, the inputs have a value (voltage) at all times, not in response to something happening.
this is why there cannot be a select in axoloti , since every wires always has a value... you cant change the way the signals flow - initially this may feel odd/counter intuitive, but its not really, its just different.

ok, that may be a bit technical/and difficult to explain in one short paragraph,
but the upshot is, sometimes you might have to approach the problem in a different way to how its done in PD.


#4

thanks @thetechnobear and @deadsy

that all makes sense, still I making much slower progress than I was expecting, that's fine, I guess I just have to lower my ideas/expectations.

so, now I've followed the above advice regarding mux (converting the midi note I want to be the trigger, into a value to 1-8 so I can use that to trigger the output of a mux 8), however I am still stuck trying to connect multiple outputs of each converted note into the mux input, seems you cannot just drag multiple cables onto the same input....

I looked around a few more objects. but couldn't see anything yet. I had assumed this was the easy part of the patch - hooking up the midi controls. Now I'm worried about doing midi CCs (atleast that will be full range so easier to map).

here's where I am mapping 3 midi notes to trigger 3 values with a range of 0 to +64 (this is to input into factotoum phase input - I was wrong before when I thought it was 0-1 input range, it's 0 to +64). The midi note values will probably change down the line, so I wanted to allow this to handle any particular notes in any order (they're just midi pad triggers).


#5

Do you know how to code in C? From the looks of things you are just trying to map arbitrary midi notes values onto arbitrary constants. You could do it all in one object with not a lot of C code. I'm not saying you can't do it by hooking up the squares, but it's a bit long-winded/inefficient.

Something like:

table = {
  {60. 1.0},
  {63, 3.141},
  {49, 2.7},
  {-1, 0}, // eol
};
ptr = &table[0]
while (ptr->note > 0) {
  if (in == ptr->note) {
    out = ptr->val;
    return;
  }
  ptr ++;
} 
out = 0;

#6

thanks, I've done a bit of C, Python, and some javascript, mostly I've forgotten C. So I'd much rather the above approach than trying to guess how a load of boxes work (especially in a 'signal world' which makes it hard to track down what is actually happening in what order)


#7

I'm nearly there now. I re-mapped the midi notes of my device sending the midi to make the calculations easier.

It's not doing exactly what I expect, but it's getting closer, I'll keep playing (although at some point it would be nice to start making some music.. :slight_smile: )

I just want to send an int (0 to 64) and a 'high yellow' signal simultaneously to trigger playback at a certain position.

edit: played around a bit more, still no closer, it seems the signal phase position (0-64) is being sent before the yellow gate signal (and the yellow gate sync value is the one that triggers playback). I'm gonna put this down for a few days, hopefully my brain will work out another way to think about this in the mean time.

I haven't used a modular synth before, so I think that's a critical skill / pre-requisite to creating axoloti patches - currently I can't really think in a signal way.


#8

I'm probably misunderstanding this as no one else has provided this answer, but if you look for instance in one of the oscillator objects in factory/osc, there is a macro called MTOFEXTENDED() which converts an Axoloti pitch (in fixed point format) to a frequncy (also in fixed point format), for use for instance as a phase increment in an oscillator (see osc/saw cheap.axo for a trivial sawtooth implementation for instance).


#9

I've made some progress with this, I found the midi/in keyb note, which will output a high signal (yellow cable) when it receives a certain midi note (that you can set), so I just need to hook up 4-6 of these.

The only problem now , is that I need to strip out the 'note -off', because I want to hit a midi note and use that to toggle something on or off.


#10

You should be able to modify the MIDI code in the object so that instead of turning the gate output on when note on is received and off when note off is received, it toggles the gate each time note on is received (and ignores the note off).


#11

Thanks, I discovered there is a user object called 'rbrt/midi/in/note on' where you can specifiy a range of notes.

if you limit this to just one note, and combine it with logic/toggle you can turn a midi note on a controller into an on/off toggle - which is nearly what I want to do.

For future reference / any beginners, here is my latest version of this patch - just an image because it's not particularly usable yet, too glitchy.