Sunday, May 6, 2012


So far I've been learning synthesizers, directly "inventing" sound from known, easily-made mathematical waveforms.  Today I've got some recipes for sampling with the microphone (or other audio equipment).

First, basic sampling.  With an array called loop01 stuffed into its own patch (better for various performance reasons), I set up a bang to trigger the tabwrite~ function and put half a second of data into the array.

This streams straight in from the ADC and into the array, which I've made 22000 samples long to store half a second of 44000Hz data.  (Working on a more sophisticated version of this patch that'd have adjustable length, but one thing at a time.)

Next, playback.  I had a lot of fun hooking up a phasor~ object to the tabread4~ block and sliding it around, but for simple sampling, just feed it a vline~ that goes to near the end of the array based on an input argument.

My input argument here has been hacked up a little so that middle C on my nanoKey leaves the pitch unaltered.  This creates the (wrong, but useful) impression that the sample is taken at "normal" and the MIDI keyboard slows it down and speeds it up depending on how high or low you go.  I wired the "mod" button on my keyboard to take samples, but the bang is accessible in case you don't have that particular feature.  I also put a slider in so that if you're using this without a keyboard, everything will still work.

Before I go to the more sophisticated sampler with polyphonic MIDI control, I want to thank GuitarExtended for this excellent patch for detecting sounds at the input.  I appropriated this into a patch called threshbang which I used to give the next version of the sampler the ability to detect things like claps or vocalizations and trigger the sampler.  (Its details are currently beyond the scope of the blog, but I've included it so the whole polyphonic sampler patch works.)

Packing the note interpreter, pitch shifting part, line generator and tabread4~ object all into a subpatch and then duplicating it up for polyphony works about the same as for any other sound effect, but now the keyboard can play chords of whatever sound you've put into the half-second memory space of this simple patch.

Sampling and pitch-shifting sounds from around the desk quickly yields a lot of rich sound, and I can't wait to store all the funky audio I'm getting from this!

Today's Files:
Simple Sampler
Polyphonic Sampler
"Bang on Threshold" generator

1 comment:

  1. Very cool! Thanks for posting this, I can't wait to try it.