«Re: Load and play samples from GUI (Qt GUI only), adapted to use SoundFile:cue» by LFSaw
on 30 Apr'12 13:07 inNeeds Qt GUI (VLayout)
Basic GUI for loading samples and playing them via button presses. Differences to the original version by rukano:
- adapted to use SoundFile:cue
- you can start and stop playing the samples
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
//samplePlayerGUI var make; var dialog = Dialog.openPanel({ |list| make.(list) }, nil, true); var win = Window("Sample Player 3001").front; var samples = (); var buttons = (); var players = (); make = { |paths| { paths.do{ |path| [\loaded, path.basename].postln; samples[path] = SoundFile.collect(path).first; buttons[path] = Button() .states_([[path.basename], [path.basename, Color.red]]) .action_{|me| (me.value == 1).if({ players[path] = samples[path].cue((amp: 1, server: Server.default), true) }, { players[path].release; }); }; }; win.layout = VLayout(*buttons.asArray); win.onClose_{ samples.do{ |player| player.release; }; }; }.fork(AppClock); };
ancestors
full graph
reception
you can also stop the samples from playing with this version.
Nice, I never used SoundFile before... looks simple and easy to use! :)
It is to my knowledge the easiest way to play back soundfiles while still being able to control playback parameters (by the environment argument you give at cueing...)