# Digital Audio

## San Skulrattanakulchai

### November 4, 2019

# Acoustics

- Sound is the perception of vibration of our eardrums.
- The
`Minim`

package is a user-contributed audio library in the processing library for playing, manipulating, and synthesizing sound.
- A musical note is a wave that oscillates at a certain frequency.
- We will use
**concert A**, the A above middle C, as a reference note.
- Concert A (also known as
**A440**, **A4**, **Stuttgart pitch**) has been standardized to oscillate at a frequency of 440 times per second (Hz).
- When you double or halve the frequency, you move up or down one octave on the scale. E.g., 880 Hz is one octave above concert A; 110 Hz is three octaves below concert A.

# Acoustics, continued

- A newborn baby can hear sound waves of frequency between 20 to 20,000 Hz. People lose the ability to hear the high-frequency sounds as they grow older.
- The
`sin`

function repeats itself once every \(2\pi\) units, so if we measure \(t\) in seconds and plot \(\sin(2\pi t \times 440)\), we get a curve that oscillates 440 times per second.
- The amplitude of the wave determines what we perceive as volume. We'll plot our curves between –1.0 and +1.0 and assume the devices that record and play sound will scale as appropriate.
- When a guitar string is plugged, the string vibrates, producing a sine wave that is the prominent part of the sound that you hear and recognize as a note.
- There are 12 notes on the chromatic scale, evenly spaced on a (base 2) logarithmic scale. For any given note, we get the \(i\)th note above it by multiplying its frequency by \(2^{i/12}\).

# Chromatic scale

A |
0 |
440.00 |

A♯ or B♭ |
1 |
466.16 |

B |
2 |
493.88 |

C |
3 |
523.25 |

C♯ or D♭ |
4 |
554.37 |

D |
5 |
587.33 |

D♯ or E♭ |
6 |
622.25 |

E |
7 |
659.26 |

F |
8 |
698.46 |

F♯ or G♭ |
9 |
739.99 |

G |
10 |
783.99 |

G♯ or A♭ |
11 |
830.61 |

A |
12 |
880.00 |

# Sampling

- For digital sound, we represent a curve by sampling it at regular intervals.
- We will use the commonly used sampling rate of 44,100 samples per second.
- For concert A, that rate corresponds to plotting each cycle of the sine wave by sampling it at about 100 points.
- We represent sound as an array of real numbers between –1.0 and +1.0.