Capture: Write simple metadata for baseband and audio files.

Will probably turn the audio metadata file into .wav data, eventually.
This commit is contained in:
Jared Boone 2016-04-30 11:25:04 -07:00
parent a6d41547a0
commit 24192b4043
4 changed files with 33 additions and 0 deletions

View File

@ -30,6 +30,8 @@ using namespace portapack;
#include "utility.hpp"
#include "string_format.hpp"
namespace ui {
/* AMOptionsView *********************************************************/
@ -322,6 +324,8 @@ void AnalogAudioView::record_start() {
return;
}
write_metadata_file(filename_stem + ".TXT");
capture_thread = std::make_unique<CaptureThread>(filename_stem + ".S16", 12, 2);
button_record.set_bitmap(&bitmap_stop);
}
@ -331,4 +335,22 @@ void AnalogAudioView::record_stop() {
button_record.set_bitmap(&bitmap_record);
}
void AnalogAudioView::write_metadata_file(const std::string& filename) {
// TODO: This doesn't belong here! There's a better way.
const auto modulation = static_cast<ReceiverModel::Mode>(receiver_model.modulation());
size_t sampling_rate = 0;
switch(modulation) {
case ReceiverModel::Mode::AMAudio: sampling_rate = 12000; break;
case ReceiverModel::Mode::NarrowbandFMAudio: sampling_rate = 24000; break;
case ReceiverModel::Mode::WidebandFMAudio: sampling_rate = 48000; break;
default:
return;
}
File file;
file.open_for_writing(filename);
file.puts("sample_rate=" + to_string_dec_uint(sampling_rate) + "\n");
file.puts("center_frequency=" + to_string_dec_uint(receiver_model.tuning_frequency()) + "\n");
}
} /* namespace ui */

View File

@ -181,6 +181,7 @@ private:
bool is_recording() const;
void record_start();
void record_stop();
void write_metadata_file(const std::string& filename);
};
} /* namespace ui */

View File

@ -130,6 +130,8 @@ void CaptureAppView::record_start() {
return;
}
write_metadata_file(filename_stem + ".TXT");
capture_thread = std::make_unique<CaptureThread>(filename_stem + ".C16", 14, 1);
button_record.set_bitmap(&bitmap_stop);
}
@ -139,6 +141,13 @@ void CaptureAppView::record_stop() {
button_record.set_bitmap(&bitmap_record);
}
void CaptureAppView::write_metadata_file(const std::string& filename) {
File file;
file.open_for_writing(filename);
file.puts("sample_rate=" + to_string_dec_uint(sampling_rate) + "\n");
file.puts("center_frequency=" + to_string_dec_uint(receiver_model.tuning_frequency()) + "\n");
}
void CaptureAppView::on_tick_second() {
if( capture_thread ) {
const auto dropped_percent = std::min(99U, capture_thread->state().dropped_percent());

View File

@ -64,6 +64,7 @@ private:
bool is_recording() const;
void record_start();
void record_stop();
void write_metadata_file(const std::string& filename);
void on_tick_second();