function parseChunkData() { if (isset($this->detail)) { return; } $detailData = array(); $id = $this->id; $reader = new IO_Bit(); $reader->input($this->data); $this->data = null; // XXX switch ($id) { // INFO sub-chunks case 'ifil': $detailData['sfVersionMajor'] = $reader->getUI16LE(); $detailData['sfVersionMinor'] = $reader->getUI16LE(); break; case 'INAM': $detailData['sfName'] = $this->data; // String break; case 'isng': $detailData['sfEngine'] = $this->data; // String break; case 'IENG': $detailData['sfEngineers'] = $this->data; // String break; case 'ISFT': $detailData['sfTools'] = $this->data; // String break; case 'ICMT': $detailData['Comments'] = $this->data; // String break; case 'ICOP': $detailData['Copyright'] = $this->data; // String break; // sdta sub-chunks // sdta sub-chunks case 'smpl': $detailData['Samples'] = $this->data; // String break; // pdta sub-chunks // pdta sub-chunks case 'phdr': $detailData = array(); while ($reader->hasNextData()) { $preset = array(); $presetName = explode("", $reader->getData(20)); $preset['PresetName'] = $presetName[0]; $preset['Preset'] = $reader->getUI16LE(); $preset['Bank'] = $reader->getUI16LE(); $preset['PresetBagNdx'] = $reader->getUI16LE(); $preset['Library'] = $reader->getUI32LE(); $preset['Genre'] = $reader->getUI32LE(); $preset['MorphologyGenre'] = $reader->getUI32LE(); $detailData[] = $preset; } break; case 'pbag': $detailData = array(); while ($reader->hasNextData()) { $presetBag = array(); $presetBag['GenNdx'] = $reader->getUI16LE(); $presetBag['ModNdx'] = $reader->getUI16LE(); $detailData[] = $presetBag; } break; case 'pmod': case 'imod': $detailData = array(); while ($reader->hasNextData()) { $sfMod = array(); $sfMod['sfModSrcOper'] = IO_SoundFont_Modulator::parse($reader); $sfMod['sfModDestOper'] = $reader->getUI16LE(); $sfMod['modAmount'] = $reader->getSI16LE(); $sfMod['sfModAmtSrcOper'] = IO_SoundFont_Modulator::parse($reader); $sfMod['sfModTransOper'] = $reader->getUI16LE(); $detailData[] = $sfMod; } break; case 'pgen': case 'igen': $detailData = array(); while ($reader->hasNextData()) { $detailData[] = IO_SoundFont_Generator::parse($reader); } break; case 'inst': $detailData = array(); while ($reader->hasNextData()) { $sfInst = array(); $InstName = explode("", $reader->getData(20)); $sfInst['InstName'] = $InstName[0]; $sfInst['InstBagNdx'] = $reader->getSI16LE(); $detailData[] = $sfInst; } break; case 'ibag': $detailData = array(); while ($reader->hasNextData()) { $presetBag = array(); $presetBag['GenNdx'] = $reader->getUI16LE(); $presetBag['ModNdx'] = $reader->getUI16LE(); $detailData[] = $presetBag; } break; case 'shdr': $detailData = array(); while ($reader->hasNextData()) { $sfSample = array(); $SampleName = explode("", $reader->getData(20)); $sfSample['SampleName'] = $SampleName[0]; $sfSample['Start'] = $reader->getUI32LE(); $sfSample['End'] = $reader->getUI32LE(); $sfSample['StartLoop'] = $reader->getUI32LE(); $sfSample['EndLoop'] = $reader->getUI32LE(); $sfSample['SampleRate'] = $reader->getUI32LE(); $sfSample['OriginalPitch'] = $reader->getUI8(); $sfSample['PitchCorrection'] = $reader->getSI8(); $sfSample['SampleLink'] = $reader->getUI16LE(); $sfSample['SampleType'] = $reader->getUI16LE(); $detailData[] = $sfSample; } break; default: return; // nothing to do break; } $this->detail = $detailData; }
function generatorTree($gen, $indentLevel) { $indentSpace = str_repeat(" ", $indentLevel); echo $indentSpace . IO_SoundFont_Generator::string($gen) . PHP_EOL; $genOper = $gen['sfGenOper']; if ($genOper === 41) { // instrument $instIdx = $gen['Amount']; $inst = $this->pdtaMap['inst'][$instIdx]; $this->instrumentTree($inst, $indentLevel + 1); } else { if ($genOper === 53) { // sampleID $sampleIdx = $gen['Amount']; $sample = $this->pdtaMap['shdr'][$sampleIdx]; echo $indentSpace . IO_SoundFont_Sample::string($sample) . PHP_EOL; } } }