# Analyzing Xylophone Sound Clips Found On the Web

As the previous posts note, the desired frequency ratios for the first 3 partials of a xylophone are 1:3:6.  However, I needed to know how accurate these frequencies had to be to yield a nice-sounding instrument. I couldn’t find comments on the web about the tuning accuracy requirements, so I set out to spectrally measure some instruments to serve as a guidepost. Specifically, I needed to know how accurate I needed to tune the fundamental and higher partials.

## Finding Sound Samples On the Web

The web was pretty skimpy when it came finding sound clips of xylophones.

Here was the first clip that I found – basically a guy playing a C-major scale. There was no info on the type of xylophone he was playing, but it looked pretty decent.

Here is another video that I found of a DeMarrow instrument. He hits some notes at the end of the video.

Finally, at  this site I found a third clip of a guy from the Oregon Symphony playing an xylophone. Again, the I couldn’t find the xylophone brand, but decided it must be a good one if it is used in the symphony.

## Spectral Analysis

So here is where the magic starts – I wrote some software in Matlab that analyzes these clips to determine how accurately tuned the xylophone is. The tool, called AnalyzeClip, performs the following steps:

2. Delineate  each discrete note (i.e., each time a bar is struck) into its own clip.
3. For each clip, perform a windowed spectral analysis.
4. Find the peaks in the spectrum (aka, the modes). This identifies the frequencies associated with the fundamental frequency and the higher partials.
5. Find the fundamental. This is the lowest mode and typically has the most power (although not always – sometimes I found that the second partial had more power.)
6. Associate the fundamental with the closest ideal note, assuming an equal-tempered scale with a 442 Hz reference pitch (Wikipedia has a nice description of equal temperament.)
7. Compute the frequency error of the fundamental relative to the ideal desired pitch.

The “ideal pitch” noted in the last step is computed for a an equal tempered scale with a 442 Hz reference. The notes in an equal tempered scale have a ratio that is given by 2^(1/12) power, which is about 1.0595. So if you want to determine the frequencies associated with a note, just multiple the previous notes frequency by 1.0595. If you do this multiplication for 12 successive notes, the two bookending notes will have a ration of 2, or an octave apart. For my 3.5 octave xylophone, the following table gives the desired frequency for each note.

## Note frequencies

Bar NumberNoteFrequency
1F4350.816
2F#4371.676
3G4393.777
4G#4417.192
5A4442.000
6A#4468.283
7B4496.128
8C5525.630
9C#5556.885
10D5589.999
11D#5625.082
12E5662.252
13F5701.631
14F#5743.352
15G5787.554
16G#5834.385
17A5884.000
18A#5936.565
19B5992.256
20C61051.259
21C#61113.770
22D61179.998
23D#61250.165
24E61324.503
25F61403.263
26F#61486.705
27G61575.109
28G#61668.770
29A61768.000
30A#61873.131
31B61984.513
32C72102.518
33C#72227.540
34D72359.997
35D#72500.330
36E72649.007
37F72806.525
38F#72973.410
39G73150.218
40G#73337.540
41A73536.000
42A#73746.262
43B73969.026
44C84205.036

Notice that bar 5 (A4) has a pitch of exactly 442.00 Hz. This is because I referenced all of the other notes to this pitch.

In my next post, I will show some results form the spectral analysis of the sound bites that I found on the web.