SACC

/ / navigation

Pitch
Volume
Additive Sound
Subtractive Synthesis
Making Waveforms
Sampling


// Pitch



Pd works with two kinds of pitches - Hertz or MIDI numbers. The traditional signs: A, B-flat, G-sharp, etc. are not used at all in Pd. Instead all chromatic pitches have MIDI numbers: A4 is the number 69, B-flat4 is 70, etc. The other way to describe pitch in Pd is in Hertz. To understand this, we'll need to understand a bit about musical acoustics.

Sound is air in vibration. Traditional instruments are used to vibrate air at specific frequencies. You can do this with strings (violin), lips (trumpet), or membranes (timpani). We even have a membrane in our ears - the eardrum - that vibrates sympathetically with vibrations in the air. Our brain transforms these vibrations into a different form, which is what we would call sound.

In electronic music, speakers are used to generate sound. They also have a membrane that vibrates back and forth, which causes the air to vibrate.

The vibrations of the speaker membrane are controlled by the computer. In Pd, the dac~ object (digital audio converter) handles this. Here's how it works: sound is a physical phenomenon - vibrations in the air to be precise - and, as such, it is analog. Computers, however, work only with numbers, which means they are digital. The dac~ object turns numbers into sound by converting numbers into fluctuations of electrical current that - once amplified - cause the speaker membrane(s) to vibrate accordingly.
3-1-1-1bbb.jpg

A speaker's membrane can move back and forth. The outermost position (the most convex) is understood by the computer as position 1. The innermost position (the most concave) is position -1. When the membrane is precisely in the middle, as when at rest, this is position 0. All other positions are values of between -1 and 1.
3-1-1-1dd.jpg

The number of times per second a speaker vibrates makes the frequency (the note, tone or pitch) of the sound you hear.


Waves
This is what a membrane that moves from one extreme limit to the next (most convex, most concave) at a constant tempo:
3-1-1-1ee.jpg

If you marked the individual stages:
3-1-1-1f.jpg

In an abstracted form with membrane position on the y-axis and time on the x-axis, you could represent such motion like this:
3-1-1-1g.jpg

In physics terminology, this is called a wave. Here you can clearly see the waveform - a triangle. There are different waveforms for different kinds of membrane movement. Their names reflect their visual resemblance:
3-1-1-1i.jpg
In Pd
Sine Wave oscillator


Sawtooth Wave oscillator


Square Wave oscillator


In order to to create sound, each oscillator object takes a numerical input which represents a frequency in Hertz. This number determines the number of times the oscillator will make its waveform during one second. By using a creation argument (a default setting typed into the object box when the object is first created), you can set the initial frequency of an oscillator. And by using an hslider (Horizontal Slider), a Number or a Message, you can send numerical messages to change the frequency of the oscillator.


A period is one complete cycle of a vibration that constantly repeats.
3-1-1-1j.jpg
What makes periodic vibrations special is that we hear them as clear tones with definite pitch. In contrast, noises are aperiodic vibrations.
3-1-1-1k-1.jpg

If you counted the number of periods in a second, this number would be the vibration's frequency and is measured in Hertz (Hz); frequency in this context always means how often something repeats in one second (expressed mathematically: 1/second).
3-1-1-1l.jpg

A tone's frequency determines its pitch. A440, also called A4, is the standard pitch that orchestras use for tuning. A440 means that the air vibrates periodically at a rate of 440 times per second; C5 vibrates 523 times per second; the low G on a cello vibrates about 100 times per second.

The slower the frequency, the lower the pitch appears to your ear. In fact, humans - depending on age - hear pitches between 20 Hz and 15000 Hz. Children can hear up to 20000 Hz; elderly people can often only hear up to 10000 Hz. Dogs and bats can hear well over 20000 Hz. This range is referred to as ultrasonic. In contrast to this is the infrasonic range, which is lower than the bottom of the audible threshold - i.e., between 0 and 20 Hz. This range is perceived by us as rhythm.

Try this:

