The Math of Music |

The waveform of a sound is a graph of the way the pressure changes between the wavefronts. This is usually a very convoluted pattern and the actual sound of the wave is not apparent from looking at the waveform. As a matter of fact, the waveform does not usually repeat exactly from one cycle to another.
The waveform produced by simple harmonic motion is the SINE WAVE. We
graph a
sine wave by plotting the function: To do this we divide up our graph paper horizontally into equal chunks to represent a time scale, and for each time t we want to plot, we multiply t by 2[pi]f (f=frequency) and look up the sine of the result. That sine value is what gets used for the vertical part of the graph. There is also a function called a cosine wave.
and it looks just like the sine wave. The difference is that the cosine of an angle is equal to the sine of an angle 90 degrees bigger. When we have two waveforms which have the same shape and frequency but are offset in time, we say they are out of phase by the amount of angle you have to add to the 2[pi]ft term of the first to move them together. In other words the wave defined by sin(2[pi]ft) is out of phase with the wave defined as sin(2[pi]ft+p) by the angle p. The second simplest waveform is probably the combination of two sine waves. Any combination of waves is interpreted by the ear as a single waveform, and that waveform is merely the sum of all of the waves passing that spot. Here are a few rules about the addition of two sine waves: - If both have the same frequency and phase, the result is a sine wave of amplitude equal to the sum of the two amplitudes.
- If both have the same frequency and amplitude but are 180 degrees out of phase, the result is zero. Any other combinations of amplitude produce a result of amplitude equal to the difference in the two original amplitudes.
- If both are the same frequency and amplitude but are out of phase a value other 180 degrees, you get a sine wave of amplitude less than the sum of the two and of intermediate phase.
- If the two sine waves are not the same frequency, the result is complex. In fact, the waveform will not be the same for each cycle unless the frequency of one sine wave is an exact multiple of the frequency of the other.
If you explore combinations of more than two sine waves you find that the waveforms become very complex indeed, and depend on the amplitude, frequency and phase of each component. Every stable waveform you discover will be made up of sine waves with frequencies that are some whole number multiple of the frequency of the composite wave. ## Fourier AnalysisThe reverse process has been shown mathematically to be true: Any waveform can be analyzed as a combination of sine waves of various amplitude, frequency and phase. The method of analysis was developed by Fourier in 1807 and is called Fourier Analysis. The actual procedure for Fourier analysis is too complex to get into here, but the result (with stable waveforms) is an expression of the form:
and so forth. The omega (looks like a w) represents the frequency in radians per second, also known as angular frequency. The inclusion of cosine waves as well as sine waves takes care of phase, and the letters represent the amplitude of each component. This result is easily translated into a bar graph with one bar per component. Since the ear is apparently not sensitive to phase, we often simplify the graph into a sine waves only form. Such a graph is called a spectral plot:
The lowest component of the waveform is known as the FUNDAMENTAL, and the others are HARMONICS, with a number corresponding to the multiple of the fundamental frequency. The second harmonic is twice the fundamental frequency, the third harmonic is three times the fundamental frequency, and so forth. It is important to recognize that the harmonic number is not the same as the equivalent musical interval name, although the early harmonics do approximate some of the intervals. The most important relationship is that the harmonics numbered by powers of two are various octaves. Non-repeating waveforms may be disassembled by Fourier means also, but the result is a complex integral that is not useful as a visual aid. However, if we disregard phase, these waveforms may also be represented on a spectral plot as long as we remember that the components are not necessarily whole number multiples of the fundamental frequency and therefore do not qualify as harmonics. We should not say that a non-harmonic waveform is not pitched, but it is true that the worse the spectral plot fits the harmonic model the more difficult it is to perceive pitch in a sound. There are sounds whose waveforms are so complex that the Fourier process gives a statistical answer. (These waveforms are the sounds commonly called noise.) You can express the likelihood of finding a particular frequency as a component over a large enough time but you cannot assign any component a constant amplitude. To describe such sounds on a spectral plot, we plot the probability curve. A very narrow band of noise will sound like a pitched tone, but as the curve widens, we lose the impression of pitch, aware only of a vague highness or lowness of the sound. Noise that spreads across the entire range of hearing is called WHITE NOISE if it has equal probability of all frequencies being represented. Such noise sounds high pitched because of the logarithmic response of the ear to frequency. (Our ears consider the octave 100 hz to 200 hz to be equal to the octave 1000 hz to 2000 hz, even though the higher one has a much wider frequency spread, and therefore more power.) Noise with emphasis added to the low end to compensate for this is called PINK NOISE. ## SonogramsA sound event is only partially described by its spectral plot. For a complete description, we need to graph the way the sound changes over time. There are two ways in which such graphs are presented. In the Sonogram, the horizontal axis is time, the vertical axis is frequency, and the amplitude is represented by the darkness of the mark. There is a machine that produces this kind of chart by mechanical means.
The three dimensional graph gives a clearer sense of how the amplitudes of various components of a sound change. This really shows amplitude envelopes for each partial of the sound. In this case, frequency is represented by the apparent depth into the screen. Most analysis programs allow you to either show high frequency behind low, as this one does, or low behind high. This and the ability to swap parameters among the three axes allows you to pick a view with the least information hidden. ## The Mathematics of Electronic MusicOne of the difficult aspects of the study of electronic music is the accurate description of the sounds used. With traditional music, there is a general understanding of what the instruments sound like, so a simple notation of 'violin', or 'steel guitar' will convey enough of an aural image for study or performance. In electronic music, the sounds are usually unfamiliar, and a composition may involve some very delicate variations in those sounds. In order to discuss and study such sounds with the required accuracy, we must use the tools of mathematics. ## HertzIn dealing with sound, we are constantly concered with frequency, the number of times some event occurs within a second. In old literature, you will find this parameter measured in c.p.s., standing for cycles per second. In modern usage, the unit of frequency is the Hertz, (abbr. hz) which is officially defined as the reciprocal of one second. This makes sense if you remember that the period of a cyclical process, which is a time measured in seconds, is equal to one over the frequency. (P=1/f) Since we often discuss frequencies in the thousands of Hertz, the unit kiloHertz (1000hz=1khz) is very useful. ## Exponential functions
Many concepts in electronic music involve logarithmic or exponential
relationships. A relationship between two parameters is
where k is a number that does not change (a constant). A relationship between two parameters is exponential if the expression has this form:
In this situation, a small change in X will cause a small change in Y, but a moderate change in X will cause a large change in Y. The two kinds of relationship can be shown graphically like this:
One fact to keep in mind whenever you are confronted with exponential functions: X^0=1 no matter what X is. Logarithms
A logarithm is a method of representing large numbers. It is the
inverse of an exponential
relationship. If We find logarithmic and exponential relationships within many places in music. For
instance the octave's numerical relationship may be expressed as Freq=
F*2^n... ## DecibelsThe strength of sounds, and related electronic measurements are often expressed in decibels (abbr. dB). The dB is not an absolute measurement; it is based upon the relative strengths of two sounds. Furthermore, it is a logarithmic concept, so that very large ratios can be expressed with small numbers. The formula for computing the decibel relationship between two sounds of powers A and B is 10 log(A/B). ## The Spectral PlotA spectral plot is a map of the energy of a sound. It shows the frequency and strength of each component.
Each component of a complex sound is represented by a bar on the graph.
The
frequency of a component is indicated by its position to the right or
left, and
its amplitude is represented by the height of the bar. The frequencies
are
marked out in a manner that gives equal space to each octave of the
audible
spectrum. The amplitude scale is not usually marked, since we are
usually only
concerned with the ## EnvelopesEnvelopes are a very familiar type of graph, showing how some parameter changes with time.
This example shows how a sound starts from nothing, builds quickly to a peak, falls to an intermediate value and stays near that value a while, then falls back to zero. When we use these graphs, we are usually more concerned with the rate of the changes that take place than with any actual values. A variation of this type of graph has the origin in the middle:
Even when the numbers are left off, we understand that values above the line are positive and values below the line are negative. The origin does not represent 'zero frequency', it represents no change from the expected frequency. ## Spectral EnvelopesThe most complex graph you will see combines spectral plots and envelopes in a sort of three dimensional display:
This graph shows how the amplitudes of all of the components of a sound change with time. The 'F' stands for frequency, which is displayed in this instance with the lower frequency components in the back. That perspective was chosen because the lowest partials of this sound have relaltively high amplitudes. A different sound may be best displayed with the low components in front. ## Frequency ResponseWhen we are discussing the effects of various devices on sounds, we often are concerned with the way such effects vary with frequency. The most common frequency dependent effect is a simple change of amplitude; in fact all electronic devices show some variation of output level with frequency. We call this overall change frequency response, and usually show it on a simple graph:
The dotted line represents 0 dB, which is defined as the 'flat' output, which would occur if the device responded the same way to all frequencies of input. This is not a spectral plot; rather, it shows how the spectrum of a sound would be changed by the device. In the example, if a sound with components of 1 kHz, 3kHz, and 8kHz were applied, at the device output the 1kHz partial would be reduced by 2dB, the 8kHz partial would be increased by 3dB, and the 3kHz partial would be unaffected. There would be nothing happening at 200Hz since there was no such component in the input signal. When we analyze frequency response curves, we will often be interested in the rate of change, or slope of the curve. This is expressed in number of dB change per octave. In the example, the output above 16kHz seems to be dropping at about 6 dB/oct. ## WaveformsOnce in a while, we will look at the details of the change in pressure (or the electrical equivalent, voltage) over a single cycle of the sound. A graph of the changing voltage is the waveform, as:
Time is along the horizontal axis, but we usually do not indicate any units, as the waveform of a sound is more or less independent of its frequency. The graph is always one complete period. The dotted line is the average value of the signal. This value may be zero volts, or it may not. The amplitude of the signal is the maximum departure from this average. ## Sine wavesThe most common waveform we will see is the sine wave, a graph of the function v=AsinT. Understanding of some of the applications of sine functions in electronic music may come more easily if we review how sine values are derived.
You can mechanically construct sine values by moving a point around a circle as illustrated. Start at the left side of the circle and draw a radius. Move the point up the circle some distance, and draw another radius. The height of the point above the original radius is the sine of the angle formed by both radii. The sine is expressed as a fraction of the radius, and so must fall between 1 and -1. Imagine that the circle is spinning at a constant rate. A graph of the height of the point vs. time would be a sine wave. Now imagine that there is a new circle drawn about the point that is also spinning. A point on this new circle would describe a very complex path, which would have an equally complex graph. It is this notion of circles upon circles upon circles which is the basis for the concept of breaking waveforms into collections of sine waves.
This fanciful machine shows how complex curves are made up of simple ones. ## The Harmonic SeriesA mathematical series is a list of numbers in which each new member is derived by performing some computation with previous members of the list. A famous one is the Fibonacci series, where each new number is the sum of the two previous numbers (1,1,2,3,5,8 etc.) In music, we often encounter the harmonic series, constructed by multiplying a base number by each integer in turn. The harmonic series built on 5 would be 5,10,15,20,25,30 and so forth. The number used as the base is called the fundamental, and is the first number in the series. Other members are named after their order in the series, so you would say that 15 is the third harmonic of 5. The series was called harmonic because early mathematicians considered it the foundation of musical harmony. (They were right, but it is only part of the story.) ## TemperamentOne of the aspects of music that is based on tradition is which frequencies of sound may be used for 'correct' notes. The concept of the octave, where one note is twice the frequency of another is almost universal, but the number of other notes that may be found between is highly variable from one culture to another, as is the tuning of those notes. In the western European tradition, there are twelve scale degrees, which are generally used in one or two assortments of seven. For the past hundred and fifty years or so, the tunings of these notes have been standardized as dividing the octave into twelve equal steps. The western equal tempered scale can then be defined as a series built by multiplying the last member by the twelfth root of two (1.05946). The distance between two notes is known by the musical term interval. (Frequency specifications are not very useful when we are talking about notes.) The smallest interval is the half step, which can be further broken down into one hundred units called cents. Equal temperament has a variety of advantages over the alternatives, the most notable one being the ability of simple keyboard instruments to play in any key. The major disadvantage of the system is that none of the intervals beside the octave is in tune. To justify that last statement we have to define "in tune". When two musicians who have control of their instruments attempt to play the same pitch, they will adjust their pitch so the resulting sound is beat free. (Beating occurs when two tones of almost the same frequency are combined. The beat rate is the difference between the frequencies.) If the two attempt to play an interval expected to be consonant, they will also try for a beat free effect. This will occur when the frequencies of the notes fall at some simple whole number ratio, such as 3:2 or 5:4. If the instruments are restricted to equal tempered steps, that 5:4 ratio is unobtainable. The actual interval (supposed to be a third) is almost an eighth of a step too large. It is possible to build scales in which all common intervals are simple ratios of frequency. It was such scales that were replaced by equaltemperament. We say scales-plural, because a different scale is required for each key; if you build a pure scale on C and one on D, you find that some notes which are supposed to occur in both scales come out with different frequencies. String instruments, and to some extent winds can deal with this, but keyboard instruments cannot. If you combine a musical style that requires modulation from key to key with the popularity keyboards have had for the last two centuries you have a situation where equal temperament is going to be the rule. I wouldn't even bring this topic up if it weren't for two factors. One is that the different temperaments have a strong effect on the timbres achieved when harmony is part of a composition. The other is that the techniques of electronic music offer the best of both systems. It is possible to have the nice intonation of pure scales and the flexability for modulation offered by equal temperament. Composers are starting to explore the possibilities, and some commercial instrument makers are including multi-temperament capability on their products, so the near future may hold some interesting developments in the area. ## The Science of Electronic MusicDigital vs AnalogueWhat is wrong with analogue?Not much really. If you keep them serviced, manually controlled and test that everything works every day. What is wrong with digital? The more general question is "What is wrong with digital processing?"
And I'm sorry to say that in some cases the answer is quite a lot.
Basically it comes down to either not enough silicon or not enough
knowledge, or both. There are certainly digital audio products which
are engineered to superlative standards but there's also a lot of
stuff, particularly inside PCs which truncates (not dithers) the audio
signal to ridiculously small internal word lengths, or doesn't
interpolate coefficients, or uses on-screen controls with far to little
accuracy or other basically silly techniques.## Making Waves From Numbers## Wavetables
Nearly all digital music systems use some form of F=SR/n The output is a very high fidelity copy of the waveform:
To produce higher pitches,
the system skips some values each time. The number
of values skipped is the
The frequency produced is the original multiplied by the sampling increment. F=SIxSR/n
Point
of fact, the number
of the
most recent value chosen is kept in a register known as the Digitally speaking, the value obtained from one wavetable lookup is added to the sampling increment for another wavetable lookup.
Amplitude control can be added with a variety of techniques. The straightforward way is to simply multiply the sample value by a number derived in a similar manner from an envelope table. A more efficient technique is available if the waveform is a sine. During each sample period two values are taken from the table: one found the usual way, and another at a location offset from the first according to the envelope. The two values are then added before moving to the output. The sum of two sine waves that are out of phase is a sine of amplitude determined by the phase difference. If the offset equals half the table size, the output will be zero. ## Frequency ModulationFrequency modulation is a very powerful algorithm for creating sounds. The heart of the technique is the way extra tones (sidebands) are created when one oscillator is used to modulate the frequency of another. The carrier is the oscillator we listen to; the modulator is an oscillator that changes the frequency of the carrier at an audio rate. These sidebands are symmetrically spaced about the frequency of the carrier (If all numbers are read twice, the pitch is one octave down), and the size of the spaces is equal to the frequency of the modulator. Increasing modulation increases the number of sidebands, but the amplitude of the sidebands varies in a rather complex way as the modulation changes.
Fig. 4 Spectrum of simple frequency modulation There are three kinds of relationship between the frequencies of the carrier and modulator, and each produces a different family of sounds. If the modulator and carrier are the same frequency, all of the sidebands will be harmonics of that frequency, and the sound will be strongly pitched. You may wonder how that can be if there are supposed to be sidebands at frequencies lower than the carrier. If the spacing of the sidebands is the same as the carrier frequency (as it will be if modulator equals carrier), the sideband just below the carrier will be zero in frequency. The sideband just below that will be the carrier frequency, but negative. When that concept is applied in reality, the result is the carrier frequency, but 180deg. out of phase. That sideband therefore weakens or strengthens the fundamental, depending on the modulation index. Further low sidebands interact with upper sidebands in the same way. The regularity of the sidebands produces the strongly harmonic sound usually associated with synthesizers, but if the modulation index is changed during the note (dynamic modulation) the intensity of the sidebands will change in some very voicelike effects.
Fig. 5 Harmonic spectrum generated with FM If the frequencies of the carrier and modulator are different but rationally related, the result will again be strongly harmonic, and the pitch will be the root of the implied series. (For instance, frequencies of 400hz and 500hz imply a root of 100hz. ) If the carrier is the higher frequency, the resultant sound will be quite bright, sounding like a high pass effect at low modulation and becoming very brash as the modulation increases. The frequency of the carrier is always prominent. If the carrier is the lower frequency, the sound will have "missing" harmonics, and those that are present will appear in pairs (see figure 6). At low modulation index, you will hear two distinct pitches in the tone; as the index is increased, the timbre of the upper pitch seems to become brighter.
Fig. 6 FM with modulator frequency higher than carrier
If the frequencies of the carrier and modulator are not rationally
related, the
tone will have a less definite pitch, and will have a rich sound. Very
often the
effect is of two tones, a weak pure tone at the carrier frequency, plus
a rough
sound with a vague pitch. With careful adjustment of the operator level
of the
modulator, the carrier tone can be nearly eliminated. If the
frequencies of the
carrier and modulator are close to, but not quite harmonic,
Fig. 7 Nonharmonic FM spectrum A particularly powerful aspect of frequency modulation as a music generating technique is that the timbres can be dynamically varied. By applying an envelope function to the amount of modulation or the frequencies of carrier and modulator, sounds can be produced that have a life and excitement far beyond that available with the older synthesis methods. Midi,
the Music Math in the Computer
Problems Mathematics in Music Composition
Analysis
Music
The Schenkerian analysis was founded on that most musical
works have a fundamental tonal structure embracing the whole
composition. The Schenkerian technique reduces a composition down into
successive scores, each with fewer and fewer notes. The downward
progression from one score to another involved grouping notes together
and replacing each group by a single note. The final score, called the
background, contained only one note that represented the work's
fundamental tonal structure. This fundamental mathematical
decomposition process certainly derives many new musical
works
from the original. Two
representative mathematical results describing such patterns are the
law of large numbers and the central limit theorem. As a mathematical
foundation for statistics, probability theory is essential to many
human activities that involve quantitative analysis of large sets of
data. Methods of probability theory also apply to descriptions of
complex systems given only partial knowledge of their state, as in
statistical mechanics. Most introductions to probability theory
treat discrete probability distributions and continuous probability
distributions separately. The more mathematically advanced measure
theory based treatment of probability covers both the discrete, the
continuous, any mix of these two and more. In
the 1960s, Xenakis put forward the idea of extending the use of
stochastic laws to all the levels of the composition, including sound
production. Xenakis said, "Although this
program gives a satisfactory solution to the minimal structure, it is,
however, necessary to jump to the stage of pure composition by coupling
a digital-to-analog converter to the computer". This proposition was renewed in 1971: Any theory or
solution given on one level can be assigned to the solution of problems
of another level. Thus the solutions in macro-composition (programmed
stochastic mechanisms) can engender simpler and more powerful new
perspectives in the shaping of microsounds than the usual trigonometric
functions can ... All music is thus homogenized and unified. In the
1970s, at the University of Indiana, Xenakis experimented with new
methods for synthesizing sounds based on random walks, the theoretical
aspects of which are described in probability theory. In 1991 Xenakis
returned to his dream of making music that would be entirely governed
by stochastic laws and entirely computed. At CEMAMu, Xenakis wrote a
program in Basic that runs on a PC. The program is called GENDY: GEN
stands for Generation and DY for Dynamic; it generates both the musical
structure and the actual sound. |