Skip to content

Trying to get an RP2040 USB audio to i2s working. #5

Answered by pschatzmann
sniperzero22 asked this question in Q&A
Discussion options

You must be logged in to vote

I added some manual feedback support which takes the buffer fill status into consideration. This is working now w/o any under or overruns:

#include "Adafruit_TinyUSB.h"
#include "AudioTools.h"
#include "AudioTools/Concurrency/RP2040.h"

AudioInfo info(44100, 2, 16);
Adafruit_USBD_Audio usb;
BufferRP2040 buffer(256, 20); 
QueueStream queue(buffer);
I2SStream i2s;
StreamCopy copier(i2s, queue);

size_t writeCB(const uint8_t* data, size_t len, Adafruit_USBD_Audio& ref) {
  usb.setFeedbackPercent(buffer.size()*100 / buffer.available());
  return queue.write(data, len);
}

void setup() {  
  Serial.begin(115200);
  AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Warning);
  while(!Serial);  //

Replies: 7 comments 16 replies

Comment options

You must be logged in to vote
3 replies
@h5n1xp
Comment options

@sniperzero22
Comment options

@h5n1xp
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@sniperzero22
Comment options

Comment options

You must be logged in to vote
1 reply
@pschatzmann
Comment options

Comment options

You must be logged in to vote
5 replies
@pschatzmann
Comment options

@h5n1xp
Comment options

@h5n1xp
Comment options

@pschatzmann
Comment options

@h5n1xp
Comment options

Comment options

You must be logged in to vote
5 replies
@h5n1xp
Comment options

@sniperzero22
Comment options

@pschatzmann
Comment options

@h5n1xp
Comment options

@sniperzero22
Comment options

Answer selected by pschatzmann
Comment options

You must be logged in to vote
1 reply
@pschatzmann
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants