//
you're reading...
Uncategorized

Visualizing Musical Intervals and Harmonies using Matlab Figures

Visualizing Musical Harmonies

In this post we consider the issue of providing a visual interpretation of musical harmonies. Our approach is via
the simple model of Lissajous (“LEE-suh-zhoo”) figures, which are parametric plots that capture the visual nature of a harmonic system. Lissajous figures provide visual insight into the mathematical behavior of musical intervals in two dimensions and musical chords in three or more dimensions. For example, given two or more waveforms of fundamental frequencies: wavfreq1=sin (at + α), wavfreq2=sin(bt + β), etc., then we can easily plot the parametric curves using Matlab with lovely results.

In the theory of music, an octave is an interval with a pair of acoustic frequencies that range over a factor of two.

• On a piano (and most Western music) an octave is divided into twelve semitones with equal frequency ratios.
• Since twelve semitones comprise a factor of two, one semitone spans a factor that is 12th root of 2.
• The pitch we hear is the log of frequency, so successive pitches sound as if they are equally separated.
• σ (sigma) will be the basis for determining frequency intervals in our Matlab programs.
>> sigma = 2^(1/12)

% Here is code for plotting the 12 harmonic music intervals in Western music
% We take rational powers that approximate integral powers of sigma,

% which achieve more satisfying results

sigma = 2^(1/12);

powers = (0:12)’;
equal = sigma .^ powers; % equal temperament
[num den] = rat(equal, .02);
figure;
for s = 1:12
t = linspace(0, 2 * den(s + 1) * pi, 500);
x = sin(t);
y = sin(num(s + 1)/den(s + 1) * t);
subplot(3, 4, s);
plot(x, y);
st = sprintf(‘%d/%d’, num(s + 1), den(s + 1));
title([‘\sigma^p : ‘ st]);
end

Here is a sample Matlab program based on usage of fractional powers of sigma for a sequence of 2-D plots of musical intervals. I leave the reader with the challenge to design a simple user interface to control the plot with respect to the movement to higher and lower frequencies.

%Matlab code to plot an animation of changing musical intervals
sigma=2^(1/12)
t = (0:0.1:100);
for a=0:.01:12
plot(sin(t),sin(sigma^a*t))
title(a)
if (mod(a,1)==0)
pause(1); else pause(.05); end
end

% Here is code for plotting musical chords based on 3-dimensional Lissajous figures
t = (0:0.1:360);
for a= 11:1/60:60
plot3(sin(t),sin((1+a/60)*t),sin(3/2*t))
title(a)
if (mod(a,1)==0)
pause(2); else pause(.05); end
end

Advertisements

Discussion

2 thoughts on “Visualizing Musical Intervals and Harmonies using Matlab Figures

  1. Could you please add the axis for the third figure?

    Like

    Posted by Abhijit Sarkar | September 11, 2012, 10:47 pm
  2. Great idea! How did you find it? I'm a musician and mathematician and see these figures in my imagination when play. But you describe and draw them sciencly.
    Thanx, great work!

    Like

    Posted by SuperD | September 12, 2012, 6:48 am

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: