how to make an audio

2 Ansichten (letzte 30 Tage)
caitlyn
caitlyn am 26 Nov. 2022
Kommentiert: Star Strider am 27 Nov. 2022
i want to know how to generate a stereo audio matrix in matlab and make tones of different frequencies
  1 Kommentar
Jan
Jan am 26 Nov. 2022
As I have asked in your deleted question already: What have you tried so far? What is your question concering Matlab?
You do not have to delete a question to insert new details. Questions can be edited.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Star Strider
Star Strider am 26 Nov. 2022
I would use a Gaussian for the envelope function, similar to:
envfcn = @(ct,sf,t) exp(-(t-ct).^2*sf);
where ‘t’ is the time vector, ‘ct’ is the centre time of the Gaussian function, and ‘sf’ is the scaling factor so that the envelope function has the correct shape (width). Experiment with ‘envfcn’ first so you understand how it works (plot it), then create the tones and do an element-wise multiplication of the tone vector and the envelope function.
That is how I would approach this, anyway.
Then check the result using the pspectrum function, similar to this analysis of the provided example —
Uz = unzip('https://www.mathworks.com/matlabcentral/answers/uploaded_files/1208748/sample1.zip');
[y,Fs] = audioread(Uz{1});
L = size(y,1);
t = linspace(0, L-1, L)/Fs;
figure
plot(t, y)
grid
[p1,f1,t1] = pspectrum(y(:,1),Fs,'spectrogram');
[p2,f2,t2] = pspectrum(y(:,2),Fs,'spectrogram');
figure
waterfall(f1,t1,p1')
xlabel('Frequency (Hz)')
ylabel('Time (seconds)')
wtf = gca;
wtf.XDir = 'reverse';
view([30 45])
xlim([0 4E3])
title('Left Channel')
figure
waterfall(f2,t2,p2')
xlabel('Frequency (Hz)')
ylabel('Time (seconds)')
wtf = gca;
wtf.XDir = 'reverse';
view([30 45])
xlim([0 4E3])
title('Right Channel')
Since this is your assignment, I leave the rest to you.
.
  2 Kommentare
caitlyn
caitlyn am 27 Nov. 2022
Bearbeitet: caitlyn am 27 Nov. 2022
what lol i just want to know how to generate the sound
Star Strider
Star Strider am 27 Nov. 2022
What I wrote here tells you haow to analyse the result.
To crreate the sound, use the sin function. Create a time vector for all the different sine vectors you want to create (it will have to be long enough to accommodate the entire time, so 6 seconds), then create a matrix of the different frequencies, apply the envelope function to each one, and save the result in a matrix.
Example —
envfcn = @(ct,sf,t) exp(-(t-ct).^2*sf);
Fs = 44100; % Sampling Frequency
t = linspace(0, Fs-1, Fs)/Fs;
s = sin(2*pi*1500*t);
env = envfcn(0.66,64,t);
se = s .* env;
figure
plot(t, se)
grid
Make appropriate changes to this example code, and complete your assignment.
I will let you figure out how the code works.

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by