Clear Filters
Clear Filters

streaming sound in realtime

2 views (last 30 days)
Partha Ghosh
Partha Ghosh on 15 Aug 2011
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

Accepted Answer

Daniel Shub
Daniel Shub on 2 Sep 2011
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.

More Answers (1)

Walter Roberson
Walter Roberson on 15 Aug 2011
Please see this previous discussion
Short answer: 1 ms is not feasible with that configuration.
  1 Comment
Partha Ghosh
Partha Ghosh on 2 Sep 2011
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

Sign in to comment.

Categories

Find more on Audio Processing Algorithm Design 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!