Browse Source

[alsa_io] add linear component to the dll and some dampening.

git-svn-id: svn+ssh://jackaudio.org/trunk/jack@3345 0c269be4-1314-0410-8aa9-9f06e86f4224
tags/0.117.0
torben 16 years ago
parent
commit
88f9fe85a4
2 changed files with 29 additions and 0 deletions
  1. +15
    -0
      tools/alsa_in.c
  2. +14
    -0
      tools/alsa_out.c

+ 15
- 0
tools/alsa_in.c View File

@@ -52,6 +52,8 @@ int num_periods = 2;
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 catch_factor = 1000;
int catch_factor2 = 1000000;
int good_window=0;

// Debug stuff:

@@ -307,9 +309,22 @@ int process (jack_nframes_t nframes, void *arg) {
double compute_factor = (double) nframes / frlen;

double diff_value = pow(current_resample_factor - compute_factor, 3) / (double) catch_factor;
diff_value += pow(current_resample_factor - compute_factor, 1) / (double) catch_factor2;

current_resample_factor -= diff_value;

if( good_window ) {
if( (offset > 150) || (offset < -150) ) {
good_window = 0;
}
} else {
if( (offset < 50) && (offset > -50) ) {
if( 0.0001 < fabs( current_resample_factor - ((double) sample_rate / (double) jack_sample_rate) ) )
current_resample_factor = ((double) sample_rate / (double) jack_sample_rate);
good_window = 1;
}
}

// clamp...
current_resample_factor = current_resample_factor < 0.25 ? 0.25 : current_resample_factor;



+ 14
- 0
tools/alsa_out.c View File

@@ -73,6 +73,7 @@ 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 catch_factor = 1000;
int catch_factor2 = 1000000;
int good_window=0;

// Debug stuff:

@@ -344,6 +345,19 @@ int process (jack_nframes_t nframes, void *arg) {
diff_value = pow(current_resample_factor - compute_factor, 3) / (double) catch_factor;
diff_value += pow(current_resample_factor - compute_factor, 1) / (double) catch_factor2;
current_resample_factor -= diff_value;

if( good_window ) {
if( (offset > 150) || (offset < -150) ) {
good_window = 0;
}
} else {
if( (offset < 50) && (offset > -50) ) {
if( 0.0001 < fabs( current_resample_factor - ((double) sample_rate / (double) jack_sample_rate) ) )
current_resample_factor = ((double) sample_rate / (double) jack_sample_rate);
good_window = 1;
}
}

periods_until_stability -= 1;
}
else


Loading…
Cancel
Save