Prev: matlab + simulink in a cave-type system?
Next: textread
From: Peng Liang on 18 Jun 2010 11:36 Hi experts, I want to continuously get the data(speech) from microphone in MATLAB. I know I can use analoginput object. However, it seems only acquire data with limit time. time can be defined. for example, look at the following code: % Create an analog input object to communicate with the % data acquisition device. ai = analoginput('winsound'); addchannel(ai, 1); % Configure the object to acquire 2 seconds of data at 8000 Hz. Fs = 8000; duration = 2; set(ai, 'SampleRate', Fs); set(ai, 'SamplesPerTrigger', duration*Fs); % Start the acquisition and retrieve the data. start(ai); data = getdata(ai); delete(ai); clear ai; it only can acquire 2 seconds of data with 8000Hz. I need acquire continuously until I stop data acquisition. anyone has idea how to achieve continuously data acquisition? Thank you in advance.
From: Walter Roberson on 18 Jun 2010 13:58 Peng Liang wrote: > I want to continuously get the data(speech) from microphone in MATLAB. I > know I can use analoginput object. However, it seems only acquire data > with limit time. time can be defined. for example, look at the following > code: > % Create an analog input object to communicate with the % data > acquisition device. > ai = analoginput('winsound'); > addchannel(ai, 1); > % Configure the object to acquire 2 seconds of data at 8000 Hz. > Fs = 8000; > duration = 2; > set(ai, 'SampleRate', Fs); > set(ai, 'SamplesPerTrigger', duration*Fs); That is not by time, that is by number of samples that works out to take that amount of time. > % Start the acquisition and retrieve the data. > start(ai); > data = getdata(ai); > > delete(ai); > clear ai; > > it only can acquire 2 seconds of data with 8000Hz. > > I need acquire continuously until I stop data acquisition. > anyone has idea how to achieve continuously data acquisition? You cannot get continuous data acquisition, but you can set it to retrigger and then you loop around getting a buffer-worth and dealing with that buffer.
From: Peng Liang on 18 Jun 2010 15:19 Walter Roberson <roberson(a)hushmail.com> wrote in message <hvgc8o$ehj$3(a)canopus.cc.umanitoba.ca>... > Peng Liang wrote: > > > I want to continuously get the data(speech) from microphone in MATLAB. I > > know I can use analoginput object. However, it seems only acquire data > > with limit time. time can be defined. for example, look at the following > > code: > > % Create an analog input object to communicate with the % data > > acquisition device. > > ai = analoginput('winsound'); > > addchannel(ai, 1); > > % Configure the object to acquire 2 seconds of data at 8000 Hz. > > Fs = 8000; > > duration = 2; > > set(ai, 'SampleRate', Fs); > > set(ai, 'SamplesPerTrigger', duration*Fs); > > That is not by time, that is by number of samples that works out to take that > amount of time. > > > % Start the acquisition and retrieve the data. > > start(ai); > > data = getdata(ai); > > > > delete(ai); > > clear ai; > > > > it only can acquire 2 seconds of data with 8000Hz. > > > > I need acquire continuously until I stop data acquisition. > > anyone has idea how to achieve continuously data acquisition? > > You cannot get continuous data acquisition, but you can set it to retrigger > and then you loop around getting a buffer-worth and dealing with that buffer. Hi Walter, Could you give more some details? Thank you!
From: Sherryl Radbil on 21 Jun 2010 13:50 Hi Peng Liang, There is a new demo with Data Acquisition Toolbox in R2010a that shows this. It is called: Continuous Acquisition Using Analog Input To see it, in MATLAB R2010a and later execute: >> showdemo('demoai_continuous') See especially the section: Continuously Acquire Data until a Particular Condition Occurs which uses set(ai,'SamplesPerTrigger',Inf); to set up the continuous acquisition. A timer callback is also demonstrated. It looks for a particular condition and then stops the acquisition. All the best, Sherryl
From: Peng Liang on 22 Jun 2010 11:49
"Sherryl Radbil" <sherryl.radbil.dontspamme(a)mathworks.com> wrote in message <hvo8og$10p$1(a)fred.mathworks.com>... > Hi Peng Liang, > There is a new demo with Data Acquisition Toolbox in R2010a that shows this. > It is called: Continuous Acquisition Using Analog Input > > To see it, in MATLAB R2010a and later execute: > > >> showdemo('demoai_continuous') > > See especially the section: Continuously Acquire Data until a Particular Condition Occurs > > which uses > set(ai,'SamplesPerTrigger',Inf); > to set up the continuous acquisition. > A timer callback is also demonstrated. It looks for a particular condition and then stops the acquisition. > > All the best, > > Sherryl Hi Sherryl. Thank you for the information. unfortunately, I don't have MATLAB R2010a. I am using MATLAB 7.1 version. Is it possible to see that demo somewhere else? Thank you |