RGADamplitude2dB example

if (!isset($this->info['replay_gain']['reference_volume'])) {
                $this->info['replay_gain']['reference_volume'] = 89.0;
            }
            if (isset($this->info['replay_gain']['track']['adjustment'])) {
                $this->info['replay_gain']['track']['volume'] = $this->info['replay_gain']['reference_volume'] - $this->info['replay_gain']['track']['adjustment'];
            }
            if (isset($this->info['replay_gain']['album']['adjustment'])) {
                $this->info['replay_gain']['album']['volume'] = $this->info['replay_gain']['reference_volume'] - $this->info['replay_gain']['album']['adjustment'];
            }

            if (isset($this->info['replay_gain']['track']['peak'])) {
                $this->info['replay_gain']['track']['max_noclip_gain'] = 0 - getid3_lib::RGADamplitude2dB($this->info['replay_gain']['track']['peak']);
            }
            if (isset($this->info['replay_gain']['album']['peak'])) {
                $this->info['replay_gain']['album']['max_noclip_gain'] = 0 - getid3_lib::RGADamplitude2dB($this->info['replay_gain']['album']['peak']);
            }
        }
        return true;
    }

    /** * @return bool */
    
// LAME 3.94a16 and later - 9.23 fixed point                                 // ie 0x0059E2EE / (2^23) = 5890798 / 8388608 = 0.7022378444671630859375                                 $thisfile_mpeg_audio_lame_RGAD['peak_amplitude'] = (float) ((getid3_lib::BigEndian2Int(substr($headerstring$LAMEtagOffsetContant + 0xA7, 4))) / 8388608);
                            } else {
                                // LAME 3.94a15 and earlier - 32-bit floating point                                 // Actually 3.94a16 will fall in here too and be WRONG, but is hard to detect 3.94a16 vs 3.94a15                                 $thisfile_mpeg_audio_lame_RGAD['peak_amplitude'] = getid3_lib::LittleEndian2Float(substr($headerstring$LAMEtagOffsetContant + 0xA7, 4));
                            }
                            if ($thisfile_mpeg_audio_lame_RGAD['peak_amplitude'] == 0) {
                                unset($thisfile_mpeg_audio_lame_RGAD['peak_amplitude']);
                            } else {
                                $thisfile_mpeg_audio_lame_RGAD['peak_db'] = getid3_lib::RGADamplitude2dB($thisfile_mpeg_audio_lame_RGAD['peak_amplitude']);
                            }

                            $thisfile_mpeg_audio_lame_raw['RGAD_track']      =   getid3_lib::BigEndian2Int(substr($headerstring$LAMEtagOffsetContant + 0xAB, 2));
                            $thisfile_mpeg_audio_lame_raw['RGAD_album']      =   getid3_lib::BigEndian2Int(substr($headerstring$LAMEtagOffsetContant + 0xAD, 2));


                            if ($thisfile_mpeg_audio_lame_raw['RGAD_track'] != 0) {

                                $thisfile_mpeg_audio_lame_RGAD_track['raw']['name']        = ($thisfile_mpeg_audio_lame_raw['RGAD_track'] & 0xE000) >> 13;
                                $thisfile_mpeg_audio_lame_RGAD_track['raw']['originator']  = ($thisfile_mpeg_audio_lame_raw['RGAD_track'] & 0x1C00) >> 10;
                                $thisfile_mpeg_audio_lame_RGAD_track['raw']['sign_bit']    = ($thisfile_mpeg_audio_lame_raw['RGAD_track'] & 0x0200) >> 9;
                                
        // -5 -24.08 dB         // -6 -30.10 dB         // -7 -36.12 dB         // -8 -42.14 dB
        $fourbit = str_pad(decbin(($compre & 0xF0) >> 4), 4, '0', STR_PAD_LEFT);
        if ($fourbit[0] == '1') {
            $log_gain = -8 + bindec(substr($fourbit, 1));
        } else {
            $log_gain = bindec(substr($fourbit, 1));
        }
        $log_gain = ($log_gain + 1) * getid3_lib::RGADamplitude2dB(2);

        // The value of Y is a linear representation of a gain change of up to -6 dB. Y is considered to         // be an unsigned fractional integer, with a leading value of 1, or: 0.1 Y4 Y5 Y6 Y7 (base 2). Y can         // represent values between 0.111112 (or 31/32) and 0.100002 (or 1/2). Thus, Y can represent gain         // changes from -0.28 dB to -6.02 dB.
        $lin_gain = (16 + ($compre & 0x0F)) / 32;

        // The combination of X and Y values allows compr to indicate gain changes from         // 48.16 - 0.28 = +47.89 dB, to         // -42.14 - 6.02 = -48.16 dB.
Home | Imprint | This part of the site doesn't use cookies.