Day 21

Thursday, April 20, 2017

Sounds and spectra

(from last time in case needed)

This code plots the spectrum of a sound in a wav file:

Example wav files: guitar low E, piano low F, brass bar

Here is the spectrum of the brass bar:


And here is the spectrum of the low piano note:


(Notice that the "fundamental" (the lowest frequency) is almost not present.)

Online tone generator in case it's useful



This code produces a sound with components we specify:

Let us see if we can synthesize the recorded brass bar sound above using frequencies and amplitudes read from the spectrum of the recording:


Drum (circular stretched membrane)

Let's record the sound a drum, and analyze and synthesize it.

[In case of difficulties, I prepared these in advance: small tom closed, small tom open]

Solving the wave equation on a disk

Let's solve this problem by separation of variables, find the spectrum, and see if it matches the recording of the real drum.

2017_04_20/20170420_135305.jpg 2017_04_20/20170420_135321.jpg 2017_04_20/20170420_135332.jpg

Relationship between F and f:

bessel_fF.png 2017_04_20/20170420_135359.jpg bessel_functions.png

Code that made the picture above:


Synthesis of drum sound from solution of wave equation on disk

# enter frequency components here
freqs = 120.*array([1,1.593,2.136,2.295,2.653,2.917])
amps  = array([1.,1,1,1,1,1])

synthesized_drum.wav (first effort, just guessing frequency of fundamental)

actual drum recording