Tutorial 3 - Audio input and recording

Audio input and output, [adc~] and [dac~]

Audio input and output in PD is done via [adc~] (analog to digital converter) and [dac~] (digital to analog converter). In most cases this is simply a number-by-number mapping to and from physical hardware. Setting [adc~] to [adc~ 3] tells PD to take in audio from the 3rd hardware input. By default both [adc~] and [dac~] use the frst two inputs/outputs.

A simple recorder

To build a recording mechanism we need to steps, audio input and audio writing. We'll assume, for now, using the first two audio inputs, as if you were going to try this patch out on a laptop. The only other object we need is [writesf~], although there are several other ways to write audio in PD (see tabwrite~, soundfiler, and sfrecord). [writesf~] simply writes the audio it receives to disk given a filename with [open filename.wav] and a [start ( or [stop ( message. So the patch in it's most basic form is just:

Note that this gives us no control over the level in (except the hardware level) and no way to do anything except overwrite the same file, filename.wav, over and over. Not very useful.

To fix the problem, we need to insert audio multipliers before the signal reaches [writesf~]. A multiplier of "1" means what multiplying by 1 always means, you get "itself". Multiplying by .5 gives you half, etc. We also want a way to change the filename, the simplest thing would be for the recorder to simply make a ew filename each time you start a new recording. The new, fancy, little hand-held recorders do this but we're going to save you some cash with a free PD solution.

Example patch

Like the patch in tutorial 2, we're going to build a patch with a graphical front end, giving the user a simple interface to interact with. In this case, we want:

  1. Ability to enable/control signal mic level
  2. Ability to start recording to a new file (value added: something to tell us the name of the new file)
  3. A set of meters to show the signal level so we can avoid clipping

So in addition to the basic [writesf~] mechanism we want to create something to control mic levels (a multiplier), something to increment through a set of filenames, and as wtih the Tutorial 2 patch, VU meters to show the audio level.

The fist one is easy, just insert an audio multiplier that can be turned up and down from the front page via send/receive. Here a toggle object, which sends "0" or "1" when off or on, is sent to a [line] which ramps up and down over 200ms. So the level is raised when the toggle is checked and lowered when it is not.

The filename question is a little more complicated but basically we just want to write a new file each time, something like soundfile1.wav, soundfile2.wav, soundfileN.wav. So we need our [open filename ( message to change each time, ideally with something that can just substitute a new number at the end of the filename.

The solution is to use [makefilename]. See its help patch for the available options. Here we are using %d to substitute a new number at the end of the filename. Beyond that, this patch is almost identical to the coutner patch from Tutorial 1 (a great composer steals).

Like the counter, numbers increment within float and this number is added to the end of the filename soundfile%d.wav at the %d position. This filename is then send to [writesf~] as the file to [open (.

Finally, we want all of this information to be accesible via a graphical front end. We want to be able to enable and.or adjust the mic level, we want to see the level in a set of VU meters, we want to be able to enable the recording, and we want to see what filename is curretly in use. This can all be done via send and receive to and from the guts of the path. See attached.

AttachmentSize
gui_simple-record.pd 2.65 KB