We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
With this example code, setting the recording rate to 320 samples per second works, but setting it to 319 hangs when recording and never "stops".
#include "MicroBit.h" #include "StreamRecording.h" MicroBit uBit; const int SAMPLE_RATE = 319; const int BUFFER_LEN = SAMPLE_RATE * 5; int main() { uBit.init(); SplitterChannel *splitterChannel = uBit.audio.splitter->createChannel(); splitterChannel->requestSampleRate( SAMPLE_RATE ); StreamRecording *recording = new StreamRecording(*splitterChannel, BUFFER_LEN); // Setting the mixer channel to a different sampling rate doesn't make a difference MixerChannel *recordingChannel = uBit.audio.mixer.addChannel(*recording, SAMPLE_RATE); recordingChannel->setVolume(75.0); MicroBitAudio::requestActivation(); while (true) { if (uBit.buttonA.isPressed()) { recording->erase(); recording->recordAsync(); while (recording->isRecording()) { uBit.display.print("R"); uBit.sleep(5); } uBit.display.clear(); } else if (uBit.buttonB.isPressed()) { recording->playAsync(); while (recording->isPlaying()) { uBit.display.print("P"); uBit.sleep(20); } uBit.display.clear(); } uBit.sleep(200); } }
To replicate:
The text was updated successfully, but these errors were encountered:
Single byte buffers are quietly rejected, though the format has one byte per sample https://github.com/lancaster-university/codal-core/blob/df05db9e15499bd8906618192a4d482e3836c62f/source/streams/StreamRecording.cpp#L96
data == ManagedBuffer() doesn't seem to add anything.
data == ManagedBuffer()
To reject buffers without a whole sample, the test could be if( data.length() < DATASTREAM_FORMAT_BYTES_PER_SAMPLE( this->upStream.getFormat()) {
if( data.length() < DATASTREAM_FORMAT_BYTES_PER_SAMPLE( this->upStream.getFormat()) {
With this, the sample rate borderline for "records forever" moves to 142/143, as in #428
With low sample rates, I think StreamRecording will build a list of tiny buffers, with a 12+ byte overhead for each node https://github.com/lancaster-university/codal-core/blob/df05db9e15499bd8906618192a4d482e3836c62f/inc/streams/StreamRecording.h#L19
Sorry, something went wrong.
finneyj
No branches or pull requests
With this example code, setting the recording rate to 320 samples per second works, but setting it to 319 hangs when recording and never "stops".
To replicate:
The text was updated successfully, but these errors were encountered: