GUI window displaying audio files

hello I have made the following code:

// Tu código original
d =;
d.add(\folders -> PathName(thisProcess.nowExecutingPath.dirname ++"/Biblioteca Audio" ).entries);

	0, d[\folders].size -1,
		d.add(d[\folders][i].folderName -> d[\folders][i].entries.collect({
		|sf|, sf.fullPath);
// Código para crear la ventana GUI
w ="Biblioteca Sonidos", Rect(100, 100, 300, 200)); // Crear una ventana con un título y un tamaño
w.background = "blue";
w.layout = VLayout( // Asignar un diseño vertical a la ventana
	HLayout( // Crear un diseño horizontal para los botones
		Button(w, "Mostrar carpetas").action_({ // Crear un botón para mostrar las carpetas
			d[\folders].do({|f| f.folderName.postln}); // Mostrar los nombres de las carpetas en la consola
		Button(w, "Reproducir sonido"
		).action_({ // Crear un botón para reproducir un sonido
			var carpeta = d[\folders][rrand(0, d[\folders].size - 1)].folderName; // Elegir una carpeta al azar
			var sonido = d[carpeta][rrand(0, d[carpeta].size - 1)]; // Elegir un sonido al azar de la carpeta; // Reproducir el sonido
			("Carpeta: " ++ carpeta ++ ", Sonido: " ++ sonido.bufnum).postln; // Mostrar el nombre de la carpeta y el sonido en la consola
w.front; // Mostrar la ventana

up to here I managed to create a window that with two buttons, one shows me the folders that I have of audio in my library and the other one selects me to randomly sounds of some of them and makes them sound. Now I would like to improve this script a little more, for example that it can show me all the audio files when I select a folder, to be able to listen to them, and finally if I find the audio that I like, to be able to use it in the script with its path address.
Does anyone have any idea how to implement these ideas to improve the script?

I actually have pretty much exactly this script, but I’m in transit now, could share it a few hours later.


1 Like

Great, I look forward to it
thank you!!!

OK, here’s the script. I made it when I got tired of right-click → Audacity repeatedly for drum samples or breaks.

sample-audition.scd (9.4 KB)

(BTW if you have ffmpeg on mac or linux, it will automatically decode mp3s too.)


Thank you very much,
one doubt, how do you work with this .scd document in practice. Do you make a ‘.loadRelative’, or do you execute it directly?

Either way should be fine – it shouldn’t matter whether you execute the whole file in an editor window, or loading from disk.


I have already checked it, very useful. Thank you very much for the contribution!