# how to make an audio

조회 수: 2(최근 30일)
caitlyn 2022년 11월 26일
댓글: Star Strider 2022년 11월 27일
i want to know how to generate a stereo audio matrix in matlab and make tones of different frequencies
##### 댓글 수: 1표시숨기기 없음
Jan 2022년 11월 26일
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 —
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표시숨기기 이전 댓글 수: 1
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.

댓글을 달려면 로그인하십시오.

### 범주

Find more on Speech Recognition in Help Center and File Exchange

### Community Treasure Hunt

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

Start Hunting!