You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.3 KiB
40 lines
1.3 KiB
5 years ago
|
#pragma once
|
||
|
#include "config.h"
|
||
|
#include "dexed.h"
|
||
|
|
||
|
#include <AudioStream.h>
|
||
|
|
||
|
class AudioSourceMicroDexed : public AudioStream {
|
||
|
public:
|
||
|
const uint16_t audio_block_time_us = 1000000 / (SAMPLE_RATE / AUDIO_BLOCK_SAMPLES);
|
||
|
uint32_t xrun = 0;
|
||
|
uint16_t render_time_max = 0;
|
||
|
AudioAnalyzePeak * peak1 =NULL;
|
||
|
int num_dexeds = 0;
|
||
|
Dexed ** dexeds = NULL;
|
||
|
AudioSourceMicroDexed() : AudioStream(0, NULL) {
|
||
|
};
|
||
|
void setDexeds(int num, Dexed ** pdexed) {
|
||
|
dexeds = pdexed;
|
||
|
num_dexeds = num;
|
||
|
}
|
||
|
void update(void) {
|
||
|
elapsedMicros render_time;
|
||
|
audio_block_t *lblock;
|
||
|
lblock = allocate();
|
||
|
if (!lblock) return;
|
||
|
for (uint8_t i = 0; i < num_dexeds; i++)
|
||
|
{
|
||
|
dexeds[i]->getSamples(AUDIO_BLOCK_SAMPLES, lblock->data);
|
||
|
}
|
||
|
if (render_time > audio_block_time_us) // everything greater 2.9ms is a buffer underrun!
|
||
|
xrun++;
|
||
|
if (render_time > render_time_max)
|
||
|
render_time_max = render_time;
|
||
|
|
||
|
transmit(lblock, 0);
|
||
|
release(lblock);
|
||
|
};
|
||
|
private:
|
||
|
};
|