how to use audiowrite
6 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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);
0 commentaires
Réponse acceptée
Star Strider
le 1 Mai 2024
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 commentaires
Star Strider
le 1 Mai 2024
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Linear Prediction dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!