streaming sound in realtime

2 次查看(过去 30 天)
I want to stream sound from the microphone,perform some processing on it(though i have done nothing in this code here) and play it back.The lower the phase lag the better it serves me(less than a millisecond(For when i'm using 1000 HZ audio)is needed).(Initial phase i haven't taken care of that much though it can be reduced)To achieve that i tried the following code, but if you run it u may see that the phase lag is increasing as time goes on!!! and that should be also because of 600 additional data in 13 line is introduced! But if i don't do that the buffer runs out of data. So what do you suggest?
clc
clear all
close all
ao = analogoutput('winsound');
addchannel(ao,1:2);
data=wavrecord(11025,11025,1);
set(ao,'SampleRate',11025);
set(ao,'SamplesOutputFcnCount',1);
putdata(ao,[data data]);
start(ao)
for i=1:100000
clear data
data=wavrecord(5512,11025,1);
data=[data;data(4912:5512)];
putdata(ao,[data data])
end

采纳的回答

Daniel Shub
Daniel Shub 2011-9-2
You will probably have better control if you use the DAQ toolbox for everything (i.e create an analogoutput and an analogutinput object) instead of mixing it with wavrecord. That said, if you want reasonable good sound streaming you have to switch to port audio.

更多回答(1 个)

Walter Roberson
Walter Roberson 2011-8-15
Please see this previous discussion
Short answer: 1 ms is not feasible with that configuration.
  1 个评论
Partha Ghosh
Partha Ghosh 2011-9-2
ok if 1ms is too short for matlab, lets forget about the phase shift. CAN YOU MAKE SOMETHING WICH WILL STREAM AUDIO SMOOTHLY? i mean some way in which i neednt do the following silly thing!!
data=[data;data(4912:5512)];
about 400 false data eachtime!!
thanks

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Audio Processing Algorithm Design 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by