Sound DAQ Demo

Contents

Create analog output object

clear
ao = analogoutput('winsound',0);
disp(ao);
Display Summary of Analog Output (AO) Object Using 'SigmaTel Audio'.

       Output Parameters:  8000 samples per second on each channel.

      Trigger Parameters:  1 'Immediate' trigger on START.

           Engine status:  Waiting for START.
                           0 total sec. of data currently queued for START.
                           0 samples currently queued by PUTDATA.
                           0 samples sent to output device since START.

AO object contains no channels.

Show properties

fprintf('Sample Rate:\n');
disp(propinfo(ao,'SampleRate'));

addchannel(ao,1);
disp(ao.Channel);
Sample Rate:
               Type: 'double'
         Constraint: 'bounded'
    ConstraintValue: [5000 96000]
       DefaultValue: 8000
           ReadOnly: 'whileRunning'
     DeviceSpecific: 0

   Index:  ChannelName:  HwChannel:  OutputRange:  UnitsRange:  Units:   
   1       'Mono'        1           [-1 1]        [-1 1]       'Volts'  

Generate sounds

fs = 8000;
t = (0:4000)/fs;
freq = [220 440 880];
vol = [1 0.5 0.25];
for k=1:3;
    data = vol(k)*sin(2*pi*freq(k)*t);
    putdata(ao,data');
    start(ao);
    wait(ao,1); % wait for 1 second
end

close all open DAQ objects

for obj=daqfind
    delete(obj);
end
clear ao obj