Signals, Waves, Acoustics, Psychoacoustics, and music

From CCE wiki archived
Revision as of 23:20, 24 October 2017 by Michaelf (talk | contribs) (Demos)
Jump to: navigation, search

Concepts

Read through the following and get a sense of the terms and concepts, or you may prefer to start with the demos & simulations below....

Signals

  • A function assigns every value in a domain a single value in a range.
  • A signal is a function of time and/or space, assigning for instance every time point in an interval to a single value, e.g. which may be interpreted as a voltage or a pressure.
  • Periodic vs non-periodic signals
  • Analog vs. digital signals
    • Continuous or Analog signal
      • An analog signal is a continuous function of time and/or space into a continuous domain.
      • Analog signals may be represented in the physical world, for instance as time varying pressure (in air) or voltage (on a wire)
      • Analog filtering and synthesis
    • Discrete or Digital signal
      • A discrete signal is a function of discrete time points (e.g. integers); values may be continuous.
      • A digital signal is a discrete signal where values must also be drawn from a discrete set: A digital signal is a discrete function of time and/or space into a discrete domain (e.g. integers)
      • Digital signals tend not to exist in the physical world, at least not at the level of human perception, but result from the need for computer representations of analog signals
      • Digital filtering and synthesis
  • Mono vs. stereo signals

Waves

  • A wave is an oscillation in some physical value (e.g. pressure, voltage) carrying energy through space/time, often carried by a medium and constrained by physics (including physics of the medium)
    • The wave's value at a particular point in space (over time) or in time (over space) defines a signal
    • Mechanical waves are carried by an elastic (transmission medium), analogous to weights connected by springs
    • Electromagnetic waves (e.g. light waves) travel without any medium
    • Waves may be transverse or longitudinaldemo
    • Dimensionality:
      • Of wave: (1D, 2D, 3D).
      • Of wavefront: (0D, 1D, 2D)
  • Inverse square law: in the absence of boundaries, waves spread. In 3D, the spread is proportional to the square of the distance from the source. If the power (energy per unit time) is constant, then intensity (power per unit area) is inversely proportional to the square of the distance. What this means: a flashlight's intensity at 8 feet is only a quarter its intensity at 4 feet.
  • Wave amplitude (A):
    • the peak-to-peak amplitude is the difference between the wave's maximum and minimum values.
    • the RMS (root mean square) amplitude is the square root of the average of the wave's squared value
    • Wave power (P = A^2): waves carry energy; the power (energy per unit time) carried by a wave is proportional to the square of its RMS amplitude.
    • We measure the "difference" in power between two waves using a logarithmic scale, dB, applied to the power ratio between the two waves, which is the square of the amplitude ratio, A/B
    • dB = 10*Log(power ratio) = 10*log(A^2/B^2) = 10 * 2 * log (A/B) = 20 log (A/B)
    • [recall from high school math that log(A squared) = 2 log (A) ]
  • Wave properties
    • Wave superposition principle: in a linear medium, waves combine simply by adding their values. Traveling waves will appear to pass through each other unscathed. It's also possible to cancel a wave by adding its inversion (as in noise canceling headphones). See this simple 1D string animation, or play with this ripple tank.
    • Reflection: a wave will reflect off a boundary. See animation
    • Diffraction: a wave can travel around an obstacle, or spread after passing through a hole. Diffraction effects are greatest when the wavelength is roughly equal to the size of the diffracting object.
    • Refraction: a wave changes direction when the medium changes.
    • Sound waves are longitudinal traveling pressure waves through air (the medium) in 3D, with a 2D usually roughly spherical wavefront. A violin string carries a transverse displacement standing wave in 1D. Either kind may or may not be periodic...

Periodic waves

