;*********************************************************************
; OM-SoX, (c) 2011-2016 Marlon Schumacher (CIRMMT/McGill University) *
; http://sourceforge.net/projects/omsox/ *
; *
; Multichannel Audio Manipulation and Functional Batch Processing. *
; DSP based on SoX - (c) C.Bagwell and Contributors *
; http://sox.sourceforge.net/ *
;*********************************************************************
;
;This program is free software; you can redistribute it and/or
;modify it under the terms of the GNU General Public License
;as published by the Free Software Foundation; either version 2
;of the License, or (at your option) any later version.
;
;See file LICENSE for further informations on licensing terms.
;
;This program is distributed in the hope that it will be useful,
;but WITHOUT ANY WARRANTY; without even the implied warranty of
;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;GNU General Public License for more details.
;
;You should have received a copy of the GNU General Public License
;along with this program; if not, write to the Free Software
;Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,10 USA.
;
;Authors: M. Schumacher
(in-package :om)
; Set OM Preferences
(defmethod put-external-preferences ((module (eql 'sox)) moduleprefs)
(when (get-pref moduleprefs :Sox-path)
(setf *SOX-PATH* (find-true-external (get-pref moduleprefs :Sox-path)))
(when (probe-file *SOX-PATH*)
(om-cmd-line (format nil "chmod 777 ~s" (namestring *sox-path*)) t))
))
; Set Normalization Module
(unless (find :sox *loaded-normalizers*)
(pushr :sox *loaded-normalizers*))
(defmethod get-def-normalize-value ((self (eql :sox))) 0.0)
(defmethod get-module-name ((self (eql :sox))) "sox")
(defmethod general-normalize ((norm (eql :sox)) inpath outpath val &optional resolution)
(let ((normval (or val *normalize-level*)))
(sox-process inpath (sox-normalize :level normval) :output outpath))) ; resolution could be added here: Or only if sox uses OM audio settings
(defparameter *om-sox-lib-path* (make-pathname :directory (pathname-directory *load-pathname*)))
(defparameter *om-sox-version* "1.0.1")
(load (om-make-pathname :directory (x-append (pathname-directory *load-pathname*) "sources") :name "preferences" :type "lisp"))
; Load Classes
(defparameter *sox-classes* '(
"sox-input"
"sox-concatenate"
"sox-merge"
"sox-mix-console"
"sox-mix"
"sox-multiply"
"sox-pan"
"sox-record"
"sox-remix"
"sox-splice"
"sox-split"
))
(defun load-sox-classes (subdir &optional pack)
(loop for item in *sox-classes* do
(let ((itempath (om-relative-path subdir item)))
(compile&load itempath)
(let ((classname (intern (string-upcase item))))
(when (and pack (find-class classname nil))
(unless (equal item "sox-input")
(addclass2pack classname pack)))))
)
)
(load-sox-classes '("sources" "classes") (find-library "OM-SoX"))
; Load Functions
(defun recursive-load-files (dir &optional pack)
(loop for item in (om-directory dir) do
;(print item)
(if (directoryp item)
(unless (equal (car (last (pathname-directory item))) "classes") ;don't load classes
(let ((thepackage
(or (and pack (find (car (last (pathname-directory item)))
(subpackages pack) :key 'name :test 'string-equal))
pack)))
(recursive-load-files item thepackage)))
(cond ((and (>= *om-version* 6.07) (< *om-version* 6.08))
(when (string-equal (pathname-type item) "lisp")
(unless (or (string-equal (pathname-name item) "player-om606")
(string-equal (pathname-name item) "player-om608"))
(compile&load item))))
((>= *om-version* 6.08)
(when (string-equal (pathname-type item) "lisp")
(unless (or (string-equal (pathname-name item) "player-om606")
(string-equal (pathname-name item) "player-om607"))
(compile&load item))))
((string-equal (pathname-type item) "lisp")
(unless (or (string-equal (pathname-name item) "player-om607")
(string-equal (pathname-name item) "player-om608"))
(compile&load item))))
)))
(recursive-load-files (om-relative-path '("sources") nil) (find-library "OM-SoX"))
; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
(om::fill-library '(
;(sub-pack-name subpack-lists class-list function-list class-alias-list)
("Main functions" nil nil (sox-process sox-analysis) nil)
("Statistics" (
("Durations" nil nil (sox-samples sox-duration) nil)
("Amplitudes" nil nil (sox-peak-amplitude sox-max-positive-amplitude sox-max-negative-amplitude
sox-mid-amplitude sox-mean-amplitude sox-mean-norm-amplitude sox-rms-amplitude) nil)
("Levels" nil nil (sox-peak-level sox-rms-level sox-rms-peak-level sox-rms-trough-level sox-headroom) nil)
("Descriptors" nil nil (sox-fundamental-frequency sox-dc-offset sox-crest-factor sox-flat-factor sox-peak-count sox-dft) nil)
("Deltas" nil nil (sox-max-delta-amplitude sox-min-delta-amplitude sox-mean-delta-amplitude sox-rms-delta-amplitude) nil)
("Bits" nil nil (sox-bit-depth-ratio sox-scale-factor) nil)))
("Effects" (
("Delays&Reverbs" nil nil (sox-delay sox-tapdelay sox-reverb sox-convolve) nil)
("Dynamics" nil nil (sox-normalize sox-amplitude sox-level sox-compand sox-contrast sox-loudness sox-overdrive) nil)
("Editing" nil nil (sox-reverse sox-repeat sox-pad sox-trim sox-voicetrim sox-fade sox-trimsilence) nil)
("Filters" nil nil (sox-lowpass sox-highpass sox-band sox-allpass sox-sinc sox-fir sox-shelf-eq sox-peak-eq sox-biquad sox-hilbert) nil)
("Mastering" nil nil (sox-denoise sox-dcremove sox-riaa sox-invert sox-dither) nil)
("Modulation" nil nil (sox-tremolo sox-phaser sox-flanger sox-chorus) nil)
("Multichannel" nil nil (sox-downmix) nil)
("Time-Frequency" nil nil (sox-transpose sox-multi-transpose sox-stretch sox-speed) nil)
)
)
))
; %%%%%%%% SPLASH SCREEN %%%%%%%%%
(om-message-dialog (string+
"===========================
OM-SoX " *om-sox-version*"
http://sourceforge.net/projects/omsox/
(c) Marlon Schumacher, 2011-2016
")
:window-title *om-sox-version*
:size (om-make-point 335 200)
:position (om-make-point 200 140)
)
(format *om-stream* (string+
"
=========================================
| OM-SoX "*om-sox-version*
"
| ----------------------
| Symbolic Multichannel Audio Manipulation and
| Functional Batch Processing
| http://sourceforge.net/projects/omsox/
|
| (c) M. Schumacher, CIRMMT/McGill 2011-2016
| www.idmil.org/people/marlon_schumacher
| ALL RIGHTS RESERVED
|
| dsp based on SoX - (c) C.Bagwell and Contributors
| http://sourceforge.net/projects/sox/
=========================================
"))
;%%%%%%%% URLs %%%%%%%%%
(defmethod! developer-page ()
:icon 98
:numouts 0
(sys:open-url "http://www.idmil.org/people/marlon_schumacher")
)
(defmethod! om-sox-mailing-list ()
:icon 98
:numouts 0
(sys:open-url "https://lists.sourceforge.net/lists/listinfo/omsox-users")
)
(defmethod! gnu-gpl3 ()
:icon 96
:numouts 0
(sys:open-url "http://www.gnu.org/licenses/gpl-3.0.html")
)
(defmethod! om-sox-page ()
:icon 99
:numouts 0
(sys:open-url "http://sourceforge.net/projects/omsox/")
)
(defmethod! sox-html-documentation ()
:icon 08
:numouts 0
(sys:open-url "http://sox.sourceforge.net/sox.html")
)
(defmethod! src.infinitewave.ca ()
:icon 96
:numouts 0
(sys:open-url "http://src.infinitewave.ca")
)
; Version control
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; before committing
; (clean-sources *om-sox-lib-path*)
; Distribution
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; generate html reference
; (gen-lib-reference "OM-SoX")
; before distribution
; (clean-repo *om-sox-lib-path*)
(set-lib-release 1.0)
;(reset-lib-doc)
;(om::set-lib-release 1.0 (find-library "OM-Sox"))
(defun clean-sources (&optional dir)
(let ((src-root (or dir (make-pathname :directory (butlast (pathname-directory *load-pathname*) 2)))))
(mapc #'(lambda (file)
(if (system::directory-pathname-p file)
(clean-sources file)
(when (and (pathname-type file)
(or (string-equal (pathname-type file) "xfasl")
(string-equal (pathname-type file) "fasl")
(string-equal (pathname-type file) "DS_STORE")
(string-equal (pathname-type file) "nfasl")
(string-equal (pathname-type file) "ofasl")
(string-equal (pathname-type file) "ufasl")
(string-equal (pathname-type file) "lisp~")
;(string-equal (pathname-type file) "html")
)) ;removes html reference
(print (concatenate 'string "Deleting " (namestring file) " ..."))
(delete-file file)
)))
(directory (namestring src-root) :directories t))
))
(defun clean-repo (&optional dir)
(let ((src-root (or dir (make-pathname :directory (butlast (pathname-directory *load-pathname*) 2)))))
(mapc #'(lambda (file)
(if (system::directory-pathname-p file)
(if (cond (
(string-equal ".git" (car (last (pathname-directory file))))
(string-equal ".dropbox" (car (last (pathname-directory file))))
(string-equal ".svn" (car (last (pathname-directory file))))
(system::call-system (concatenate 'string "rm -Rf \"" (namestring file) "\""))
(clean-repo file))
(when (and (pathname-type file)
(or (string-equal (pathname-type file) "xfasl")
(string-equal (pathname-type file) "fasl")
(string-equal (pathname-type file) "DS_STORE")
(string-equal (pathname-type file) "nfasl")
(string-equal (pathname-type file) "ofasl")
(string-equal (pathname-type file) "ufasl")
(string-equal (pathname-type file) "lisp~")))
(print (concatenate 'string "Deleting " (namestring file) " ..."))
(delete-file file)
))
)))
(directory (namestring src-root) :directories t))
))
#|
global audio variables:
(defvar *audio-sr* 44100) samplerate
(defvar *audio-res* 16) bitsize
(defvar *automatic-rename* nil) auto-rename
(defvar *delete-inter-file* t)
(defvar *def-snd-format* 'aiff)
(defvar *normalize* t)
(defvar *normalize-level* 0.0)
(defvar *normalizer* :csound)
|#