mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-01-11 23:39:29 -05:00
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:
parent
a6d41547a0
commit
24192b4043
@ -30,6 +30,8 @@ using namespace portapack;
|
|||||||
|
|
||||||
#include "utility.hpp"
|
#include "utility.hpp"
|
||||||
|
|
||||||
|
#include "string_format.hpp"
|
||||||
|
|
||||||
namespace ui {
|
namespace ui {
|
||||||
|
|
||||||
/* AMOptionsView *********************************************************/
|
/* AMOptionsView *********************************************************/
|
||||||
@ -322,6 +324,8 @@ void AnalogAudioView::record_start() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
write_metadata_file(filename_stem + ".TXT");
|
||||||
|
|
||||||
capture_thread = std::make_unique<CaptureThread>(filename_stem + ".S16", 12, 2);
|
capture_thread = std::make_unique<CaptureThread>(filename_stem + ".S16", 12, 2);
|
||||||
button_record.set_bitmap(&bitmap_stop);
|
button_record.set_bitmap(&bitmap_stop);
|
||||||
}
|
}
|
||||||
@ -331,4 +335,22 @@ void AnalogAudioView::record_stop() {
|
|||||||
button_record.set_bitmap(&bitmap_record);
|
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 */
|
} /* namespace ui */
|
||||||
|
@ -181,6 +181,7 @@ private:
|
|||||||
bool is_recording() const;
|
bool is_recording() const;
|
||||||
void record_start();
|
void record_start();
|
||||||
void record_stop();
|
void record_stop();
|
||||||
|
void write_metadata_file(const std::string& filename);
|
||||||
};
|
};
|
||||||
|
|
||||||
} /* namespace ui */
|
} /* namespace ui */
|
||||||
|
@ -130,6 +130,8 @@ void CaptureAppView::record_start() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
write_metadata_file(filename_stem + ".TXT");
|
||||||
|
|
||||||
capture_thread = std::make_unique<CaptureThread>(filename_stem + ".C16", 14, 1);
|
capture_thread = std::make_unique<CaptureThread>(filename_stem + ".C16", 14, 1);
|
||||||
button_record.set_bitmap(&bitmap_stop);
|
button_record.set_bitmap(&bitmap_stop);
|
||||||
}
|
}
|
||||||
@ -139,6 +141,13 @@ void CaptureAppView::record_stop() {
|
|||||||
button_record.set_bitmap(&bitmap_record);
|
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() {
|
void CaptureAppView::on_tick_second() {
|
||||||
if( capture_thread ) {
|
if( capture_thread ) {
|
||||||
const auto dropped_percent = std::min(99U, capture_thread->state().dropped_percent());
|
const auto dropped_percent = std::min(99U, capture_thread->state().dropped_percent());
|
||||||
|
@ -64,6 +64,7 @@ private:
|
|||||||
bool is_recording() const;
|
bool is_recording() const;
|
||||||
void record_start();
|
void record_start();
|
||||||
void record_stop();
|
void record_stop();
|
||||||
|
void write_metadata_file(const std::string& filename);
|
||||||
|
|
||||||
void on_tick_second();
|
void on_tick_second();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user