Skip to content

Obsolete

Phil Schatzmann edited this page Jul 3, 2026 · 2 revisions

Please note that the Audio Branch described in this document is obsolete and not maintained any more. Please use the USB Audio Functionality provided by the AudioTools library!

This fork contains the implementation for the support of Audio.

I recommend to test it with PlatformIO because the installation is quite simple. Here is the platformio.ini:

Example Sketch

and here is the related minimal sketch

#include <Arduino.h>
#include "Adafruit_TinyUSB.h"

Adafruit_USBD_Audio usb;

size_t readCB(uint8_t* data, size_t len, Adafruit_USBD_Audio& ref) {
  int16_t* data16 = (int16_t*)data;
  size_t samples = len / sizeof(int16_t);
  size_t result = 0;
  // generate random stereo data
  for (int j = 0; j < samples; j+=2) {
    data16[j] = random(-32000, 32000);
    data16[j+1] = random(-32000, 32000);;
    result += sizeof(int16_t)*2;
  }
  return result;
}

void setup() {
  // Start USB device as Audio Source
  usb.setReadCallback(readCB);
  usb.begin(44100, 2, 16);
}

void loop() {
  // use LED do display status
  usb.updateLED();
}

Arduino RP2040 Installation Instructions

Clone this wiki locally