Skip to content
View in the app

A better way to browse. Learn more.

Learn more

rewrite-dyn function

Featured Replies

Hello, Opusmoders

This is a very cool and easy to use function to rewrite dynamics.

Check it out. Hope you like it !

Best,

Julio

(defun rewrite-dyn (expressao-omn dynamic-list)

"Substitui as dinâmicas de uma expressão OMN por uma lista customizada,

fazendo a rotação cíclica se a lista for menor que o número de notas."

(let* ((dis (disassemble-omn expressao-omn)) ; [2, 3]

(pitches (getf dis :pitch))

(lengths (getf dis :length))

(articulations (getf dis :articulation))

;; 1. Mapeia a estrutura de cada sublista (quantidade de notas por compasso)

(counts (mapcar #'length pitches)) ; [6]

;; 2. Calcula o total de notas para gerar dinâmicas suficientes

(total-notes (apply #'+ (flatten counts))) ; [7]

;; 3. Cria a lista plana de dinâmicas repetindo o padrão do usuário [4]

(flat-vels (gen-trim total-notes dynamic-list))

;; 4. Redistribui as dinâmicas na estrutura de sublistas original [5]

(structured-vels (gen-divide counts flat-vels)))

;; 5. Remonta o objeto OMN completo com os novos parâmetros [3]

(make-omn :pitch pitches

:length lengths

:velocity structured-vels

:articulation articulations)))

;; USE

;; Exemplo 1: Dinâmicas simples

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

(e. d4 a4 eb4 d4)

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

image.png

(rewrite-dyn expressao-omn '(p mf ff))

;; >> ((s eb4 p d4 mf e a4 ff -s eb4 p tie) (h eb4 mf a4 ff -s eb4 p d4 mf - d4 ff tie) (e. d4 p a4 mf eb4 ff d4 p) (-q e f4 mf s c5 ff qs fs4 p))

;; Exemplo 2: Incluindo crescendos

(rewrite-dyn expressao-omn '(ff > p p< ff> pp ff p p< ff p mf ppp p < ff))

;; ((s eb4 ff d4 > e a4 p -s eb4 p< tie) (h eb4 ff> a4 pp -s eb4 ff d4 p - d4 p< tie) (e. d4 ff a4 p eb4 mf d4 ppp) (-q e f4 p s c5 < qs fs4 ff))

image.png

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.