Bonus one-line sampler

Let's wrap up the chapter with a trivial project that's got big pranking potential.

First, make nine short samples, each sample being one second in length, using the following command:

pi@raspberrypi ~ $ sox -t alsa plughw:1 sample.wav trim 0 00:00:01 : newfile : restart

Now, enter this one-line sampler command and use your number keys 1 to 9 to trigger the samples and Ctrl + Cto quit:

pi@raspberrypi ~ $ while true; do read -n 1 -s REPLY; sox~/sample00$REPLY.wav -d; done

This is a small piece of Bash script, where the commands have been separated with the ; character instead of spreading over multiple lines. It starts off with a while true infinite loop, which makes the commands that follow repeat over and over again forever.

The next command is read -n 1 -s REPLY, which reads one character from the keyboard and stores it in the REPLY variable. We then trigger the sox command to play the sample associated with the number by inserting the $REPLY value as part of the filename.

When you get tired of your own voice, replace your samples with small clips of movie dialog!

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.205.235