mirror of
https://github.com/eried/portapack-mayhem.git
synced 2024-10-01 01:26:06 -04:00
More debug Audio Beep Test tweaks (#2028)
This commit is contained in:
parent
28a5fc5915
commit
81e24d582d
@ -35,39 +35,51 @@ AudioTestView::AudioTestView(NavigationView& nav)
|
|||||||
add_children({&labels,
|
add_children({&labels,
|
||||||
&options_sample_rate,
|
&options_sample_rate,
|
||||||
&field_frequency,
|
&field_frequency,
|
||||||
|
&options_step,
|
||||||
&field_duration,
|
&field_duration,
|
||||||
&field_volume,
|
&field_volume,
|
||||||
&toggle_speaker});
|
&toggle_speaker});
|
||||||
|
|
||||||
audio::set_rate(audio::Rate::Hz_24000);
|
audio::set_rate(audio::Rate::Hz_24000);
|
||||||
options_sample_rate.on_change = [this](size_t, int32_t v) {
|
options_sample_rate.on_change = [this](size_t, int32_t v) {
|
||||||
if (options_sample_rate.selected_index_value() == 24000) {
|
switch (v) {
|
||||||
audio::set_rate(audio::Rate::Hz_24000);
|
case 12000:
|
||||||
field_frequency.set_range(100, v / 2); // 24000/128 = ~100 (audio_dma uses 128 samples)
|
audio::set_rate(audio::Rate::Hz_12000);
|
||||||
} else {
|
break;
|
||||||
audio::set_rate(audio::Rate::Hz_48000);
|
case 24000:
|
||||||
field_frequency.set_range(200, v / 2); // 48000/128 = ~200
|
audio::set_rate(audio::Rate::Hz_24000);
|
||||||
|
break;
|
||||||
|
case 48000:
|
||||||
|
audio::set_rate(audio::Rate::Hz_48000);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
field_frequency.set_range(v / 128, v / 2);
|
||||||
update_audio_beep();
|
update_audio_beep();
|
||||||
};
|
};
|
||||||
|
options_sample_rate.set_selected_index(0, 1);
|
||||||
|
|
||||||
field_frequency.set_value(1000);
|
|
||||||
field_frequency.on_change = [this](int32_t) {
|
field_frequency.on_change = [this](int32_t) {
|
||||||
update_audio_beep();
|
update_audio_beep();
|
||||||
};
|
};
|
||||||
|
field_frequency.set_value(1000);
|
||||||
|
|
||||||
|
options_step.on_change = [this](size_t, int32_t v) {
|
||||||
|
field_frequency.set_step(v);
|
||||||
|
};
|
||||||
|
options_step.set_by_value(100);
|
||||||
|
|
||||||
field_duration.set_value(100);
|
|
||||||
field_duration.on_change = [this](int32_t v) {
|
field_duration.on_change = [this](int32_t v) {
|
||||||
(void)v;
|
(void)v;
|
||||||
update_audio_beep();
|
update_audio_beep();
|
||||||
};
|
};
|
||||||
|
field_duration.set_value(100);
|
||||||
|
|
||||||
toggle_speaker.on_change = [this](bool v) {
|
toggle_speaker.on_change = [this](bool v) {
|
||||||
beep = v;
|
beep = v;
|
||||||
update_audio_beep();
|
update_audio_beep();
|
||||||
};
|
};
|
||||||
|
|
||||||
field_volume.set_value(0);
|
field_volume.set_value(0); // seems that a change is required to force update, so setting to 0 first
|
||||||
field_volume.set_value(80);
|
field_volume.set_value(80);
|
||||||
|
|
||||||
audio::set_rate(audio::Rate::Hz_24000);
|
audio::set_rate(audio::Rate::Hz_24000);
|
||||||
|
@ -46,20 +46,31 @@ class AudioTestView : public View {
|
|||||||
Labels labels{
|
Labels labels{
|
||||||
{{7 * 8, 3 * 16}, "Audio Beep Test", Color::light_grey()},
|
{{7 * 8, 3 * 16}, "Audio Beep Test", Color::light_grey()},
|
||||||
{{0 * 8, 6 * 16}, "Sample Rate (Hz):", Color::light_grey()},
|
{{0 * 8, 6 * 16}, "Sample Rate (Hz):", Color::light_grey()},
|
||||||
|
{{25 * 8, 7 * 16}, "Step:", Color::light_grey()},
|
||||||
{{0 * 8, 8 * 16}, "Frequency (Hz):", Color::light_grey()},
|
{{0 * 8, 8 * 16}, "Frequency (Hz):", Color::light_grey()},
|
||||||
{{0 * 8, 10 * 16}, "Duration (ms):", Color::light_grey()},
|
{{0 * 8, 10 * 16}, "Duration (ms):", Color::light_grey()},
|
||||||
|
{{25 * 8, 10 * 16}, "0=con", Color::light_grey()},
|
||||||
{{0 * 8, 12 * 16}, "Volume:", Color::light_grey()}};
|
{{0 * 8, 12 * 16}, "Volume:", Color::light_grey()}};
|
||||||
|
|
||||||
OptionsField options_sample_rate{
|
OptionsField options_sample_rate{
|
||||||
{18 * 8, 6 * 16},
|
{18 * 8, 6 * 16},
|
||||||
5,
|
5,
|
||||||
{{"24000", 24000},
|
{{"24000", 24000},
|
||||||
{"48000", 48000}}};
|
{"48000", 48000},
|
||||||
|
{"12000", 12000}}};
|
||||||
|
|
||||||
|
OptionsField options_step{
|
||||||
|
{26 * 8, 8 * 16},
|
||||||
|
4,
|
||||||
|
{{" 1", 1},
|
||||||
|
{" 10", 10},
|
||||||
|
{" 100", 100},
|
||||||
|
{"1000", 1000}}};
|
||||||
|
|
||||||
NumberField field_frequency{
|
NumberField field_frequency{
|
||||||
{18 * 8, 8 * 16},
|
{18 * 8, 8 * 16},
|
||||||
5,
|
5,
|
||||||
{100, 24000 / 2},
|
{},
|
||||||
100,
|
100,
|
||||||
' ',
|
' ',
|
||||||
true};
|
true};
|
||||||
|
@ -27,7 +27,13 @@
|
|||||||
// Functions for audio beep (used by Sonde RSSI)
|
// Functions for audio beep (used by Sonde RSSI)
|
||||||
void ToneGen::configure_beep(const uint32_t freq, const uint32_t sample_rate) {
|
void ToneGen::configure_beep(const uint32_t freq, const uint32_t sample_rate) {
|
||||||
f_delta_ = (float)(freq * sizeof(sine_table_i8)) / sample_rate;
|
f_delta_ = (float)(freq * sizeof(sine_table_i8)) / sample_rate;
|
||||||
f_tone_phase_ = sizeof(sine_table_i8) / 4; // Start at sine peak to handle case of freq=sample_rate/2
|
f_tone_phase_ = 0.0;
|
||||||
|
|
||||||
|
// For higher frequencies, start at sine peak to handle case of freq=sample_rate/2;
|
||||||
|
// we don't want to sample the sine wave only when it's crossing 0!
|
||||||
|
// There is still an amplitude issue though depending on magnitude of selected sine sample deltas.
|
||||||
|
if (f_delta_ >= sizeof(sine_table_i8) / 4)
|
||||||
|
f_tone_phase_ = sizeof(sine_table_i8) / 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t ToneGen::process_beep() {
|
int16_t ToneGen::process_beep() {
|
||||||
|
Loading…
Reference in New Issue
Block a user