mirror of
https://github.com/lwvmobile/dsd-fme.git
synced 2026-11-17 11:17:22 -05:00
Temp Commit WIP;
This commit is contained in:
@@ -1,5 +1,26 @@
|
|||||||
|
/*-------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* TODO: Fill me in'
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* LWVMOBILE
|
||||||
|
* 2023-07 DSD-FME Florida Man Edition
|
||||||
|
*-----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "dsd.h"
|
#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)
|
void agf (dsd_opts * opts, dsd_state * state, float samp[160], int slot)
|
||||||
{
|
{
|
||||||
int i, run;
|
int i, run;
|
||||||
@@ -7,9 +28,9 @@ void agf (dsd_opts * opts, dsd_state * state, float samp[160], int slot)
|
|||||||
float empty[160];
|
float empty[160];
|
||||||
memset (empty, 0.1f, sizeof(empty));
|
memset (empty, 0.1f, sizeof(empty));
|
||||||
|
|
||||||
float max = 0.0f;
|
|
||||||
float mmax = 0.75f;
|
float mmax = 0.75f;
|
||||||
float mmin = -0.75f;
|
float mmin = -0.75f;
|
||||||
|
float aavg = 0.0f; //average of the absolute value
|
||||||
float df; //decimation value
|
float df; //decimation value
|
||||||
|
|
||||||
if (slot == 0)
|
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++)
|
for (i = 0; i < 160; i++)
|
||||||
{
|
{
|
||||||
|
|
||||||
samp[i] = samp[i] / df;
|
samp[i] = samp[i] / df;
|
||||||
|
|
||||||
|
aavg += fabsf(samp[i]);
|
||||||
|
|
||||||
//simple clipping
|
//simple clipping
|
||||||
if (samp[i] > mmax)
|
if (samp[i] > mmax)
|
||||||
samp[i] = mmax;
|
samp[i] = mmax;
|
||||||
if (samp[i] < mmin)
|
if (samp[i] < mmin)
|
||||||
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 (slot == 0)
|
||||||
{
|
{
|
||||||
if (max < 0.351f && max > 0.1f && state->aout_gain < 42.0f) state->aout_gain++;
|
if (aavg < 0.075f && state->aout_gain < 42.0f) state->aout_gain += 1.0f;
|
||||||
if (max > 0.35f && state->aout_gain > 1.0f) state->aout_gain--;
|
if (aavg >= 0.075f && state->aout_gain > 1.0f) state->aout_gain -= 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (slot == 1)
|
if (slot == 1)
|
||||||
{
|
{
|
||||||
if (max < 0.351f && max > 0.1f && state->aout_gainR < 42) state->aout_gainR++;
|
if (aavg < 0.075f && state->aout_gainR < 42.0f) state->aout_gainR += 1.0f;
|
||||||
if (max > 0.35f && state->aout_gainR > 1) state->aout_gainR--;
|
if (aavg >= 0.075f && state->aout_gainR > 1.0f) state->aout_gainR -= 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (slot == 0)
|
//debug
|
||||||
// {
|
// fprintf (stderr, "\nS%d - DF = %f AAVG = %f", slot, df, aavg);
|
||||||
// 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;
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
AGF_END: ; //do nothing
|
AGF_END: ; //do nothing
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -720,9 +720,6 @@ initOpts (dsd_opts * opts)
|
|||||||
//Use P25p1 heuristics
|
//Use P25p1 heuristics
|
||||||
opts->use_heuristics = 0;
|
opts->use_heuristics = 0;
|
||||||
|
|
||||||
// if (opts->floating_point == 1)
|
|
||||||
// state->aout_gain = 25.0f;
|
|
||||||
|
|
||||||
} //initopts
|
} //initopts
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -1323,13 +1320,9 @@ liveScanner (dsd_opts * opts, dsd_state * state)
|
|||||||
|
|
||||||
if (opts->floating_point == 1)
|
if (opts->floating_point == 1)
|
||||||
{
|
{
|
||||||
//use this for now, but see if we can really start on zero later on
|
//continue testing for as high as we can go without it suddenly clipping
|
||||||
//when we have a more normalized gain attack
|
|
||||||
if (opts->audio_gain == 0)
|
|
||||||
opts->audio_gain = 25.0f;
|
|
||||||
|
|
||||||
opts->audio_gain /= 2.0f;
|
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)
|
// if (opts->audio_in_type == 1)
|
||||||
|
|||||||
@@ -17,6 +17,27 @@
|
|||||||
|
|
||||||
#include "dsd.h"
|
#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
|
int
|
||||||
getSymbol (dsd_opts * opts, dsd_state * state, int have_sync)
|
getSymbol (dsd_opts * opts, dsd_state * state, int have_sync)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user