本文整理匯總了PHP中getid3_lib::trunc方法的典型用法代碼示例。如果您正苦於以下問題:PHP getid3_lib::trunc方法的具體用法?PHP getid3_lib::trunc怎麽用?PHP getid3_lib::trunc使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類getid3_lib
的用法示例。
在下文中一共展示了getid3_lib::trunc方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: Float2BinaryDecimal
static function Float2BinaryDecimal($floatvalue)
{
// http://www.scri.fsu.edu/~jac/MAD3401/Backgrnd/binary.html
$maxbits = 128;
// to how many bits of precision should the calculations be taken?
$intpart = getid3_lib::trunc($floatvalue);
$floatpart = abs($floatvalue - $intpart);
$pointbitstring = '';
while ($floatpart != 0 && strlen($pointbitstring) < $maxbits) {
$floatpart *= 2;
$pointbitstring .= (string) getid3_lib::trunc($floatpart);
$floatpart -= getid3_lib::trunc($floatpart);
}
$binarypointnumber = decbin($intpart) . '.' . $pointbitstring;
return $binarypointnumber;
}
示例2: Analyze
function Analyze()
{
$info =& $this->getid3->info;
$OriginalAVdataOffset = $info['avdataoffset'];
fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
$VOCheader = fread($this->getid3->fp, 26);
$magic = 'Creative Voice File';
if (substr($VOCheader, 0, 19) != $magic) {
$info['error'][] = 'Expecting "' . getid3_lib::PrintHexBytes($magic) . '" at offset ' . $info['avdataoffset'] . ', found "' . getid3_lib::PrintHexBytes(substr($VOCheader, 0, 19)) . '"';
return false;
}
// shortcuts
$thisfile_audio =& $info['audio'];
$info['voc'] = array();
$thisfile_voc =& $info['voc'];
$info['fileformat'] = 'voc';
$thisfile_audio['dataformat'] = 'voc';
$thisfile_audio['bitrate_mode'] = 'cbr';
$thisfile_audio['lossless'] = true;
$thisfile_audio['channels'] = 1;
// might be overriden below
$thisfile_audio['bits_per_sample'] = 8;
// might be overriden below
// byte # Description
// ------ ------------------------------------------
// 00-12 'Creative Voice File'
// 13 1A (eof to abort printing of file)
// 14-15 Offset of first datablock in .voc file (std 1A 00 in Intel Notation)
// 16-17 Version number (minor,major) (VOC-HDR puts 0A 01)
// 18-19 2's Comp of Ver. # + 1234h (VOC-HDR puts 29 11)
$thisfile_voc['header']['datablock_offset'] = getid3_lib::LittleEndian2Int(substr($VOCheader, 20, 2));
$thisfile_voc['header']['minor_version'] = getid3_lib::LittleEndian2Int(substr($VOCheader, 22, 1));
$thisfile_voc['header']['major_version'] = getid3_lib::LittleEndian2Int(substr($VOCheader, 23, 1));
do {
$BlockOffset = ftell($this->getid3->fp);
$BlockData = fread($this->getid3->fp, 4);
$BlockType = ord($BlockData[0]);
$BlockSize = getid3_lib::LittleEndian2Int(substr($BlockData, 1, 3));
$ThisBlock = array();
getid3_lib::safe_inc($thisfile_voc['blocktypes'][$BlockType], 1);
switch ($BlockType) {
case 0:
// Terminator
// do nothing, we'll break out of the loop down below
break;
case 1:
// Sound data
$BlockData .= fread($this->getid3->fp, 2);
if ($info['avdataoffset'] <= $OriginalAVdataOffset) {
$info['avdataoffset'] = ftell($this->getid3->fp);
}
fseek($this->getid3->fp, $BlockSize - 2, SEEK_CUR);
$ThisBlock['sample_rate_id'] = getid3_lib::LittleEndian2Int(substr($BlockData, 4, 1));
$ThisBlock['compression_type'] = getid3_lib::LittleEndian2Int(substr($BlockData, 5, 1));
$ThisBlock['compression_name'] = $this->VOCcompressionTypeLookup($ThisBlock['compression_type']);
if ($ThisBlock['compression_type'] <= 3) {
$thisfile_voc['compressed_bits_per_sample'] = getid3_lib::CastAsInt(str_replace('-bit', '', $ThisBlock['compression_name']));
}
// Less accurate sample_rate calculation than the Extended block (#8) data (but better than nothing if Extended Block is not available)
if (empty($thisfile_audio['sample_rate'])) {
// SR byte = 256 - (1000000 / sample_rate)
$thisfile_audio['sample_rate'] = getid3_lib::trunc(1000000 / (256 - $ThisBlock['sample_rate_id']) / $thisfile_audio['channels']);
}
break;
case 2:
// Sound continue
// Sound continue
case 3:
// Silence
// Silence
case 4:
// Marker
// Marker
case 6:
// Repeat
// Repeat
case 7:
// End repeat
// nothing useful, just skip
fseek($this->getid3->fp, $BlockSize, SEEK_CUR);
break;
case 8:
// Extended
$BlockData .= fread($this->getid3->fp, 4);
//00-01 Time Constant:
// Mono: 65536 - (256000000 / sample_rate)
// Stereo: 65536 - (256000000 / (sample_rate * 2))
$ThisBlock['time_constant'] = getid3_lib::LittleEndian2Int(substr($BlockData, 4, 2));
$ThisBlock['pack_method'] = getid3_lib::LittleEndian2Int(substr($BlockData, 6, 1));
$ThisBlock['stereo'] = (bool) getid3_lib::LittleEndian2Int(substr($BlockData, 7, 1));
$thisfile_audio['channels'] = $ThisBlock['stereo'] ? 2 : 1;
$thisfile_audio['sample_rate'] = getid3_lib::trunc(256000000 / (65536 - $ThisBlock['time_constant']) / $thisfile_audio['channels']);
break;
case 9:
// data block that supersedes blocks 1 and 8. Used for stereo, 16 bit
$BlockData .= fread($this->getid3->fp, 12);
if ($info['avdataoffset'] <= $OriginalAVdataOffset) {
$info['avdataoffset'] = ftell($this->getid3->fp);
}
fseek($this->getid3->fp, $BlockSize - 12, SEEK_CUR);
//.........這裏部分代碼省略.........