1. ALT and left-click the name, which should download it onto the desktop. Then drag and drop it into Matlab's working directory. Or...
2. Right-click the name, choose 'save link as...', and notice it wants to be saved as .wav or .m, so that's good. Then just navigate in that same download GUI through testing, Documents, to MATLAB. Save. This will go more quickly for the next file. Don't know if it makes sense to do several files at once; I couldn't figure out how.
This is boring, right enough.
>> [sound, freq] = wavread('guitAmin.wav'); >> wavplay(sound, freq);
Or wavplay(wavread('guitAmin.wav')); should work, no?
The data is single notes and chords produced on different 'instruments', or sources. Some of the following questions are pretty easy for humans. Others require 'perfect pitch' to identify exactly the pitch of a note or the pitches in a chord. Humans don't need perfect pitch to tell major from minor chords, but you'll be dealing with computers and using your visual system to analyze outputs, so it gets more interesting. Also humans may need more than a second of data to answer these questions, so it's entirely possible that this computational approach can outperform humans with short inputs.
Following are some questions you might want to answer, ranked in CB's version of "likelihood of success". Keep on asking and answering until you're out of time.
Maybe other questions will occur to you.
Your method is just to plot and "eyeball" the power spectra of the sound data. Then you can see whether your powerful visual perceptions can identify characterics in the frequency domain representation of the signal to answer your question.
The function in PowSpec.m in the SoundLab Directory is a place to start, could be all you need. It takes a sound file name (e.g. 'hiss.wav') and a number saying how much data to read. This number should be a power of 2, since we're going to FFT the data. I find 2048 is a reasonable size, you could try 4096 I suppose, or 1024. The data is read from the start of the sound, so 2048 points from files (all but the guitar sounds) digitized at 22050 samples/sec is about 1/10 second.
The guitar files are sampled at 44100 Hz, so 2048 is about 1/20 second. The overtones of the non-guitar sound are probably pretty constant, so you'll get very similar power spectra after about 1/5 second (size 4096); that is, you'll be using a longer sample of an unchanging sound to get the same information out, since "more of the same" sound doesn't tell you anything new about its frequency content. But the guitar sound decays and so my guess is using a big size, like 32768 or about 3/4 second, will include more of the later sound that has less information about what differentiates it from other similar sounds (see below on overtones). So shorter sizes give probably more uniform sounds, and earlier, shorter sizes are more representative of what makes a sound unique.
The function reads and plays the sound, plots it, computes the spectrum and plots its right-hand side, from 0 to the highest frequency in the file. It also returns the vector of frequencies (x-axis of PS plot) and the PS data that was plotted. These vectors can be used to zoom in on parts of the data. You can use hold to compare plots.
Example: get the sound pipeA.wav and PowSpec.m into your working Matlab directory, then:
>> [freqA powA] = PowSpec('pipeA.wav', 4096); %plays, plots twice >> plot(freqA(1:400),powA(1:400), '-g'); % zooms in on low-frequency part of the spectrum.
The following relation of pitches to frequencies should help
you analyze your power spectra:
Pitches and Frequencies
Notes from instruments have a complex frequency make-up, which is why glockenspiels don't sound like bassoons or pitchpipes like guitar strings. We call the differnce the timbre of the instrument, and it depends on what the instrument is made of (wood, brass), how the sound is generated (striking, bowing, single-reed like clarinet, double-reed like oboe or bassoon, etc.) If we knew more about timbre, then MIDI files, electronic keyboards, or synthetic voices could be made to sound more like real instruments. But we don't, really -- it's still a mystery. Some of our questions above are about timbre: can we tell from the power spectrum (or maybe the sound waveform) the difference between a pitchpipe and a guitar or humming? Note the Wikipedia link just below has a later section on timbre.
One difference in timbre is the presence and amplitude of overtones. Look at this link: The Harmonic Series. Here you'll see the "modes" or harmonics of string vibration when both ends of the string are kept from moving. These are analogous to the modes of a vibrating drumhead we saw two links for when we discussed basis functions.
You see that there's one mode with wavelength twice the string's length (top picture), one whose wavelength is = the string's length (2nd picture), then ones with wavelengths 2/3, 2/4, etc. In terms of frequencies therefore, which are inverses of wavelengths, the harmonic frequencies corresponding to a fundamental frequency f are f, 2f, 3f, 4f,... the overtones occur at equal intervals in frequency space -- they are evenly spaced in the power spectrum!
To make things interesting, open pipes have more possible harmonics, including those with wavelengths of the fundamental pipe wavelength divided by an odd number.
For a visualization, follow this link from the Wikipedia article: Interactive Visualization. You can see the overtones (harmonics) alone or working together. Sounds from real instruments have a weighted mixture of these overtones or harmonics.
Our hearing of tones is NOT an arithmetic, but a geometric, progression. The 'same note' an octave higher is vibrating twice as fast. The octave frequency series is f, 2f, 4f, 8f, 16f,... This means that the increasing, linearly-spaced harmonics sound as decreasing musical intervals from each other. The second harmonic (first overtone) is an octave above, the third harmonic is a fifth (7 half-steps) above that, the fourth harmonic is a fourth (5 half-steps) above that (two octaves above the original), the next is a major third above that, the next a minor third above that, etc. (see the musical notation and charts further down in the article). This nice relation of common and pleasing musical intervals with the (early part of the) harmonic series is what got Pythagoras (circa 500 BC) and some people before him excited about the powers of the harmonic series.
That's a little more than we need to know; the bottom line is: one thing to look out for in the power spectra is these evenly-spaced harmonics which could be generated by the particular sound source involved producing "one note".
If you want to know more, try Wikipedia on "pythagorean overtones", "even-tempered scale", "pythagorean comma".
Last, the fundamental frequency (the pitch we humans associate with the note) of our recorded sounds is mostly in octaves 2, 3, 4 of the pitch-frequency chart (except for maybe some of the guitar harmonics: *.harm* files). It seems to us that the "fundamental frequency" (e.g. the 82 Hz of the guitar's 6th-string E) comes through pretty weakly in some of our sounds. So be open to surprises, that's the fun part.
Our sound files were made with the above questions in mind. We hope this data can support questions like the above -- a cursory look shows some is promising but there may be technical problems with some sounds.
Our files are digitized into one channel (not stereo) at 22050 samples per second (44100 for the guitar sounds) and are 2 seconds long. The function in the SoundLab directory, PowSpec(filename, size), grabs the initial size elements in the file.
Here are the files (blank entry means no file).
SINGLE PITCHES: SOURCE PITCH PITCHPIPE HUM WHISTLE GUITAR ------------------------------------------------------------------------------ | A | pipeA.wav humA.wav whistleA.wav guitA1,A2,A3 (.wav) D | pipeD.wav humD.wav whistleD.wav E | humE.wav guitE1,E2,E3,E4,E3a,E3aharm1,2 (.wav) C | humC.wav G | humG.wav VOICED VOWELS and a CONSONANT "Ahh" -- voiceA.wav "Eee" -- avoiceE.wav "Ooo" -- voiceO.wav "Uuu" -- voiceU.wav "Sss" -- hiss.wav CHORDS: GUITAR: Amajor: (E, A, E2, A2, C#, E3) -- guitAmaj.wav Aminor: (E, A, E2, A2, C, E3) -- guitAmin.wav Adom7 : (E, A, E2, G, C#, E3) -- guitA7th.wav Aminor7: (E, A, E2, G, C, E3) -- guitAmin7.wav A6: (E, A, E2, A2, C#, F#) -- guitA6th.wav PITCHPIPE: B minor 2nd: (B C) -- pipeBC.wav
The guitar chords show all 6 strings, starting with low E at 82Hz. Pitches are ascending from left to right. E2 and E3 are one and two octaves up from low E, A is the one just above E, A2 an octave above A, up to the F# two half-steps above E3.
Use your eyes (not your ears!) and the temporal and frequency domain representation of the sounds. Eyeball the plots and try to identify characteristics in them that you could use to answer the question you've picked.
Relax and have fun.
Ignoring teams, each individual should hand in a piece of paper with legible signature, telling us:
Fact: our ".wav" files are nothing but a long vector of doubles in the interval [-1, 1] (try help wavrecord. There are several corollaries to this:
Wonder about more complex, time-varying sounds and their variation of frequencies through time? You want a sound spectrogram, which is the first option in the Signal Processing assignment. It's easy. Guitar effects? They're there too, and more.
Interested in 'real sounds or songs'? Problem is it's hard to find real (uncompressed) .wav files on the web (believe me I tried). Despite their .wav extension, all I could find were .mp3 compressed files that Matlab can't deal with. There are converters, I'm told. Or you can record your own.