Write an M-file to produce a desired note, expressed in piano key number, for a given duration. Your M-file should be in the form of a function called key2note.m. Your function should have the following form:
function xx = key2note(X, keynum, dur, fsamp)
% KEY2NOTE Produce a sinusoidal waveform corresponding to a
% given piano key number
%
% usage: xx = key2note (X, keynum, dur)
%
% 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, use 11025 or 22050 Hz
%
tt = 0:(1/fsamp):dur;
freq = %<=============== fill in this line
xx = real( X*exp(j*2*pi*freq*tt) );
For the “freq =” line, use the formulas given above to determine the frequency for a sinusoid in terms of its key number. You should start from a reference note (middle-C or A-440 is recommended) and solve for the frequency based on this reference. Notice that the xx = real( ) line generates the actual sinusoid as the real part of a complex exponential at the proper frequency. Show the code and play a note, say key #47 (G4), for 2 seconds to the instructor for verification.
We need at least 10 more requests to produce the answer.
0 / 10 have requested this problem solution
The more requests, the faster the answer.
Write an M-file to produce a desired note, expressed in piano key number, for a given...
Develop a system flowchart and then write a menu-driven C++ program that uses user-defined functions arrays, and a random number generator. Upon program execution, the screen will be cleared and the menu shown below will appear at the top of the screen and centered. The menu items are explained below. Help Smallest Quit H or h ( for Help ) option will invoke a function named help() which will display a help screen. The help screen(s) should guide the user...