Learning goals
- Learn how to incorporate sample playback into a composition
What to do
Your task is to experiment with sample playback.
You will need one or more 44.1 KHz WAV audio clips (mono or stereo).
The steps are:
- Use the
samplePlayer
method to create a sample player instrument - Create rhythms, melodies, and figures for your sample player instrument, and use them in your composition
I would suggest starting out with a single sample (played in its entirety), and then find places to add other samples (possibly using partial samples.)
See the Example section below for ideas.
Example
Samples — prerecorded audio clips taken from other sources — are a standard element of many genres of electronic music.
To incorporate samples into your composition, you just need to use a sample player instrument, created using the samplePlayer
method. Then, add samples to the sample player instrument. Each sample is associated with a note number. Unlike melodic instruments, where the note number indicates pitch, and percussion instruments, where the note number selects a percussion sound, notes for sample player instruments simply indicate what sample to play.
Let’s start with a very simple percussion and bass composition. Here is some code (to put in the sketch’s create
method) to create some simple drum and bass parts:
Here’s how it sounds:
Now, we need a sample. I used a brief clip from a 1950s instructional film. Here’s the clip:
You can download this clip from the following link:
Note that you will need to be logged into your YCP account to access this download.
I saved this clip in a folder called Samples
in the same place as my SoundFonts
folder. My sketch defines a SAMPLE_DIR
variable that serves the same purpose as the SOUNDFONT_DIR
variable, to locate files (in this case samples) needed to play the composition:
You should create your own sample folder — for example, on your H:
drive, as shown above — and define a SAMPLE_DIR
variable similar to the one shown above.
Once you have one or more sample files stored in your sample folder, you can create a sample player instrument. Here is the one I will use:
Here is what is going on:
- Note 0 plays the entire sample, using .4 as the “gain” (volume)
- Notes 1–5 play parts of the overall sample, indicated by a range of milliseconds (start and end), again using .4 gain
So, my sample player defines a total of 6 “notes”.
Let’s start out by adding a very simple figure to play the entire sample:
Let’s play this along with the drum figures (but not the bass figure):
Here’s how it sounds:
Playing an entire sample is fun, but we can have even more fun if we play only parts of the samples. One possibility is to play part of a sample repeatedly, creating a “stuttering” effect. Another possibility is to mix up the sample by playing parts of it in a different order. Here are a few figures that demonstrate both techniques:
Recall that the sample player “notes” 1–5 indicate parts of the overall sample.
Let’s play these new figures:
Putting it all together, here is the overall composition:
Here is the complete code for the sketch:
Using samples creatively
The example shown above is a bit cheesy. It’s important to realize that samples can be used very creatively/artistically.
My favorite example of music incorporating samples:
My own personal effort to use samples creatively:
You can download the code for this composition:
Note that this is a zipfile because it contains two samples. To import it into your Processing folder, click on the zipfile, then copy the LinuxTechno2
folder into your Processing
folder.
Working with samples
Audacity is an excellent open-source audio file editor. You may find it useful for working with samples, including
- Converting a downloaded sample into the format that FunWithSound requires (44.1 KHz, 16 bit wave file)
- Finding parts of a sample to play
You can download Audacity Portable for Windows: I will show how to use this in class. You can install this on your own computer.