Control via audio level
Hello all,
I'm trying to trigger a "metro" object via audio input from mic (i.e. when the music starts).
Is there a convenient method for this ("control by means of detecting audio level")?
I tried it using "snapshot~", but it didn't result in consistent behavior.
Looking forward to any help...
Maybe average~ or thresh~ would give better results...
p
Thank you, I hope it will work this time...
try the right output of the levelmeter~ object
(or is it the left one ?)
oh wait i misunderstood your problem
hm so just try what Patrick said :) anyway you can use the output of that levelmeter~ (which is a unique outlet), and then use a change which causes a bang in case of 0 to non zero transition (and if you want that bang once you can add a change after that output so it won't hapen twice), and in between add or substract a value to find the good calue of threshold.
Is that it ?
is that the sort of thing you're looking for ?
Hi vichug, just seen your msgs, thank you for your help. I tried your patch (appending it to audio), but the "change"s never seem to cause a "bang". I will be on it...
He didn't test the patch...;-)
Onebang is probably also helpful in this context...
indeed, that onebang is the kind of useful basic objects i forget too easily :)
I think I did it. I followed Patrick's recommendation. Could you please have a look at this:
Hello again. About the patch I sent yesterday (could anyone try it?), it seems that each time I reload the patch, "the optimum threshold~ set value for reasonable operation" changes. Any ideas about the cause/solution?
Mmhhh... Is there an object that works as opposite of [past]?
Thanks and regards.
I would use and if statement
Thanks stoplaughing, your patch does it very well.
I'll have to add some additional controls to prevent false alarms as now the metro starts even with a click produced while taking the microphone in the hand or turning it on/off. (The [metro] should be triggered only with persistent audio level.)
(to MBM and stoplaughing... --how do we technically notify certain users during posting, anyway?)
MBM's question about the "opposite of [past]" won't be realized using that [if] statement (e.g., [if $f1
This javascript code below functions just as the opposite of [past] object:
var A = new Array(0.05, 0);
function msg_float(r)
{
A[1] = r;
if((A[0] >= 0.05) && (r < A[0]) && (r < 0.05))
outlet(0, "bang");
A[0] = A[1];
}
Meanwhile, if anyone knows a method to realize this kind of queue structure without using a js object, please teach me.
(to stefantiedje) Sorry I forgot to thank for your post. Thank you.
<< MBM's question about the "opposite of [past]" won't be realized using that [if] statement (e.g., [if $f1>
or you could use a [onebang] after the logical test
[Onebang] is the answer, of course, I didn´t realize. Thanks.
Emerson, thank you very much, but I don´t know JS and I don´t know how open your "patch" (is that its name?) with Max. Thanks.
About using a [onebang] there:
I couldn't figure it out exactly, vichug, especially how to solve the representation of current and previous values.
Could you post an example or explain it a little more?
MBM, you're welcome, you can use that code like this:
in the Max patcher, create a js (javascript) object. i.e.: write something like this on it:
js oppositepast.js
Lock the patcher, double click the js object, paste the code inside the opening window, (for a better initial value, change the 0.05 "only in the first line" with any smaller number to prevent an unnecessary single bang in the beginning -my bad), save.
Now you can connect its inlet to [meter~] and its outlet to a [bang].
Thank you very much, Emerson :-)
Best regards.
Using both the [past] and its opposite (the [js ...] above; still curious if anyone can make it without js code), I'm posting the patch below, which detects rise and fall of audio level, and restarts a [counter] whenever the audio level does not stay high for long enough at least once, otherwise quits checking.
(i.e., the controls I mentioned before, to prevent false alarms caused by clicks/pulses.)
Of course, the beginning of the music itself could consist of clicks/pulses, but I'm trying to tailor the detection to suit my specific plan: Trying to start the flow of some algorithms simultaneously with a singer starting to sing through the mic.
I've written this much about it to ask a question: Which one is a failsafe method to serve the above purpose:
-Detecting the audio level like this
or
-Detecting the -monophonic- pitch
(the first note of the singer is known a priori)
Looking forward to any ideas. Here's the patch, suggested for the 1st option:
So, any opinions?
copypasting js objecs doesn"t work here, one has to manually add your js code in the [js compseq.js] object and to save it on his computer (i think) for it to work.
I had guessed that, but I thought the content could be found above as I had given before (7 posts before, though.)
Ok, let me upload the maxpat and js files as a zip file.
Btw, the content of js was as follows:
inlets = 1;
outlets = 1;
var A = new Array(0.03, 0);
function msg_float(r)
{
A[1] = r;
if((A[0] >= 0.05) && (r < A[0]) && (r < 0.05))
outlet(0, "bang");
A[0] = A[1];
}
Hey guys, I modified the patch a bit for my own purposes and I thought you might enjoy my modifications.
I just jumped on to Max for Live, coming from PD, and I was highly surprised the incredibly useful threshold~ object from PD isn't available in Max.
My goal was to have a gate open with a kick drum, and close when the kick drops below a threshold.
I first use onepole~ with a very low cutoff so it's as cheap an LPF as I can get then send it to Miller Puckette's excellent bonk~ transient detector to grab beat onsets. I use the output of bonk~ to open my final gate as well as open the gate that leads to past and compseq.js which I use to close the final gate.
I left compseq.js the same as it is earlier in this thread but basically just use bonk~ to do my beat onset detection.
Comments are more than welcome. Enjoy!
smilinggoat wrote: "I was highly surprised the incredibly useful threshold~ object from PD isn't available in Max."
the pdmax conversion is interesting indeed... often clearcut, sometimes not so much...
you can create pd's threshold~ somewhat easily using thresh~ and edge~, although the debounce time parameter for pd's threshold~ will take a little more working out:
just in case it helps.
Thanks for the tip, Noob4Life. I wasn't aware of the edge~ object, saves me a lot of logic programming time. So many new (for me) toys to play with.