«Buffer Plotter» by Dindoléon
on 05 Jan'22 15:06 inThis is a setup that allows you to plot a Synth() output, using a buffer. See https://scsynth.org/t/what-is-the-best-way-to-plot-a-synth/5160 .
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
s.boot; ( var bufferSize = s.sampleRate * 1; // Buffer size is fixed. s.sampleRate * seconds makes sense. if( ~plotterIn == nil, { ~plotterIn = Bus.audio( s, 2 ) } ); // Declare a global channel for the plotter input, stereo if( ~plotterBuffer != nil, { ~plotterBuffer.free } ); // Reset the buffer if existant ~plotterBuffer = Buffer.alloc( s, bufferSize, 2 ); // Create our buffer, stereo SynthDef( \toBuffer, { // A simple routing synth | bufNum | var in = In.ar( ~plotterIn, 2 ); // Takes an input RecordBuf.ar( in, bufNum, loop: 0, doneAction: 2 ); // And outputs it in our buffer } ).add; ) ( // Demo Synth SynthDef( \demoSynth, { | out = 0, freq = 220 | var snd = SinOsc.ar( freq!2 ); snd = snd * EnvGen.kr( Env.perc( 0.1, 0.9 ), doneAction: 2 ); Out.ar( out, snd ); } ).add ) ( Synth( \toBuffer, [ \bufNum, ~plotterBuffer ] ); // Trigger the buffer synth Synth( \demoSynth, [ \out, ~plotterIn, \freq, 110 ] ); // Then our favorite synth ) // You will need to wait the bufferSize length before plotting it ! ~plotterBuffer.plot // Finally print the result if( ~plotterBuffer != nil, { ~plotterBuffer.free } ); // Free the buffer if existant
reception
comments