|
|
@ -85,3 +85,15 @@ void Sound::stop() { |
|
|
|
void Sound::end() { |
|
|
|
i2s_driver_uninstall(i2s_num); //stop & destroy i2s driver
|
|
|
|
} |
|
|
|
|
|
|
|
/* callback(?) for new audio data */ |
|
|
|
int Sound::render_sample_block(uint16_t *sample_buf_left, uint16_t *sample_buf_right, int num_samples) { |
|
|
|
int num_pushed_samples = 0; |
|
|
|
for (int i=0; i < num_samples; i++) { |
|
|
|
unsigned int sample = ((unsigned short) sample_buf_left[i] << 16 & 0xffff0000) | ((unsigned short) sample_buf_right[i]); |
|
|
|
int num_pushed_bytes = i2s_push_sample(i2s_num, (char *)&sample, portMAX_DELAY); |
|
|
|
if (num_pushed_bytes > 0) num_pushed_samples += num_pushed_bytes; |
|
|
|
else break; |
|
|
|
} |
|
|
|
return num_pushed_samples; |
|
|
|
} |
|
|
|