how to make an audio
조회 수: 3 (최근 30일)
이전 댓글 표시
i want to know how to generate a stereo audio matrix in matlab and make tones of different frequencies
댓글 수: 1
Jan
2022년 11월 26일
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.
답변 (1개)
Star Strider
2022년 11월 26일
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
Star Strider
2022년 11월 27일
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.
참고 항목
카테고리
Help Center 및 File Exchange에서 Multirate Signal Processing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!