reduce phase shiift between subsequent tone buffers

This commit is contained in:
Andrew 2017-01-17 13:18:14 -08:00
parent 7463853757
commit 7685502c9b
3 changed files with 11 additions and 9 deletions

View File

@ -106,7 +106,7 @@ static void * ptt_thread (void *arg)
if (err == 0) { if (err == 0) {
short* pnData; short* pnData;
short sample; short sample;
int nSamples = save_audio_config_p->adev[a].samples_per_sec / 5; int nSamples = (int)( ( (double)save_audio_config_p->adev[a].samples_per_sec / (double)freq ) * ceil( (double)freq / 5.0 ) );
int nBufferLength = save_audio_config_p->adev[a].num_channels * nSamples * sizeof(short); int nBufferLength = save_audio_config_p->adev[a].num_channels * nSamples * sizeof(short);
int i; int i;
int j; int j;
@ -198,7 +198,7 @@ static void * ptt_thread (void *arg)
int i; int i;
int j; int j;
nSamples = samples_per_sec / 5; nSamples = (int)( ( (double)samples_per_sec / (double)freq ) * ceil( (double)freq / 5.0 ) );
nBufferLength = num_channels * nSamples * sizeof(short); nBufferLength = num_channels * nSamples * sizeof(short);
pnData = (short*)malloc (nBufferLength); pnData = (short*)malloc (nBufferLength);

View File

@ -1591,7 +1591,7 @@ void config_init (char *fname, struct audio_s *p_audio_config,
dw_printf ("Config file line %d: %s with RIG is only available when hamlib support is enabled.\n", line, otname); dw_printf ("Config file line %d: %s with RIG is only available when hamlib support is enabled.\n", line, otname);
#endif #endif
} }
else if (strcasecmp( t, "CHANNEL") == 0) { else if (strcasecmp(t, "CHANNEL") == 0) {
t = split(NULL, 0); t = split(NULL, 0);
if (t == NULL) { if (t == NULL) {
text_color_set( DW_COLOR_ERROR ); text_color_set( DW_COLOR_ERROR );

14
ptt.c
View File

@ -1138,15 +1138,17 @@ void ptt_term (void)
} }
for (n = 0; n < MAX_CHANS; n++) { for (n = 0; n < MAX_CHANS; n++) {
if (save_audio_config_p->achan[n].octrl[OCTYPE_PTT].ptt_method == PTT_METHOD_AUDIO) { if (save_audio_config_p->achan[n].valid) {
if (save_audio_config_p->achan[n].octrl[OCTYPE_PTT].ptt_method == PTT_METHOD_AUDIO) {
#ifdef __WIN32__ #ifdef __WIN32__
SetEvent (save_audio_config_p->achan[n].octrl[OCTYPE_PTT].ptt_close) ; SetEvent (save_audio_config_p->achan[n].octrl[OCTYPE_PTT].ptt_close) ;
#else #else
pthread_mutex_lock (&save_audio_config_p->achan[n].octrl[OCTYPE_PTT].ptt_mutex); pthread_mutex_lock (&save_audio_config_p->achan[n].octrl[OCTYPE_PTT].ptt_mutex);
save_audio_config_p->achan[n].octrl[OCTYPE_PTT].ptt_state = PTT_AUDIO_STATE_CLOSE; save_audio_config_p->achan[n].octrl[OCTYPE_PTT].ptt_state = PTT_AUDIO_STATE_CLOSE;
pthread_cond_signal (&save_audio_config_p->achan[n].octrl[OCTYPE_PTT].ptt_condition); pthread_cond_signal (&save_audio_config_p->achan[n].octrl[OCTYPE_PTT].ptt_condition);
pthread_mutex_unlock (&save_audio_config_p->achan[n].octrl[OCTYPE_PTT].ptt_mutex); pthread_mutex_unlock (&save_audio_config_p->achan[n].octrl[OCTYPE_PTT].ptt_mutex);
#endif #endif
}
} }
} }