Periodic waves as periodic signals

    • Periodic waves repeat their values (whether pressure, for sound, or displacement, for a string) over both space (at a fixed moment in time) and in time (at a fixed point in space). The period over which a wave repeats is called wavelength (in space) and period (in time). The frequency is the number of periods per second, i.e. is the number of times the period divides into one second. Thus:
    • Period (T) can be measured in seconds; frequency (f = 1/T) is measured in Hertz (Hz), or cycles per second.
    • Wavelength (L)
    • Phase. At a fixed point in space, the waves will go through its full range of values once every period (T). So it's like a cycle, and we can identify points on the cycle as angles: for instance, we can call the beginning of the cycle (which is arbitrary) "zero" and the halfway point "180" and the quarter point "90". This angle is called phase.
    • Open Audacity and play with periodic waves (sine, or drawn)...

Wave speed

    • What is the speed of a periodic wave? Assume the wave is passing a point in space. The entire length of the wave (L) passes the point in T seconds. So the speed of the wave must be L/T, which is the same as L*f:
    • Wave speed = L/T = L*f
      • Mechanical waves travel at a speed that depends on the medium (e.g. air pressure, temperature, humidity). You can imagine these factors related to the spacing of weights and the stiffness of the springs connecting them. In room temperature dry air, sound waves travel a little faster than 1000 ft/sec; 1115 ft/sec at 20 degrees, to be precise)
      • Electromagnetic waves travel at a constant speed: 186,000 miles/second
    • demo

Standing waves

    • Boundary conditions: the medium may be infinite. Or it may (more typically) be bounded: the air in a room meets a wall, a string on a stringed instrument meets a bridge.
    • Wave reflection: at an obstacle, a boundary a wave will reflect and return. If the reflected wave matches the incident wave, you'll observe the phenomenon of resonance, and energy will be retained in the vibrating medium, until dissipated. The frequencies at which this happen are called resonant frequencies of the system (medium plus boundaries). For instance if you tie a jump rope to a doorknob and shake the rope at just the right rate, the whole rope will go into smooth up and down motion, perhaps with nodes (stationary points) in the middle. Or if you sing in a resonant room at just the right frequency, you'll find your voice amplified and echoing even after you stop singing. This is the phenomenon of Standing waves
    • Check out this demo of standing waves on a string (1D)
    • Here are standing waves on a circular membrane (like a drum head, 2D)

Resonance

    • A physical system comprising a medium with boundary (e.g. a string tied at its endpoints, an air-filled tube closed at one end, a guitar body, a room filled with air, a pendulum) can be characterized by its resonant frequencies, natural modes of vibration, at which standing waves form.
    • When waves are introduced at a resonant frequency of the system, they reflect off the boundary in such a way as to reinforce incident waves.
    • In an ideal system, a fixed amount of energy carried by a wave oscillating at the resonant frequency will continue to oscillate, without loss, as a standing wave.
    • In practice, the resonant frequency is a "sweet spot" at which energy will rapidly build a high amplitude standing wave.
    • Consider, for instance: a swing (pumping your legs at the right rate makes the swing go higher and higher), a shower stall (singing at the right frequency creates a loud sound).
    • Such systems naturally filter out non-resonant-frequency energy - thus plucking a guitar string causes it to vibrate at its resonant frequencies (though the manner of plucking may vary the timbre)
    • As resonance entails energy buildup and increasing amplitude, disaster may ensue (e.g. when bath water spills, or a bridge breaks)

Frequency analysis

    • In some sense the simplest waves are sine waves, because these result from Simple harmonic motion; they even sound simpler than other waves (due to the physics of our ears).
    • These simple waves are like an alphabet out of which other periodic waves can be constructed, through a mixing process, according to Fourier analysis:
    • Fourier analysis: a periodic wave of frequency f can be represented as a sum of a set of simple periodic waves (sine waves), at frequencies f, 2f, 3f, etc. (called harmonics) each at different phases and amplitudes. The first frequency "f" is called the fundamental, or first harmonic. Subsequent frequencies are integer multiples of f; thus 2f is the second harmonic (first overtone), 3f is the third harmonic (second overtone), and so forth.
    • Thus every periodic wave can be analyzed into its component frequencies, each at a particular power level, as given by a series of amplitude coefficients: A1 (amplitude of the first harmonic, A2 (amplitude of the second harmonic), etc.
    • The same analysis can be performed on an arbitrary (possibly non-periodic) wave, generating a Fourier transform (a density function).
    • In practice, one uses a sliding window assumed to represent a temporary period to generate a Fourier series. Obviously in this case the amplitude coefficients are varying over time.
    • We can represent the Fourier analysis as a three dimensional plot of frequency, time, and amplitude. Sometimes the plot is reduced to two dimensions, when the amplitude is plotted as intensity or color; this is called a spectrogram.

Synthesizing and Filtering

Aperiodic waves & noise

  • Even musical signals are only periodic with the following caveats:
    • Periodicity is approximate (there are always slight variations due to the addition of noise, and changes in amplitude)
    • When monophonic (polyphony introduces aperiodicities)
    • Over short periods of time (since pitch is typically changing)
  • The extreme of aperiodicity is randomness, or noise
    • White noise: flat frequency distribution
    • Pink noise 1/f distribution
    • Demo: Audacity (generate noise, analyze, and filter)

Musical acoustics

my overview of musical acoustics (set browser encoding to Western ISO) (links are unfortunately now broken :( but you can find similar content in the following demos...)

Musical psychoacoustics: pitch, loudness, timbre, duration, envelope

Note that our perception tends to be logarithmic in relation to physical quantities. For instance doubling a physical quantity produces the sensation of equal perceptual distances: Logarithmic perception (pitch, loudness): equal perceptual distances correspond to equal ratios of physical quantities

An example of such doubling is the octave: four frequencies in the relationship X, 2X, 4X, 8X (e.g. 100, 200, 400, 800) will sound equally spaced.

Basic perceptual attributes of musical sound (and their physical correlates)

  • Pitch (frequency)
  • Noise (unwanted signal, typically random and aperiodic): S/N ratio
  • Loudness (amplitude)
  • Timbre (tone color) (wave shape)
  • Duration and envelope (RMS amplitude)
  • Phase: Note that phase is not audible in itself, but is crucial in Fourier series for determining wave shape (and in particular a 180 degree phase shift can produce complete signal cancellation!)
  • Spatialization: binaural hearing implies two signals, enabling sound spatialization

Pitch

  • Audible frequency range for good hearing: from 20 Hz to 20 KHz
  • A4 = 440 Hz (octaves are numbered from C: Middle C = C4)
  • An interval is defined by two frequencies, f and g
  • Perceptually equal intervals have equal ratios. Thus the interval between f1 and g1 is heard to be the same as the interval between f2 and g2 when f1/g1 = f2/g2 (and not, as you might expect, when (f1-g1) = (f2-g2))
  • Octave ratio = 2
  • Semitone interval frequency ratio (12 semitones to the octave) = twelfth root of 2
  • Cent interval frequency ratio (100 cents to the semitone) = 1200th root of 2
  • In music we measure pitch intervals in log units, so that we can compute differences rather than ratios.
  • Pitch perception is logarithmically related to frequency
  • Musical pitch interval = log (frequency ratio) (the logarithmic base provides the interval unit; thus log base 2 gives the number of octaves, and log base twelfth root of 2 gives the number of semitones)
  • To clarify, let's pose and solve these problems:
    • What's the interval between two waves of frequency 660 Hz and 440 Hz? We compute the ratio 660/440 = 1.5, then take the log base 2 of this value to = approx. 0.585, to express this ratio in octaves. In tempered semitones, compute 12*0.585 = 7 semitones, or about a perfect tempered 5th (1.5 = 3/2 is exactly a perfect fifth in Pythagorean tuning).
    • Conversely, what's the frequency ratio corresponding to a tempered major 3rd above A4? This interval contains 4 semitones, or a third of an octave. The ratio is then 2^(1/3) = approx. 1.26. Since A4 is 440 Hz, a major third above is (1.26)* 440 = 554.4 Hz.

Loudness

  • Loudness is to power as pitch is to frequency
  • RMS amplitude gives the average sound pressure
  • Power is the square of this RMS amplitude
  • The number of dB in a ratio = 10 * log (ratio) [base 10]
  • Here the ratio is taken between the power of one wave, and the power of another wave
  • Suppose two sound waves have RMS amplitudes A and B, i.e. power A^2 and B^2. Then the number of dB between them is = 10 * log (A^2 /B^2) = 20 * log (A/B)
  • Threshold of hearing at 1 KHz: 2×10^-5 = 0.00002 Pa (RMS) (Pa = Pascale, unit of pressure = 1 newton per sq. meter). This value is used to compute sound pressure level (SPL): The SPL of a wave is the number of dB above this threshold. Thus the threshold itself is 20*log (0.000002/0.000002) = 0 dB
  • A loud sound such as a jackhammer is about 2 Pa, 100,000 times bigger than the threshold. In SPL dB we compute 20*log(100,000) = 20 * 5 = 100 dB.
  • In other words: whenever the RMS sound pressure goes up by a factor of 10, the SPL increases by 20 dB. Figure out the number of factors of 10, multiply by 20, and you've got your dB.
  • Loudness in dB SPL

Duration

  • The length of the periodic wave (so long as it remains within audible range of pitch and loudness). True periodic waves are infinite, but in practice the sound has a beginning and an end, or at least its amplitude fades beyond audibility outside a certain time interval (perhaps due to movement of the auditor).
  • You can think of the duration determined by a perfectly periodic wave, plus an on/off switch: you turn the switch on, and hear the wave, then turn it off, and hear nothing.
  • This idea can be generalized: imagine a perfectly periodic wave, plus a volume control: you bring the volume up from zero, modify it, then fade it out.
  • If we assume simple linear changes at particular points in time, we get the concept of "sound envelope".
  • The sound envelope is crucial to identification of sound source. On synthesizers, the envelope is often defined by times for ADSR (attack, decay, sustain, release).

Timbre

  • Timbre is a kind of "remainder" category, defined as that which differentiates two sounds of identical pitch, volume, and duration.
  • Timbre is closely related to the waveshape and envelope of a periodic wave.
  • Try drawing different waveforms in Audacity and hear what happens.
  • Or modify harmonics in a Fourier series, and see what happens to the waveshape.

Digitization

  • Signals can be analog (continuous in time and value) or discrete (countable in time) or digital (countable in time and value)
  • Converting the physical analog world to the digital computer world, by
    • sampling a signal at discrete moments in time
    • quantizing: converting each sample to one of a number of discrete values
    • Codecs perform A/D (and D/A)
  • Aliasing problem:
  • Noise problem:
  • Play with Audacity: examine samples

Homework

  • Compute A5 in Hz
  • Compute C5 in Hz
  • Compute 600 Hz in pitch
  • Derive the frequency, period, and wavelength of A4
    (assume dry air at 20 degrees celsius, in which case the speed of sound is 1115 ft/sec).
  • What is the pitch of a periodic sound wave with wavelength 5" (five inches)? (again assume the speed of sound = 1115 ft/sec or 340 m/sec)
  • Compute the SPL in dB of a rock concert if the RMS pressure amplitude is 10 Pascales. Could this SPL be dangerous to your hearing? Consider this table.

Lab

  • Audacity:
    • examine samples
    • draw a periodic wave, hear it (100 samples at 44.1kHz is approximately one period of a 440 Hz = 0.44 KHz wave) (use Loop Play = shift-space)
    • record, observe clipping
    • edit, analyze, normalize
  • Praat: pitch track, etc.

Demos

waves

fourier series and harmonic analysis

Two dimensional waves

Standing waves on a string

Sounds in a pipe

Audio sampling and aliasing

The wagon-wheel effect (visual aliasing)

build your own instrument and play it!

powers of ten, to put your life into perspective...