Skip to content

Commit

Permalink
Better handle high sample rate audio devices.
Browse files Browse the repository at this point in the history
  • Loading branch information
tmiw committed Jan 23, 2024
1 parent 943dad8 commit 3ef2125
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 17 deletions.
3 changes: 3 additions & 0 deletions src/audio/IAudioEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ int IAudioEngine::StandardSampleRates[] =
16000, 22050,
24000, 32000,
44100, 48000,
88200, 96000,
176400, 192000,
352800, 384000,
-1 // negative terminated list
};

Expand Down
27 changes: 10 additions & 17 deletions src/pipeline/TxRxThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -557,13 +557,6 @@ void TxRxThread::txProcessing_()
// sample rate. Typically the sound card is running at 48 or 44.1
// kHz, and the modem at 8kHz

// allocate enough room for 20ms processing buffers at maximum
// sample rate of 48 kHz. Note these buffer are used by rx and tx
// side processing

short insound_card[10*N48];
int nout;

//
// TX side processing --------------------------------------------
//
Expand Down Expand Up @@ -597,7 +590,11 @@ void TxRxThread::txProcessing_()
}

int nsam_in_48 = freedvInterface.getTxNumSpeechSamples() * ((float)inputSampleRate_ / (float)freedvInterface.getTxSpeechSampleRate());
assert(nsam_in_48 > 0 && nsam_in_48 < 10*N48);
assert(nsam_in_48 > 0);

short insound_card[nsam_in_48];
int nout;


while((unsigned)codec2_fifo_free(cbData->outfifo1) >= nsam_one_modem_frame) {
// OK to generate a frame of modem output samples we need
Expand Down Expand Up @@ -657,13 +654,6 @@ void TxRxThread::rxProcessing_()
// sample rate. Typically the sound card is running at 48 or 44.1
// kHz, and the modem at 8kHz.

// allocate enough room for 20ms processing buffers at maximum
// sample rate of 48 kHz. Note these buffer are used by rx and tx
// side processing

short insound_card[10*N48];
int nout;

//
// RX side processing --------------------------------------------
//
Expand All @@ -679,8 +669,11 @@ void TxRxThread::rxProcessing_()
// Attempt to read one processing frame (about 20ms) of receive samples, we
// keep this frame duration constant across modes and sound card sample rates
int nsam = (int)(inputSampleRate_ * FRAME_DURATION);
assert(nsam <= 10*N48);
assert(nsam != 0);
assert(nsam > 0);

short insound_card[nsam];
int nout;


bool processInputFifo =
(g_voice_keyer_tx && wxGetApp().appConfiguration.monitorVoiceKeyerAudio) ||
Expand Down

0 comments on commit 3ef2125

Please sign in to comment.