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');
addchannel(ai,1);
set(ai,'SamplesPerTrigger',Inf);
daqmem(ai)
set(ai,'TimerPeriod',0.5);
%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)')
ylabel('|Y(f)|')
grid on;
set(ai,'TimerFcn',{@demoai_continuous_timer_callback,P,T});
start(ai);
while(strcmpi(get(ai,'Running'),'On')) % To keep the code running till the callback issues a stop
pause(0.5);
end
%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');
figure;
plot(allData.time,allData.data);
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.
delete(ai);
clear all; % to remove persistent data
%Print demoai_continuous_fft.m file
type demoai_continuous_fft.m
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');
addchannel(ai,1);
set(ai,'SamplesPerTrigger',Inf);
daqmem(ai)
set(ai,'TimerPeriod',0.5);
%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)')
ylabel('|Y(f)|')
grid on;
set(ai,'TimerFcn',{@demoai_continuous_timer_callback,P,T});
start(ai);
while(strcmpi(get(ai,'Running'),'On')) % To keep the code running till the callback issues a stop
pause(0.5);
end
%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');
figure;
plot(allData.time,allData.data);
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.
delete(ai);
clear all; % to remove persistent data
%Print demoai_continuous_fft.m file
type demoai_continuous_fft.m