Browse Source

[alsa-out] some changes again.

tools/.libs/alsa_out -d hw:1 -p128 -n7 -m256 -f10000000 -F8020 -i >alsa_out.dat

git-svn-id: svn+ssh://jackaudio.org/trunk/jack@3380 0c269be4-1314-0410-8aa9-9f06e86f4224
tags/0.117.0
torben 17 years ago
parent
commit
d68137aaea
1 changed files with 12 additions and 4 deletions
  1. +12
    -4
      tools/alsa_out.c

+ 12
- 4
tools/alsa_out.c View File

@@ -39,7 +39,7 @@
(d) = f_round ((s) * SAMPLE_16BIT_SCALING);\
}

#define OFF_D_SIZE 128
#define OFF_D_SIZE 256

typedef signed short ALSASAMPLE;

@@ -70,6 +70,8 @@ int offset_differential_index = 0;
double old_resample_factor = 1.0;
double old_old_resample_factor = 1.0;
double dd_resample_factor = 0.0;

double offset_integral = 0;
// ------------------------------------------------------ commandline parameters

int sample_rate = 0; /* stream rate */
@@ -281,6 +283,7 @@ double hann( double x )
}

int jumped = 0;
int delay_offset = 0;
/**
* The process callback for this JACK application.
* It is called by JACK at the appropriate times.
@@ -368,22 +371,26 @@ int process (jack_nframes_t nframes, void *arg) {
smooth_offset /= (double) OFF_D_SIZE;

////////////////////////
dd_resample_factor = 0.999 * dd_resample_factor + 0.001 * smooth_offset_differential;
dd_resample_factor = 0.99 * dd_resample_factor + 0.01 * smooth_offset_differential;
smooth_offset_differential = dd_resample_factor;
///////////////////////////////////
old_offset = offset;

offset_integral += offset;

current_resample_factor -= pow(offset/ (double) nframes, 3) / (double) catch_factor;
current_resample_factor -= smooth_offset_differential / (double) nframes / (double)catch_factor2;
//current_resample_factor -= offset_integral / (double) nframes / (double)10000000 / (double) catch_factor;

//current_resample_factor -= pow(smooth_offset/ (double) nframes, 3) / (double) catch_factor;
//current_resample_factor -= dd_resample_factor/(double)nframes * 5.0;
current_resample_factor -= smooth_offset_differential / (double) nframes / (double)catch_factor2;

// Dampening:
// use hysteresis, only do it once offset was more than 150 off,
// and now came into 50samples window.
// Also only damp when current_resample_factor is more than 0.01% off.
if( good_window ) {
if( (offset > max_diff*3/4) || (offset < max_diff*3/4) ) {
if( (offset > max_diff*2/4) || (offset < -max_diff*2/4) ) {
good_window = 0;
}
} else {
@@ -456,6 +463,7 @@ int process (jack_nframes_t nframes, void *arg) {
}

// now write the output...
delay_offset += (nframes-src.output_frames_gen);
again:
err = snd_pcm_writei(alsa_handle, outbuf, src.output_frames_gen);
//err = snd_pcm_writei(alsa_handle, outbuf, src.output_frames_gen);


Loading…
Cancel
Save