Triggering Synth with Analog input

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Triggering Synth with Analog input

FelixRuiter
This post has NOT been accepted by the mailing list yet.
Hi, Me and a friend of mine are working on a project which requires our code to play a sound whenever someone hits a Piezo element. We've been screwing around a lot, but the main thing we've had problems with is getting a sound to trigger whenever the analog input reaches a certain number.

This is where I can't seem to get past. I've checked the data from the analog input, and unpressed it reaches up to 0.999 etc, and when it is pressed it goes down to about 0.2. I was wondering if there's an easy way to make a synthdef trigger whenever the analog input reaches down to 0.5 or lower.

To check the data the Analog in was putting out, I used:
{AnalogIn.ar(0 ).poll(label: \AnalogIn)}.play;

To generate a sound with the Analog in and know whenever it was being pressed, I used:

        (
          SynthDef("help-AnalogIn",{ arg out=0;
            Out.ar(out,
//The input is being read, and the signal is turned into a minimal of 200, and a maximum of 1000 Hz. A stable input should give a stable tone
              SinOsc.ar( AnalogIn.ar( DC.ar( 0 ) ).exprange( 200, 1000 ), 0, 1 )

            )
        }).send(s);
        );

I was thinking about using an if statement to trigger a sound, but until now I've only failed when trying to put an analog input or even a synth inside of an if statement as the condition.

To be honest, we're both a little new with SC and we're not exactly sure what statements to use in this kind of instance. Any help or feedback would be greatly appreciated.
Reply | Threaded
Open this post in threaded view
|

Re: Triggering Synth with Analog input

mahatGma
This post was updated on .
I highly recommend this wiki page about 'if statements in a SynthDef'
http://supercollider.sourceforge.net/wiki/index.php/If_statements_in_a_SynthDef

Something like this might help you to trigger a synth with audio input.
{a=SoundIn.ar(0);b=Amplitude.ar(a); Select.ar(b*4, [Silence.ar(), SinOsc.ar(440)])}.play;