LittleEndian2Float example



                if (isset($thisfile_riff_WAVE['rgad'][0]['data'])) {

                    // shortcuts                     $rgadData = &$thisfile_riff_WAVE['rgad'][0]['data'];
                    $thisfile_riff_raw['rgad']    = array('track'=>array(), 'album'=>array());
                    $thisfile_riff_raw_rgad       = &$thisfile_riff_raw['rgad'];
                    $thisfile_riff_raw_rgad_track = &$thisfile_riff_raw_rgad['track'];
                    $thisfile_riff_raw_rgad_album = &$thisfile_riff_raw_rgad['album'];

                    $thisfile_riff_raw_rgad['fPeakAmplitude']      = getid3_lib::LittleEndian2Float(substr($rgadData, 0, 4));
                    $thisfile_riff_raw_rgad['nRadioRgAdjust']      =        $this->EitherEndian2Int(substr($rgadData, 4, 2));
                    $thisfile_riff_raw_rgad['nAudiophileRgAdjust'] =        $this->EitherEndian2Int(substr($rgadData, 6, 2));

                    $nRadioRgAdjustBitstring      = str_pad(getid3_lib::Dec2Bin($thisfile_riff_raw_rgad['nRadioRgAdjust']), 16, '0', STR_PAD_LEFT);
                    $nAudiophileRgAdjustBitstring = str_pad(getid3_lib::Dec2Bin($thisfile_riff_raw_rgad['nAudiophileRgAdjust']), 16, '0', STR_PAD_LEFT);
                    $thisfile_riff_raw_rgad_track['name']       = getid3_lib::Bin2Dec(substr($nRadioRgAdjustBitstring, 0, 3));
                    $thisfile_riff_raw_rgad_track['originator'] = getid3_lib::Bin2Dec(substr($nRadioRgAdjustBitstring, 3, 3));
                    $thisfile_riff_raw_rgad_track['signbit']    = getid3_lib::Bin2Dec(substr($nRadioRgAdjustBitstring, 6, 1));
                    $thisfile_riff_raw_rgad_track['adjustment'] = getid3_lib::Bin2Dec(substr($nRadioRgAdjustBitstring, 7, 9));
                    $thisfile_riff_raw_rgad_album['name']       = getid3_lib::Bin2Dec(substr($nAudiophileRgAdjustBitstring, 0, 3));
                    $thisfile_riff_raw_rgad_album['originator'] = getid3_lib::Bin2Dec(substr($nAudiophileRgAdjustBitstring, 3, 3));
                    
// bytes $A7-$AE Replay Gain                             // https://web.archive.org/web/20021015212753/http://privatewww.essex.ac.uk/~djmrob/replaygain/rg_data_format.html                             // bytes $A7-$AA : 32 bit floating point "Peak signal amplitude"                             if ($thisfile_mpeg_audio_lame['short_version'] >= 'LAME3.94b') {
                                // 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));


                            
Home | Imprint | This part of the site doesn't use cookies.