Matlab: echo generator question

In summary, the task is to add an echo to an original signal using an input column vector with values between -1 and 1, a sampling rate, a delay representing the delay of the echo in seconds, and an amplification factor. The output vector will be longer than the input vector when the delay is non-zero, and the delay is rounded to the nearest number of points. If the echo causes some values to be outside of the range -1 to 1, the entire vector is rescaled while maintaining their relative amplitudes.
  • #1
binbagsss
1,254
11
The task is to given an input column vector (with values between -1 and 1 representing the digitized data), fs the sampling rate, delay to represent the delay of the echo in seconds, amp specifying the amplification of the echo, to add this echo to the original signal after delay seconds.

Other information given is:
  • the output vector will be longer than the input vector when the delay is nonzero- round to the nearest number of points needed to get the delay, as opposted to floor or ceil.
  • if the echo causes some values to be outside of the range -1 to 1, scale the entire vector retaining their relative amplitudes.
Below is the code I have so far. One simple test for the assignment which my code fails is the case:
input= [-0.5; 0; 0.5; 0] and the following parameters: fs = 1, delay: 0.0 seconds, amp = 0.5
For this, I thought the answer should be: [-0.25;0;0.25;0] which my code DOES yield. So I'm wondering if I've mis understood the task also tbh?
Aside from that, for the amplitude rescaling, where I've put 'if norm(input(a)) > 1', from playing around in MATLAB outside of this function in the live script, I don't think how I've wrote it, in terms of a, some arbitary variable, works? But I'm unsure how to write it without this? thanks
This is what I have wrote so far...

Matlab:
[I]function [output]=echo_gen(input,fs,delay,amp)N = length(input); % sample lenth
%time = N/fs ;% total time span of audio signaltif
%dt * d=delay

lowerlimit=floor(delay*fs);M=N+lowerlimit;

%implementingtheecho
length(((lowerlimit+1):M));
length((1:N));
input((lowerlimit+1):M)=amp*input(1:(N));

%condition to check amps and scale relative amps if over

a=[];
if norm(input(a)) > 1
    %conditiontoscale
    c=max(abs(input))
    %solve for the sf s.t c*sf=1
    sf=1/c
    input=input*sf;
else
  
    output=input;
   
end
output=input;
end[/I]
 
Last edited by a moderator:
Physics news on Phys.org
  • #2
bump, much appreciated
 
  • #3
anyone ? :(
 

1. What is Matlab?

Matlab is a high-level programming language and interactive environment used for numerical computation, data analysis, and visualization. It is widely used by scientists and engineers for various applications in mathematics, engineering, and science.

2. What is an echo generator in Matlab?

An echo generator in Matlab is a tool that creates an echo effect on an audio signal. It adds a delayed and attenuated version of the original signal, creating a repeating and fading effect that resembles an echo.

3. How do I use an echo generator in Matlab?

To use an echo generator in Matlab, you can use the built-in function "echo" or create a custom echo effect using the "conv" function. The "echo" function takes in the original audio signal, the delay time, and the decay factor as input parameters. The "conv" function convolves the original signal with an echo impulse response to create the echo effect.

4. Can I adjust the parameters of the echo effect in Matlab?

Yes, you can adjust the delay time and decay factor of the echo effect in Matlab to customize the sound. The delay time determines the time between the original signal and the echo, while the decay factor controls how quickly the echo fades out. You can experiment with different values to achieve the desired echo effect.

5. What are some applications of an echo generator in Matlab?

An echo generator in Matlab can be used in various applications, such as sound effects in music production, creating virtual environments in virtual reality simulations, and improving speech intelligibility in noisy environments. It can also be used in scientific research to study the effects of echo on human perception and cognition.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
10
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
574
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
14
Views
5K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
5K
Back
Top