连接无线电流和 MP3 解码器

Connecting RadioStream and a MP3 decoder

本文关键字:MP3 解码器 无线电 连接      更新时间:2023-10-16

我正在尝试构建一个用于读取流和解码流的arduino网络收音机 我有以下两种写入和读取流的方法,需要连接,但我想不出一个好方法:

在这种方法中,我们读取无线电流并将其内容写入 32 字节缓冲区。

uint8_t buff[32];
// from the server, read them and print them:
while (true)
{
int ret = client.read(buff, sizeof(buff) / 2 );
if (ret <= 0)
break;
for(int i = 0; i < ret; i++)
{//instead of Serial write we need to do something with the contents of this buffer
Serial.write((char)buff[i]);
}
}

下一个方法从网络无线电中获取二进制流并对其进行解码:

int getMoreData(uint8_t *writeHere, int available)
{
/* TODO: write up to 'available' bytes of MP3 data 
* to the location 'writeHere'. Return the actual number of bytes
* that were written
*/}

这两种方法需要相互连接,但我不确定如何连接。

谢谢!

所以基本上我在这里需要的是一个可以填充和异步读取的缓冲区。

或者换句话说,消费者和生产者以不同的速度工作。

所以对我有用的是一个标准的环形缓冲区,几乎每个平台(包括arduino(都有各种各样的实现。