From 3f36d8b7bf6773982c38e175e597ecf415b9a2df Mon Sep 17 00:00:00 2001 From: Jared Boone Date: Mon, 2 May 2016 11:44:37 -0700 Subject: [PATCH] Push record file type support into RecordView. --- firmware/application/analog_audio_app.hpp | 2 +- firmware/application/capture_app.hpp | 2 +- firmware/application/ui_record_view.cpp | 38 +++++++++++++++++------ firmware/application/ui_record_view.hpp | 9 ++++-- 4 files changed, 37 insertions(+), 14 deletions(-) diff --git a/firmware/application/analog_audio_app.hpp b/firmware/application/analog_audio_app.hpp index 1498cbc1..ebef06e3 100644 --- a/firmware/application/analog_audio_app.hpp +++ b/firmware/application/analog_audio_app.hpp @@ -143,7 +143,7 @@ private: RecordView record_view { { 0 * 8, 2 * 16, 30 * 8, 1 * 16 }, - "AUD_????", ".S16", 12, 2, + "AUD_????", RecordView::FileType::WAV, 12, 2, }; spectrum::WaterfallWidget waterfall; diff --git a/firmware/application/capture_app.hpp b/firmware/application/capture_app.hpp index e16ad17b..bc896f9e 100644 --- a/firmware/application/capture_app.hpp +++ b/firmware/application/capture_app.hpp @@ -78,7 +78,7 @@ private: RecordView record_view { { 0 * 8, 2 * 16, 30 * 8, 1 * 16 }, - "BBD_????", ".C16", 14, 1, + "BBD_????", RecordView::FileType::RawS16, 14, 1, }; spectrum::WaterfallWidget waterfall; diff --git a/firmware/application/ui_record_view.cpp b/firmware/application/ui_record_view.cpp index b37678ff..52e3e548 100644 --- a/firmware/application/ui_record_view.cpp +++ b/firmware/application/ui_record_view.cpp @@ -35,12 +35,12 @@ namespace ui { RecordView::RecordView( const Rect parent_rect, std::string filename_stem_pattern, - std::string filename_extension, + const FileType file_type, const size_t buffer_size_k, const size_t buffer_count_k ) : View { parent_rect }, filename_stem_pattern { filename_stem_pattern }, - filename_extension { filename_extension }, + file_type { file_type }, buffer_size_k { buffer_size_k }, buffer_count_k { buffer_count_k } { @@ -93,15 +93,33 @@ void RecordView::start() { return; } - write_metadata_file(filename_stem + ".TXT"); + std::unique_ptr writer; + switch(file_type) { + case FileType::WAV: + writer = std::make_unique( + filename_stem + ".WAV", + sampling_rate + ); + break; - capture_thread = std::make_unique( - std::make_unique( - filename_stem + filename_extension - ), - buffer_size_k, buffer_count_k - ); - button_record.set_bitmap(&bitmap_stop); + case FileType::RawS16: + write_metadata_file(filename_stem + ".TXT"); + writer = std::make_unique( + filename_stem + ".C16" + ); + break; + + default: + break; + }; + + if( writer ) { + capture_thread = std::make_unique( + std::move(writer), + buffer_size_k, buffer_count_k + ); + button_record.set_bitmap(&bitmap_stop); + } } void RecordView::stop() { diff --git a/firmware/application/ui_record_view.hpp b/firmware/application/ui_record_view.hpp index 6367c3ac..c133f19e 100644 --- a/firmware/application/ui_record_view.hpp +++ b/firmware/application/ui_record_view.hpp @@ -35,10 +35,15 @@ namespace ui { class RecordView : public View { public: + enum FileType { + RawS16 = 2, + WAV = 3, + }; + RecordView( const Rect parent_rect, std::string filename_stem_pattern, - std::string filename_extension, + FileType file_type, const size_t buffer_size_k, const size_t buffer_count_k ); @@ -65,7 +70,7 @@ private: void on_tick_second(); 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_count_k; size_t sampling_rate { 0 };