;;; The program copies numbered wav files, to the files, as described by the ;;; -.spk file generated by leno in the internal directory. ;;; Change the constants in the section below. ;;; Put this file in a directory together with the sound clips. ;;; The program copies the sound clips from the current directory to the parent directory (../), ;;; performing the necessary renamings. It only copies those files, such as 1.wav, 2.wav, which actually ;;; are located in the directory.
(load (string-append laml-dir "laml.scm")) ; --------------------------------------------------------------------------------------------------- ; PARAMETERS - USER SETTINGS

(define max-file-name-length 64) ; CHANGE SETTINGS IN THIS SECTION OF THE PROGRAM

(define lecture-id 'single-audio) ; The relative path from the sound source dir (current dir) to the note source directory.

(define note-source-directory "../../")
(define sound-extension "wav") ; END USER SETTINGS. ; ------------------------------------------------------------------

(define (wave-file-numbers-from-current-dir) (let ((files (directory-list (startup-directory)))) (filter (lambda (x) x) (map (lambda (fn) (if (numeric-string? (file-name-proper fn)) (as-number (file-name-proper fn)) #f)) files))))
(define wave-file-numbers (wave-file-numbers-from-current-dir))
(define speak-info-list (file-read (string-append (startup-directory) note-source-directory "internal/" (as-string lecture-id) "." "spk"))) (display-message "THE NEW LENO SHOW-AND-SPEAK SOUND UTILTIY PROGRAM.") (display-message "Moving and renaming files to parent directory")
(define (find-sound-entry n speak-info-list) (find-in-list (lambda (e) (let ((sound-number (list-ref e 9))) (= n sound-number))) speak-info-list)) (for-each (lambda (n) (let* ((sound-entry (find-sound-entry n speak-info-list)) (sound-name (list-ref sound-entry 6)) (sound-name-ext (string-append sound-name "." sound-extension)) (wav-name (string-append "../" sound-name-ext)) (orig-name (string-append (as-string n) "." sound-extension)) ) (if (> (string-length sound-name-ext) max-file-name-length) (error (string-append "File name length exceeded: " sound-name-ext))) (if (not (file-exists? wav-name)) (begin ; move file
(display-message (as-string n)) (copy-file orig-name wav-name) (delete-file orig-name) ) (display-warning (string-append "The file " sound-name "." sound-extension " exists - cannot overwrite"))))) wave-file-numbers) (display-message "Done")