Question

Write a short matlab function that modifies the volume of a wavefile. The function should have...

Write a short matlab function that modifies the volume of a wavefile. The function should have the following parameters: the input wavefile path, the signed value in dB which amplifies/attenuates the wavefile, the output wavefile. Make use of the following functions: wavread (or audioread), wavwrite (or audiowrite), plot, figure, subplot. Also use "help <function>" to see the meaning and parameters of these functions. Parse the wave samples using a for loop. Plot the input wave and the output wave on the same figure to see the difference.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

The .wav file was downloaded from the internet. The function audioread returns the signal values as well the sampling frequency. audiowrite writes the data to the audiofile specified. The signed value is given in dB, which is converted into a decimal value and the signal is attenuated or amplified accordingly.

The matlab code is as follows:

function aud=aud_vol(in_path,sig_val,out_path);
[y,fs] = audioread(in_path); % Reading the audio file
y_1=y(:,2);
info=audioinfo(in_path); % Getting the info of audio file
t=0:seconds(1/fs):seconds(info.Duration);
t=t(1:end-1);

fac=10^(sig_val/20); % Conversion from dB as sig_val is in dB
aud=y_1*fac;
audiowrite(out_path,aud,fs) % Writing audio file

subplot(121)
plot(t,y_1)
title('input signal')

The output is obtained is as follows:

The signed value is given as 3 dB which is 1.5 in numerical terms. Hence the signal is amplified 1.5 times as we can see in the output plot in the right side.

Add a comment
Know the answer?
Add Answer to:
Write a short matlab function that modifies the volume of a wavefile. The function should have...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 1. Write a short MATLAB script or function (m-file) that generates the functions (t)eu(t) for a =...

    Only calculate manually 1. Write a short MATLAB script or function (m-file) that generates the functions (t)eu(t) for a = 0.1. Plot the value of x(t). Since the e-af almost attenuates to 0 after 5T, where T1. So make your time vector from 0 to 5T would be enough to capture the signal.) 2. Using the definition of the FT (1), manually calculate the FT of the given functions in previous exercise 0O x(t)e 3. Plot the absolute values and...

  • MATLAB The aim of this assignment is to write a function to generate stock prices over...

    MATLAB The aim of this assignment is to write a function to generate stock prices over time, based on therandom walk algorithm, which is .Stock (t+1) = Stock(t) + Delta, where Delta= (-1 or +1),and is given by a random draw.Consider the following code and output(check out what the function diff()does in MATLAB, and see how that is shown on the second graph). Also, subplot()allows you to create a number of graphs, and hold on retains previous graph output so...

  • Consider the function f(x) 1 25x which is used to test various interpolation methods. For the rem...

    Consider the function f(x) 1 25x which is used to test various interpolation methods. For the remainder of this problem consider only the interval [-1, 1] The x-values for the knots (or base-points) of the interpolation algorithm are located at x--1,-0.75, -0.5, -0.25, 0, 0.25, 0.5, 0.75 1. (a) Create a "single" figure in Matlab that contains 6 subplots (2x3) and is labelled as figure (777), i.e the figure number is 777. Plot in each subplot the function f(x) using...

  • Problem 7. [MAILABⓒproblem] Write a short MATLAB script to construct the transfer function of a system...

    Problem 7. [MAILABⓒproblem] Write a short MATLAB script to construct the transfer function of a system that is described by the following poles, zeros, and gain zeros =-1,1 ±2j poles =-2土2,-0.4 k = 1.28 and plot its response to a step input with amplitude 5 (meaning, u(t)-5 × 1(t). Determine the system's (1) time constant and (2) rise time from the plot of the step response. (Submit the MATLABO script and the plot; both should fit into one page. You...

  • Matlab control

    The open-loop system dynamics model for the NASA eight-axis Advanced Research Manipulator II (ARM II) electromechanical shoulder joint/link, actuated by an armature-controlled dc servomotor is shown in Figure P1.The ARM II shoulder joint constant parameters areKa= 12, L=0.006 H, R= 1.4 Ω, Kb= 0.00867, n=200, Km= 4.375, J=Jm+ JL /n2, D=Dm+DL /n2, JL= 1, DL= 0.5, Jm= 0.00844, and Dm= 0.00013.FIGURE P1 Open-loop model for ARM ll(Due to 29/8/2020)a. Obtain the equivalent open-loop transfer function, ?(?) (with a unity feedback...

  • Write a MATLAB function with the following specifications: Input parameter 1: A Input parameter 2: B...

    Write a MATLAB function with the following specifications: Input parameter 1: A Input parameter 2: B Input parameter 3: C Input parameter 4: D Output parameter: Sum of the input parameters Time interval: -2T lessthanorequalto t lessthanorequalto 2T Waveform 1 to plot: y(t) = A sin(B(t - c))+D Waveform 2 to plot: y(t) = A cos(B(t - c)) + D Display two plots in vertical fashion on one figure Include all labeling on both plots. Add a grid to both...

  • Matlab Matlab Matlab Matlab, Please solve this problem Problem 4 : Runge's phenomenon For this proble,...

    Matlab Matlab Matlab Matlab, Please solve this problem Problem 4 : Runge's phenomenon For this proble, you wil interpolate the function h(x) = tanh(10x) in I [a, b, through n datapoints (xi, hx with equidistant nodes for several values of n, and observe the behavior of the interpolating polynomial as n increases. You should use the pair of functions polyfit and polyval In your prob40: (a) Interpolate the function tanh(10x) in [-1,1] using a uniform grid of n nodes, where...

  • It has to be answered using matlab and other programs as each section says

    The open-loop system dynamics model for the NASA eight-axis Advanced Research Manipulator II (ARM II) electromechanical shoulder joint/link, actuated by an armature-controlled dc servomotor is shown in Figure P1.The ARM II shoulder joint constant parameters areKa= 12, L=0.006 H, R= 1.4 Ω, Kb= 0.00867, n=200, Km= 4.375, J=Jm+ JL /n2, D=Dm+DL /n2, JL= 1, DL= 0.5, Jm= 0.00844, and Dm= 0.00013.FIGURE P1 Open-loop model for ARM ll(Due to 29/8/2020)a. Obtain the equivalent open-loop transfer function, ?(?) (with a unity feedback...

  • MATLAB question I need the code exactly as you would write it in MATLAB. thank you...

    MATLAB question I need the code exactly as you would write it in MATLAB. thank you 1. Consider a Gaussian solution of the traveling-wave form ψ(z,t)-exp(-a(z-vt)2). The parameter values are a 1, 2. (a) Explain the physical meaning of these parameters (eg. what would happen if we took a = 10 instead?) Determine the direction of propagation of this solution: Is it traweling to the left or to the right? (2pts) (b) Write a Matlab code to plot the Gaussian...

  • Problem 1 MATLAB A Taylor series is a series expansion of a function f()about a given point a. For one-dimensional real...

    Problem 1 MATLAB A Taylor series is a series expansion of a function f()about a given point a. For one-dimensional real-valued functions, the general formula for a Taylor series is given as ia) (a) (z- a) (z- a)2 + £(a (r- a) + + -a + f(x)(a) (1) A special case of the Taylor series (known as the Maclaurin series) exists when a- 0. The Maclaurin series expansions for four commonly used functions in science and engineering are: sin(x) (-1)"...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT