Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
soundcard data continuous acquisition code.

Subject: soundcard data continuous acquisition code.

From: gana

Date: 11 May, 2013 03:34:14

Message: 1 of 1

Hello below code is soundcard data continuous acquisition code.

it works with only 1 channel(mono) but i need 2 channels (stereo) .

i added channel like addchannel(ai,2) but it just shows me recorded stereo input not shows me two plots with 2 channels separately those shows me countinuous running mode.

what i want is this code shows me one plot that shows continuous recording of one channel.
but i want to see 2 plots those shows me right left channels separately.

my aim is to calculate two different channels countinuously.
Any suggest would be appreciated.

ai = analoginput('winsound');




%Set up the Plot for FFT of live input and start the analog input.
figure; % Setting up the plot
P = plot(zeros(1000,1)); % Initially blank plot
T = title(['Discrete Fourier Transform Plot (fft),Number of callback function calls: ', num2str(0)]);
xlabel('Frequency (Hz)')
grid on;


while(strcmpi(get(ai,'Running'),'On')) % To keep the code running till the callback issues a stop

%The callback function, demoai_continuous_timer_callback, uses getdata to
%bring the data into MATLAB. The functiona also calls a custom demoai_continuous_fft function that returns a boolean signifying whether the particular frequency is detected. If the result is true, then the function copies the data to the UserData property of the analog object and issues a stop command to the object.
type demoai_continuous_timer_callback.m
%Plot the captured data.

allData = get(ai,'UserData');


xlabel('Time (s)')
ylabel('Signal (Volts)')
title('Total Data captured');
grid on;
% * Delete it with the delete function to free memory and other system resources.
  % * Clear it from the Workspace.

clear all; % to remove persistent data
%Print demoai_continuous_fft.m file
type demoai_continuous_fft.m

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us