Created
February 16, 2017 19:10
-
-
Save ryrun/90afcdb059cc9fcca4934e1ac18b5fb4 to your computer and use it in GitHub Desktop.
Convert VST Avenger .avgr Patches to VSTi patches .fxp in PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$path = ""; //add your avenger expansion path here | |
$dir = scandir( $path ); | |
$dir = array_diff($dir,["." , ".." ]); | |
//all expansions | |
foreach($dir as $exp) { | |
$presetpath = $path . $exp . "\\presets\\"; | |
$presettypes = scandir($presetpath); | |
$presettypes = array_diff($presettypes,[".",".."]); | |
//all preset types | |
foreach($presettypes as $presettype) { | |
$presetfilespath = $presetpath . $presettype . "\\"; | |
$presets = scandir($presetfilespath); | |
$presets = array_diff($presets,[".",".."]); | |
if(count($presets)) { | |
foreach($presets as $preset) { | |
if(!preg_match("~\.avgr$~", $preset)) { | |
continue; | |
} | |
$name = basename($preset,".avgr"); | |
$content = file_get_contents($presetfilespath . $preset); | |
echo $name . " - Size: " . strlen($content) . "\n"; | |
$targetfile = $presetfilespath . $name . ".fxp"; | |
$fxp = 'CcnK'; //vst fxp patch | |
$fxp .= pack("N", strlen($content) + 0x34 ); //size of content + some of header | |
$fxp .= 'FPCh'; //plugin program | |
$fxp .= pack("N",1); //version | |
$fxp .= 'Avgr'; //plugin id | |
$fxp .= pack("N",1); //plugin version | |
$fxp .= pack("N",0x511); //count of parameters | |
$fxp .= str_pad("", 28, "\0"); | |
$fxp .= pack("N", strlen($content) ); //size of avgr preset | |
$fxp .= $content; | |
file_put_contents( $targetfile, $fxp ); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment