Temp Commit WIP;

This commit is contained in:
lwvmobile 2023-07-26 15:53:55 -04:00
parent a92736bb3a
commit d982a2b91e
3 changed files with 56 additions and 32 deletions

View File

@ -1,5 +1,26 @@
/*-------------------------------------------------------------------------------
*
*
*
* TODO: Fill me in'
*
*
* LWVMOBILE
* 2023-07 DSD-FME Florida Man Edition
*-----------------------------------------------------------------------------*/
#include "dsd.h"
//TODO: Add audio handling for left over types (X2-TDMA, dPMR, Provoice...MBEPlayback?)
//TODO: Test All voice decoders with all combos 'short mono, short stereo, float mono, float stereo)
//TODO: Look at upscaling on M17 codec 2 audio for OSS support and backport to 2.1b
//TODO: Clean comments and unused code in here
//TODO: Change + and - keys to allow switching to '0' on shorts for auto or manual with values
//CHECKLIST(PULSE): DMR BS(OK) DMR MS (OK) P25p1 (OK) P25p2 (OK) YSF (OK) NXDN (OK) M17 (short only!) pV (OK) dPMR (OK) MBEplayback (OK) X2-TDMA (who cares lol)
//TODO: WAV File saving (works fine on shorts, but on float, writing short to wav is not auto-gained, so super quiet, either convert to float wav files, or run processAudio AFTER memcpy of the temp_buf)
void agf (dsd_opts * opts, dsd_state * state, float samp[160], int slot)
{
int i, run;
@ -7,9 +28,9 @@ void agf (dsd_opts * opts, dsd_state * state, float samp[160], int slot)
float empty[160];
memset (empty, 0.1f, sizeof(empty));
float max = 0.0f;
float mmax = 0.75f;
float mmin = -0.75f;
float aavg = 0.0f; //average of the absolute value
float df; //decimation value
if (slot == 0)
@ -23,47 +44,36 @@ void agf (dsd_opts * opts, dsd_state * state, float samp[160], int slot)
for (i = 0; i < 160; i++)
{
samp[i] = samp[i] / df;
aavg += fabsf(samp[i]);
//simple clipping
if (samp[i] > mmax)
samp[i] = mmax;
if (samp[i] < mmin)
samp[i] = mmin;
//determine max value for adjustments
if (fabs(samp[i]) > max)
max = samp[i];
}
//crude auto gain for float values
aavg /= 160.0f;
if (slot == 0)
{
if (max < 0.351f && max > 0.1f && state->aout_gain < 42.0f) state->aout_gain++;
if (max > 0.35f && state->aout_gain > 1.0f) state->aout_gain--;
if (aavg < 0.075f && state->aout_gain < 42.0f) state->aout_gain += 1.0f;
if (aavg >= 0.075f && state->aout_gain > 1.0f) state->aout_gain -= 1.0f;
}
if (slot == 1)
{
if (max < 0.351f && max > 0.1f && state->aout_gainR < 42) state->aout_gainR++;
if (max > 0.35f && state->aout_gainR > 1) state->aout_gainR--;
if (aavg < 0.075f && state->aout_gainR < 42.0f) state->aout_gainR += 1.0f;
if (aavg >= 0.075f && state->aout_gainR > 1.0f) state->aout_gainR -= 1.0f;
}
// if (slot == 0)
// {
// if (max < 0.351f && max > 0.1f && state->aout_gain < 42.0f) state->aout_gain += 0.33f;
// if (max > 0.35f && state->aout_gain > 1.0f) state->aout_gain -= 0.33f;
// }
// if (slot == 1)
// {
// if (max < 0.351f && max > 0.1f && state->aout_gainR < 42) state->aout_gainR += 0.33f;
// if (max > 0.35f && state->aout_gainR > 1) state->aout_gainR -= 0.33f;
// }
//debug
// fprintf (stderr, "\nS%d - DF = %f AAVG = %f", slot, df, aavg);
AGF_END: ; //do nothing
}

View File

@ -720,9 +720,6 @@ initOpts (dsd_opts * opts)
//Use P25p1 heuristics
opts->use_heuristics = 0;
// if (opts->floating_point == 1)
// state->aout_gain = 25.0f;
} //initopts
void
@ -1323,13 +1320,9 @@ liveScanner (dsd_opts * opts, dsd_state * state)
if (opts->floating_point == 1)
{
//use this for now, but see if we can really start on zero later on
//when we have a more normalized gain attack
if (opts->audio_gain == 0)
opts->audio_gain = 25.0f;
//continue testing for as high as we can go without it suddenly clipping
opts->audio_gain /= 2.0f;
if (opts->audio_gain > 45.0f) opts->audio_gain = 45.0f;
if (opts->audio_gain > 42.0f) opts->audio_gain = 42.0f;
}
// if (opts->audio_in_type == 1)

View File

@ -17,6 +17,27 @@
#include "dsd.h"
//testing sending samples into this to get an RMS value
int disctap_rms(int16_t *samples, int len, int step) //use samplespersymbol as len
/* largely lifted from rtl_power */
{
int i;
long p, t, s;
double dc, err;
p = t = 0L;
for (i=0; i<len; i+=step) {
s = (long)samples[i];
t += s;
p += s * s;
}
/* correct for dc offset in squares */
dc = (double)(t*step) / (double)len;
err = t * 2 * dc - dc * dc * len;
return (int)sqrt((p-err) / len);
}
int
getSymbol (dsd_opts * opts, dsd_state * state, int have_sync)
{