I'm a software developer and I am trying to understand sound a bit better for a project I want to start working on.

Sorry if this is a bad place for this, if needed I can delete and repost elsewhere. Let me know.

Anyways, it is quite obvious to us when a flute plays a note compared to a piano playing that same note. What makes them so different though? If I wanted to mathematically represent the exact sound a flute makes at a certain note, what are the values that I would need to record. Values such as frequency, volume, etc. I want to understand this because if we are able to reproduce these sounds on speakers we must have this data stored in our audio files.

All of the data mentioned above, how much does it vary depending on pitch and volume?

In basic what I want to understand is what constitutes the sound that we hear. There is definitely a lot more I need to know, but I fear I don't know enough as it is with my current knowledge and I'll probably edit this question later.

  • Note the musical term for the difference between the sounds of two different instruments is timbre. You might do a web search and see if that helps give you more detail. Commented Oct 18, 2017 at 4:17
  • Hi Connor. I edited the title and some of the text to try to clarify your query a bit. Feel free to change the words I used if you don't think they convey your intent.
    – n00dles
    Commented Oct 28, 2017 at 17:44

4 Answers 4


The highly simplified answer is that sound in the real world is not sine waves with fixed frequencies. We learn about sound initially as frequencies or notes and simplify the concept down to thinking about various sine waves to make it easier to understand the fundamentals of what is going on.

The reality, however, is that all sound propagates through the same medium (air) and is additively combined in to a complex waveform.

Outside of using a sine wave generator, no sound you hear is actually just one frequency. Most are complex combinations of many different frequencies of sound which are being combined in to a complex waveform that your brain sorts out. This is why things like speech recognition are so difficult and why it is extremely difficult to try to fake someone's voice or even just generate believable synthesized speech.

A flute and a piano may have the same apparent tone, but the overall set of components combining to give it the sound it has are completely different. These other frequencies, other than the pure sine wave of the particular note, are what make the particular instrument or singer recognizable.

Trying to accurately reproduce the sound of a particular instrument is tricky, but is a common thing to do. This is how synthesizer voices are created. Techniques can vary from getting a broad generalization based on the other portions of the sound for each note to make more sine waves directly, sampling an existing instrument for each note and simply playing it back, or advanced acoustic modeling that calculates the impact of various different aspects of an instrument and space on the overall sound in order to produce a final output.

Synthesizer design is where you want to look for more info, but it's an incredibly broad space with many different techniques so we aren't going to be able to give a detailed answer about all of them here.


Ok, let's start from the basics. Audio is usually recorded (sampled - converted from a continuous analogue signal to a digital record) and stored as a series of numbers representing the momentary voltage of the signal at regular intervals.

Sampling rate is the rate at which we check and record the momentary value of the analogue signal. Common sampling rates are 44.1kHz, 48kHz, 96kHz and 192kHz.

Bit depth is the bit resolution of each sample. A very low voltage would be represented as a very low (binary) number and a very large voltage as a number close to the maximum possible. Common values are 16 bit and 24 bit but also floating point.

This data is recorded as a .wav file. These files have a header describing the form of the following data, including number of channels since a .wav file can be mono or stereo.

Now, the difference between a flute and a piano note lays in a different domain altogether. What I described above (sampling) is a digital representation of a signal in the time domain. But the difference between sounds can be in any or both, the time and the frequency domain.

Timbre or harmonic content of a sound is the amount of each frequency present in that sound. It is what allows us to distinguish different sounds.

To get from the time to the frequency domain, you need to perform an FFT (fast Fourier transform) on your data. This will give you the spectrogram of the sound which contains the information you need.

Interpreting a spectrogram to distinguish/recognize sounds can be quite a challenge and I guess it would be done statistically with some degree of error. To give you a starting point in what you're looking for, a guitar is a stringed instrument and strings have harmonic series with amplitudes 1/n*(nf) where 'n' is the number of the harmonic (multiple of its fundamental frequency) and 'f' is the fundamental frequency. A trumpet is a piped instrument, closed at one end and its harmonic series in the form of 1/(2n-1)[(2n-1)f].

So if we had both playing a middle 'A' (440Hz), the guitar would have harmonics (peaks on the spectrograph) at 440, 880, 1320, 1760 etc, while the trumpet would have them at 440, 1320, 2200, 3080 etc.

