Audio I/O Demo 2 -- Recording and playing back microphone input ================================================================================== This demo records in real-time the audio from the microphone and plays it with a given delay (the minimum possible delay being 1 ms at 48 000 Samples per seconds (48 kSPS) or 0.5 ms at 96 kSPS). The minimum delay possible is defined by 2 audio samples. .. Note:: You can only play audio on the full version of a device; the lite version does not have audio playback capabilities. This demo is done in precise steps: - Compute feedback delay - Configure audio acquisition ``Datapixx('SetMicrophoneSource', 1, 100);`` Here the ``1`` is the source of the audio input: 1 signifies microphone, 2 would be Audio In. The 100 is the gain for the microphone, which is always a value between 1 and 1000. - Configure record buffer ``Datapixx('SetMicrophoneSchedule', 0, sampleRate, 0, 3, 0, 20e6);`` No delay on the Microphone Schedule (first zero), we sample at ``sampleRate``, 2nd zero zero signifies we are continuously acquiring data, the 3 signifies we are in stereo mode, the third zero is the base address we will use for this and, we will use a 20 megabytes buffer (``20e6``) - Set up audio playback schedule ``Datapixx('SetAudioSchedule', feedbackDelay, sampleRate, 0, 3, 0, 20e6);`` Here, instead of zero we have a ``feedbackDelay`` as explained before. We start at the same place as the Microphone schedule such that we playback the same audio that was recorded with the microphone, in the same mode. - Start record and playback schedules at the same time, but playback has the feedback delay before it starts. .. literalinclude:: ../DatapixxToolbox/DatapixxDemos/DatapixxAudioFeedbackDemo.m :language: matlab :emphasize-lines: 32, 60, 65, 70, 71 :linenos: