Tutorial - Understanding spectrograms

From Audacity Development Manual
Revision as of 17:01, 10 June 2015 by Paul L (talk | contribs) (Zero padding factor: outline chirp example)
Jump to: navigation, search

Under construction

Introduction

Example sounds

In this tutorial, several example sounds are shown repeatedly with variations of settings. Follow these instructions to recreate those sounds.

  • Silence: Use the Silence generator to create silence of any given duration.
  • Impulses: To create the briefest possible click sound or "impulse," enable the Draw Tool, then zoom the view of a track until individual samples are visible. Hold CTRL and drag one sample upward or downward as far as possible.
  • Chromatic Scale: Generate one second of silence. Select the silence. Use the Nyquist_Prompt effect, and copy and paste the following code into the text entry. Click OK. The result is an ascending chromatic scale of pure tones separated by rests. The notes begin at middle C and continue for four octaves. Each is one-half second long with a tapering envelope.
  (let ((scale (s-rest 0))
        (env (hzosc (/ (get-duration 1)))))
     (dotimes (ii 49)
        (setq scale
           (sum scale
              (at ii
                 (seq
                    (prod
                       (cue env)
                       (cue env)
                       (cue (osc (+ 60 ii) 0.5)))
                    (s-rest 0.5))))))
   (prod 0.99 scale))
  • Overtone scale: The following code generates the note two octaves below middle C, and successive whole-number multiples of that frequency.
  (let ((scale (s-rest 0))
          (env (hzosc (/ (get-duration 1)))))
     (dotimes (ii 32)
        (setq scale
           (sum scale
              (at ii
                 (seq
                    (prod
                       (cue env)
                       (cue env)
                       (cue (osc (hz-to-step (* 65.406 (1+ ii))) 0.5)))
                    (s-rest 0.5))))))
     (prod 0.99 scale))
  • Pluck: The Pluck generator simulates a plucked string.
  • Chirp: The Chirp generator creates a continuously varying tone, rising or falling linearly or exponentially in frequency.

Default Preferences

Unless otherwise specified, all images use default values for Spectrogram Preferences. These are:

  • WindowSize: 256
  • WindowType: Hanning
  • Zero Padding Factor: 1
  • Minimum Frequency: 0 Hz
  • Maximum Frequency: 8000 Hz
  • Gain: 20 dB
  • Range: 80 dB
  • Frequency gain: 0 dB/decade
  • Grayscale: off

Linear and logarithmic scales

See the linear view of a pluck, up to 22050 Hz (shift-right click in vertical scale). The overtone series appears evenly spaced. Many naturally occurring sounds have similar series. See the logarithmic view. Now the spacing between overtones grows ever smaller as frequency increases.

Compare linear and logarithmic views of a chromatic scale (from 200 to 4800 Hz, window size 4096). The logarithmic view spaces musical semitones evenly on the vertical scale, so that the sequence of notes falls on a straight line.

Maybe generate an overtone scale and make the same contrast.

Spectral selection

Preferences

Window size

Generate a chirp, Sine waveform, 20 to 2000 Hz, constant 0.8 amplitude, Linear, 1 s. (Just show a screenshot of those settings).

Create a superposed impulse at approximately 0.5 seconds.

View with linear spectrogram, scale from 0 to 3000 Hz, otherwise defaults.

View again with windows size of 4096.

This demonstrates the tradeoff between time and frequency localization. While the impulse looks narrower in the first picture, the white band is wider.

Zero padding factor

Increased zero padding can make a more smoothed image for shorter window size, at the expense of increased computation time. The product of window size and zero padding factor is not allowed to exceed the maximum window size without zero padding.

Reproduce the two examples of the previous section, but with Zero padding factor increased to 8. Note that there is no effect on the localization tradeoff. However the images appear much more smoothed, more so for the shorter window size. The white band has straighter boundaries and the "side lobes" of the window function's spectral leakage appear more distinctly as ripples.

Window type

Minimum and Maximum Frequencies

Gain, Range, and Frequency gain

Grayscale