::  
::  
::  > 
::  > As a value of 200 for BLACKSIZE showed an improvement in resampling, why
::  > does is still got a value as low as 25?
::  > 
::  > 
::  > Regards,
::  > 
::  > --
::  > 
::  > Gabriel Bouvigne - France
::  
::  Hi Gabriel,
::  
::  Increasing BLACKSIZE only improves the sharpness of the lowpass
::  cutoff.  For resampling, I dont think we need an extremely sharp
::  cutoff, and maybe a more gradual cutoff even sounds better?
::  
::  The problem David discovered (on that mp3.com posting) (aliasing onto
::  lower frequencies) was related to BPC - the number of precomputed
::  convolution functions.  LAME was precomputing only 16, but this is now
::  bumped up to 160 in lame 3.87.  
::  
::  I hope to add something soon which has it precompute the exact amount
::  needed.  Does anyone have code which computes the lcd (largest
::  common denominator) of two ints?  
::
Frequencies are real numbers, not integral numbers.
And I don't like code like:

    if ( Frequency == 44055 || Frequency == 44056 ) Frequency = 2863636/65.L;  // NTSC 
PCM
    if ( Frequency == 31468 || Frequency == 31469 ) Frequency = 2863636/91.L;  // NTSC 
Hi8 Digital
    if ( Frequency == 22254 || Frequency == 22255 ) Frequency =  244800/11.L;  // MAC 
HQ
    if ( Frequency == 11127 || Frequency == 11128 ) Frequency =  122400/11.L;  // MAC 
LQ
    if ( Frequency ==  8012 || Frequency ==  8013 ) Frequency =  312500/39.L;  // 
NeXT/Telco
    if ( Frequency ==  5512 || Frequency ==  5513 ) Frequency =   44100/ 8.L;  // 1/8 
CD

Table index search is done by:

double  Factorize ( const long double f1, const long double f2, int* x1, int* x2 )
{
    unsigned     i;
    long         ltmp;
    long double  ftmp;
    double       minerror = 1.;
    double       abserror = 1.;
    double       error;

    assert ( f1 > 0. );
    assert ( f2 > 0. );
    assert ( x1 != NULL );
    assert ( x2 != NULL );

    for ( i = 1; i <= MAX_TABLES; i++) {
        ftmp  = f2 * i / f1;
        ltmp  = (long) ( ftmp + 0.5 );
        error = fabs ( ltmp/ftmp - 1.);
        if ( error < minerror ) {
            *x1      = i;
            *x2      = (int)ltmp;
            minerror = error * 0.999999999;
            abserror = ltmp/ftmp - 1.;
        }
    }
    return abserror;
}

::  I think the number of windows needed
::  is given by:  out_samplerate/(lcd(in_samplerate,out_samplerate))
::  
::  (44.1khz -> 32khz requires 320 windows, but 48khz->32khz only
::  requires 4!)
::  
48 kHz -> 32 kHz requires 2 sets of coefficients. This coefficients are not
the windows. The window function is the same for all sets of coefficients.

You need setup code like:

    err = Factorize ( NewFrequency, Frequency, &iNew, &iOld );
    if ( err != 0. )
        fprintf ( stderr, "(%.6Lf => %.6Lf Hz, Ratio %u:%u, Error %+.3f ppm) ", 
Frequency, NewFrequency, iNew, iOld, 1.e6*err );
    else
        fprintf ( stderr, "(%.6Lf => %.6Lf Hz, Ratio %u:%u) ", Frequency, 
NewFrequency, iNew, iOld );

    ...

    for ( i = 0; i < iNew; i++ ) {
        k = imuldiv (i, iOld, iNew) - WINDOW_SIZE;

        (iNew < iOld ? Calc_Coeffs_Down : Calc_Coeffs_Up) ( Coeff [i], iNew, iOld, i, 
k );
    }



and transforming code like:

    for ( ...; i < ...; i++ ) {
        k = imuldiv (i, iOld, iNew) - WINDOW_SIZE;

        ScalarWindow ( Dest.fData [i], Coeff [i%iNew], sData + k );
    }


-- 
Mit freundlichen Grüßen
Frank Klemm
 
eMail | [EMAIL PROTECTED]       home: [EMAIL PROTECTED]
phone | +49 (3641) 64-2721    home: +49 (3641) 390545
sMail | R.-Breitscheid-Str. 43, 07747 Jena, Germany

--
MP3 ENCODER mailing list ( http://geek.rcc.se/mp3encoder/ )

Reply via email to