Skip to content
Snippets Groups Projects

High blue rec

Closed Pierre Mahe requested to merge pierre.mahe/highblueparsers:HighBlueRec into main
2 files
+ 10
1
Compare changes
  • Side-by-side
  • Inline

Files

+ 9
0
@@ -56,6 +56,7 @@ int record(size_t channels, size_t rate, std::string &filename, float chunklen,
allow_clean_exit();
size_t total_samples_wanted = totallen * rate;
size_t total_samples_read = 0;
size_t failed_attempts = 0;
std::vector<std::int16_t> samples;
try {
recorder.start_recording();
@@ -74,6 +75,14 @@ int record(size_t channels, size_t rate, std::string &filename, float chunklen,
}
// pass it on to the file writer
filewriter->write(samples);
failed_attempts = 0;
}
else {
// if we received no message or no audio data 20x in a row, abort
failed_attempts += 1;
if (failed_attempts >= 20) {
throw std::runtime_error("Device does not send audio data.");
}
}
}
recorder.stop_recording();
Loading