Function Canon
% Cripple Pachebel's Canon on Matlab
% Have fun
Fs = 44100; % sample rate
Dt = 1/fs;
T16 = 0.125;
T16 = [0: dt: T16];
[Temp k] = size (t16 );
T4 = linspace (0, 4 * T16, 4 * k );
T8 = linspace (0, 2 * T16, 2 * k );
[Temp I] = size (t4 );
[Temp j] = size (t8 );
% Modification functions
Mod4 = sin (pi * t4/t4 (end ));
Mod8 = sin (pi * t8/t8 (end ));
Mod16 = sin (pi * t16/t16 (end ));
F0 = 2*146.8; % reference frequency
ScaleTable = [2/3 3/4 5/6 15/16...
1 9/8 5/4 4/3 3/2 5/3 9/5 15/8...
2 9/4 5/2 8/3 3 10/3 15/4 4...
1/2 9/16 5/8];
% 1/4 notes
Do0f = mod4. * cos (2 * pi * ScaleTable (21) * f0 * t4 );
Re0f = mod4. * cos (2 * pi * ScaleTable (22) * f0 * t4 );
Mi0f = mod4. * cos (2 * pi * ScaleTable (23) * f0 * t4 );
Fa0f = mod4. * cos (2 * pi * ScaleTable (1) * f0 * t4 );
So0f = mod4. * cos (2 * pi * ScaleTable (2) * f0 * t4 );
La0f = mod4. * cos (2 * pi * ScaleTable (3) * f0 * t4 );
Ti0f = mod4. * cos (2 * pi * ScaleTable (4) * f0 * t4 );
Do1f = mod4. * cos (2 * pi * ScaleTable (5) * f0 * t4 );
Re1f = mod4. * cos (2 * pi * ScaleTable (6) * f0 * t4 );
Mi1f = mod4. * cos (2 * pi * ScaleTable (7) * f0 * t4 );
Fa1f = mod4. * cos (2 * pi * ScaleTable (8) * f0 * t4 );
So1f = mod4. * cos (2 * pi * ScaleTable (9) * f0 * t4 );
La1f = mod4. * cos (2 * pi * ScaleTable (10) * f0 * t4 );
Tb1f = mod4. * cos (2 * pi * ScaleTable (11) * f0 * t4 );
Ti1f = mod4. * cos (2 * pi * ScaleTable (12) * f0 * t4 );
Do2f = mod4. * cos (2 * pi * ScaleTable (13) * f0 * t4 );
Re2f = mod4. * cos (2 * pi * ScaleTable (14) * f0 * t4 );
Mi2f = mod4. * cos (2 * pi * ScaleTable (15) * f0 * t4 );
Fa2f = mod4. * cos (2 * pi * ScaleTable (16) * f0 * t4 );
So2f = mod4. * cos (2 * pi * ScaleTable (17) * f0 * t4 );
La2f = mod4. * cos (2 * pi * ScaleTable (18) * f0 * t4 );
Ti2f = mod4. * cos (2 * pi * ScaleTable (19) * f0 * t4 );
Do3f = mod4. * cos (2 * pi * ScaleTable (20) * f0 * t4 );
Blkf = zeros (1, I );
% 1/8 notes
Fa0e = mod8. * cos (2 * pi * ScaleTable (1) * f0 * t8 );
So0e = mod8. * cos (2 * pi * ScaleTable (2) * f0 * t8 );
La0e = mod8. * cos (2 * pi * ScaleTable (3) * f0 * t8 );
Ti0e = mod8. * cos (2 * pi * ScaleTable (4) * f0 * t8 );
Do1e = mod8. * cos (2 * pi * ScaleTable (5) * f0 * t8 );
Re1e = mod8. * cos (2 * pi * ScaleTable (6) * f0 * t8 );
Mi1e = mod8. * cos (2 * pi * ScaleTable (7) * f0 * t8 );
Fa1e = mod8. * cos (2 * pi * ScaleTable (8) * f0 * t8 );
So1e = mod8. * cos (2 * pi * ScaleTable (9) * f0 * t8 );
La1e = mod8. * cos (2 * pi * ScaleTable (10) * f0 * t8 );
Tb1e = mod8. * cos (2 * pi * ScaleTable (11) * f0 * t8 );
Ti1e = mod8. * cos (2 * pi * ScaleTable (12) * f0 * t8 );
Do2e = mod8. * cos (2 * pi * ScaleTable (13) * f0 * t8 );
Re2e = mod8. * cos (2 * pi * ScaleTable (14) * f0 * t8 );
Mi2e = mod8. * cos (2 * pi * ScaleTable (15) * f0 * t8 );
Fa2e = mod8. * cos (2 * pi * ScaleTable (16) * f0 * t8 );
So2e = mod8. * cos (2 * pi * ScaleTable (17) * f0 * t8 );
La2e = mod8. * cos (2 * pi * ScaleTable (18) * f0 * t8 );
Ti2e = mod8. * cos (2 * pi * ScaleTable (19) * f0 * t8 );
Do3e = mod8. * cos (2 * pi * ScaleTable (20) * f0 * t8 );
Blke = zeros (1, j );
% 1/16 notes
Fa0s = mod16. * cos (2 * pi * ScaleTable (1) * f0 * t16 );
So0s = mod16. * cos (2 * pi * ScaleTable (2) * f0 * t16 );
La0s = mod16. * cos (2 * pi * ScaleTable (3) * f0 * t16 );
Ti0s = mod16. * cos (2 * pi * ScaleTable (4) * f0 * t16 );
Do1s = mod16. * cos (2 * pi * ScaleTable (5) * f0 * t16 );
Re1s = mod16. * cos (2 * pi * ScaleTable (6) * f0 * t16 );
Mi1s = mod16. * cos (2 * pi * ScaleTable (7) * f0 * t16 );
Fa1s = mod16. * cos (2 * pi * ScaleTable (8) * f0 * t16 );
So1s = mod16. * cos (2 * pi * ScaleTable (9) * f0 * t16 );
La1s = mod16. * cos (2 * pi * ScaleTable (10) * f0 * t16 );
Tb1s = mod16. * cos (2 * pi * ScaleTable (11) * f0 * t16 );
Ti1s = mod16. * cos (2 * pi * ScaleTable (12) * f0 * t16 );
Do2s = mod16. * cos (2 * pi * ScaleTable (13) * f0 * t16 );
Re2s = mod16. * cos (2 * pi * ScaleTable (14) * f0 * t16 );
Mi2s = mod16. * cos (2 * pi * ScaleTable (15) * f0 * t16 );
Fa2s = mod16. * cos (2 * pi * ScaleTable (16) * f0 * t16 );
So2s = mod16. * cos (2 * pi * ScaleTable (17) * f0 * t16 );
La2s = mod16. * cos (2 * pi * ScaleTable (18) * f0 * t16 );
Ti2s = mod16. * cos (2 * pi * ScaleTable (19) * f0 * t16 );
Do3s = mod16. * cos (2 * pi * ScaleTable (20) * f0 * t16 );
Blks = zeros (1, k );
% Blank Block
Blkblock = [blkfBlkf...
BlkfBlkf];
% Base Melody
Cello = [do1f do1f so0f so0fLa0f la0f mi0f mi0f...
Fa0f fa0f do0f do0fFa0f fa0f so0f so0f];
% So-FUCKING-Long Melody
Violin = [mi2f mi2f re2f re2f re2fDo2f do2f ti1f ti1f...
La1f la1f so1f so1fLa1f la1f ti1f ti1f... %
Do2f do2f ti1f ti1fLa1f la1f so1f so1f...
Fa1f fa1f mi1f mi1fFa1f fa1f re1f re1f... %
Do1f mi1f so1f fa1fMi1f do1f mi1f re1f...
Do1f la0f do1f so1fFa1f la1f so1f fa1f... %
Mi1f do1f re1f ti1fDo2f mi2f so2f so1f...
La1f fa1f so1f mi1fDo1f do2f blkf blke ti1e... %
Do2e ti1e do2e do1eTi0e so1e re1e mi1e...
Do1e do2e ti1e la1eTi1e mi2e so2e la2e...
Fa2e mi2e re2e fa2eMi2e re2e do2e ti1e...
La1e so1e fa1e mi1eRe1e fa1e mi1e re1e... %
Do1e re1e mi1e fa1eSo1e re1e so1e fa1e...
Mi1e la1e so1e fa1eSo1e fa1e mi1e re1e...
Do1e la0e la1e ti1eDo2e ti1e la1e so1e...
Fa1e mi1e re1e la1eSo1e la1e so1e fa1e... %
Mi1f mi2e blke re2f re2fBlkf do1f mi2f mi2f...
La2f la2f so2f so2fLa2f la2f ti2f ti2f... %
Do3e blke do2e blke ti1f ti1fBlkf la1f do2f do2f...
Do2f do2f do2f do2fDo2f fa2f re2f so2f... %
So2e mi2s fa2s so2e mi2s fa2s so2s so1s la1s ti1s...
Do2s re2s mi2s fa2s mi2e do2s re2s...
Mi2e mi1s fa1s so1s la1s so1s fa1s so1s mi1s fa1s so1s...
Fa1e la1s so1s fa1e mi1s re1s mi1s re1s do1s re1s mi1s fa1s so1s la1s...
Fa2e la1s so1s la1e ti1s do2s so1s la1s ti1s do2s re2s mi2s fa2s so2s... %