|
|
@@ -59,6 +59,8 @@ int target_delay = 0; /* the delay which the program should try to approach. |
|
|
int max_diff = 0; /* the diff value, when a hard readpointer skip should occur */ |
|
|
int max_diff = 0; /* the diff value, when a hard readpointer skip should occur */ |
|
|
int catch_factor = 100000; |
|
|
int catch_factor = 100000; |
|
|
int catch_factor2 = 10000; |
|
|
int catch_factor2 = 10000; |
|
|
|
|
|
double pclamp = 15.0; |
|
|
|
|
|
double controlquant = 10000.0; |
|
|
int good_window=0; |
|
|
int good_window=0; |
|
|
int verbose = 0; |
|
|
int verbose = 0; |
|
|
int instrument = 0; |
|
|
int instrument = 0; |
|
|
@@ -305,7 +307,7 @@ int process (jack_nframes_t nframes, void *arg) { |
|
|
* calculate the number of frames, we want to get. |
|
|
* calculate the number of frames, we want to get. |
|
|
*/ |
|
|
*/ |
|
|
|
|
|
|
|
|
double offset = (delay - target_delay); |
|
|
|
|
|
|
|
|
double offset = delay - target_delay; |
|
|
|
|
|
|
|
|
// Save offset. |
|
|
// Save offset. |
|
|
offset_array[(offset_differential_index++)% OFF_D_SIZE ] = offset; |
|
|
offset_array[(offset_differential_index++)% OFF_D_SIZE ] = offset; |
|
|
@@ -325,7 +327,7 @@ int process (jack_nframes_t nframes, void *arg) { |
|
|
// the smooth offset still contains unwanted noise |
|
|
// the smooth offset still contains unwanted noise |
|
|
// which would go straigth onto the resample coeff. |
|
|
// which would go straigth onto the resample coeff. |
|
|
// it only used in the P component and the I component is used for the fine tuning anyways. |
|
|
// it only used in the P component and the I component is used for the fine tuning anyways. |
|
|
if( fabs( smooth_offset ) < 15.0 ) |
|
|
|
|
|
|
|
|
if( fabs( smooth_offset ) < pclamp ) |
|
|
smooth_offset = 0.0; |
|
|
smooth_offset = 0.0; |
|
|
|
|
|
|
|
|
// ok. now this is the PI controller. |
|
|
// ok. now this is the PI controller. |
|
|
@@ -334,7 +336,7 @@ int process (jack_nframes_t nframes, void *arg) { |
|
|
double current_resample_factor = static_resample_factor - smooth_offset / (double) catch_factor - offset_integral / (double) catch_factor / (double)catch_factor2; |
|
|
double current_resample_factor = static_resample_factor - smooth_offset / (double) catch_factor - offset_integral / (double) catch_factor / (double)catch_factor2; |
|
|
|
|
|
|
|
|
// now quantize this value around resample_mean, so that the noise which is in the integral component doesnt hurt. |
|
|
// now quantize this value around resample_mean, so that the noise which is in the integral component doesnt hurt. |
|
|
current_resample_factor = floor( (current_resample_factor - resample_mean) * 10000.0 + 0.5 ) / 10000.0 + resample_mean; |
|
|
|
|
|
|
|
|
current_resample_factor = floor( (current_resample_factor - resample_mean) * controlquant + 0.5 ) / controlquant + resample_mean; |
|
|
|
|
|
|
|
|
// Output "instrumentatio" gonna change that to real instrumentation in a few. |
|
|
// Output "instrumentatio" gonna change that to real instrumentation in a few. |
|
|
output_resampling_factor = (float) current_resample_factor; |
|
|
output_resampling_factor = (float) current_resample_factor; |
|
|
@@ -347,8 +349,8 @@ int process (jack_nframes_t nframes, void *arg) { |
|
|
if( current_resample_factor > 4 ) current_resample_factor = 4; |
|
|
if( current_resample_factor > 4 ) current_resample_factor = 4; |
|
|
|
|
|
|
|
|
// Now Calculate how many samples we need. |
|
|
// Now Calculate how many samples we need. |
|
|
rlen = ceil( ((double)nframes) / current_resample_factor )+20; |
|
|
|
|
|
assert( rlen > 10 ); |
|
|
|
|
|
|
|
|
rlen = ceil( ((double)nframes) / current_resample_factor )+2; |
|
|
|
|
|
assert( rlen > 2 ); |
|
|
|
|
|
|
|
|
// Calculate resample_mean so we can init ourselves to saner values. |
|
|
// Calculate resample_mean so we can init ourselves to saner values. |
|
|
resample_mean = 0.9999 * resample_mean + 0.0001 * current_resample_factor; |
|
|
resample_mean = 0.9999 * resample_mean + 0.0001 * current_resample_factor; |
|
|
@@ -523,7 +525,7 @@ int main (int argc, char *argv[]) { |
|
|
int errflg=0; |
|
|
int errflg=0; |
|
|
int c; |
|
|
int c; |
|
|
|
|
|
|
|
|
while ((c = getopt(argc, argv, "ivj:r:c:p:n:d:m:t:f:")) != -1) { |
|
|
|
|
|
|
|
|
while ((c = getopt(argc, argv, "ivj:r:c:p:n:d:m:t:f:F:C:Q:")) != -1) { |
|
|
switch(c) { |
|
|
switch(c) { |
|
|
case 'j': |
|
|
case 'j': |
|
|
strcpy(jack_name,optarg); |
|
|
strcpy(jack_name,optarg); |
|
|
@@ -555,6 +557,12 @@ int main (int argc, char *argv[]) { |
|
|
case 'F': |
|
|
case 'F': |
|
|
catch_factor2 = atoi(optarg); |
|
|
catch_factor2 = atoi(optarg); |
|
|
break; |
|
|
break; |
|
|
|
|
|
case 'C': |
|
|
|
|
|
pclamp = (double) atoi(optarg); |
|
|
|
|
|
break; |
|
|
|
|
|
case 'Q': |
|
|
|
|
|
controlquant = (double) atoi(optarg); |
|
|
|
|
|
break; |
|
|
case 'v': |
|
|
case 'v': |
|
|
verbose = 1; |
|
|
verbose = 1; |
|
|
break; |
|
|
break; |
|
|
|