Question: Need help developing MATLAB code - explicit answer not needed but Objective Make a function that takes in the values (duration) (frequency) (gain) and makes
Need help developing MATLAB code - explicit answer not needed but
Objective Make a function that takes in the values (duration) (frequency) (gain) and makes a musical note ie. note = maketone(duration,frequency,gain)
background
example of note frequency A = 220; G = 196 (hz)
sampling frequency is 8192 consequently period would be 1/8192
Current function call:
Fs= 8192;
whole_note = 2.0 (seconds)
Z = 1/8; duration = [0:Sampling_Period:whole_note*Z]; gain = 1; frequency = A ; %220 noteAb = makenote(duration,@frequency,gain);
Current code function
[note] = makenote(duration,frequency,gain) % makenote function: % Generates a note [ A B C D E F G] , takes in argument % Duration(time to play note) % frequency( note frequency A = 440hz) % Gain -> amplitude? %for k = 1:duration note = gain*sin(2*pi*duration*frequency); sound(note,Fs) % note and sampling frequency pause(0.03) % so we can hear between notes
current error
Operator '*' is not supported for operands of type 'function_handle'.
Error in makenote (line 8) note = sin(2*pi*duration*frequency*gain);
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
