minimodem carrier detect
This commit is contained in:
parent
4aa97884c4
commit
9e4ad3a2f7
@ -237,41 +237,37 @@ reprocess_audio:
|
|||||||
|
|
||||||
float msdelta = mag_mark - mag_space;
|
float msdelta = mag_mark - mag_space;
|
||||||
|
|
||||||
#define TRICK_DETECT ( 0.5 * MAX(mag_mark,mag_space) )
|
|
||||||
|
|
||||||
// Detect carrier
|
#define CD_MIN_TONEMAG 0.001
|
||||||
float mag_detect = 0.001;
|
#define CD_MIN_MSDELTA_RATIO 0.5
|
||||||
unsigned char carrier_detect =
|
|
||||||
mag_mark + mag_space > mag_detect
|
/* Detect bfsk carrier */
|
||||||
|
int carrier_detect /*boolean*/ =
|
||||||
|
mag_mark + mag_space > CD_MIN_TONEMAG
|
||||||
&&
|
&&
|
||||||
fabs(msdelta) >= TRICK_DETECT;
|
fabs(msdelta) > CD_MIN_MSDELTA_RATIO * MAX(mag_mark, mag_space);
|
||||||
|
|
||||||
#ifdef TRICK
|
#ifdef TRICK
|
||||||
|
|
||||||
// EXCELLENT trick -- fixes 300 baud perfectly
|
// EXCELLENT trick -- fixes 300 baud perfectly
|
||||||
// shift the input window if the msdelta is small
|
// shift the input window if the msdelta is small
|
||||||
static unsigned int skipped_frames = 0;
|
static unsigned int skipped_frames = 0;
|
||||||
if ( carrier_detected && fabs(msdelta) < TRICK_DETECT )
|
if ( ! carrier_detect )
|
||||||
{
|
{
|
||||||
# if 0
|
|
||||||
skipped_frames++;
|
|
||||||
if ( skipped_frames >= nsamples ) // maybe nsamples/2 ??
|
|
||||||
nframes = 0;
|
|
||||||
else
|
|
||||||
nframes = 1;
|
|
||||||
printf( "*" );
|
|
||||||
# else
|
|
||||||
|
|
||||||
if ( nframes == nsamples ) {
|
if ( nframes == nsamples ) {
|
||||||
|
#if 0
|
||||||
// nframes = nsamples / 2;
|
// nframes = nsamples / 2;
|
||||||
// nframes = nsamples / 16; // shift by 1/4 the bit width
|
nframes = nsamples / 4; // shift by 1/4 the bit width
|
||||||
nframes = 1;
|
|
||||||
nframes = nframes ? nframes : 1;
|
nframes = nframes ? nframes : 1;
|
||||||
|
#else
|
||||||
|
nframes = 1;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
skipped_frames += nframes;
|
skipped_frames += nframes;
|
||||||
if ( skipped_frames >= nsamples ) // maybe nsamples/2 ??
|
if ( skipped_frames >= nsamples ) // maybe nsamples/2 ??
|
||||||
nframes = 0;
|
nframes = 0;
|
||||||
# endif
|
|
||||||
if ( nframes ) {
|
if ( nframes ) {
|
||||||
size_t nbytes = nframes * pa_framesize;
|
size_t nbytes = nframes * pa_framesize;
|
||||||
size_t reuse_bytes = nsamples*pa_framesize - nbytes;
|
size_t reuse_bytes = nsamples*pa_framesize - nbytes;
|
||||||
@ -287,7 +283,7 @@ reprocess_audio:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( textscope ) {
|
if ( carrier_detect && textscope ) {
|
||||||
if ( skipped_frames )
|
if ( skipped_frames )
|
||||||
printf( "<skipped %u (of %u) frames>\n",
|
printf( "<skipped %u (of %u) frames>\n",
|
||||||
skipped_frames, nsamples);
|
skipped_frames, nsamples);
|
||||||
@ -298,6 +294,7 @@ reprocess_audio:
|
|||||||
|
|
||||||
unsigned char bit;
|
unsigned char bit;
|
||||||
|
|
||||||
|
|
||||||
if ( carrier_detect )
|
if ( carrier_detect )
|
||||||
{
|
{
|
||||||
bit = signbit(msdelta) ? 0 : 1;
|
bit = signbit(msdelta) ? 0 : 1;
|
||||||
@ -335,7 +332,7 @@ reprocess_audio:
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( ! carrier_detected )
|
if ( ! carrier_detected )
|
||||||
printf( "###CARRIER###\n");
|
printf( "###CARRIER###\n");
|
||||||
carrier_detected = carrier_detect;
|
carrier_detected = carrier_detect;
|
||||||
|
|
||||||
if ( textscope ) {
|
if ( textscope ) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user