Added generators for various instruments.
This commit is contained in:
parent
d8f3d07d60
commit
46f323270f
41
src/Generators/generate_arcoStrings.m
Normal file
41
src/Generators/generate_arcoStrings.m
Normal file
@ -0,0 +1,41 @@
|
||||
function x = generate_arcoStrings(amplitude, frequency, phase, fs, duration, duty)
|
||||
% GENERATE_ARCOSTRINGS: returns a matrix of sampled waveform similar to
|
||||
% strings played arco.
|
||||
|
||||
% CONTRIBUTORS:
|
||||
% Brandon Roberts: Original author
|
||||
% MuseScore: Reference source for overtone information
|
||||
|
||||
% DOCUMENTATION:
|
||||
% phase shift is in number of periods
|
||||
% fs is the sampling frequency: how many sample points per second
|
||||
% duration is time in seconds
|
||||
% duty does not apply for instruments
|
||||
|
||||
|
||||
% setup needed variables
|
||||
n = fs * duration; % total data points
|
||||
dt = 1 / fs; % space between samples
|
||||
|
||||
% initialize template time scale
|
||||
t = [1:n].*dt - phase;
|
||||
f = frequency .* (1 + 0.0002 .* sin(10.*pi.*t)./t); %frequency vibrato
|
||||
|
||||
% generate proper fundamental and overtones
|
||||
x = (amplitude .* sin(2.*pi.*f.*t)) ... %fundamental (first partial)
|
||||
+ (0.237992723.*amplitude .* sin(4.*pi.*f.*t)) ... %second partial
|
||||
+ (0.0523347308.*amplitude .* sin(6.*pi.*f.*t)) ... %third partial
|
||||
+ (0.124586119.*amplitude .* sin(8.*pi.*f.*t)) ... %fourth partial
|
||||
+ (0.0854326396.*amplitude .* sin(10.*pi.*f.*t)) ... %fifth partial
|
||||
+ (0.0578741297.*amplitude .* sin(12.*pi.*f.*t)) ... %sixth partial
|
||||
+ (0.0291070237.*amplitude .* sin(14.*pi.*f.*t)) ... %seventh partial
|
||||
+ (0.0270171595.*amplitude .* sin(16.*pi.*f.*t)) ... %eighth partial
|
||||
+ (0.0290818446.*amplitude .* sin(18.*pi.*f.*t)) ... %ninth partial
|
||||
+ (0.0356787652.*amplitude .* sin(20.*pi.*f.*t)) ... %tenth partial
|
||||
+ (0.0112928202.*amplitude .* sin(22.*pi.*f.*t)) ... %eleventh partial
|
||||
+ (0.00547645126.*amplitude .* sin(24.*pi.*f.*t)) ... %twelth partial
|
||||
+ (0.00800694943.*amplitude .* sin(26.*pi.*f.*t)) ... %thirteenth partial
|
||||
+ (0.00463295187.*amplitude .* sin(28.*pi.*f.*t)); %fourteenth partial
|
||||
x = x .* (1 + 0.1 .* sin(10.*pi.*t)); %volume vibrato
|
||||
end
|
||||
|
45
src/Generators/generate_bassoon.m
Normal file
45
src/Generators/generate_bassoon.m
Normal file
@ -0,0 +1,45 @@
|
||||
function x = generate_bassoon(amplitude, frequency, phase, fs, duration, duty)
|
||||
% GENERATE_BASSOON: returns a matrix of sampled waveform similar to
|
||||
% a bassoon.
|
||||
|
||||
% CONTRIBUTORS:
|
||||
% Brandon Roberts: Original author
|
||||
% MuseScore: Reference source for overtone information
|
||||
|
||||
% DOCUMENTATION:
|
||||
% phase shift is in number of periods
|
||||
% fs is the sampling frequency: how many sample points per second
|
||||
% duration is time in seconds
|
||||
% duty does not apply for instruments
|
||||
|
||||
|
||||
% setup needed variables
|
||||
n = fs * duration; % total data points
|
||||
dt = 1 / fs; % space between samples
|
||||
|
||||
% initialize template time scale
|
||||
t = [1:n].*dt - phase;
|
||||
f = frequency .* (1 + 0.0001 .* sin(4.*pi.*t)./t); %frequency vibrato
|
||||
|
||||
% generate proper fundamental and overtones
|
||||
x = (0.0934091627.*amplitude .* sin(2.*pi.*f.*t)) ... %fundamental (first partial)
|
||||
+ (0.0257187994.*amplitude .* sin(4.*pi.*f.*t)) ... %second partial
|
||||
+ (0.120530806.*amplitude .* sin(6.*pi.*f.*t)) ... %third partial
|
||||
+ (amplitude .* sin(8.*pi.*f.*t)) ... %fourth partial
|
||||
+ (0.216745656.*amplitude .* sin(10.*pi.*f.*t)) ... %fifth partial
|
||||
+ (0.0561137441.*amplitude .* sin(12.*pi.*f.*t)) ... %sixth partial
|
||||
+ (0.0300031596.*amplitude .* sin(14.*pi.*f.*t)) ... %seventh partial
|
||||
+ (0.0863949447.*amplitude .* sin(16.*pi.*f.*t)) ... %eighth partial
|
||||
+ (0.0574533965.*amplitude .* sin(18.*pi.*f.*t)) ... %ninth partial
|
||||
+ (0.0337819905.*amplitude .* sin(20.*pi.*f.*t)) ... %tenth partial
|
||||
+ (0.0576176935.*amplitude .* sin(22.*pi.*f.*t)) ... %eleventh partial
|
||||
+ (0.0107298578.*amplitude .* sin(24.*pi.*f.*t)) ... %twelth partial
|
||||
+ (0.00582622433.*amplitude .* sin(26.*pi.*f.*t)) ... %thirteenth partial
|
||||
+ (0.00540916272.*amplitude .* sin(28.*pi.*f.*t)) ... %fourteenth partial
|
||||
+ (0.00615481833.*amplitude .* sin(30.*pi.*f.*t)) ... %fifteenth partial
|
||||
+ (0.00480252765.*amplitude .* sin(32.*pi.*f.*t)) ... %sixteenth partial
|
||||
+ (0.0100473934.*amplitude .* sin(34.*pi.*f.*t)) ... %seventeenth partial
|
||||
+ (0.00528278041.*amplitude .* sin(36.*pi.*f.*t)); %eighteenth partial
|
||||
x = x .* (1 + 0.1 .* sin(4.*pi.*t)); %volume vibrato
|
||||
end
|
||||
|
38
src/Generators/generate_clarinet.m
Normal file
38
src/Generators/generate_clarinet.m
Normal file
@ -0,0 +1,38 @@
|
||||
function x = generate_clarinet(amplitude, frequency, phase, fs, duration, duty)
|
||||
% GENERATE_CLARINET: returns a matrix of sampled waveform similar to
|
||||
% a clarinet.
|
||||
|
||||
% CONTRIBUTORS:
|
||||
% Brandon Roberts: Original author
|
||||
% MuseScore: Reference source for overtone information
|
||||
|
||||
% DOCUMENTATION:
|
||||
% phase shift is in number of periods
|
||||
% fs is the sampling frequency: how many sample points per second
|
||||
% duration is time in seconds
|
||||
% duty does not apply for instruments
|
||||
|
||||
|
||||
% setup needed variables
|
||||
n = fs * duration; % total data points
|
||||
dt = 1 / fs; % space between samples
|
||||
|
||||
% initialize template time scale
|
||||
t = [1:n].*dt - phase;
|
||||
f = frequency; %clarinets play without vibrato
|
||||
|
||||
% generate proper fundamental and overtones. Note that the clarinet has
|
||||
% heavily suppressed odd-numbered partials
|
||||
x = (amplitude .* sin(2.*pi.*f.*t)) ... %fundamental (first partial)
|
||||
+ (0.00290397158.*amplitude .* sin(4.*pi.*f.*t)) ... %second partial
|
||||
+ (0.368654023.*amplitude .* sin(6.*pi.*f.*t)) ... %third partial
|
||||
+ (0.0733323309.*amplitude .* sin(8.*pi.*f.*t)) ... %fourth partial
|
||||
+ (0.299729339.*amplitude .* sin(10.*pi.*f.*t)) ... %fifth partial
|
||||
+ (0.0483901284.*amplitude .* sin(12.*pi.*f.*t)) ... %sixth partial
|
||||
+ (0.0941300303.*amplitude .* sin(14.*pi.*f.*t)) ... %seventh partial
|
||||
+ (0.033165423.*amplitude .* sin(16.*pi.*f.*t)) ... %eighth partial
|
||||
+ (0.00803526117.*amplitude .* sin(18.*pi.*f.*t)) ... %ninth partial
|
||||
+ (0.0131383569.*amplitude .* sin(20.*pi.*f.*t)); %tenth partial
|
||||
x = x .* (1 + 0.05 .* sin(10.*pi.*t)); %slight volume vibrato added for character
|
||||
end
|
||||
|
34
src/Generators/generate_flute.m
Normal file
34
src/Generators/generate_flute.m
Normal file
@ -0,0 +1,34 @@
|
||||
function x = generate_flute(amplitude, frequency, phase, fs, duration, duty)
|
||||
% GENERATE_FLUTE: returns a matrix of sampled waveform similar to
|
||||
% a flute.
|
||||
|
||||
% CONTRIBUTORS:
|
||||
% Brandon Roberts: Original author
|
||||
% MuseScore: Reference source for overtone information
|
||||
|
||||
% DOCUMENTATION:
|
||||
% phase shift is in number of periods
|
||||
% fs is the sampling frequency: how many sample points per second
|
||||
% duration is time in seconds
|
||||
% duty does not apply for instruments
|
||||
|
||||
|
||||
% setup needed variables
|
||||
n = fs * duration; % total data points
|
||||
dt = 1 / fs; % space between samples
|
||||
|
||||
% initialize template time scale and frequency
|
||||
t = [1:n].*dt - phase;
|
||||
f = frequency .* (1 + 0.0002 .* sin(7.*pi.*t)./t); %frequency vibrato
|
||||
|
||||
% generate proper fundamental and overtones
|
||||
x = (amplitude .* sin(4.*pi.*f.*t)) ... %fundamental (first partial)
|
||||
+ (0.396821591.*amplitude .* sin(4.*pi.*f.*t)) ... %second partial
|
||||
+ (0.157568887.*amplitude .* sin(6.*pi.*f.*t)) ... %third partial
|
||||
+ (0.151279648.*amplitude .* sin(8.*pi.*f.*t)) ... %fourth partial
|
||||
+ (0.106818975.*amplitude .* sin(10.*pi.*f.*t)) ... %fifth partial
|
||||
+ (0.0138755668.*amplitude .* sin(12.*pi.*f.*t)) ... %sixth partial
|
||||
+ (0.0100279037.*amplitude .* sin(14.*pi.*f.*t)); %seventh partial
|
||||
x = x .* (1 + 0.25 .* sin(7.*pi.*t)); %volume vibrato
|
||||
end
|
||||
|
41
src/Generators/generate_horn.m
Normal file
41
src/Generators/generate_horn.m
Normal file
@ -0,0 +1,41 @@
|
||||
function x = generate_horn(amplitude, frequency, phase, fs, duration, duty)
|
||||
% GENERATE_HORN: returns a matrix of sampled waveform similar to
|
||||
% a horn.
|
||||
|
||||
% CONTRIBUTORS:
|
||||
% Brandon Roberts: Original author
|
||||
% MuseScore: Reference source for overtone information
|
||||
|
||||
% DOCUMENTATION:
|
||||
% phase shift is in number of periods
|
||||
% fs is the sampling frequency: how many sample points per second
|
||||
% duration is time in seconds
|
||||
% duty does not apply for instruments
|
||||
|
||||
|
||||
% setup needed variables
|
||||
n = fs * duration; % total data points
|
||||
dt = 1 / fs; % space between samples
|
||||
|
||||
% initialize template time scale
|
||||
t = [1:n].*dt - phase;
|
||||
f = frequency .* (1 + 0.0002 .* sin(4.*pi.*t)./t); %frequency vibrato
|
||||
|
||||
% generate proper fundamental and overtones
|
||||
x = (0.21707879.*amplitude .* sin(2.*pi.*f.*t)) ... %fundamental (first partial)
|
||||
+ (amplitude .* sin(4.*pi.*f.*t)) ... %second partial
|
||||
+ (0.234667056.*amplitude .* sin(6.*pi.*f.*t)) ... %third partial
|
||||
+ (0.088606568.*amplitude .* sin(8.*pi.*f.*t)) ... %fourth partial
|
||||
+ (0.0864485981.*amplitude .* sin(10.*pi.*f.*t)) ... %fifth partial
|
||||
+ (0.0275181724.*amplitude .* sin(12.*pi.*f.*t)) ... %sixth partial
|
||||
+ (0.0472968588.*amplitude .* sin(14.*pi.*f.*t)) ... %seventh partial
|
||||
+ (0.0246462876.*amplitude .* sin(16.*pi.*f.*t)) ... %eighth partial
|
||||
+ (0.00816134476.*amplitude .* sin(18.*pi.*f.*t)) ... %ninth partial
|
||||
+ (0.00691199377.*amplitude .* sin(20.*pi.*f.*t)) ... %tenth partial
|
||||
+ (0.00494872793.*amplitude .* sin(22.*pi.*f.*t)) ... %eleventh partial
|
||||
+ (0.0048026999.*amplitude .* sin(24.*pi.*f.*t)) ... %twelth partial
|
||||
+ (0.00335864486.*amplitude .* sin(26.*pi.*f.*t)) ... %thirteenth partial
|
||||
+ (0.00262850467.*amplitude .* sin(28.*pi.*f.*t)); %fourteenth partial
|
||||
x = x .* (1 + 0.05 .* sin(2.*pi.*t)); %volume vibrato
|
||||
end
|
||||
|
37
src/Generators/generate_oboe.m
Normal file
37
src/Generators/generate_oboe.m
Normal file
@ -0,0 +1,37 @@
|
||||
function x = generate_oboe(amplitude, frequency, phase, fs, duration, duty)
|
||||
% GENERATE_OBOE: returns a matrix of sampled waveform similar to
|
||||
% an oboe.
|
||||
|
||||
% CONTRIBUTORS:
|
||||
% Brandon Roberts: Original author
|
||||
% MuseScore: Reference source for overtone information
|
||||
|
||||
% DOCUMENTATION:
|
||||
% phase shift is in number of periods
|
||||
% fs is the sampling frequency: how many sample points per second
|
||||
% duration is time in seconds
|
||||
% duty does not apply for instruments
|
||||
|
||||
|
||||
% setup needed variables
|
||||
n = fs * duration; % total data points
|
||||
dt = 1 / fs; % space between samples
|
||||
|
||||
% initialize template time scale
|
||||
t = [1:n].*dt - phase;
|
||||
f = frequency .* (1 + 0.0001 .* sin(10.*pi.*t)./t); %frequency vibrato
|
||||
|
||||
% generate proper fundamental and overtones
|
||||
x = (0.274577037.*amplitude .* sin(2.*pi.*f.*t)) ... %fundamental (first partial)
|
||||
+ (0.612336031.*amplitude .* sin(4.*pi.*f.*t)) ... %second partial
|
||||
+ (amplitude .* sin(6.*pi.*f.*t)) ... %third partial
|
||||
+ (0.105870314.*amplitude .* sin(8.*pi.*f.*t)) ... %fourth partial
|
||||
+ (0.00825325944.*amplitude .* sin(10.*pi.*f.*t)) ... %fifth partial
|
||||
+ (0.0767380354.*amplitude .* sin(12.*pi.*f.*t)) ... %sixth partial
|
||||
+ (0.0381430831.*amplitude .* sin(14.*pi.*f.*t)) ... %seventh partial
|
||||
+ (0.010765121.*amplitude .* sin(16.*pi.*f.*t)) ... %eighth partial
|
||||
+ (0.0024454102.*amplitude .* sin(18.*pi.*f.*t)) ... %ninth partial
|
||||
+ (0.00963544782.*amplitude .* sin(20.*pi.*f.*t)); %tenth partial
|
||||
x = x .* (1 + 0.1 .* sin(10.*pi.*t)); %volume vibrato
|
||||
end
|
||||
|
44
src/Generators/generate_organ.m
Normal file
44
src/Generators/generate_organ.m
Normal file
@ -0,0 +1,44 @@
|
||||
function x = generate_organ(amplitude, frequency, phase, fs, duration, duty)
|
||||
% GENERATE_ORGAN: returns a matrix of sampled waveform similar to
|
||||
% an organ.
|
||||
|
||||
% CONTRIBUTORS:
|
||||
% Brandon Roberts: Original author
|
||||
% MuseScore: Reference source for overtone information
|
||||
|
||||
% DOCUMENTATION:
|
||||
% phase shift is in number of periods
|
||||
% fs is the sampling frequency: how many sample points per second
|
||||
% duration is time in seconds
|
||||
% duty does not apply for instruments
|
||||
|
||||
|
||||
% setup needed variables
|
||||
n = fs * duration; % total data points
|
||||
dt = 1 / fs; % space between samples
|
||||
|
||||
% initialize template time scale
|
||||
t = [1:n].*dt - phase;
|
||||
f = frequency; %no frequency vibrato
|
||||
|
||||
% generate proper fundamental and overtones
|
||||
x = (0.605975181.*amplitude .* sin(2.*pi.*f.*t)) ... %fundamental (first partial)
|
||||
+ (0.96669476.*amplitude .* sin(4.*pi.*f.*t)) ... %second partial
|
||||
+ (0.509982853.*amplitude .* sin(6.*pi.*f.*t)) ... %third partial
|
||||
+ (amplitude .* sin(8.*pi.*f.*t)) ... %fourth partial
|
||||
+ (0.138074341.*amplitude .* sin(10.*pi.*f.*t)) ... %fifth partial
|
||||
+ (0.397744776.*amplitude .* sin(12.*pi.*f.*t)) ... %sixth partial
|
||||
+ (0.00348745968.*amplitude .* sin(14.*pi.*f.*t)) ... %seventh partial
|
||||
+ (0.350983754.*amplitude .* sin(16.*pi.*f.*t)) ... %eighth partial
|
||||
+ (0.0326368101.*amplitude .* sin(18.*pi.*f.*t)) ... %ninth partial
|
||||
+ (0.0121770467.*amplitude .* sin(20.*pi.*f.*t)) ... %tenth partial
|
||||
+ (0.000406870296.*amplitude .* sin(22.*pi.*f.*t)) ... %eleventh partial
|
||||
+ (0.0440001162.*amplitude .* sin(24.*pi.*f.*t)) ... %twelth partial
|
||||
+ (0.00299340289.*amplitude .* sin(26.*pi.*f.*t)) ... %thirteenth partial
|
||||
+ (0.00767241129.*amplitude .* sin(28.*pi.*f.*t)) ... %fourteenth partial
|
||||
+ (0.00337121102.*amplitude .* sin(30.*pi.*f.*t)) ... %fifteenth partial
|
||||
+ (0.0389432997.*amplitude .* sin(32.*pi.*f.*t)) ... %sixteenth partial
|
||||
+ (0.00496963004.*amplitude .* sin(64.*pi.*f.*t)); %thirty-second partial
|
||||
%no volume vibrato
|
||||
end
|
||||
|
46
src/Generators/generate_saxophone.m
Normal file
46
src/Generators/generate_saxophone.m
Normal file
@ -0,0 +1,46 @@
|
||||
function x = generate_saxophone(amplitude, frequency, phase, fs, duration, duty)
|
||||
% GENERATE_SAXOPHONE: returns a matrix of sampled waveform similar to
|
||||
% a saxophone.
|
||||
|
||||
% CONTRIBUTORS:
|
||||
% Brandon Roberts: Original author
|
||||
% MuseScore: Reference source for overtone information
|
||||
|
||||
% DOCUMENTATION:
|
||||
% phase shift is in number of periods
|
||||
% fs is the sampling frequency: how many sample points per second
|
||||
% duration is time in seconds
|
||||
% duty does not apply for instruments
|
||||
|
||||
|
||||
% setup needed variables
|
||||
n = fs * duration; % total data points
|
||||
dt = 1 / fs; % space between samples
|
||||
|
||||
% initialize template time scale
|
||||
t = [1:n].*dt - phase;
|
||||
f = frequency .* (1 + 0.0001 .* sin(9.*pi.*t)./t); %frequency vibrato
|
||||
|
||||
% generate proper fundamental and overtones
|
||||
x = (0.64011635.*amplitude .* sin(2.*pi.*f.*t)) ... %fundamental (first partial)
|
||||
+ (0.558462369.*amplitude .* sin(4.*pi.*f.*t)) ... %second partial
|
||||
+ (amplitude .* sin(6.*pi.*f.*t)) ... %third partial
|
||||
+ (0.156636999.*amplitude .* sin(8.*pi.*f.*t)) ... %fourth partial
|
||||
+ (0.102886106.*amplitude .* sin(10.*pi.*f.*t)) ... %fifth partial
|
||||
+ (0.289185376.*amplitude .* sin(12.*pi.*f.*t)) ... %sixth partial
|
||||
+ (0.21277411.*amplitude .* sin(14.*pi.*f.*t)) ... %seventh partial
|
||||
+ (0.108250745.*amplitude .* sin(16.*pi.*f.*t)) ... %eighth partial
|
||||
+ (0.077212478.*amplitude .* sin(18.*pi.*f.*t)) ... %ninth partial
|
||||
+ (0.285980527.*amplitude .* sin(20.*pi.*f.*t)) ... %tenth partial
|
||||
+ (0.167644958.*amplitude .* sin(22.*pi.*f.*t)) ... %eleventh partial
|
||||
+ (0.115479073.*amplitude .* sin(24.*pi.*f.*t)) ... %twelth partial
|
||||
+ (0.0345740512.*amplitude .* sin(26.*pi.*f.*t)) ... %thirteenth partial
|
||||
+ (0.0192987651.*amplitude .* sin(28.*pi.*f.*t)) ... %fourteenth partial
|
||||
+ (0.0140386324.*amplitude .* sin(30.*pi.*f.*t)) ... %fifteenth partial
|
||||
+ (0.0102938359.*amplitude .* sin(32.*pi.*f.*t)) ... %sixteenth partial
|
||||
+ (0.0166338634.*amplitude .* sin(34.*pi.*f.*t)) ... %seventeenth partial
|
||||
+ (0.0128019786.*amplitude .* sin(36.*pi.*f.*t)) ... %eighteenth partial
|
||||
+ (0.00442408514.*amplitude .* sin(38.*pi.*f.*t)); %nineteenth partial
|
||||
x = x .* (1 + 0.1 .* sin(9.*pi.*t)); %volume vibrato
|
||||
end
|
||||
|
27
src/Generators/generate_shepardsCarillon.m
Normal file
27
src/Generators/generate_shepardsCarillon.m
Normal file
@ -0,0 +1,27 @@
|
||||
function x = generate_shepardsCarillon(amplitude, frequency, phase, fs, duration, duty)
|
||||
% GENERATE_SHEPARDSCARILLON: returns a matrix of sampled waveform similar to
|
||||
% tubular bells, doubled at octaves.
|
||||
% Calls generate_tubularBells
|
||||
|
||||
% CONTRIBUTORS:
|
||||
% Brandon Roberts: Original author
|
||||
% MuseScore: Reference source for overtone information
|
||||
|
||||
% DOCUMENTATION:
|
||||
% phase shift is in number of periods
|
||||
% fs is the sampling frequency: how many sample points per second
|
||||
% duration is time in seconds
|
||||
% duty does not apply for instruments
|
||||
|
||||
% generate proper tone
|
||||
x = generate_tubularBells(amplitude/5, frequency/16, phase, fs, duration, duty) ... %4 octaves below
|
||||
+ generate_tubularBells(amplitude/4, frequency/8, phase, fs, duration, duty) ... %3 octaves below
|
||||
+ generate_tubularBells(amplitude/3, frequency/4, phase, fs, duration, duty) ... %2 octaves below
|
||||
+ generate_tubularBells(amplitude/2, frequency/2, phase, fs, duration, duty) ... %1 octave below
|
||||
+ generate_tubularBells(amplitude, frequency, phase, fs, duration, duty) ... %unison
|
||||
+ generate_tubularBells(amplitude/2, frequency*2, phase, fs, duration, duty) ... %1 octave above
|
||||
+ generate_tubularBells(amplitude/3, frequency*4, phase, fs, duration, duty) ... %2 octaves above
|
||||
+ generate_tubularBells(amplitude/4, frequency*8, phase, fs, duration, duty) ... %3 octaves above
|
||||
+ generate_tubularBells(amplitude/5, frequency*16, phase, fs, duration, duty); %4 octaves above
|
||||
end
|
||||
|
33
src/Generators/generate_shepardsOrgan.m
Normal file
33
src/Generators/generate_shepardsOrgan.m
Normal file
@ -0,0 +1,33 @@
|
||||
function x = generate_shepardsOrgan(amplitude, frequency, phase, fs, duration, duty)
|
||||
% GENERATE_SHEPARDSORGAN: returns a matrix of sampled waveform similar to
|
||||
% an organ, doubled at octaves.
|
||||
% Calls generate_organ
|
||||
|
||||
% CONTRIBUTORS:
|
||||
% Brandon Roberts: Original author
|
||||
% MuseScore: Reference source for overtone information
|
||||
|
||||
% DOCUMENTATION:
|
||||
% phase shift is in number of periods
|
||||
% fs is the sampling frequency: how many sample points per second
|
||||
% duration is time in seconds
|
||||
% duty does not apply for instruments
|
||||
|
||||
% generate proper tone
|
||||
x = generate_organ(amplitude/8, frequency/128, phase, fs, duration, duty) ... %7 octaves below
|
||||
+ generate_organ(amplitude/7, frequency/64, phase, fs, duration, duty) ... %6 octaves below
|
||||
+ generate_organ(amplitude/6, frequency/32, phase, fs, duration, duty) ... %5 octaves below
|
||||
+ generate_organ(amplitude/5, frequency/16, phase, fs, duration, duty) ... %4 octaves below
|
||||
+ generate_organ(amplitude/4, frequency/8, phase, fs, duration, duty) ... %3 octaves below
|
||||
+ generate_organ(amplitude/3, frequency/4, phase, fs, duration, duty) ... %2 octaves below
|
||||
+ generate_organ(amplitude/2, frequency/2, phase, fs, duration, duty) ... %1 octave below
|
||||
+ generate_organ(amplitude, frequency, phase, fs, duration, duty) ... %unison
|
||||
+ generate_organ(amplitude/2, frequency*2, phase, fs, duration, duty) ... %1 octave above
|
||||
+ generate_organ(amplitude/3, frequency*4, phase, fs, duration, duty) ... %2 octaves above
|
||||
+ generate_organ(amplitude/4, frequency*8, phase, fs, duration, duty) ... %3 octaves above
|
||||
+ generate_organ(amplitude/5, frequency*16, phase, fs, duration, duty) ... %4 octaves above
|
||||
+ generate_organ(amplitude/6, frequency*32, phase, fs, duration, duty) ... %5 octaves above
|
||||
+ generate_organ(amplitude/7, frequency*64, phase, fs, duration, duty) ... %6 octaves above
|
||||
+ generate_organ(amplitude/8, frequency*128, phase, fs, duration, duty); %7 octaves above
|
||||
end
|
||||
|
33
src/Generators/generate_shepardsStrings.m
Normal file
33
src/Generators/generate_shepardsStrings.m
Normal file
@ -0,0 +1,33 @@
|
||||
function x = generate_shepardsStrings(amplitude, frequency, phase, fs, duration, duty)
|
||||
% GENERATE_SHEPARDSSTRINGS: returns a matrix of sampled waveform similar to
|
||||
% arco strings, doubled at octaves.
|
||||
% Calls generate_arcoStrings
|
||||
|
||||
% CONTRIBUTORS:
|
||||
% Brandon Roberts: Original author
|
||||
% MuseScore: Reference source for overtone information
|
||||
|
||||
% DOCUMENTATION:
|
||||
% phase shift is in number of periods
|
||||
% fs is the sampling frequency: how many sample points per second
|
||||
% duration is time in seconds
|
||||
% duty does not apply for instruments
|
||||
|
||||
% generate proper tone
|
||||
x = generate_arcoStrings(amplitude/8, frequency/128, phase, fs, duration, duty) ... %7 octaves below
|
||||
+ generate_arcoStrings(amplitude/7, frequency/64, phase, fs, duration, duty) ... %6 octaves below
|
||||
+ generate_arcoStrings(amplitude/6, frequency/32, phase, fs, duration, duty) ... %5 octaves below
|
||||
+ generate_arcoStrings(amplitude/5, frequency/16, phase, fs, duration, duty) ... %4 octaves below
|
||||
+ generate_arcoStrings(amplitude/4, frequency/8, phase, fs, duration, duty) ... %3 octaves below
|
||||
+ generate_arcoStrings(amplitude/3, frequency/4, phase, fs, duration, duty) ... %2 octaves below
|
||||
+ generate_arcoStrings(amplitude/2, frequency/2, phase, fs, duration, duty) ... %1 octave below
|
||||
+ generate_arcoStrings(amplitude, frequency, phase, fs, duration, duty) ... %unison
|
||||
+ generate_arcoStrings(amplitude/2, frequency*2, phase, fs, duration, duty) ... %1 octave above
|
||||
+ generate_arcoStrings(amplitude/3, frequency*4, phase, fs, duration, duty) ... %2 octaves above
|
||||
+ generate_arcoStrings(amplitude/4, frequency*8, phase, fs, duration, duty) ... %3 octaves above
|
||||
+ generate_arcoStrings(amplitude/5, frequency*16, phase, fs, duration, duty) ... %4 octaves above
|
||||
+ generate_arcoStrings(amplitude/6, frequency*32, phase, fs, duration, duty) ... %5 octaves above
|
||||
+ generate_arcoStrings(amplitude/7, frequency*64, phase, fs, duration, duty) ... %6 octaves above
|
||||
+ generate_arcoStrings(amplitude/8, frequency*128, phase, fs, duration, duty); %7 octaves above
|
||||
end
|
||||
|
49
src/Generators/generate_trumpet.m
Normal file
49
src/Generators/generate_trumpet.m
Normal file
@ -0,0 +1,49 @@
|
||||
function x = generate_trumpet(amplitude, frequency, phase, fs, duration, duty)
|
||||
% GENERATE_TRUMPET: returns a matrix of sampled waveform similar to
|
||||
% a trumpet.
|
||||
|
||||
% CONTRIBUTORS:
|
||||
% Brandon Roberts: Original author
|
||||
% MuseScore: Reference source for overtone information
|
||||
|
||||
% DOCUMENTATION:
|
||||
% phase shift is in number of periods
|
||||
% fs is the sampling frequency: how many sample points per second
|
||||
% duration is time in seconds
|
||||
% duty does not apply for instruments
|
||||
|
||||
|
||||
% setup needed variables
|
||||
n = fs * duration; % total data points
|
||||
dt = 1 / fs; % space between samples
|
||||
|
||||
% initialize template time scale
|
||||
t = [1:n].*dt - phase;
|
||||
f = frequency .* (1 + 0.00005 .* sin(10.*pi.*t)./t); %frequency vibrato
|
||||
|
||||
% generate proper fundamental and overtones
|
||||
x = (0.802698298.*amplitude .* sin(2.*pi.*f.*t)) ... %fundamental (first partial)
|
||||
+ (amplitude .* sin(4.*pi.*f.*t)) ... %second partial
|
||||
+ (0.700319932.*amplitude .* sin(6.*pi.*f.*t)) ... %third partial
|
||||
+ (0.748098515.*amplitude .* sin(8.*pi.*f.*t)) ... %fourth partial
|
||||
+ (0.909272003.*amplitude .* sin(10.*pi.*f.*t)) ... %fifth partial
|
||||
+ (0.471477725.*amplitude .* sin(12.*pi.*f.*t)) ... %sixth partial
|
||||
+ (0.200863214.*amplitude .* sin(14.*pi.*f.*t)) ... %seventh partial
|
||||
+ (0.264578051.*amplitude .* sin(16.*pi.*f.*t)) ... %eighth partial
|
||||
+ (0.282234698.*amplitude .* sin(18.*pi.*f.*t)) ... %ninth partial
|
||||
+ (0.128787879.*amplitude .* sin(20.*pi.*f.*t)) ... %tenth partial
|
||||
+ (0.100688156.*amplitude .* sin(22.*pi.*f.*t)) ... %eleventh partial
|
||||
+ (0.0874984909.*amplitude .* sin(24.*pi.*f.*t)) ... %twelth partial
|
||||
+ (0.0488047809.*amplitude .* sin(26.*pi.*f.*t)) ... %thirteenth partial
|
||||
+ (0.0261680551.*amplitude .* sin(28.*pi.*f.*t)) ... %fourteenth partial
|
||||
+ (0.0186224798.*amplitude .* sin(30.*pi.*f.*t)) ... %fifteenth partial
|
||||
+ (0.0255342267.*amplitude .* sin(32.*pi.*f.*t)) ... %sixteenth partial
|
||||
+ (0.0111674514.*amplitude .* sin(34.*pi.*f.*t)) ... %seventeenth partial
|
||||
+ (0.010020524.*amplitude .* sin(36.*pi.*f.*t)) ... %eighteenth partial
|
||||
+ (0.00694192925.*amplitude .* sin(38.*pi.*f.*t)) ... %nineteenth partial
|
||||
+ (0.00307859471.*amplitude .* sin(40.*pi.*f.*t)) ... %twentieth partial
|
||||
+ (0.00338041772.*amplitude .* sin(42.*pi.*f.*t)) ... %twentyfirst partial
|
||||
+ (0.0026862248.*amplitude .* sin(44.*pi.*f.*t)); %twentysecond partial
|
||||
x = x .* (1 + 0.02 .* sin(10.*pi.*t)); %volume vibrato
|
||||
end
|
||||
|
38
src/Generators/generate_tubularBells.m
Normal file
38
src/Generators/generate_tubularBells.m
Normal file
@ -0,0 +1,38 @@
|
||||
function x = generate_tubularBells(amplitude, frequency, phase, fs, duration, duty)
|
||||
% GENERATE_TUBULARBELLS: returns a matrix of sampled waveform similar to
|
||||
% a tubular bell.
|
||||
|
||||
% CONTRIBUTORS:
|
||||
% Brandon Roberts: Original author
|
||||
% MuseScore: Reference source for overtone information
|
||||
|
||||
% DOCUMENTATION:
|
||||
% phase shift is in number of periods
|
||||
% fs is the sampling frequency: how many sample points per second
|
||||
% duration is time in seconds
|
||||
% duty does not apply for instruments
|
||||
% amplitude decays exponentially at varying rates for different paritals
|
||||
|
||||
|
||||
% setup needed variables
|
||||
n = fs * duration; % total data points
|
||||
dt = 1 / fs; % space between samples
|
||||
|
||||
% initialize template time scale
|
||||
t = [1:n].*dt - phase;
|
||||
f = frequency; %no frequency vibrato
|
||||
|
||||
% generate proper fundamental and overtones
|
||||
x = (0.105668016.*amplitude .* sin(pi.*f.*t))./(2.^(t./10)) ... %hum tone
|
||||
+ (0.143724696.*amplitude .* sin(2.*pi.*f.*t))./(2.^(t./5)) ... %strike tone
|
||||
+ (0.12.*amplitude .* sin(12./5.*pi.*f.*t))./(2.^(t./3)) ... %minor third overtone
|
||||
+ (0.10.*amplitude .* sin(3.*pi.*f.*t))./(2.^(t./2.5)) ... %perfect fifth overtone
|
||||
+ (0.8.*amplitude .* sin(4.*pi.*f.*t))./(2.^(t./2)) ... %perfect octave overtone
|
||||
+ (0.6.*amplitude .* sin(5.*pi.*f.*t))./(2.^(t./1.5)) ... %major third overtone
|
||||
+ (0.4.*amplitude .* sin(8.*pi.*f.*t))./(2.^(t)) ... %second perfect fifth overtone
|
||||
+ (0.4.*amplitude .* sin(2.2.*pi.*f.*t))./(2.^(4.*t)) ... %transient 1
|
||||
+ (0.4.*amplitude .* sin(1.8.*pi.*f.*t))./(2.^(8.*t)) ... %transient 2
|
||||
+ (0.4.*amplitude .* sin(2.7.*pi.*f.*t))./(2.^(10.*t));%transient 3
|
||||
x = x .* (1 + 0.02 .* sin(10.*pi.*t)); %volume vibrato
|
||||
end
|
||||
|
Reference in New Issue
Block a user