// title: Re: Load and play samples from GUI (Qt GUI only), adapted to use SoundFile:cue // author: LFSaw // description: // *Needs 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 // code: //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); };