Skip to content
View in the app

A better way to browse. Learn more.

Learn more

rewrite-len function

Featured Replies

Last one... Time to go to bed in Brasil

Function to rewrite lengths

BEst,

Julio

(defun rewrite-len (expressao-omn new-lengths-list)

"Substitui os comprimentos (lengths) de uma expressão OMN por uma lista fornecida,

repetindo-a ciclicamente e mantendo a estrutura de sublistas original."

(let* ((dis (disassemble-omn expressao-omn)) ;; Desmonta a expressão original [2]

(old-pit (getf dis :pitch)) ;; Extrai as alturas [4]

(old-vel (getf dis :velocity)) ;; Extrai as velocidades [4]

(old-art (getf dis :articulation)) ;; Extrai as articulações [4]

;; 1. Mapeia a estrutura original (quantidade de eventos por sublista)

;; Captura o número de elementos rítmicos em cada compasso [3, 5]

(structure (mapcar #'length (getf dis :length)))

(total-events (apply #'+ structure)) ;; Soma total de eventos [6]

;; 2. Gera a sequência rítmica cíclica com base no total de eventos

;; gen-trim estende a lista do usuário para preencher todos os espaços [3, 7]

(new-flat-lengths (gen-trim total-events new-lengths-list))

;; 3. Re-organiza os novos ritmos na estrutura de sublistas original [3, 8]

(new-structured-lengths (gen-divide structure new-flat-lengths)))

;; 4. Remonta o objeto OMN completo com os parâmetros preservados [3, 4]

(make-omn :pitch old-pit

:length new-structured-lengths

:velocity old-vel

:articulation old-art)))

;;USE

(setf expressao-omn '((s eb4 d4 e a4 -s s eb4) (h eb4 a4 -s eb4 d4 -s)

(e. d4 a4 eb4 d4)

(-q e f4 s c5 qs fs4)))

(omn-to-time-signature (rewrite-len expressao-omn '(h -e s q -h q -q s s s)) '(3 4))

;;RESULT

((h eb4 mf -e s d4 a4 tie) (e. a4 -h s eb4 mf tie) (e. eb4 mf -q s a4 eb4 d4 e eb4 tie) (q. eb4 -e s d4 mf e. a4 tie) (s a4 -h e. f4 mf tie) (s f4 mf -q s c5 fs4))

Create an account or sign in to comment

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.