You should hear a rhythm of clicks (that's the sound of a sawtooth wave) that gradually gets faster. After a certain speed (over 20 clicks per second), our perception 'shifts gears' and begins to hear a low pitch. For the air (and for the computer), this is still a rhythm. But for the human ear (ca. 20 Hz) it's a pitch! The faster this rhythm becomes, the higher the pitch we hear.

Another defining characteristic of the human ear is that it hears pitches logarithmically. This means when a given frequency is doubled, we perceive this as an octave leap. If you change from A4 (440 Hz) to its double (880 Hz), you hear A5, which is exactly one octave higher:


What number would you need to move to the next octave?

From 30 Hz to 60 Hz, you hear an octave, but from 1030 Hz to 1060 Hz, you hear just a small step. In fact, the jump from 10000 Hz to 20000 Hz is only an octave! The Pd object osc~ creates a sine wave.


Microphones
A microphone also has a membrane that responds to vibrations in the air. A microphone converts these vibrations into electric current, which it sends to the computer. The computer then converts the current into numbers. In Pd, this input can be received with the adc~ object.
3-1-1-1cc.jpg



This is an example of a linear and logarithmic equation:


Exercise: Create a patch that outputs 8 different frequencies from 100 to 800 that increments by 100. This should prove that while you are involved in an additive process in which the same amount is added each time, our ears, perceive that this amount gets smaller and smaller with every step.

If you want to hear a linear progression - i.e., a process by which the same interval is added, for example the octave - the mathematical function has to be exponential. Double the frequency each step.

MIDI
For many musical applications, the MIDI scale is a useful way of controlling the frequency of an oscillator. Think of the MIDI scale as a piano keyboard with 128 keys on it, and each key has been marked with a frequency in Hertz which represents that musical note. The most important thing to notice is that a note which is one octave higher than another note (for example, the three A notes of 55 Hz, 110 Hz and 220 Hz) has a frequency which is twice that of the lower note.

You can convert entries in frequencies and MIDI numbers in Pd:
to_midi.png

Here's an example patch that uses a slider:


Oscillators like osc~ or phasor~ have to receive their input in Hertz


Sample Rate


Objects like osc~ generate a very fast sequence of numbers between -1 and 1 sent to the speaker by the dac~ object. 44100 numbers per second are generated and sent. The loudspeaker makes 44100 tiny movements between -1 and 1 within one second. This number, 44100, is called the sample rate.

Every sound in Pd is produced using numbers between -1 and 1 at a rate of 44100 numbers per second. A single individual number is called a sample.

All Pd objects that generate or process data at this speed have a tilde ~ in the object box. These objects are connected to each other with thick cables. These numbers are referred to as signals.


While the object that supplies the osc~ is not constantly transmitting, the osc~ object's outlet is. It is constantly sending signals, or numbers between -1 and 1, 44100 per second (per second means: Hertz). The thick cable indicates to the programmer that this outlet is a constant transmission.



Number boxes can only be used for control connections, not signal connections. Signal connections are too fast: you can't see 44100 different numbers per second. You can, however, show selected numbers from a signal with the snapshot~ object. As inputs, it receives the sound signal and a bang that, when clicked, displays the current number when clicked. To see this number, connect either a number box or a print object to its output:


If you wanted a constant stream of numbers, you would need to attach a trigger and before the bang. Alternatively, you could use unsig~ which automatically connects a metronome. Just enter the metronome value as the argument:




Samples
There are two different units in Pd for measuring time: samples and milliseconds. Samples are usually used for counting signals while milliseconds are used for control data.

here's how to convert duration in milliseconds to duration in samples:



Why 44100
The number 44100 was chosen for a good reason. Humans can hear up to 20000 Hertz at most. In 1928, U.S. physicist Harry Nyquist (1889-1976) proposed a theory stating that a frequency of at least twice the signal frequency was necessary to accurately represent a sound signal digitally. This means that one needs the maximum and minimum values for each period to accurately represent a waveform's basic shape, or two points per period:


For a wave with 20000 Hz, which equals 20000 periods per second, you need at least 40000 points per second to accurately represent it. To ensure that the entire spectrum of sounds audible to humans was included, a sample rate of 44100 was chosen for audio CDs. This means that waves of up to 22050 Hz could be captured. For computers, a wide selection of frequency bandwidths exist, all the way down to 8000 Hertz for system sounds. High-quality audio recordings work with sample rates of 48000 Hz (48 kHz = kiloHertz, where kilo = thousand), 96 kHz, or even 192 kHz.


Source:http://www.pd-tutorial.com/english/
http://en.flossmanuals.net/PureData/