2016-05-09 14:42:20 -04:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
|
2016-08-26 02:11:24 -04:00
|
|
|
* Copyright (C) 2016 Furrtek
|
2016-05-09 14:42:20 -04:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2016-08-26 02:11:24 -04:00
|
|
|
#ifndef __UI_SOUNDBOARD_H__
|
|
|
|
#define __UI_SOUNDBOARD_H__
|
|
|
|
|
2016-05-09 14:42:20 -04:00
|
|
|
#include "ui.hpp"
|
|
|
|
#include "ui_widget.hpp"
|
|
|
|
#include "ui_font_fixed_8x16.hpp"
|
2016-08-26 02:11:24 -04:00
|
|
|
#include "baseband_api.hpp"
|
2016-05-09 14:42:20 -04:00
|
|
|
#include "ui_receiver.hpp"
|
2017-01-15 22:45:44 -05:00
|
|
|
#include "io_wave.hpp"
|
2016-12-08 10:13:27 -05:00
|
|
|
#include "ctcss.hpp"
|
2016-05-09 14:42:20 -04:00
|
|
|
|
|
|
|
namespace ui {
|
2016-09-23 17:08:54 -04:00
|
|
|
|
2016-05-09 14:42:20 -04:00
|
|
|
class SoundBoardView : public View {
|
|
|
|
public:
|
|
|
|
SoundBoardView(NavigationView& nav);
|
|
|
|
~SoundBoardView();
|
|
|
|
|
2017-01-16 03:40:17 -05:00
|
|
|
SoundBoardView(const SoundBoardView&) = delete;
|
|
|
|
SoundBoardView(SoundBoardView&&) = delete;
|
|
|
|
SoundBoardView& operator=(const SoundBoardView&) = delete;
|
|
|
|
SoundBoardView& operator=(SoundBoardView&&) = delete;
|
|
|
|
|
2016-05-09 14:42:20 -04:00
|
|
|
void focus() override;
|
|
|
|
|
2016-08-26 02:11:24 -04:00
|
|
|
std::string title() const override { return "Soundboard"; };
|
|
|
|
|
2016-05-09 14:42:20 -04:00
|
|
|
private:
|
2016-12-06 07:31:38 -05:00
|
|
|
NavigationView& nav_;
|
|
|
|
|
2016-08-26 02:11:24 -04:00
|
|
|
enum tx_modes {
|
|
|
|
NORMAL = 0,
|
|
|
|
RANDOM
|
|
|
|
};
|
|
|
|
|
|
|
|
tx_modes tx_mode = NORMAL;
|
|
|
|
|
2016-05-09 14:42:20 -04:00
|
|
|
struct sound {
|
2017-01-15 22:45:44 -05:00
|
|
|
std::filesystem::path path { };
|
2016-08-26 03:54:17 -04:00
|
|
|
bool sixteenbit = false;
|
|
|
|
uint32_t sample_rate = 0;
|
|
|
|
uint32_t size = 0;
|
|
|
|
uint32_t sample_duration = 0;
|
|
|
|
uint32_t ms_duration = 0;
|
2017-03-10 19:59:04 -05:00
|
|
|
std::string title { };
|
2016-05-09 14:42:20 -04:00
|
|
|
};
|
|
|
|
|
2017-02-01 18:31:16 -05:00
|
|
|
uint32_t sample_counter { 0 };
|
|
|
|
uint32_t sample_duration { 0 };
|
2016-08-26 02:11:24 -04:00
|
|
|
uint8_t page = 0;
|
|
|
|
|
2017-02-02 04:29:14 -05:00
|
|
|
uint32_t lfsr_v = 0x13377331;
|
2016-08-26 02:11:24 -04:00
|
|
|
|
2017-02-01 18:31:16 -05:00
|
|
|
std::unique_ptr<WAVFileReader> reader { };
|
2016-12-07 14:49:42 -05:00
|
|
|
|
2017-03-10 19:59:04 -05:00
|
|
|
sound sounds[108]; // 6 pages * 18 buttons
|
2017-02-02 04:29:14 -05:00
|
|
|
uint32_t max_sound { };
|
|
|
|
uint8_t max_page { };
|
2016-08-26 02:11:24 -04:00
|
|
|
|
2017-03-05 10:37:56 -05:00
|
|
|
int8_t audio_buffer[512];
|
2016-08-26 02:11:24 -04:00
|
|
|
|
|
|
|
Style style_a {
|
|
|
|
.font = font::fixed_8x16,
|
|
|
|
.background = Color::black(),
|
|
|
|
.foreground = { 255, 51, 153 }
|
|
|
|
};
|
|
|
|
Style style_b {
|
|
|
|
.font = font::fixed_8x16,
|
|
|
|
.background = Color::black(),
|
|
|
|
.foreground = { 153, 204, 0 }
|
|
|
|
};
|
|
|
|
Style style_c {
|
|
|
|
.font = font::fixed_8x16,
|
|
|
|
.background = Color::black(),
|
|
|
|
.foreground = { 51, 204, 204 }
|
|
|
|
};
|
|
|
|
Style style_d {
|
|
|
|
.font = font::fixed_8x16,
|
|
|
|
.background = Color::black(),
|
|
|
|
.foreground = { 153, 102, 255 }
|
|
|
|
};
|
2016-05-09 14:42:20 -04:00
|
|
|
|
2017-03-10 19:59:04 -05:00
|
|
|
std::array<Button, 18> buttons { };
|
2016-08-26 02:11:24 -04:00
|
|
|
const Style * styles[4] = { &style_a, &style_b, &style_c, &style_d };
|
2016-05-09 14:42:20 -04:00
|
|
|
|
|
|
|
void on_tuning_frequency_changed(rf::Frequency f);
|
|
|
|
|
2016-08-26 02:11:24 -04:00
|
|
|
void do_random();
|
|
|
|
void show_infos(uint16_t id);
|
|
|
|
void change_page(Button& button, const KeyEvent key);
|
|
|
|
void refresh_buttons(uint16_t id);
|
|
|
|
void play_sound(uint16_t id);
|
|
|
|
void prepare_audio();
|
2016-09-23 17:08:54 -04:00
|
|
|
void on_ctcss_changed(uint32_t v);
|
2016-08-26 02:11:24 -04:00
|
|
|
|
2016-05-09 14:42:20 -04:00
|
|
|
FrequencyField field_frequency {
|
2017-03-10 19:59:04 -05:00
|
|
|
{ 0, 4 },
|
2016-05-09 14:42:20 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
NumberField number_bw {
|
2017-03-10 19:59:04 -05:00
|
|
|
{ 10 * 8, 4 },
|
2016-09-23 11:34:50 -04:00
|
|
|
3,
|
|
|
|
{1, 150},
|
2016-08-26 02:11:24 -04:00
|
|
|
1,
|
2016-05-09 14:42:20 -04:00
|
|
|
' '
|
|
|
|
};
|
|
|
|
|
2016-08-26 02:11:24 -04:00
|
|
|
Text text_kHz {
|
2017-03-10 19:59:04 -05:00
|
|
|
{ 13 * 8, 4, 8 * 8, 16 },
|
|
|
|
"k CTCSS:"
|
2016-08-26 02:11:24 -04:00
|
|
|
};
|
|
|
|
|
2016-09-23 17:08:54 -04:00
|
|
|
OptionsField options_ctcss {
|
2017-03-10 19:59:04 -05:00
|
|
|
{ 21 * 8, 4 },
|
|
|
|
8,
|
2016-12-08 10:13:27 -05:00
|
|
|
{ }
|
2016-09-23 17:08:54 -04:00
|
|
|
};
|
|
|
|
|
2017-03-10 19:59:04 -05:00
|
|
|
Text text_title {
|
|
|
|
{ 1 * 8, 26 * 8, 20 * 8, 16 },
|
|
|
|
"-"
|
|
|
|
};
|
|
|
|
|
2016-08-26 02:11:24 -04:00
|
|
|
Text text_page {
|
2017-03-10 19:59:04 -05:00
|
|
|
{ 22 * 8 - 4, 26 * 8, 8 * 8, 16 },
|
|
|
|
"Page -/-"
|
|
|
|
};
|
|
|
|
|
|
|
|
Text text_duration {
|
|
|
|
{ 1 * 8, 30 * 8, 5 * 8, 16 }
|
2016-05-09 14:42:20 -04:00
|
|
|
};
|
|
|
|
|
2016-08-26 02:11:24 -04:00
|
|
|
ProgressBar pbar {
|
2017-03-10 19:59:04 -05:00
|
|
|
{ 9 * 8, 30 * 8, 19 * 8, 16 }
|
2016-08-26 02:11:24 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
Checkbox check_loop {
|
2016-12-09 12:21:47 -05:00
|
|
|
{ 8, 274 },
|
2016-08-26 02:11:24 -04:00
|
|
|
4,
|
|
|
|
"Loop"
|
|
|
|
};
|
|
|
|
|
|
|
|
Button button_random {
|
2017-03-10 19:59:04 -05:00
|
|
|
{ 10 * 8, 34 * 8, 9 * 8, 32 },
|
2016-08-26 02:11:24 -04:00
|
|
|
"Random"
|
2016-05-09 14:42:20 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
Button button_exit {
|
2017-03-10 19:59:04 -05:00
|
|
|
{ 21 * 8, 34 * 8, 8 * 8, 32 },
|
2016-05-09 14:42:20 -04:00
|
|
|
"Exit"
|
|
|
|
};
|
2016-08-26 02:11:24 -04:00
|
|
|
|
|
|
|
MessageHandlerRegistration message_handler_fifo_signal {
|
2017-03-14 03:24:04 -04:00
|
|
|
Message::ID::RequestSignal,
|
2016-08-26 02:11:24 -04:00
|
|
|
[this](const Message* const p) {
|
2017-03-14 03:24:04 -04:00
|
|
|
const auto message = static_cast<const RequestSignalMessage*>(p);
|
|
|
|
if (message->signal == RequestSignalMessage::Signal::FillRequest) {
|
2016-08-26 02:11:24 -04:00
|
|
|
this->prepare_audio();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2016-05-09 14:42:20 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
} /* namespace ui */
|
2016-08-26 02:11:24 -04:00
|
|
|
|
|
|
|
#endif/*__UI_SOUNDBOARD_H__*/
|