Control master volume based on sound_in

I’m trying to figure out how to control the master volume using the volume of the sound that is heard through the live_audio.

Example if its quiet, the playback is also quiet, and the volume of the playback will increase as the volume increased.

I’ve searched the forums, and found stuff close to it, but keep getting stuck. I see how to control with a MIDI, how to crossfade two so the sound is consistant. I can randomise the amp, but not how to sync them to the same volume based on the input is hears.

Can anyone help me?

Hi @je12,

unfortunately we don’t currently have a way of detecting the amplitude of an audio signal and then feeding that back to the language so it can change the behaviour of the code.

For this to be possible, we’d/you’d need to implement a new SuperCollider synthdef that did this and then sent the amplitude out as OSC messages to be picked up and then forwarded to the language runtime as an event.

I built something similar a while back that did basic pitch detection, but it was pretty useless (the SuperCollider pitch detection ugen wasn’t/isn’t that good) so stopped working on it. Detecting amplitude would be much more reliable though as it’s a much simpler algorithm.

Hi! Can you share it with me? I am willing to try. :slight_smile:

Share what - my old experiments? I deleted them years ago, sorry.

If you’d like to try to work on this, the first step is to see if you can build and use a simple SuperCollider synthdef. For that you’ll have to download SuperCollider and follow some tutorials. Once you’ve built a few synthdefs and triggered them from SuperCollider directly, you should then look into importing them into Sonic Pi using the fn load_synthdefs. Take a look at the function’s documentation for a couple of important design constraints and an example synthdef you can try out. If you made it that far and are still interested to build a synthdef to extract amp information, then I’d be really happy to help out :slight_smile:

2 Likes