That was an example using two sounds with an obvious difference in the frequency domain. Next, lets compare two sounds that are very similar in the frequency domain but have a difference in the time domain - a guitar and a piano, both stringed instruments.

They both have strings so their harmonic series are the same, but one is a plucked instrument (guitar) while the other is struck (piano - has hammers striking the strings). Striking gives a faster attack (how fast the sound reaches its maximum level) than plucking does. So by measuring the time it takes a sound to reach its maximum level, we can differentiate a guitar from a piano.

Please feel free to ask if something from the above confuses you and I will edit my answer to clarify. I understand this might be too much information for one answer.

  • I may have accidentally suggested and edit instead of commenting, my bad. Do you think you could go more in-depth on .wav files? Thanks! Commented Oct 18, 2017 at 14:32
  • It's been a few years since I was playing around with this but you can think of them as a chunk binary of data of fixed bit resolution (e.g. 16 bit), describing a waveform. I believe it's two's compliment since it can have negative values and there's only one zero. The amount of values (samples) determines the length of the sound/song if you know the sampling frequency(Fs). As said above, this information is contained in the file header - The first portion of the file which is clear text. I remember using Mathematica to look at the header but there's probably easier ways. Commented Oct 19, 2017 at 15:11
  • I just checked to see if a normal text editor would show the header in clear text but it didn't work. I googled it and came across this which seems better than I could explain it to a programmer (since I'm not one). truelogic.org/wordpress/2015/09/04/parsing-a-wav-file-in-c Commented Oct 19, 2017 at 15:14

All of the answers so far talk about the harmonic content/timbre, but there is another very important concept that you have to keep in mind. The concept is touched on, but not explicitly. So I wanted to expand on that.

The 'Envelope' is vastly different between the two instruments

Envelope refers to the dynamics (amplitude) at specific times. Components of the envelope include (but are not limited to):

Attack - the time for initial increase from nil to the designated (or preset) level, beginning when the key is first pressed.

Decay - the time it takes for the attack level to drop to the sustain level.

Sustain - the level that the sound will remain at for as long as the note is held (key held down or continued blowing).

Release - the time that it takes for the level to drop to zero after releasing the note.

This is the standard ADSR model, but you can also use loops and whatnot, but that's more relevant to the digital realm than modeling.

So anyway, regarding your specific instruments:

Flute - This is a woodwind, which means that there is slightly slower (than piano) Attack as you build your breathing to full strength. There is usually a peak level right there, then Decay is fairly quick. The Sustain goes at a constant level for as long as you want (depending on skill and lung capacity). Then there is a very quick release once you stop blowing.

Piano - This is a percussive stringed instrument. There is a hammer that swings and strikes a string. So the Attack is almost immediate, and then you deal with decay and release only. If you hold the key, then you will get a longer decay which will eventually go to zero. If you let go of the key, you get a fairly quick release.

Using Massive or Reaktor, I like to play around by making a sound, and only changing the ADSR settings. Using the same oscillators and filters, you can greatly change the sound. You could make a square wave (which would be similar to a flute) but if you don't have the right Envelope, you'll never get it to sound right.

  • 1
    Technically, timbre includes the envelopes, transients, and noises. The spectrum does not include those other elements, only the amplitudes of the different harmonics. An I mportant element of instrument recognition not discussed here is the noise content. Specifically, flute features distinctive breath and wind noise, while piano has a whole constellation of noises, including hammer noises, upper and lower key noises, and possibly pedal noises and other odds and ends. Commented Oct 18, 2017 at 4:19
  • You're absolutely right, forgot about that. I still think a breakdown of the envelope may help the OP understand though. As for noise, on of the more fun projects in school was creating completely digital sounds, then recording the instrument noises and layering them in to make our own samples. It really made me appreciate the work that had to be put into (for example) Kontakt.
    – user22688
    Commented Oct 19, 2017 at 19:35

A way to understand timbre and differences between instruments is to interpret harmonics by casting an eye on their spectrograms: flute and piano spectrogram The flute has some tremolo visible on the high-end sustained harmonics that look consistent throughout the sample.

Piano, on the other hand, has gradient like harmonics fading towards the higher ones. Also the wavefile has a shorter release time than the flute one.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.