mirror of
https://github.com/eried/portapack-mayhem.git
synced 2024-10-01 01:26:06 -04:00
Add simple record UI to audio app.
This commit is contained in:
parent
a6538bc48b
commit
adf573be20
@ -84,6 +84,8 @@ AnalogAudioView::AnalogAudioView(
|
|||||||
&field_vga,
|
&field_vga,
|
||||||
&options_modulation,
|
&options_modulation,
|
||||||
&field_volume,
|
&field_volume,
|
||||||
|
&button_record,
|
||||||
|
&text_record_filename,
|
||||||
&waterfall,
|
&waterfall,
|
||||||
} });
|
} });
|
||||||
|
|
||||||
@ -136,6 +138,10 @@ AnalogAudioView::AnalogAudioView(
|
|||||||
this->on_headphone_volume_changed(v);
|
this->on_headphone_volume_changed(v);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
button_record.on_select = [this](ImageButton&) {
|
||||||
|
this->on_record();
|
||||||
|
};
|
||||||
|
|
||||||
audio::output::start();
|
audio::output::start();
|
||||||
|
|
||||||
update_modulation(static_cast<ReceiverModel::Mode>(modulation));
|
update_modulation(static_cast<ReceiverModel::Mode>(modulation));
|
||||||
@ -281,7 +287,7 @@ void AnalogAudioView::on_headphone_volume_changed(int32_t v) {
|
|||||||
|
|
||||||
void AnalogAudioView::update_modulation(const ReceiverModel::Mode modulation) {
|
void AnalogAudioView::update_modulation(const ReceiverModel::Mode modulation) {
|
||||||
audio::output::mute();
|
audio::output::mute();
|
||||||
capture_thread.reset();
|
record_stop();
|
||||||
|
|
||||||
const auto is_wideband_spectrum_mode = (modulation == ReceiverModel::Mode::SpectrumAnalysis);
|
const auto is_wideband_spectrum_mode = (modulation == ReceiverModel::Mode::SpectrumAnalysis);
|
||||||
receiver_model.set_baseband_configuration({
|
receiver_model.set_baseband_configuration({
|
||||||
@ -293,12 +299,36 @@ void AnalogAudioView::update_modulation(const ReceiverModel::Mode modulation) {
|
|||||||
receiver_model.enable();
|
receiver_model.enable();
|
||||||
|
|
||||||
if( !is_wideband_spectrum_mode ) {
|
if( !is_wideband_spectrum_mode ) {
|
||||||
const auto filename = next_filename_matching_pattern("AUD_????.S16");
|
|
||||||
if( !filename.empty() ) {
|
|
||||||
capture_thread = std::make_unique<CaptureThread>(filename);
|
|
||||||
}
|
|
||||||
audio::output::unmute();
|
audio::output::unmute();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool AnalogAudioView::is_recording() const {
|
||||||
|
return (bool)capture_thread;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AnalogAudioView::on_record() {
|
||||||
|
if( is_recording() ) {
|
||||||
|
record_stop();
|
||||||
|
} else {
|
||||||
|
record_start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AnalogAudioView::record_start() {
|
||||||
|
const auto filename = next_filename_matching_pattern("AUD_????.S16");
|
||||||
|
text_record_filename.set(filename);
|
||||||
|
if( filename.empty() ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
capture_thread = std::make_unique<CaptureThread>(filename);
|
||||||
|
button_record.set_bitmap(&bitmap_stop);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AnalogAudioView::record_stop() {
|
||||||
|
capture_thread.reset();
|
||||||
|
button_record.set_bitmap(&bitmap_record);
|
||||||
|
}
|
||||||
|
|
||||||
} /* namespace ui */
|
} /* namespace ui */
|
||||||
|
@ -93,7 +93,7 @@ public:
|
|||||||
void focus() override;
|
void focus() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static constexpr ui::Dim header_height = 2 * 16;
|
static constexpr ui::Dim header_height = 3 * 16;
|
||||||
|
|
||||||
const Rect options_view_rect { 0 * 8, 1 * 16, 30 * 8, 1 * 16 };
|
const Rect options_view_rect { 0 * 8, 1 * 16, 30 * 8, 1 * 16 };
|
||||||
|
|
||||||
@ -142,6 +142,18 @@ private:
|
|||||||
|
|
||||||
std::unique_ptr<Widget> options_widget;
|
std::unique_ptr<Widget> options_widget;
|
||||||
|
|
||||||
|
ImageButton button_record {
|
||||||
|
{ 0 * 8, 2 * 16, 2 * 8, 1 * 16 },
|
||||||
|
&bitmap_record,
|
||||||
|
Color::red(),
|
||||||
|
Color::black()
|
||||||
|
};
|
||||||
|
|
||||||
|
Text text_record_filename {
|
||||||
|
{ 3 * 8, 2 * 16, 12 * 8, 16 },
|
||||||
|
"",
|
||||||
|
};
|
||||||
|
|
||||||
spectrum::WaterfallWidget waterfall;
|
spectrum::WaterfallWidget waterfall;
|
||||||
|
|
||||||
std::unique_ptr<CaptureThread> capture_thread;
|
std::unique_ptr<CaptureThread> capture_thread;
|
||||||
@ -164,6 +176,11 @@ private:
|
|||||||
void set_options_widget(std::unique_ptr<Widget> new_widget);
|
void set_options_widget(std::unique_ptr<Widget> new_widget);
|
||||||
|
|
||||||
void update_modulation(const ReceiverModel::Mode modulation);
|
void update_modulation(const ReceiverModel::Mode modulation);
|
||||||
|
|
||||||
|
void on_record();
|
||||||
|
bool is_recording() const;
|
||||||
|
void record_start();
|
||||||
|
void record_stop();
|
||||||
};
|
};
|
||||||
|
|
||||||
} /* namespace ui */
|
} /* namespace ui */
|
||||||
|
Loading…
Reference in New Issue
Block a user