Changeset 412
- Timestamp:
- 11/01/08 22:01:10 (16 years ago)
- Location:
- libreplaygain
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
libreplaygain/include/replaygain/gain_analysis.h
r403 r412 70 70 /// right_samples NULL, and make sure num_channels = 1. 71 71 72 Float_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 72 76 Float_t gain_get_title ( void ); 73 77 /// will return the recommended dB level change for all samples analyzed -
libreplaygain/src/gain_analysis.c
r403 r412 65 65 #define MAX_SAMP_FREQ 48000. // maximum allowed sample frequency [Hz] 66 66 #define RMS_WINDOW_TIME 0.050 // Time slice size [s] 67 #define STEPS_per_dB 100 .// Table entries per dB68 #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) 69 69 70 70 #define MAX_ORDER (BUTTER_ORDER > YULE_ORDER ? BUTTER_ORDER : YULE_ORDER) 71 71 #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) 72 73 #define PINK_REF 64.82 //298640883795 // calibration value 73 74 … … 90 91 static int freqindex; 91 92 static 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)]; 93 static int chap_void; // if == 0 gain_analyze_samples as been called 94 static Uint32_t A [ANALYZE_SIZE]; // chapter 95 static Uint32_t B [ANALYZE_SIZE]; // title 96 static Uint32_t C [ANALYZE_SIZE]; // album 94 97 95 98 // for each filter: … … 236 239 237 240 memset ( B, 0, sizeof(B) ); 241 memset ( C, 0, sizeof(C) ); 242 chap_void = 1; 238 243 239 244 return INIT_GAIN_ANALYSIS_OK; … … 349 354 int ival = (int) val; 350 355 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; 352 357 A [ival]++; 353 358 lsum = rsum = 0.; … … 371 376 memcpy ( rinprebuf, right_samples + num_samples - MAX_ORDER, MAX_ORDER * sizeof(Float_t) ); 372 377 } 378 chap_void = 0; 373 379 374 380 return GAIN_ANALYSIS_OK; … … 400 406 401 407 Float_t 402 gain_get_ title( void )408 gain_get_chapter ( void ) 403 409 { 404 410 Float_t retval; 405 411 int i; 406 412 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++ ) { 410 416 B[i] += A[i]; 411 417 A[i] = 0; … … 417 423 totsamp = 0; 418 424 lsum = rsum = 0.; 425 chap_void = 1; 419 426 return retval; 427 } 428 429 Float_t 430 gain_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; 420 446 } 421 447 … … 424 450 gain_get_album ( void ) 425 451 { 426 return analyzeResult ( B, sizeof(B)/sizeof(*B));452 return analyzeResult ( C, ANALYZE_SIZE ); 427 453 } 428 454
Note: See TracChangeset
for help on using the changeset viewer.