image thumbnail

Waveform Generator GUI 2

by

 

22 Feb 2012 (Updated )

Generate waveformed signal and play it. Interactive GUI with movable datapoints.

open_device(po,Fs,ic,nblocks,margin)
function open_device(po,Fs,ic,nblocks,margin)
% open sound device, prepare , and start
global pco ao
pso=round(po*Fs);
ao = analogoutput('winsound');
ch = addchannel(ao,1:2);
%set(ao,'Timeout',3);
set(ao,'SampleRate',Fs);
set(ao,'BufferingConfig',[pso nblocks]);
set(ao,'SamplesOutputFcn',{@add_to_buffer,Fs,ao,po pso,ic});
set(ao,'SamplesOutputFcnCount',pso);
for mc=1:margin % 5 pieces margin
    x=(pso*(mc-1)+(0:pso-1))/Fs;
    d1=ic.interpData(x,true)';
%     figure;
%     plot(x,d1);
    d2=[d1 d1];
    putdata(ao,d2);
    pco=mc; % piece counter
end
pco=pco+1;
% set(ao, {'StartFcn', 'StopFcn', 'TriggerFcn'}, {'', '', ''});
start(ao);

Contact us