Analog I/O Demo 6 -- Generating audio with the digital to analog converter ================================================================================== This demo is very similar to Demo 4, except it plays the audio on the DAC. Playing the audio on the DAC allows the generation of precise audio stimuli. Using DAC eliminates variations between consumer electronics player, and also eliminates the delay between the different possible codecs. .. Note:: You can only use ADC/DAC with the full version of a device; the lite version does not have ADC/DAC capabilities. To play back audio, we write the file in the DAC buffer. When we load the audio, we must make sure to obtain the frequency, otherwise the playback will be distorted. If audio is more than one channel, we also receive this information. A schedule is also created for proper playback. ``Datapixx('SetDacSchedule', 0, freq, nTotalFrames*repetitions, [0: nChannels-1], 0, nTotalFrames);`` The first zero is the delay, ``freq`` is the audio frequency acquired when loading the audio file. If you want to repeat the sound, you must know how many frames your sound file possesses. Here, there is no 'mode', since we are sending this to the DAC. The next argument sets up the ADC channel(s). The second zero is the address of the audio stimulus and the final argument is the number of frames. .. literalinclude:: ../DatapixxToolbox/DatapixxDemos/DatapixxDacWaveDemo.m :language: matlab :emphasize-lines: 74, 80, 86 :linenos: