Ignore:
Timestamp:
04/25/08 17:03:53 (16 years ago)
Author:
r2d
Message:
  • reduced libreplaygain symbol exports
  • prefixed API function names with gain_
  • moved API info in header
  • added -fpic to compilation flags
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libreplaygain/src/gain_analysis.c

    r230 r403  
    3232
    3333/*
    34  *  Here's the deal. Call
    35  *
    36  *    InitGainAnalysis ( long samplefreq );
    37  *
    38  *  to initialize everything. Call
    39  *
    40  *    AnalyzeSamples ( const Float_t*  left_samples,
    41  *                     const Float_t*  right_samples,
    42  *                     size_t          num_samples,
    43  *                     int             num_channels );
    44  *
    45  *  as many times as you want, with as many or as few samples as you want.
    46  *  If mono, pass the sample buffer in through left_samples, leave
    47  *  right_samples NULL, and make sure num_channels = 1.
    48  *
    49  *    GetTitleGain()
    50  *
    51  *  will return the recommended dB level change for all samples analyzed
    52  *  SINCE THE LAST TIME you called GetTitleGain() OR InitGainAnalysis().
    53  *
    54  *    GetAlbumGain()
    55  *
    56  *  will return the recommended dB level change for all samples analyzed
    57  *  since InitGainAnalysis() was called and finalized with GetTitleGain().
    58  *
    59  *  Pseudo-code to process an album:
    60  *
    61  *    Float_t       l_samples [4096];
    62  *    Float_t       r_samples [4096];
    63  *    size_t        num_samples;
    64  *    unsigned int  num_songs;
    65  *    unsigned int  i;
    66  *
    67  *    InitGainAnalysis ( 44100 );
    68  *    for ( i = 1; i <= num_songs; i++ ) {
    69  *        while ( ( num_samples = getSongSamples ( song[i], left_samples, right_samples ) ) > 0 )
    70  *            AnalyzeSamples ( left_samples, right_samples, num_samples, 2 );
    71  *        fprintf ("Recommended dB change for song %2d: %+6.2f dB\n", i, GetTitleGain() );
    72  *    }
    73  *    fprintf ("Recommended dB change for whole album: %+6.2f dB\n", GetAlbumGain() );
    74  */
    75 
    76 /*
    7734 *  So here's the main source of potential code confusion:
    7835 *
     
    8138 *  AND up to <filter order> number of previous filtered samples.
    8239 *
    83  *  I set up the AnalyzeSamples routine to minimize memory usage and interface
     40 *  I set up the gain_analyze_samples routine to minimize memory usage and interface
    8441 *  complexity. The speed isn't compromised too much (I don't think), but the
    8542 *  internal complexity is higher than it should be for such a relatively
     
    11572#define PINK_REF                64.82 //298640883795                              // calibration value
    11673
    117 Float_t          linprebuf [MAX_ORDER * 2];
    118 Float_t*        linpre;                                          // left input samples, with pre-buffer
    119 Float_t          lstepbuf  [MAX_SAMPLES_PER_WINDOW + MAX_ORDER];
    120 Float_t*        lstep;                                           // left "first step" (i.e. post first filter) samples
    121 Float_t          loutbuf   [MAX_SAMPLES_PER_WINDOW + MAX_ORDER];
    122 Float_t*        lout;                                            // left "out" (i.e. post second filter) samples
    123 Float_t          rinprebuf [MAX_ORDER * 2];
    124 Float_t*        rinpre;                                          // right input samples ...
    125 Float_t          rstepbuf  [MAX_SAMPLES_PER_WINDOW + MAX_ORDER];
    126 Float_t*        rstep;
    127 Float_t          routbuf   [MAX_SAMPLES_PER_WINDOW + MAX_ORDER];
    128 Float_t*        rout;
    129 long             sampleWindow;                                    // number of samples required to reach number of milliseconds required for RMS window
    130 long             totsamp;
    131 double           lsum;
    132 double           rsum;
    133 int              freqindex;
    134 int              first;
    135 static Uint32_t  A [(size_t)(STEPS_per_dB * MAX_dB)];
    136 static Uint32_t  B [(size_t)(STEPS_per_dB * MAX_dB)];
     74static Float_t  linprebuf [MAX_ORDER * 2];
     75static Float_t* linpre;                                          // left input samples, with pre-buffer
     76static Float_t  lstepbuf  [MAX_SAMPLES_PER_WINDOW + MAX_ORDER];
     77static Float_t* lstep;                                           // left "first step" (i.e. post first filter) samples
     78static Float_t  loutbuf   [MAX_SAMPLES_PER_WINDOW + MAX_ORDER];
     79static Float_t* lout;                                            // left "out" (i.e. post second filter) samples
     80static Float_t  rinprebuf [MAX_ORDER * 2];
     81static Float_t* rinpre;                                          // right input samples ...
     82static Float_t  rstepbuf  [MAX_SAMPLES_PER_WINDOW + MAX_ORDER];
     83static Float_t* rstep;
     84static Float_t  routbuf   [MAX_SAMPLES_PER_WINDOW + MAX_ORDER];
     85static Float_t* rout;
     86static long     sampleWindow;                                    // number of samples required to reach number of milliseconds required for RMS window
     87static long     totsamp;
     88static double   lsum;
     89static double   rsum;
     90static int      freqindex;
     91static int      first;
     92static Uint32_t A [(size_t)(STEPS_per_dB * MAX_dB)];
     93static Uint32_t B [(size_t)(STEPS_per_dB * MAX_dB)];
    13794
    13895// for each filter:
     
    232189// returns a INIT_GAIN_ANALYSIS_OK if successful, INIT_GAIN_ANALYSIS_ERROR if not
    233190
    234 int
     191static int
    235192ResetSampleFrequency ( long samplefreq ) {
    236193    int  i;
     
    265222
    266223int
    267 InitGainAnalysis ( long samplefreq )
     224gain_init_analysis ( long samplefreq )
    268225{
    269226    if (ResetSampleFrequency(samplefreq) != INIT_GAIN_ANALYSIS_OK) {
     
    290247
    291248int
    292 AnalyzeSamples ( const Float_t* left_samples, const Float_t* right_samples, size_t num_samples, int num_channels )
     249gain_analyze_samples ( const Float_t* left_samples, const Float_t* right_samples, size_t num_samples, int num_channels )
    293250{
    294251    const Float_t*  curleft;
     
    443400
    444401Float_t
    445 GetTitleGain ( void )
     402gain_get_title ( void )
    446403{
    447404    Float_t  retval;
     
    465422
    466423Float_t
    467 GetAlbumGain ( void )
     424gain_get_album ( void )
    468425{
    469426    return analyzeResult ( B, sizeof(B)/sizeof(*B) );
Note: See TracChangeset for help on using the changeset viewer.