00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef GAIN_ANALYSIS_H
00029 #define GAIN_ANALYSIS_H
00030
00031 #ifdef HAVE_INTTYPES_H
00032 # include <inttypes.h>
00033 #else
00034 # ifdef HAVE_STDINT_H
00035 # include <stdint.h>
00036 # endif
00037 #endif
00038
00039 #ifdef __cplusplus
00040 extern "C" {
00041 #endif
00042
00043
00044 typedef sample_t Float_t;
00045
00046
00047 #define PINK_REF 64.82
00048
00049
00050 #define YULE_ORDER 10
00051 #define BUTTER_ORDER 2
00052 #define YULE_FILTER filterYule
00053 #define BUTTER_FILTER filterButter
00054 #define RMS_PERCENTILE 0.95
00055 #define MAX_SAMP_FREQ 48000L
00056 #define RMS_WINDOW_TIME_NUMERATOR 1L
00057 #define RMS_WINDOW_TIME_DENOMINATOR 20L
00058 #define STEPS_per_dB 100.
00059 #define MAX_dB 120.
00060
00061 enum { GAIN_NOT_ENOUGH_SAMPLES = -24601, GAIN_ANALYSIS_ERROR = 0, GAIN_ANALYSIS_OK =
00062 1, INIT_GAIN_ANALYSIS_ERROR = 0, INIT_GAIN_ANALYSIS_OK = 1
00063 };
00064
00065 enum { MAX_ORDER = (BUTTER_ORDER > YULE_ORDER ? BUTTER_ORDER : YULE_ORDER)
00066 , MAX_SAMPLES_PER_WINDOW = ((MAX_SAMP_FREQ * RMS_WINDOW_TIME_NUMERATOR) / RMS_WINDOW_TIME_DENOMINATOR + 1)
00067 };
00068
00069 struct replaygain_data {
00070 Float_t linprebuf[MAX_ORDER * 2];
00071 Float_t *linpre;
00072 Float_t lstepbuf[MAX_SAMPLES_PER_WINDOW + MAX_ORDER];
00073 Float_t *lstep;
00074 Float_t loutbuf[MAX_SAMPLES_PER_WINDOW + MAX_ORDER];
00075 Float_t *lout;
00076 Float_t rinprebuf[MAX_ORDER * 2];
00077 Float_t *rinpre;
00078 Float_t rstepbuf[MAX_SAMPLES_PER_WINDOW + MAX_ORDER];
00079 Float_t *rstep;
00080 Float_t routbuf[MAX_SAMPLES_PER_WINDOW + MAX_ORDER];
00081 Float_t *rout;
00082 long sampleWindow;
00083 long totsamp;
00084 double lsum;
00085 double rsum;
00086 int freqindex;
00087 int first;
00088 uint32_t A[(size_t) (STEPS_per_dB * MAX_dB)];
00089 uint32_t B[(size_t) (STEPS_per_dB * MAX_dB)];
00090
00091 };
00092 #ifndef replaygain_data_defined
00093 #define replaygain_data_defined
00094 typedef struct replaygain_data replaygain_t;
00095 #endif
00096
00097
00098
00099
00100 int InitGainAnalysis(replaygain_t * rgData, long samplefreq);
00101 int AnalyzeSamples(replaygain_t * rgData, const Float_t * left_samples,
00102 const Float_t * right_samples, size_t num_samples, int num_channels);
00103 int ResetSampleFrequency(replaygain_t * rgData, long samplefreq);
00104 Float_t GetTitleGain(replaygain_t * rgData);
00105 Float_t GetAlbumGain(replaygain_t * rgData);
00106
00107
00108 #ifdef __cplusplus
00109 }
00110 #endif
00111 #endif