;;; TEMPORARY FIX FOR OM 6.15 ;;; ADDING A :STREAM KEYWORD ARGUMENT ;;; TO GETSDIFCHORDS AND SDIF->CHORD-SEQ ;;; J. BRESSON 11/07/2019 (in-package :om) ;;; Removing previous definitions to avoid the lambda-list error (fmakunbound 'GetSDIFChords) (fmakunbound 'sdif->chord-seq) (defmethod! GetSDIFChords ((self sdiffile) &key stream) :indoc '("SDIF file" "stream ID") :doc "Returns a list of chords data from an sdif file (using 1MRK / 1TRC frames). Chords are formatted as a list of (pitch [Hz] onset [s] duration [s] velocity [lin]). " :icon 639 (let ((rawdata (chord-seq-raw-data self 'all stream))) (mapcar #'(lambda (partial) (if (consp (car partial)) ;;; trc (let ((t1 (list-min (nth 0 partial))) (t2 (list-max (nth 0 partial)))) (list (om-mean (nth 1 partial)) t1 (- t2 t1) (om-mean (nth 2 partial)))) ;;; mrk (list (nth 1 partial) (nth 0 partial) (- (nth 3 partial) (nth 0 partial)) (nth 2 partial)) )) rawdata) )) (defmethod! sdif->chord-seq ((self sdiffile) &key stream) :indoc '("SDIF file" "stream ID") :doc "Generates a CHORD-SEQ instance from the 1TRC or 1MRK frame data in . Internally calls and formats data from GetSDIFChords. " :icon 639 (let* ((rawdata (sort (GetSDIFChords self :stream stream) '< :key 'cadr)) (chords nil) (cseqdata nil)) (loop for note in rawdata do ;;; note = (pitch onset dur vel) ;;; (car chords) = (onset (pitches) (durs) (vels)) (if (and (car chords) (= (second note) (car (car chords)))) ;;; add note to chord (setf (car chords) (list (first (car chords)) (append (second (car chords)) (list (first note))) (append (third (car chords)) (list (third note))) (append (fourth (car chords)) (list (fourth note))))) ;;; else create new chord (push (list (second note) (list (first note)) (list (third note)) (list (fourth note))) chords))) (setf cseqdata (mat-trans (sort chords '< :key 'car))) (make-instance 'chord-seq :lonset (om-round (om* (first cseqdata) 1000)) :lmidic (om-round (f->mc (second cseqdata))) :ldur (om-round (om* (third cseqdata) 1000)) :lvel (om-round (om-scale (fourth cseqdata) 50 127)))))