mirror of
https://github.com/eried/portapack-mayhem.git
synced 2024-12-25 07:19:28 -05:00
Extract RecordView from AnalogAudioApp, CaptureApp.
This commit is contained in:
parent
24192b4043
commit
4d6fccd8ea
@ -167,6 +167,7 @@ CPPSRC = main.cpp \
|
|||||||
ui_sd_card_debug.cpp \
|
ui_sd_card_debug.cpp \
|
||||||
ui_console.cpp \
|
ui_console.cpp \
|
||||||
ui_receiver.cpp \
|
ui_receiver.cpp \
|
||||||
|
ui_record_view.cpp \
|
||||||
ui_spectrum.cpp \
|
ui_spectrum.cpp \
|
||||||
recent_entries.cpp \
|
recent_entries.cpp \
|
||||||
receiver_model.cpp \
|
receiver_model.cpp \
|
||||||
|
@ -86,8 +86,7 @@ AnalogAudioView::AnalogAudioView(
|
|||||||
&field_vga,
|
&field_vga,
|
||||||
&options_modulation,
|
&options_modulation,
|
||||||
&field_volume,
|
&field_volume,
|
||||||
&button_record,
|
&record_view,
|
||||||
&text_record_filename,
|
|
||||||
&waterfall,
|
&waterfall,
|
||||||
} });
|
} });
|
||||||
|
|
||||||
@ -140,10 +139,6 @@ 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));
|
||||||
@ -289,7 +284,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();
|
||||||
record_stop();
|
record_view.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({
|
||||||
@ -300,57 +295,20 @@ void AnalogAudioView::update_modulation(const ReceiverModel::Mode modulation) {
|
|||||||
receiver_model.set_baseband_bandwidth(is_wideband_spectrum_mode ? 12000000 : 1750000);
|
receiver_model.set_baseband_bandwidth(is_wideband_spectrum_mode ? 12000000 : 1750000);
|
||||||
receiver_model.enable();
|
receiver_model.enable();
|
||||||
|
|
||||||
if( !is_wideband_spectrum_mode ) {
|
|
||||||
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_stem = next_filename_stem_matching_pattern("AUD_????");
|
|
||||||
text_record_filename.set(filename_stem);
|
|
||||||
if( filename_stem.empty() ) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
write_metadata_file(filename_stem + ".TXT");
|
|
||||||
|
|
||||||
capture_thread = std::make_unique<CaptureThread>(filename_stem + ".S16", 12, 2);
|
|
||||||
button_record.set_bitmap(&bitmap_stop);
|
|
||||||
}
|
|
||||||
|
|
||||||
void AnalogAudioView::record_stop() {
|
|
||||||
capture_thread.reset();
|
|
||||||
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.
|
// 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;
|
size_t sampling_rate = 0;
|
||||||
switch(modulation) {
|
switch(modulation) {
|
||||||
case ReceiverModel::Mode::AMAudio: sampling_rate = 12000; break;
|
case ReceiverModel::Mode::AMAudio: sampling_rate = 12000; break;
|
||||||
case ReceiverModel::Mode::NarrowbandFMAudio: sampling_rate = 24000; break;
|
case ReceiverModel::Mode::NarrowbandFMAudio: sampling_rate = 24000; break;
|
||||||
case ReceiverModel::Mode::WidebandFMAudio: sampling_rate = 48000; break;
|
case ReceiverModel::Mode::WidebandFMAudio: sampling_rate = 48000; break;
|
||||||
default:
|
default:
|
||||||
return;
|
break;
|
||||||
}
|
}
|
||||||
|
record_view.set_sampling_rate(sampling_rate);
|
||||||
|
|
||||||
File file;
|
if( !is_wideband_spectrum_mode ) {
|
||||||
file.open_for_writing(filename);
|
audio::output::unmute();
|
||||||
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 */
|
||||||
|
@ -26,8 +26,7 @@
|
|||||||
|
|
||||||
#include "ui_receiver.hpp"
|
#include "ui_receiver.hpp"
|
||||||
#include "ui_spectrum.hpp"
|
#include "ui_spectrum.hpp"
|
||||||
|
#include "ui_record_view.hpp"
|
||||||
#include "capture_thread.hpp"
|
|
||||||
|
|
||||||
#include "ui_font_fixed_8x16.hpp"
|
#include "ui_font_fixed_8x16.hpp"
|
||||||
|
|
||||||
@ -142,22 +141,13 @@ private:
|
|||||||
|
|
||||||
std::unique_ptr<Widget> options_widget;
|
std::unique_ptr<Widget> options_widget;
|
||||||
|
|
||||||
ImageButton button_record {
|
RecordView record_view {
|
||||||
{ 0 * 8, 2 * 16, 2 * 8, 1 * 16 },
|
{ 0 * 8, 2 * 16, 30 * 8, 1 * 16 },
|
||||||
&bitmap_record,
|
"AUD_????", ".S16", 12, 2,
|
||||||
Color::red(),
|
|
||||||
Color::black()
|
|
||||||
};
|
|
||||||
|
|
||||||
Text text_record_filename {
|
|
||||||
{ 3 * 8, 2 * 16, 8 * 8, 16 },
|
|
||||||
"",
|
|
||||||
};
|
};
|
||||||
|
|
||||||
spectrum::WaterfallWidget waterfall;
|
spectrum::WaterfallWidget waterfall;
|
||||||
|
|
||||||
std::unique_ptr<CaptureThread> capture_thread;
|
|
||||||
|
|
||||||
void on_tuning_frequency_changed(rf::Frequency f);
|
void on_tuning_frequency_changed(rf::Frequency f);
|
||||||
void on_baseband_bandwidth_changed(uint32_t bandwidth_hz);
|
void on_baseband_bandwidth_changed(uint32_t bandwidth_hz);
|
||||||
void on_rf_amp_changed(bool v);
|
void on_rf_amp_changed(bool v);
|
||||||
@ -176,12 +166,6 @@ 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();
|
|
||||||
void write_metadata_file(const std::string& filename);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} /* namespace ui */
|
} /* namespace ui */
|
||||||
|
@ -24,25 +24,16 @@
|
|||||||
#include "portapack.hpp"
|
#include "portapack.hpp"
|
||||||
using namespace portapack;
|
using namespace portapack;
|
||||||
|
|
||||||
#include "file.hpp"
|
|
||||||
#include "time.hpp"
|
|
||||||
|
|
||||||
#include "utility.hpp"
|
|
||||||
|
|
||||||
#include "string_format.hpp"
|
|
||||||
|
|
||||||
namespace ui {
|
namespace ui {
|
||||||
|
|
||||||
CaptureAppView::CaptureAppView(NavigationView& nav) {
|
CaptureAppView::CaptureAppView(NavigationView& nav) {
|
||||||
add_children({ {
|
add_children({ {
|
||||||
&button_record,
|
|
||||||
&rssi,
|
&rssi,
|
||||||
&channel,
|
&channel,
|
||||||
&field_frequency,
|
&field_frequency,
|
||||||
&field_lna,
|
&field_lna,
|
||||||
&field_vga,
|
&field_vga,
|
||||||
&text_record_filename,
|
&record_view,
|
||||||
&text_record_dropped,
|
|
||||||
&waterfall,
|
&waterfall,
|
||||||
} });
|
} });
|
||||||
|
|
||||||
@ -70,10 +61,6 @@ CaptureAppView::CaptureAppView(NavigationView& nav) {
|
|||||||
this->on_vga_changed(v_db);
|
this->on_vga_changed(v_db);
|
||||||
};
|
};
|
||||||
|
|
||||||
button_record.on_select = [this](ImageButton&) {
|
|
||||||
this->on_record();
|
|
||||||
};
|
|
||||||
|
|
||||||
receiver_model.set_baseband_configuration({
|
receiver_model.set_baseband_configuration({
|
||||||
.mode = toUType(ReceiverModel::Mode::Capture),
|
.mode = toUType(ReceiverModel::Mode::Capture),
|
||||||
.sampling_rate = sampling_rate,
|
.sampling_rate = sampling_rate,
|
||||||
@ -82,13 +69,10 @@ CaptureAppView::CaptureAppView(NavigationView& nav) {
|
|||||||
receiver_model.set_baseband_bandwidth(baseband_bandwidth);
|
receiver_model.set_baseband_bandwidth(baseband_bandwidth);
|
||||||
receiver_model.enable();
|
receiver_model.enable();
|
||||||
|
|
||||||
signal_token_tick_second = time::signal_tick_second += [this]() {
|
record_view.set_sampling_rate(sampling_rate / 8);
|
||||||
this->on_tick_second();
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CaptureAppView::~CaptureAppView() {
|
CaptureAppView::~CaptureAppView() {
|
||||||
time::signal_tick_second -= signal_token_tick_second;
|
|
||||||
receiver_model.disable();
|
receiver_model.disable();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,53 +91,7 @@ void CaptureAppView::set_parent_rect(const Rect new_parent_rect) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CaptureAppView::focus() {
|
void CaptureAppView::focus() {
|
||||||
button_record.focus();
|
record_view.focus();
|
||||||
}
|
|
||||||
|
|
||||||
bool CaptureAppView::is_recording() const {
|
|
||||||
return (bool)capture_thread;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CaptureAppView::on_record() {
|
|
||||||
if( is_recording() ) {
|
|
||||||
record_stop();
|
|
||||||
} else {
|
|
||||||
record_start();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CaptureAppView::record_start() {
|
|
||||||
const auto filename_stem = next_filename_stem_matching_pattern("BBD_????");
|
|
||||||
text_record_filename.set(filename_stem);
|
|
||||||
text_record_dropped.set("");
|
|
||||||
if( filename_stem.empty() ) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
write_metadata_file(filename_stem + ".TXT");
|
|
||||||
|
|
||||||
capture_thread = std::make_unique<CaptureThread>(filename_stem + ".C16", 14, 1);
|
|
||||||
button_record.set_bitmap(&bitmap_stop);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CaptureAppView::record_stop() {
|
|
||||||
capture_thread.reset();
|
|
||||||
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());
|
|
||||||
const auto s = to_string_dec_uint(dropped_percent, 2, ' ') + "\%";
|
|
||||||
text_record_dropped.set(s);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CaptureAppView::on_tuning_frequency_changed(rf::Frequency f) {
|
void CaptureAppView::on_tuning_frequency_changed(rf::Frequency f) {
|
||||||
|
@ -25,13 +25,9 @@
|
|||||||
#include "ui_widget.hpp"
|
#include "ui_widget.hpp"
|
||||||
#include "ui_navigation.hpp"
|
#include "ui_navigation.hpp"
|
||||||
#include "ui_receiver.hpp"
|
#include "ui_receiver.hpp"
|
||||||
|
#include "ui_record_view.hpp"
|
||||||
#include "ui_spectrum.hpp"
|
#include "ui_spectrum.hpp"
|
||||||
|
|
||||||
#include "bitmap.hpp"
|
|
||||||
|
|
||||||
#include "capture_thread.hpp"
|
|
||||||
#include "signal.hpp"
|
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
@ -56,39 +52,10 @@ private:
|
|||||||
static constexpr uint32_t sampling_rate = 4000000;
|
static constexpr uint32_t sampling_rate = 4000000;
|
||||||
static constexpr uint32_t baseband_bandwidth = 2500000;
|
static constexpr uint32_t baseband_bandwidth = 2500000;
|
||||||
|
|
||||||
std::unique_ptr<CaptureThread> capture_thread;
|
|
||||||
|
|
||||||
SignalToken signal_token_tick_second;
|
|
||||||
|
|
||||||
void on_record();
|
|
||||||
bool is_recording() const;
|
|
||||||
void record_start();
|
|
||||||
void record_stop();
|
|
||||||
void write_metadata_file(const std::string& filename);
|
|
||||||
|
|
||||||
void on_tick_second();
|
|
||||||
|
|
||||||
void on_tuning_frequency_changed(rf::Frequency f);
|
void on_tuning_frequency_changed(rf::Frequency f);
|
||||||
void on_lna_changed(int32_t v_db);
|
void on_lna_changed(int32_t v_db);
|
||||||
void on_vga_changed(int32_t v_db);
|
void on_vga_changed(int32_t v_db);
|
||||||
|
|
||||||
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, 8 * 8, 16 },
|
|
||||||
"",
|
|
||||||
};
|
|
||||||
|
|
||||||
Text text_record_dropped {
|
|
||||||
{ 16 * 8, 2 * 16, 3 * 8, 16 },
|
|
||||||
"",
|
|
||||||
};
|
|
||||||
|
|
||||||
RSSI rssi {
|
RSSI rssi {
|
||||||
{ 21 * 8, 0, 6 * 8, 4 },
|
{ 21 * 8, 0, 6 * 8, 4 },
|
||||||
};
|
};
|
||||||
@ -109,6 +76,11 @@ private:
|
|||||||
{ 18 * 8, 0 * 16 }
|
{ 18 * 8, 0 * 16 }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
RecordView record_view {
|
||||||
|
{ 0 * 8, 2 * 16, 30 * 8, 1 * 16 },
|
||||||
|
"BBD_????", ".C16", 14, 1,
|
||||||
|
};
|
||||||
|
|
||||||
spectrum::WaterfallWidget waterfall;
|
spectrum::WaterfallWidget waterfall;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
124
firmware/application/ui_record_view.cpp
Normal file
124
firmware/application/ui_record_view.cpp
Normal file
@ -0,0 +1,124 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2016 Jared Boone, ShareBrained Technology, Inc.
|
||||||
|
*
|
||||||
|
* This file is part of PortaPack.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; see the file COPYING. If not, write to
|
||||||
|
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||||
|
* Boston, MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "ui_record_view.hpp"
|
||||||
|
|
||||||
|
#include "portapack.hpp"
|
||||||
|
using namespace portapack;
|
||||||
|
|
||||||
|
#include "file.hpp"
|
||||||
|
#include "time.hpp"
|
||||||
|
|
||||||
|
#include "string_format.hpp"
|
||||||
|
#include "utility.hpp"
|
||||||
|
|
||||||
|
namespace ui {
|
||||||
|
|
||||||
|
RecordView::RecordView(
|
||||||
|
const Rect parent_rect,
|
||||||
|
std::string filename_stem_pattern,
|
||||||
|
std::string filename_extension,
|
||||||
|
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 },
|
||||||
|
buffer_size_k { buffer_size_k },
|
||||||
|
buffer_count_k { buffer_count_k }
|
||||||
|
{
|
||||||
|
add_children({ {
|
||||||
|
&button_record,
|
||||||
|
&text_record_filename,
|
||||||
|
&text_record_dropped,
|
||||||
|
} });
|
||||||
|
|
||||||
|
button_record.on_select = [this](ImageButton&) {
|
||||||
|
this->toggle();
|
||||||
|
};
|
||||||
|
|
||||||
|
signal_token_tick_second = time::signal_tick_second += [this]() {
|
||||||
|
this->on_tick_second();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
RecordView::~RecordView() {
|
||||||
|
time::signal_tick_second -= signal_token_tick_second;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RecordView::focus() {
|
||||||
|
button_record.focus();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool RecordView::is_active() const {
|
||||||
|
return (bool)capture_thread;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RecordView::toggle() {
|
||||||
|
if( is_active() ) {
|
||||||
|
stop();
|
||||||
|
} else {
|
||||||
|
start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void RecordView::start() {
|
||||||
|
stop();
|
||||||
|
|
||||||
|
if( sampling_rate == 0 ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto filename_stem = next_filename_stem_matching_pattern(filename_stem_pattern);
|
||||||
|
text_record_filename.set(filename_stem);
|
||||||
|
text_record_dropped.set("");
|
||||||
|
if( filename_stem.empty() ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
write_metadata_file(filename_stem + ".TXT");
|
||||||
|
|
||||||
|
capture_thread = std::make_unique<CaptureThread>(filename_stem + filename_extension, buffer_size_k, buffer_count_k);
|
||||||
|
button_record.set_bitmap(&bitmap_stop);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RecordView::stop() {
|
||||||
|
if( is_active() ) {
|
||||||
|
capture_thread.reset();
|
||||||
|
button_record.set_bitmap(&bitmap_record);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void RecordView::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 RecordView::on_tick_second() {
|
||||||
|
if( is_active() ) {
|
||||||
|
const auto dropped_percent = std::min(99U, capture_thread->state().dropped_percent());
|
||||||
|
const auto s = to_string_dec_uint(dropped_percent, 2, ' ') + "\%";
|
||||||
|
text_record_dropped.set(s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} /* namespace ui */
|
96
firmware/application/ui_record_view.hpp
Normal file
96
firmware/application/ui_record_view.hpp
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2016 Jared Boone, ShareBrained Technology, Inc.
|
||||||
|
*
|
||||||
|
* This file is part of PortaPack.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; see the file COPYING. If not, write to
|
||||||
|
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||||
|
* Boston, MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __UI_RECORD_VIEW_H__
|
||||||
|
#define __UI_RECORD_VIEW_H__
|
||||||
|
|
||||||
|
#include "ui_widget.hpp"
|
||||||
|
|
||||||
|
#include "capture_thread.hpp"
|
||||||
|
#include "signal.hpp"
|
||||||
|
|
||||||
|
#include "bitmap.hpp"
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
namespace ui {
|
||||||
|
|
||||||
|
class RecordView : public View {
|
||||||
|
public:
|
||||||
|
RecordView(
|
||||||
|
const Rect parent_rect,
|
||||||
|
std::string filename_stem_pattern,
|
||||||
|
std::string filename_extension,
|
||||||
|
const size_t buffer_size_k,
|
||||||
|
const size_t buffer_count_k
|
||||||
|
);
|
||||||
|
~RecordView();
|
||||||
|
|
||||||
|
void focus() override;
|
||||||
|
|
||||||
|
void set_sampling_rate(const size_t new_sampling_rate) {
|
||||||
|
if( new_sampling_rate != sampling_rate ) {
|
||||||
|
stop();
|
||||||
|
sampling_rate = new_sampling_rate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void start();
|
||||||
|
void stop();
|
||||||
|
|
||||||
|
bool is_active() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void toggle();
|
||||||
|
void write_metadata_file(const std::string& filename);
|
||||||
|
|
||||||
|
void on_tick_second();
|
||||||
|
|
||||||
|
const std::string filename_stem_pattern;
|
||||||
|
const std::string filename_extension;
|
||||||
|
const size_t buffer_size_k;
|
||||||
|
const size_t buffer_count_k;
|
||||||
|
size_t sampling_rate { 0 };
|
||||||
|
SignalToken signal_token_tick_second;
|
||||||
|
|
||||||
|
ImageButton button_record {
|
||||||
|
{ 0 * 8, 0 * 16, 2 * 8, 1 * 16 },
|
||||||
|
&bitmap_record,
|
||||||
|
Color::red(),
|
||||||
|
Color::black()
|
||||||
|
};
|
||||||
|
|
||||||
|
Text text_record_filename {
|
||||||
|
{ 3 * 8, 0 * 16, 8 * 8, 16 },
|
||||||
|
"",
|
||||||
|
};
|
||||||
|
|
||||||
|
Text text_record_dropped {
|
||||||
|
{ 16 * 8, 0 * 16, 3 * 8, 16 },
|
||||||
|
"",
|
||||||
|
};
|
||||||
|
|
||||||
|
std::unique_ptr<CaptureThread> capture_thread;
|
||||||
|
};
|
||||||
|
|
||||||
|
} /* namespace ui */
|
||||||
|
|
||||||
|
#endif/*__UI_RECORD_VIEW_H__*/
|
Loading…
Reference in New Issue
Block a user