// openpanel
The object
readsf~ plays an existing sound file— one that is saved on the hard disk.
readsf~ needs the message
open [name of sound file].
Name of sound file refers to the place where the file is stored on a data storage device. If you want to use
readsf~ in a patch that is saved in the directory
Pd/Pd-patches/ to play a sound file named
hello.wav that is also saved in the same directory, you only have to enter
open hello.wav.
Sometimes the directory path names are complicated. You can find the full path name using
openpanel. When it receives a bang, it opens a window with the available contents for all of a computer's drives. When you click on a file,
openpanel enters the entire path for the file (as a symbol) in Pd:

You must open the soundfile in advance (a couple of seconds before you'll need it) using the "open" message. The object immediately starts reading from the file, but output will only appear after you send a "1" to start playback. A "0" stops it.
//Spigot
Depending on whether its right input is a 0 or a 1, "spigot" either sends an input through or not – like a gate that is either open or closed.
By attaching a
toggle (SHIFT+⌘+T) to a
spigot you can more clearly see if the
gate is open or closed. Or to see if a relational test delivers a positive or negative result:
[spigot] does not work with audio signals. The data types which are accepted by this object are floats, symbols, lists, bangs, anythings and pointers. However, audio signals require a completely different treatment.
However, you can use a toggle instead of two messages:


Here's how to use pitch and volume together:
//Time operations
Music takes place in time. Therefore, an audio programming language has to have the capability to control the chronological sequence—durations/rhythms and sequences of events.
metro
The first basic object for controlling the chronological sequence is called
metro. As the name implies, this is a metronome. When you turn it on or off (using 1/0 in the left input or with toggle), bangs occur at the regular interval that is determined by the argument or the right input.
The tempo is set in milliseconds (ms), which are thousands of a second. If you want to send a bang once per second, enter
metro 1000,
metro 2000 for a bang every two seconds,
metro 500 for a bang every 1/2 second.
delay
delay(
del) delays an incoming bang by the number of milliseconds in the argument or the right input:
Pipe
pipe achieves the same thing with numbers and symbols as
delay does with bangs. The duration of the delay is entered as an argument. By default,
pipe expects a number as input.
clear
If an input is
waiting in a
del or
pipe object, it can be deleted before being sent with the message
clear or
stop:
Line
With
line, you can create a series of numbers in time. In other words, you can command the program to start counting within a restricted range, the start and end values of which you determine.
line normally contains no argument, but does take a message.
[line]'s left inlet defines the "target" value. The right inlet defines the "time" value. The "target, time" pair of numbers inform [line] to produce a numeric "ramp" from its current value (whatever that might be at any given moment) to the new value within the alloted time which is defined at the right inlet.
If you want to begin with a particular number and count to another number within a certain time frame, you have to first enter a value in the left input (without having entered anything in the right input). This will cause "line" to jump to this starting value (with one single message box); then you can enter the list:
timer
timer is like a stopwatch. Connect bangs to both inputs. The time measured is always the time between the left bang (which must be given first) and the right one (in milliseconds):
glissando
You can create a glissando (a glide from one pitch to another) performed or considered as continuous:
Another variation on the glissando:
How would you make sure there was a tone you could hear?
How could you make longer tones?
//Exercise
Here is a patch for an automatic random melody

You can pass metro a variable like this:

Modify the patch to so that it uses various metronome speeds.
- Start with a trigger.
- One cable should go to the metro object, another cable should connect to a bang. Place your random methods off the bang. make sure you do not pass metro a value too small.
//Textfiles
You can retrieve numbers and symbols from a normal text file or, conversely, save numbers and symbols to a text file using
textfile
First look at the saving function:

Click the messages from top to bottom. Pd will create a text file, but will not save it.
add creates a symbol or number and follows it with a semicolon.
add2 doesn't create a semicolon.
write will save the textfile in the same folder as the patch.
You can also write to a file where the semicolons don't appear:

You can also write something and read it with an object without ever saving it as a file.
You can also use
clear to delete everything.
set first deletes everything and then begins a new line.
If you want to read what you've saved, load the file and use
rewind to go all the way to the beginning. Now every time you hit
bang, one line (up to the semicolon) will be sent through the left outlet. After the last line, a bang is sent out the right outlet:
Exercise
- Create the 2 patches above.
- Click on add something else
- Click on bang
- Click on write
- Open the text file
- Click on clear
- Open the text file
- Close txt file and return to patch
- Repeat steps 2-3
- Click on rewind
- Click on clear
- Click on write
- Open the text file
- Close txt file and return to patch
- Repeat steps 2-3
- Click on rewind
- Click on clear
- Click on rewind
- Click on something else entirely
- Click on bang
- Write a file that looks like this:
something
something
something