load-sampler   scheme


Defined in:  https://github.com/digego/extempore/tree/v0.8.9/libs/external/instruments_ext-scm.xtm

Implementation

;; must be stereo samples of type wav aif or ogg
;; defaults: bank 0, parser sampler-parse-filename
(define (load-sampler sampler path . args)
  (let ((bank (if (> (length args) 0) (car args) 0))
        (filename-parser (if (> (length args) 1) (cadr args) sampler-parse-filename))
        (cnt 0))
    (for-each (lambda (filename)
                ;; skip hidden files... if you're using samples with hidden
                ;; filenames then I don't know what's wrong with you
                (if (not (regex:match? filename "^\\."))
                    ;; otherwise try and parse it with the filename-parser fn
                    (let ((samp-data (filename-parser filename)))
                      (if samp-data
                          (begin
                            (sampler-populate-slot sampler
                                                   (unix-or-Windows (string-append (sys:expand-path path) "/" (car samp-data))
                                                                    (car samp-data))
                                                   (cadr samp-data)
                                                   (caddr samp-data)
                                                   (cadddr samp-data)
                                                   bank
                                                   0)
                            (set! cnt (+ cnt 1)))))))
              (sys:directory-list (sys:expand-path path)))
    (log-info 'Loaded cnt 'files 'into 'bank bank)))


Back to Index