Push record file type support into RecordView.

This commit is contained in:
Jared Boone 2016-05-02 11:44:37 -07:00
parent 68faccfd10
commit 3f36d8b7bf
4 changed files with 37 additions and 14 deletions

View File

@ -143,7 +143,7 @@ private:
RecordView record_view { RecordView record_view {
{ 0 * 8, 2 * 16, 30 * 8, 1 * 16 }, { 0 * 8, 2 * 16, 30 * 8, 1 * 16 },
"AUD_????", ".S16", 12, 2, "AUD_????", RecordView::FileType::WAV, 12, 2,
}; };
spectrum::WaterfallWidget waterfall; spectrum::WaterfallWidget waterfall;

View File

@ -78,7 +78,7 @@ private:
RecordView record_view { RecordView record_view {
{ 0 * 8, 2 * 16, 30 * 8, 1 * 16 }, { 0 * 8, 2 * 16, 30 * 8, 1 * 16 },
"BBD_????", ".C16", 14, 1, "BBD_????", RecordView::FileType::RawS16, 14, 1,
}; };
spectrum::WaterfallWidget waterfall; spectrum::WaterfallWidget waterfall;

View File

@ -35,12 +35,12 @@ namespace ui {
RecordView::RecordView( RecordView::RecordView(
const Rect parent_rect, const Rect parent_rect,
std::string filename_stem_pattern, std::string filename_stem_pattern,
std::string filename_extension, const FileType file_type,
const size_t buffer_size_k, const size_t buffer_size_k,
const size_t buffer_count_k const size_t buffer_count_k
) : View { parent_rect }, ) : View { parent_rect },
filename_stem_pattern { filename_stem_pattern }, filename_stem_pattern { filename_stem_pattern },
filename_extension { filename_extension }, file_type { file_type },
buffer_size_k { buffer_size_k }, buffer_size_k { buffer_size_k },
buffer_count_k { buffer_count_k } buffer_count_k { buffer_count_k }
{ {
@ -93,15 +93,33 @@ void RecordView::start() {
return; return;
} }
write_metadata_file(filename_stem + ".TXT"); std::unique_ptr<Writer> writer;
switch(file_type) {
case FileType::WAV:
writer = std::make_unique<WAVFileWriter>(
filename_stem + ".WAV",
sampling_rate
);
break;
capture_thread = std::make_unique<CaptureThread>( case FileType::RawS16:
std::make_unique<RawFileWriter>( write_metadata_file(filename_stem + ".TXT");
filename_stem + filename_extension writer = std::make_unique<RawFileWriter>(
), filename_stem + ".C16"
buffer_size_k, buffer_count_k );
); break;
button_record.set_bitmap(&bitmap_stop);
default:
break;
};
if( writer ) {
capture_thread = std::make_unique<CaptureThread>(
std::move(writer),
buffer_size_k, buffer_count_k
);
button_record.set_bitmap(&bitmap_stop);
}
} }
void RecordView::stop() { void RecordView::stop() {

View File

@ -35,10 +35,15 @@ namespace ui {
class RecordView : public View { class RecordView : public View {
public: public:
enum FileType {
RawS16 = 2,
WAV = 3,
};
RecordView( RecordView(
const Rect parent_rect, const Rect parent_rect,
std::string filename_stem_pattern, std::string filename_stem_pattern,
std::string filename_extension, FileType file_type,
const size_t buffer_size_k, const size_t buffer_size_k,
const size_t buffer_count_k const size_t buffer_count_k
); );
@ -65,7 +70,7 @@ private:
void on_tick_second(); void on_tick_second();
const std::string filename_stem_pattern; const std::string filename_stem_pattern;
const std::string filename_extension; const FileType file_type;
const size_t buffer_size_k; const size_t buffer_size_k;
const size_t buffer_count_k; const size_t buffer_count_k;
size_t sampling_rate { 0 }; size_t sampling_rate { 0 };