필터 지우기
필터 지우기

how to use audiowrite

조회 수: 6 (최근 30일)
wissal
wissal 2024년 5월 1일
댓글: Star Strider 2024년 5월 1일
clear; clc; close all;
data= load('am_data.mat');
d=data.d';
%
ds = d(16000+1:16000+2560);
%
Ds = fftshift(fft(ds));
%
f = ((-2560/2) : (2560/2 - 1)) * 0.100;
plot(f,abs(Ds));
%
T=1/256000;
t=(1:length(d))*T;
fc=-17000;
%
dm=d.*(exp(-1i*2*pi*t*fc))';
%
Dm=fftshift(fft(dm(16000+1:16000+2560)));
%
figure();
plot(f,abs(Dm));
%
th = (-100:100)*T;
h = sin(10000*pi*th + 1e-6)./(10000*pi*th+1e-6);
%
figure()
plot(th,h);
%
dmf = conv(dm,h);
%
Dmf = fftshift(fft(dmf(16000+1:16000+2560)));
figure()
plot(f,abs(Dmf));
%
dmfs = dmf(1:32:end)/max(abs(dmf));
sound(real(dmfs));
pause;
%
sound(abs(dmfs));
%
audiowrite('test.wav',dmfs,256000);

채택된 답변

Star Strider
Star Strider 2024년 5월 1일
You did not actually ask a question.
However I get the impression that ‘dmfs’ is complex, and that is not going to work. That argument has to be a (samples x channels) real matrix, so you either need to use:
audiowrite('test.wav',real(dmfs),256000);
or:
audiowrite('test.wav',abs(dmfs),256000);
to get it to work.
If you want to write extra channels with the imaginary or phase information, that is certainly possible.
Something like that might be:
audiowrite('test.wav',[real(dmfs) imag(dmfs)],256000);
or:
audiowrite('test.wav',[abs(dmfs) angle(dmfs)],256000);
For this, ‘dmfs’ must be a column vector.
You can reconstruct it after you read it.
If you want to save a complex vector, it might be easier to just use the save function to save it as a .mat file:
Fs = 256000;
save('dmfs.mat','dmfs','Fs')
.
  댓글 수: 2
wissal
wissal 2024년 5월 1일
you were right thank you so mush
Star Strider
Star Strider 2024년 5월 1일
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Linear Prediction에 대해 자세히 알아보기

제품


릴리스

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by