Audio I/O Demo 1 -- Playing audio ================================================================================== This demo will load an audio file and play it on your device. .. Note:: You can only play audio on the full version of a device; the lite version does not have audio playback capabilities. To playback audio, we write the file in the audio buffer. When we load the audio, we need to make sure we obtain the frequency, otherwise the playback will be distorted. Once the audio buffer is written ``Datapixx('WriteAudioBuffer', waveData, 0);``, we must again create a schedule for proper playback. As you can see, most functions are executed through a schedule. ``Datapixx('SetAudioSchedule', 0, freq, nTotalFrames*repetitions, lrMode, 0, nTotalFrames);`` Again, 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 need to know how many frames your sound file possesses. ``lrMode`` can take values ``[0 1 2 3]``, signifying respectively mono, left only, right only and stereo. The second zero is the address of the audio stimulus and the final argument is the number of frames. .. literalinclude:: ../DatapixxToolbox/DatapixxDemos/DatapixxAudioDemo.m :language: matlab :emphasize-lines: 54, 65, 71 :linenos: