Changeset 412


Ignore:
Timestamp:
11/01/08 22:01:10 (16 years ago)
Author:
r2d
Message:

libreplaygain can now handle chapters

Location:
libreplaygain
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • libreplaygain/include/replaygain/gain_analysis.h

    r403 r412  
    7070/// right_samples NULL, and make sure num_channels = 1.
    7171
     72Float_t gain_get_chapter ( void );
     73/// will return the recommended dB level change for all samples analyzed
     74/// SINCE THE LAST TIME you called gain_get_chapter() OR gain_init_analysis() OR gain_get_title.
     75
    7276Float_t gain_get_title ( void );
    7377/// will return the recommended dB level change for all samples analyzed
  • libreplaygain/src/gain_analysis.c

    r403 r412  
    6565#define MAX_SAMP_FREQ   48000.          // maximum allowed sample frequency [Hz]
    6666#define RMS_WINDOW_TIME     0.050       // Time slice size [s]
    67 #define STEPS_per_dB      100.          // Table entries per dB
    68 #define MAX_dB            120.          // Table entries for 0...MAX_dB (normal max. values are 70...80 dB)
     67#define STEPS_per_dB      100           // Table entries per dB
     68#define MAX_dB            120           // Table entries for 0...MAX_dB (normal max. values are 70...80 dB)
    6969
    7070#define MAX_ORDER               (BUTTER_ORDER > YULE_ORDER ? BUTTER_ORDER : YULE_ORDER)
    7171#define MAX_SAMPLES_PER_WINDOW  (size_t) (MAX_SAMP_FREQ * RMS_WINDOW_TIME)      // max. Samples per Time slice
     72#define ANALYZE_SIZE                    (STEPS_per_dB * MAX_dB)
    7273#define PINK_REF                64.82 //298640883795                              // calibration value
    7374
     
    9091static int      freqindex;
    9192static int      first;
    92 static Uint32_t A [(size_t)(STEPS_per_dB * MAX_dB)];
    93 static Uint32_t B [(size_t)(STEPS_per_dB * MAX_dB)];
     93static int              chap_void;      // if == 0 gain_analyze_samples as been called
     94static Uint32_t A [ANALYZE_SIZE];       // chapter
     95static Uint32_t B [ANALYZE_SIZE];       // title
     96static Uint32_t C [ANALYZE_SIZE];       // album
    9497
    9598// for each filter:
     
    236239
    237240    memset ( B, 0, sizeof(B) );
     241        memset ( C, 0, sizeof(C) );
     242        chap_void = 1;
    238243
    239244    return INIT_GAIN_ANALYSIS_OK;
     
    349354            int     ival = (int) val;
    350355            if ( ival <                     0 ) ival = 0;
    351             if ( ival >= (int)(sizeof(A)/sizeof(*A)) ) ival = sizeof(A)/sizeof(*A) - 1;
     356                        if ( ival >= ANALYZE_SIZE ) ival = ANALYZE_SIZE - 1;
    352357            A [ival]++;
    353358            lsum = rsum = 0.;
     
    371376        memcpy  ( rinprebuf, right_samples + num_samples - MAX_ORDER, MAX_ORDER * sizeof(Float_t) );
    372377    }
     378        chap_void = 0;
    373379
    374380    return GAIN_ANALYSIS_OK;
     
    400406
    401407Float_t
    402 gain_get_title ( void )
     408gain_get_chapter ( void )
    403409{
    404410    Float_t  retval;
    405411    int    i;
    406412
    407     retval = analyzeResult ( A, sizeof(A)/sizeof(*A) );
    408 
    409     for ( i = 0; i < (int)(sizeof(A)/sizeof(*A)); i++ ) {
     413        retval = analyzeResult ( A, ANALYZE_SIZE );
     414
     415        for ( i = 0; i < ANALYZE_SIZE; i++ ) {
    410416        B[i] += A[i];
    411417        A[i]  = 0;
     
    417423    totsamp = 0;
    418424    lsum    = rsum = 0.;
     425        chap_void = 1;
    419426    return retval;
     427}
     428
     429Float_t
     430gain_get_title ( void )
     431{
     432        Float_t  retval;
     433        int    i;
     434       
     435        if (chap_void == 0)
     436                gain_get_chapter();
     437       
     438        retval = analyzeResult ( B, ANALYZE_SIZE );
     439       
     440        for ( i = 0; i < ANALYZE_SIZE; i++ ) {
     441                C[i] += B[i];
     442                B[i]  = 0;
     443        }
     444       
     445        return retval;
    420446}
    421447
     
    424450gain_get_album ( void )
    425451{
    426     return analyzeResult ( B, sizeof(B)/sizeof(*B) );
     452        return analyzeResult ( C, ANALYZE_SIZE );
    427453}
    428454
Note: See TracChangeset for help on using the changeset viewer.