0% found this document useful (0 votes)
25 views

5.3 GUI+Loop Example

The document describes code for looping a sound file selection in a graphical display. The code loads a sound file, defines a synth to loop the selection, and creates a graphical view to select and display portions of the sound file. Dragging a selection in the view will update the loop points for the synth.

Uploaded by

Manu Codjia
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views

5.3 GUI+Loop Example

The document describes code for looping a sound file selection in a graphical display. The code loads a sound file, defines a synth to loop the selection, and creates a graphical view to select and display portions of the sound file. Dragging a selection in the view will update the loop points for the synth.

Uploaded by

Manu Codjia
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

//In this example code, a sound file can be made to loop at any selection in the

graphical display

//load soundfile onto Server


b = Buffer.read(s,Platform.resourceDir +/+ "sounds/a11wlk01.wav");

//SynthDef (making Synth straight away) which has arguments for the loop points
c= SynthDef(\loopbuffer, {arg start=0, end=10000; Out.ar(0,Pan2.ar(BufRd.ar(1, 0,
Phasor.ar(0, BufRateScale.kr(b.bufnum), start, end),0.0)))}).play(s);
//*BufFrames.ir(b.bufnum) //this isn't needed since the GUI gives us positions
directly in samples

( // make a simple SCSoundFileView


w = Window("soundfiles looper", Rect(10, 700, 750, 100));
w.front;
a = SoundFileView(w, Rect(20,20, 700, 60));

f = SoundFile.new;
f.openRead(Platform.resourceDir +/+ "sounds/a11wlk01.wav");

a.soundfile = f; // set soundfile


a.read(0, f.numFrames); // read in the entire file.
a.refresh; // refresh to display the file.

//set a function which is called when the mouse is let go, i.e. just after dragging
out a selection in the window
a.mouseUpAction_({arg view;
var where;

where= (view.selections[0]); //get the latest selection (assuming no other


selections going on)

where.postln; //post where - start sample and length in samples of selection

c.set(\start, where[0], \end, where[0]+where[1]); //convert to start and end


samples for loop area
});
)

You might also like