Question
can someone help me change my skeleton code into a working function sounVecEcho in MATLAB here is this assignment For this assignment you will create
can someone help me change my skeleton code into a working function sounVecEcho in MATLAB
here is this assignment
For this assignment you will create an audio effects and analysis tool. Your program will need to have a Graphical User Interface (GUI) menu with the following functionality:
1. Choose a File. This menu item will allow the user to enter exact name of audio file to be read into the program. The file has to be in .wav format. The audio vector and sampling frequency (Fs) from this module will be used for the remaining features of this program.
2. Play the original audio vector.
3. Echo effect. Create a function that will add an echo effect to the audio signal. The function should take in the sound vector, sampling frequency, delay in seconds, and echo amplitude. The function should return a vector containing the echoed sound. sounVecEcho = soundEcho(soundVec, Fs, delay, echoGain) Steps you should follow when designing your function:
a. Take in the audio vector and sampling frequency, delay and echo gain.
b. Convert the delay in seconds to number of samples delaySamples = Fs * delay;
c. Figure out a way to add a delayed version of the signal vector to the original sound vector. delaySamples tells you how many elements the offset needs to be. echoGain sets the amplitude of the echo signal (1 = 100% amplitude, 0.5 = 50% amplitude, 1.5 = 150% amplitude, etc.) to be added.
d. Play the new version of your sound vector.
4. Compress. Create a function that takes in the sound vector and compression ratio. The function should compress the file by removing vector elements based on the compression ratio. (i.e. if you the compression ratio is 3, keep only every third element.) The function should return the compressed vector. compSoundVec = compress(soundVec, compression ratio)
5. Frequency spectrum. While it is perhaps most intuitive to consider signals in the time domain (i.e. plot amplitude vs time), the frequency domain can tell us interesting information about the energy of a given signal. We can transform an audio signal from the time domain to the frequency domain by applying the Discrete Fourier Transform. Write a function that will do the following: fftBar(soundVec, Fs)
a. Take in the audio vector and sampling frequency.
b. Only use at the first 1000 samples of the audio vector.
c. Use the fast fourier transform function in MATLAB (fft) to convert the audio signal into the frequency domain. Y = fft(audioVec);
d. The fft function will return the input signal transformed into the frequency domain. You will see that the vector elements will contain both real and imaginary components. For the purpose of this function, we will go ahead and ignore the imaginary component of the signal. This can be done by taking the absolute value of the entire vector . Y = abs(Y);
e. The fft function returns both positive and negative frequencies (referred to as a 2-sided plot). We only want to display the positive ones. In order to do so, create a new vector that only contains the first half of the original vec (Y).
f. Create a frequency vector. We will need this for our bar graph. Use the following expression: f = Fs*(0:(length(Y)-1)/2)/length(Y);
g. Create a bar graph with frequencies on the horizontal axis and amplitudes on the vertical axis. Format your horizontal axis to show frequencies from 0 to 5 kHz. Your vertical axis should be scaled such that the maximum Y value takes up most of the bar graph.
h. The function does not need to return anything.
Here is my code so far
%fiona farley %lab 5 %3/1/19 %fifa5522@colorado.edu
%create menu function and GUI
choice = 1; while(choice ~=0); choice = menu('Choose one of the following', 'Echo effect', 'Compres','frequency spectrum', 'exit'); switch(choice) case 1: soundEcho(a, b, c, d); case 2: compress(x, y); case 3: fftBar(num1, num2); case 0: disp("exit"); end end
here are my function stubs
%compress %fiona farley %lab 5 %3/1/19 %fifa5522@colorado.edu %create the function function out = compress(soundVec, compression ratio)
%compress file by removing vector elements based on compression ratio
%return compressed vector
out = [0]; end
%fftBar function stub %fiona farley %lab 5 %3/1/19 %fifa5522@colorado.edu %create the function
function fftBar(soundVec, Fs)
%for the limit to be only the first 1000 files od audio
%ignore imaginary components Y = abs(Y);
%have it include the positive value --- then create a vector that %onlyhas the first half of the initial vector
%then make the frequency vector with a bar graph f = Fs*(0:(length(Y)-1)/2)/length(Y);
%make a bar graph with the frequency on the x axis (0,5) kHz and scle so %that the y direction takes up the most of the graph %no return value end
%soundEcho %fiona farley %lab 5 %3/1/19 %fifa5522@colorado.edu %create the function
function out = soundEcho (soundVec, Fs, delay, echoGain) %convert the delay in seconds to the number of samples delaySamples = Fs* delay; %add a delayed version of signal vec that uses delaySamples to find the %number of elements and echoGain to set the amplitude
%play the new soundVec out = 0; end
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started