Question: Modify key2note_env.m to include a second and third harmonic. Be sure to apply the envelope to all three components of the note. Choose the relative
Modify key2note_env.m to include a second and third harmonic. Be sure to apply the envelope to all three components of the note. Choose the relative amplitude of the second and third harmonics so the note sounds good to you, but remember that the relative amplitudes must be less than one. Call your new function key2note_fancy.m. (Using Matlab)
Here is the key2note_env.m:
X represents the amplitude, and getADSR is the function that synthesizes the envelope to the key2note_env..
![function [xx, tt] = key2note_env (X, keynum, dur, fs) % KEY2NOTE Produce](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2022/07/62d4fa07aa2f3_1658124807398.jpg)
You can choose the amplitude of the second and third harmonics less than 1.
function [xx, tt] = key2note_env (X, keynum, dur, fs) % KEY2NOTE Produce a sinusoidal waveform corresponding to a % given piano key number % usage: xx = key2note (X, keynum, dur, fs) % XX = the output sinusoidal waveform % X = complex amplitude for the sinusoid, X = A*exp(j*phi). % keynum = the piano keyboard number of the desired note % dur = the duration (in seconds) of the output note % fs = sampling frequency tt = 0: (1/fs): dur; freq = 440*2^((1/12) * (keynum-49)); XX = real (x*exp(1j*2*pi*freq*tt)).* (getADSR (dur*fs+1));
Step by Step Solution
3.36 Rating (168 Votes )
There are 3 Steps involved in it
To modify key2noteenvm to include a second and third harmonic you can simply add two more sinusoidal ... View full answer
Get step-by-step solutions from verified subject matter experts
