audio to midi for metering - how to translate the audio signal?

seb's icon

hey,

i just came up with the idea to use the volume of the track to create a midi driven meter. for the last couple of hours i tried to translate a audio signal into a midi signal without any usefull success.
at the end i would like to have a midi signal with a range between 0 and 127 like the CC events. this should give me the possibility to connect to a meter or a slider to have a visualisation.

it would be great if somebody could show me how to translate the signals.

thx

Max Patch
Copy patch and select New From Clipboard in Max.

seb

ShelLuser's icon

I spotted a bug in your scale device; it uses "min input, max input" optionally followed by "min output, max output" but you have those two values reversed. So 127 0 instead of 0 127.

But I also don't quite get the problem. If you have a value range of -1. to 1. (floats) you could easily use a live.meter and then configure its display range. That should do the trick afaik.

Ernest's icon

Nice thought. Does that fix the design? Not for sure you've the audio range you're wanting, you could want a control to adjust that inside MAX. Then, the output of your SCALE could then connect to a MIDIFORMAT object; the .maxhelp for that shows how to create the controller messages and send them to MIDI very clearly.

seb's icon

the value range between -1. to 1. would be also ok, but i cant get a proper displayed metering. i can send you a patch where i tried this but it does´nt works. thats the reason why i´m think that my mistake is the translation of the audio signal from the plugin object into something (i´m not shure if its an amplitude?) between -1. to 1. or a CC event rang from 0 to 127.

i changed the values but it doesn´t fix the problem. if i change the values the meter show full peak all the time, even if no music is playing.

@ ernest

sorry but i didn´t get your comment. sorry i´m not really experienced in m4l so please be gentle with me. :D what do you mean with this : “Not for sure you've the audio range you're wanting, you could want a control to adjust that inside MAX. “ ? and what do you mean with .maxhelp ? is this the help if i do a right click on the object or do you mean the help pages and tutorials from the menu? anyway i will have a look for both. :)

Ernest's icon

Yes of course. It's difficult to know from over here, and knowing alot of differnt things could be happening in Ableton too, what is a problem in the Ableton environment, and what is a problem in the MAX environment. What I'd suggest is adding a simple test tone source inside MAX, with a toggle to select it instead of the Ableton source, for example, a phasor~ at frequency 440Hz and ampolitude 0.5, going into a gate~ with a toggle control to select it or Ableton audio as an input. That helps find the problem. Then, when it displays what you want inside MAX, you do get to the point of adding a MIDI controller output as well as metering.

ShelLuser's icon

Right, 2nd synth evening this week (due to the heat I'm shortening my sessions ;-)) and I just tested your patch above. I don't quite understand the problem anymore because everything works as it should.

If you fix the scale object and then check your message boxes you'll see that its working as it should; it generates a value between 0 and 127.

Your problem with the meters is simply that you fed it a range from 0 to 127 while the meters react to a range of 0. - 1. So obviously putting 127 into it is getting them over the top so to speak. You can easily test this yourself. Disconnect the left live.meter, add a message box and connect it. Put 0.5 into the message box and click it; you'll see the meter react. Now put 50 into that message box, click it and you'll see the meter go into the red.

Ernest's icon

Then, when you get to adding the MIDI cdontroller output, you'll probably want a way to set up the external thing you're controlling with MIDI without changing the audio track source, For that, adding say, a slider to control the phasor~ output gain helps you see the results.

Currently you're converting 'db to a' and then adjusting the range linearly. You could also adjust the level response non-linearly, for example, by scaling the input before the dbtoa module, instead of after it. Sometimes dB level is a better control source, and sometimes gain is a better control sourcd.

Also, you could find the MIDI controller values change too quickly or too slowly, but that's something to fix *after* you have at least some MIDI controller output :)

Ernest's icon

Err....Was that too much all at once?

seb's icon

no no :)... but i found a way to fix the design of my patch. should be workin like a charm in a bit. i will come back later and show you the results. my way seems to be another way than yours ernest but it looks like it heads in the right direction.

anyway, thx for your last comment cause it give me some new input that i could add to my design.

seb's icon

sooo, like i wrote last night i found a really nice workaround for my patch design. i think the main problem was that i never thought that it could be so easy. :) if i use the send/receive object to transmit the data there is no significant latency because of its more like an event signal not an audio signal. of course thats my assumption. ;)

there is one thing i have to say, at the end a friend of mine help me last night with the design cause i couldn´t find a way do get it done. after a couple of other designs we discovered that its just to easy like that. so its not only my credit. ;)

Max Patch
Copy patch and select New From Clipboard in Max.
Max Patch
Copy patch and select New From Clipboard in Max.

here is the design:@ ShelLuser

sorry, but i dont think that my first design worked like what i expected. even if i scale the metering to another range there is still something wrong. another thing is that i told you before, the shown signal volume in the meter raise if the actual audio signal turn lower. i changed the values like you told me in your first comment but this changed nothing. after a some test on the design i found another way but it is a way more sophisticated like the final design. if you are interested you can have a look on this patch.

edit////

sorry for all who are looking for a real audio to midi solution but it was just my first thought for a workaround. this patch design is just to send and receive a peak value without/with the smallest amount of latency to drive a meter as exact as possible. in a couple of days when its finished you can find the whole metering patch ver. 1.0 and a description on http://maxforlive.com/ . i just want to work a little bit on the gui to let it look nice and clear and of course i add the direct link to this topic when its done. may someone is interested in this whole thing, specially when you use ableton for DJing.