portapack-mayhem / mayhem-firmware

Custom firmware for the HackRF+PortaPack H1/H2
GNU General Public License v3.0
3.22k stars 530 forks source link

Add audio "beep" support #1973

Closed NotherNgineer closed 5 months ago

NotherNgineer commented 5 months ago

Description of the feature you're suggesting.

Reminder to myself to add support to baseband for outputting an audible tone of a specified frequency to the speaker/headphones (preferably sine wave).

To be used by apps in the future to represent signal strength (higher tone frequency = higher signal strength).

(Current baseband::request_beep() code only works in the Sonde app, and audio frequency and duration are not configurable.)

Anything else?

No response

RomanEmelyanov commented 5 months ago

What we need to do to make a beep via speaker/audio_jack from UI app? I'm trying to add "baseband::request_beep();" to LookingGlass app (for make a noise on specific power level) , but it's not enough ...

NotherNgineer commented 5 months ago

At the moment, only proc_sonde supports baseband::request_beep(), for balloon tracking.

For this enhancement suggestion I was hoping to implement something a bit nicer (with less code and control over audio frequency and beep duration, for example), but I haven't finished it yet.

For now, one option might be to port the beep code from proc_sonde over to proc_wideband_spectrum (background process used by the Looking Glass app).

RomanEmelyanov commented 5 months ago

For debug purpose I'm add to proc_sonde.cpp two lines of code:

check_beep.on_select = [this](Checkbox&, bool v) {
        beep = v;
        baseband::request_beep(); // make sound on press 'BEEP' checkbox
        nav_.display_modal("Beep", "Did you listen beep?"); // show question
    };

but no voice via speaker/audio_jack, any suggestion ?

NotherNgineer commented 5 months ago

You are correct; looks like the old beep code doesn't work.

NotherNgineer commented 5 months ago

@RomanEmelyanov, fyi, PR #2012 should fix the Sonde RSSI Beep support, which you might now be able to use as an example for Looking Glass (see the audio::dma code in proc_sonde)

RomanEmelyanov commented 5 months ago

@NotherNgineer beep in sonde app works perfect)

But I have some troubles with beep in Looking glass app.

I'm add to file 'proc_wideband_spectrum.hpp' this peace of code:

void WidebandSpectrum::on_message(const Message* const msg) {
...
        case Message::ID::AudioBeep:
            on_beep_message(*reinterpret_cast<const AudioBeepMessage*>(msg));
            break;
...
void WidebandSpectrum::on_beep_message(const AudioBeepMessage& message) {
    audio::dma::beep_start(message.freq, AUDIO_SAMPLE_RATE, message.duration_ms);
}

and try to invoke 'baseband::request_audio_beep()' from 'GlassView::add_spectrum_pixel'@ui_looking_glass_app.cpp

But no sound, I'm something missing to add?

gullradriel commented 5 months ago

Looking glass is already having beep sound. You can check the source in next.

RomanEmelyanov commented 5 months ago

Looking glass is already having beep sound. You can check the source in next.

I'm use the old code, Thanks a lot!