Record audio data by sending to the Arduino sketch. This object allows sketch code to receive audio packets.
Port | Purpose |
---|---|
In 0 | Sound To Access |
begin();
Begin capturing incoming audio to the queue. After calling begin, readBuffer() and freeBuffer(), or clear() must be used frequently to prevent the queue from filling up.
available();
Returns the number of audio packets available to read.
readBuffer();
Read a single audio packet. A pointer to a 128 sample array of 16 bit integers is returned. NULL is returned if no packets are available.
freeBuffer();
Release the memory from the previously read packet returned from readBuffer(). Only a single packet at a time may be read, and each packet must be freed with this function, to return the memory to the audio library.
clear();
Discard all audio held in the queue.
end();
Stop capturing incoming audio into the queue. Data already captured remains in the queue and may be read with readBuffer().
File > Examples > Audio > Recorder
Up to 52 packets may be queued by this object, which allows approximately 150 ms of audio to be held in the queue, to allow time for the Arduino sketch to write data to media or do other high-latency tasks. The actual packets are taken from the pool created by AudioMemory().