0% found this document useful (0 votes)
33 views1 page

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)
33 views1 page

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

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

graphical display

//load soundfile onto Server


b = [Link](s,[Link] +/+ "sounds/[Link]");

//SynthDef (making Synth straight away) which has arguments for the loop points
c= SynthDef(\loopbuffer, {arg start=0, end=10000; [Link](0,[Link]([Link](1, 0,
[Link](0, [Link]([Link]), start, end),0.0)))}).play(s);
//*[Link]([Link]) //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));
[Link];
a = SoundFileView(w, Rect(20,20, 700, 60));

f = [Link];
[Link]([Link] +/+ "sounds/[Link]");

[Link] = f; // set soundfile


[Link](0, [Link]); // read in the entire file.
[Link]; // 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= ([Link][0]); //get the latest selection (assuming no other


selections going on)

[Link]; //post where - start sample and length in samples of selection

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


samples for loop area
});
)

You might also like