Skip to content

Instantly share code, notes, and snippets.

@ryrun
Created February 18, 2017 21:09
Show Gist options
  • Save ryrun/51ff74012d669255f038895f52645fd9 to your computer and use it in GitHub Desktop.
Save ryrun/51ff74012d669255f038895f52645fd9 to your computer and use it in GitHub Desktop.
Convert VST Avenger presets to fxp with emacs elisp
(require 'bindat)
;;; put your avengers content path here
(setq avenger-content-path "")
(mapcar (lambda (filename)
;; show current patch in message buffer
(message filename)
;; read file
(let ((coding-system-for-read 'binary))
(setq content (with-temp-buffer
(insert-file-contents filename)
(buffer-string))))
;;; set some test data
(setq header (bindat-pack
;; vstspec
'((magiccode str 4)
(size u32)
(vstpatchtype str 4)
(version u32)
(pluginid str 4)
(pluginversion u32)
(parametercount u32)
(presetname strz 28)
(contentsize u32))
;; data
`((magiccode . "CcnK")
(size . ,(+ (length content) #x44))
(vstpatchtype . "FPCh")
(version . 1)
(pluginid . "Avgr")
(pluginversion . 1)
;; set a name from filename, respect the limit
(presetname . ,(substring (file-name-base filename) 0 (min 27 (string-width (file-name-base filename)))))
(parametercount . 0)
(contentsize . ,(length content)))
))
;;; write to hdd as ready to use fxp patch
(let ((coding-system-for-write 'binary))
(write-region (concat header content) nil (concat (file-name-directory filename) (file-name-base filename) ".fxp"))))
;; search for avgr patches
(directory-files-recursively avenger-content-path "\\.avgr$"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment