require_once 'IO/SoundFont.php'; require_once 'sample/makeWaveData.php'; if ($argc < 2) { echo "Usage: php sfextractsample.php <sffile> [<looptime>]" . PHP_EOL; echo "ex) php sample/sfextractsample.php emuaps_8mb.sf2 3" . PHP_EOL; exit(1); } $sfdata = file_get_contents($argv[1]); if ($argc == 2) { $looptime = null; } else { $looptime = $argv[2]; } $sf = new IO_SoundFont(); $sf->parse($sfdata); $sf->analyze(); $banks = $sf->pdtaMap['phdr']; foreach ($banks as $bankIdx => $bank) { echo "Bank: idx:{$bankIdx}" . PHP_EOL; foreach ($bank as $presetIdx => $preset) { $presetName = $preset['PresetName']; $presetBagNdxStart = $preset['PresetBagNdx']; $presetBagNdxEnd = $preset['_PresetBagNdxEnd']; echo " Preset: idx:{$presetIdx} name:'{$presetName}' bag:{$presetBagNdxStart}=>{$presetBagNdxEnd}" . PHP_EOL; for ($presetBagNdx = $presetBagNdxStart; $presetBagNdx <= $presetBagNdxEnd; $presetBagNdx++) { echo " presetBag: ndx:{$presetBagNdx}" . PHP_EOL; $presetBag = $sf->pdtaMap['pbag'][$presetBagNdx]; $genNdxStart = $presetBag['GenNdx']; $genNdxEnd = $presetBag['_GenNdxEnd']; $modNdxStart = $presetBag['ModNdx'];