BigEndian2Float example

break;
                                                    case EBML_ID_TRACKNUMBER:
                                                    case EBML_ID_TRACKTYPE:
                                                    case EBML_ID_MINCACHE:
                                                    case EBML_ID_MAXCACHE:
                                                    case EBML_ID_MAXBLOCKADDITIONID:
                                                    case EBML_ID_DEFAULTDURATION: // nanoseconds per frame                                                         $track_entry[$subelement['id_name']] = getid3_lib::BigEndian2Int($subelement['data']);
                                                        break;

                                                    case EBML_ID_TRACKTIMECODESCALE:
                                                        $track_entry[$subelement['id_name']] = getid3_lib::BigEndian2Float($subelement['data']);
                                                        break;

                                                    case EBML_ID_CODECID:
                                                    case EBML_ID_LANGUAGE:
                                                    case EBML_ID_NAME:
                                                    case EBML_ID_CODECNAME:
                                                        $track_entry[$subelement['id_name']] = getid3_lib::trimNullByte($subelement['data']);
                                                        break;

                                                    case EBML_ID_CODECPRIVATE:
                                                        $track_entry[$subelement['id_name']] = $this->readEBMLelementData($subelement['length'], true);
                                                        

                }

                if (isset($thisfile_riff[$RIFFsubtype]['COMM'][0]['data'])) {

                    // shortcut                     $thisfile_riff_RIFFsubtype_COMM_0_data = &$thisfile_riff[$RIFFsubtype]['COMM'][0]['data'];

                    $thisfile_riff_audio['channels']         =         getid3_lib::BigEndian2Int(substr($thisfile_riff_RIFFsubtype_COMM_0_data,  0,  2), true);
                    $thisfile_riff_audio['total_samples']    =         getid3_lib::BigEndian2Int(substr($thisfile_riff_RIFFsubtype_COMM_0_data,  2,  4), false);
                    $thisfile_riff_audio['bits_per_sample']  =         getid3_lib::BigEndian2Int(substr($thisfile_riff_RIFFsubtype_COMM_0_data,  6,  2), true);
                    $thisfile_riff_audio['sample_rate']      = (int) getid3_lib::BigEndian2Float(substr($thisfile_riff_RIFFsubtype_COMM_0_data,  8, 10));

                    if ($thisfile_riff[$RIFFsubtype]['COMM'][0]['size'] > 18) {
                        $thisfile_riff_audio['codec_fourcc'] =                                   substr($thisfile_riff_RIFFsubtype_COMM_0_data, 18,  4);
                        $CodecNameSize                       =         getid3_lib::BigEndian2Int(substr($thisfile_riff_RIFFsubtype_COMM_0_data, 22,  1), false);
                        $thisfile_riff_audio['codec_name']   =                                   substr($thisfile_riff_RIFFsubtype_COMM_0_data, 23,  $CodecNameSize);
                        switch ($thisfile_riff_audio['codec_name']) {
                            case 'NONE':
                                $thisfile_audio['codec']    = 'Pulse Code Modulation (PCM)';
                                $thisfile_audio['lossless'] = true;
                                break;

                            
            // There may only be one 'RGAD' frame in a tag             // <Header for 'Replay Gain Adjustment', ID: 'RGAD'>             // Peak Amplitude $xx $xx $xx $xx             // Radio Replay Gain Adjustment %aaabbbcd %dddddddd             // Audiophile Replay Gain Adjustment %aaabbbcd %dddddddd             // a - name code             // b - originator code             // c - sign bit             // d - replay gain adjustment
            $frame_offset = 0;
            $parsedFrame['peakamplitude'] = getid3_lib::BigEndian2Float(substr($parsedFrame['data']$frame_offset, 4));
            $frame_offset += 4;
            foreach (array('track','album') as $rgad_entry_type) {
                $rg_adjustment_word = getid3_lib::BigEndian2Int(substr($parsedFrame['data']$frame_offset, 2));
                $frame_offset += 2;
                $parsedFrame['raw'][$rgad_entry_type]['name']       = ($rg_adjustment_word & 0xE000) >> 13;
                $parsedFrame['raw'][$rgad_entry_type]['originator'] = ($rg_adjustment_word & 0x1C00) >> 10;
                $parsedFrame['raw'][$rgad_entry_type]['signbit']    = ($rg_adjustment_word & 0x0200) >>  9;
                $parsedFrame['raw'][$rgad_entry_type]['adjustment'] = ($rg_adjustment_word & 0x0100);
            }
            $parsedFrame['track']['name']       = getid3_lib::RGADnameLookup($parsedFrame['raw']['track']['name']);
            $parsedFrame['track']['originator'] = getid3_lib::RGADoriginatorLookup($parsedFrame['raw']['track']['originator']);
            
$fractionbitstring = str_pad(substr($normalizedbinary['normalized'], 2)$fractionbits, '0', STR_PAD_RIGHT);

        return self::BigEndian2String(self::Bin2Dec($signbit.$exponentbitstring.$fractionbitstring)$bits % 8, false);
    }

    /** * @param string $byteword * * @return float|false */
    public static function LittleEndian2Float($byteword) {
        return self::BigEndian2Float(strrev($byteword));
    }

    /** * ANSI/IEEE Standard 754-1985, Standard for Binary Floating Point Arithmetic * * @link https://web.archive.org/web/20120325162206/http://www.psc.edu/general/software/packages/ieee/ieee.php * @link http://www.scri.fsu.edu/~jac/MAD3401/Backgrnd/ieee.html * * @param string $byteword * * @return float|false */
/** * @return int */
    public function readLong() { // 32-bit         return ($this->readByte() << 24) + ($this->readByte() << 16) + ($this->readByte() << 8) + $this->readByte();
    }

    /** * @return float|false */
    public function readDouble() {
        return getid3_lib::BigEndian2Float($this->read(8));
    }

    /** * @return string */
    public function readUTF() {
        $length = $this->readInt();
        return $this->read($length);
    }

    /** * @return string */
Home | Imprint | This part of the site doesn't use cookies.