Skip to content
View in the app

A better way to browse. Learn more.

Learn more

JulioHerrlein

Members
  • Joined

  • Last visited

Posts posted by JulioHerrlein

  1. Dear Janusz,


    Some Suggestions for OMN-Engraver

    In centimeters, inches and scaling percent:

    - Indentation of first stave

    - Different spacing between each line

    - Combining parts from a score into a sub score

    - Custom size and position of elements like titles, etc

    - Text frame support

    - multi-measure rests

    - customized fonts in categories:

    Title, Subtitle, Composer, Lyricist, Instrument name (long, short), header, footer, page number, measure number, measure number alternate, multimeasure rest font, tempo font, chord symbol, tuplet font,

  2. Amazing !! Great !

    I think that with a engraver options and a good sound library, Opusmodus can really be absolutely independent of other softwares, turning into a one standalone application for doing all the work.

    Part extraction, control of the distance of independent elements in the score !

    It´s possible to make line breaks, allowing an specific numbers of bars per line ? and making some bars with different spacing ?

    I miss the button "open in external editor", but I know you are trying to make everything inside.

  3. Dear Cosimo,

    I started with the NotebookLM (now Gemini Notebook). I did a notebook with many lisp related manuals and I merged all Opusmodus documentation of OMN notation and functions in one big document, so every time I ask for something, Gemini search ONLY this documentation and LISP manuals in order to give me the answer.
    Here is an example of the exact prompt I used:

    https://opusmodus.com/forums/topic/4220-idiomatic-probabilistic-function

    Good luck on vibe coding

  4. Thanks, Janusz

    I tested and it looks like it works properly, acording to the weights in the library:

    (defparameter lib-ritmos-jobim2

    '(("a" (1/16 1/16 1/16 1/16) 90 ((a 90) (b 89) (c 80)))

    ("b" (1/16 -3/16) 42 ((a 20) (c 30) (b 15)))

    ("c" (-1/16 1/16 -1/8) 30 ((a 5) (b 80) (c 40)))))

    (lib-peso 20 lib-ritmos-jobim2)

    result

    (1/16 1/16 1/16 1/16 1/16 -3/16 1/16 1/16 1/16 1/16 1/16 1/16 1/16 1/16 1/16 1/16 1/16 1/16 1/16 1/16 1/16 1/16 1/16 1/16 1/16 1/16 1/16 1/16 1/16 1/16 -1/16 1/16 -1/8 1/16 -3/16 1/16 1/16 1/16 1/16 -1/16 1/16 -1/8 1/16 -3/16 1/16 -3/16 1/16 1/16 1/16 1/16 1/16 1/16 1/16 1/16 -1/16 1/16 -1/8 -1/16 1/16 -1/8 -1/16 1/16 -1/8 -1/16 1/16 -1/8)

    (lib-peso 20 (list *lib-ritmos-jobim2* lib-alturas-jobim) :makeomn t :span :length)

    (s c4 mf d4 fs4 db4 eb4 -e. s gb5 -e. s a4 db4 eb4 gb5 b4 -e. -s c4 -e s d4 -e. s fs4 -e. s a4 cs4 ds4 fs5 b4 a4 db4 eb4 gb5 -e. -s b4 -e s c4 -e. -s d4 -e s fs4 -e. s c4 d4 fs4 c4 d4 -e. -s e4 -e -s db4 -e s eb4 -e.)

    I need to implmenent a :SEED keyword.

    Best,

    Julio

    lib_peso.lisp

  5. Hello !

    Here is an interesting function I did at Gemini with this prompt: Enjoy !

    I would like to create a general function called "lib-weight" to handle idiomatic libraries—whether they consist of lists of durations, lists of pitches, or complete OMN expressions. The concept is to develop a function capable of generating random combinations from these libraries, governed by a system of probabilistic "weights." Specifically, each entry in a library is assigned a weight—reflecting how frequently a given rhythm, melody, or OMN expression is used within a particular style—along with data on the most likely subsequent entries. In other words, if a library contains items such as "a," "b," "c," etc. (or "1," "2," "3," etc.), the system tracks not only the relative frequency of each item's occurrence but also the statistical likelihood of which item is most likely to follow it. For example, with rhythmic entries (or any OMN expression), the general format would be:

    (lib-name OMN percentage (continuation-percentage list)), where:

    - "lib-name" is the name assigned to the OMN expression.

    - "OMN" is the musical expression (a list of lengths, a list of pitches, or a complete OMN expression).

    - "percentage" is the frequency with which the expression appears within a corpus of musical repertoire.

    - "continuation-percentage list" is a nested list containing the probable statistical paths of continuation toward other entries in the library (perhaps a Markov chain?).

    ("n" "(-s e s)" 23% ((a 70) (b 52) (c 2)))

    Usage:

    (lib-weight generate-n (lib-name-list)), where:

    - "generate-n" is the number of elements to be randomly selected based on the function's weighting system, which consults the weights stored in the library.

    - "lib-name-list" is a nested list (or a simple list) containing the library entries from which selections are to be made. If it is a nested list, the function calculates the path for the first list and then for the second, subsequently grouping the results.

    - If one list within the nested structure contains pitches and the other contains lengths, the function—after ranking the probabilistic outcomes—can concatenate the lengths and pitches. By applying each pitch-length pair (following their statistical rank) into a make-omn function, it generates an OMN expression that combines pitches and rhythms. This occurs when the keyword :makeomn t is used; additionally, one may specify :span :length or :span :pitch as options for the make-omn process.

    I will provide you with an experimental rhythmic library (lengths) to get you started (based on ALMADA, 2023, "A melodia de Jobim"), though you are free to format it in whatever way best suits the functionality. function:

    (

    ("a" "(1/16 1/16 1/16 1/16)" 23 ((a 70) (b 52) (c 22)))

    ("b" "(1/16 -3/16)" 42 ((b 40) (d 30) (k 15)))

    ("c" (-1/16 1/16 -1/8) 30 ((g 30) (i 20) (k 12)))

    ("d" (-1/8 1/16 -1/16) 21 ((j 43) (l 40) (p 30)))

    ("e" (-3/16 1/16) 45 ((d 45) (m 33) (o 16)))

    ("f" (1/16 1/16 -1/8) 10 ((l 20) (m 10) (n 5)))

    ("g" (1/16 -1/16 1/16 -1/16) 5 ((l 50) (k 30) (a 15)))

    ("h" (1/16 -1/8 1/16) 2 ((k 39) (b 29) (o 14)))

    ("i" (-1/16 1/16 1/16 -1/16) 3 ((m 40) (n 30) (d 15)))

    ("j" (-1/16 1/16 -1/16 1/16) 20 ((f 45) (a 32) (n 17)))

    ("k" (-1/8 1/16 1/16) 10 ((b 40) (d 30) (k 15)))

    ("l" (1/16 1/16 1/16 -1/16) 15 ((b 40) (d 30) (k 15)))

    ("m" (1/16 1/16 -1/16 1/16) 24 ((b 40) (d 30) (k 15)))

    ("n" (1/16 -1/16 1/16 1/16) 12 ((b 40) (d 30) (k 15)))

    ("o" (-1/16 1/16 1/16 1/16) 30 ((b 40) (d 30) (k 15)))

    ("p" (-1/4) 30 ((b 40) (d 30) (k 15)))

    )

    Here, one of pitches

    (

    ("1" "(c4 d4 e4)" 23 ((a 70) (b 52) (c 22)))

    ("2" "(c4 d4 fs4)" 42 ((b 40) (d 30) (k 15)))

    ("3" (db4 eb4 gb5) 30 ((g 30) (i 20) (k 12)))

    ("4" (a4 db4 eb4 gb5 b4) 21 ((j 43) (l 40) (p 30)))

    ("5" (a4 cs4 ds4 fs5 b4) 45 ((d 45) (m 33) (o 16)))

    ("6" (a4 b4 g4) 10 ((l 20) (m 10) (n 5)))

    ("7" (a4 bb4 gb4) 5 ((l 50) (k 30) (a 15)))

    ("8" (cs4 fs3) 2 ((k 39) (b 29) (o 14)))

    )

    (lib-peso 60 lib-ritmos-jobim)

    (lib-peso 60 lib-ritmos-jobim2)

    (lib-peso 4 (list *lib-ritmos-jobim* lib-alturas-jobim))

    (lib-peso 40 (list *lib-ritmos-jobim* lib-alturas-jobim) :makeomn t :span :length)

    lib_peso.lisp

  6. Dear Robert,

    Congratulations for the reflections. I think it´s very important to elaborate our compositional process as text, to really describe step by step the intentions we have with our code: the apparent and hidden algorithms, the functions we specially create for specific music tasks and also thoughts about esthetic orientation and how to achieve our goals. Sometimes just putting comments on the code is not enough. As humans, we need things to go slower and with intention. Also the newer generations need to differentiate AI process from LISP programming. Much people simply think that using Opusmodus (or other CAC softwares) is a kind of cheating, that one must compose only manually. Thanks a lot for the text.
    Best,

    Julio

  7. I´m inclined to study more about agents (probably Claude). Is this Positron a free product ?
    My experience with coding using data about LISP and Opusmodus inside Gemini Notebook is very good. It really understand the propositions and prompts and can build functions with success (most of the weel explained prompts result in useful functions. Some of the functions I built are really complex ones ! )
    But with agents like Claude the game is much more deep.
    Best, Julio

  8. Dear Achim

    The function is just length augmentation or diminution while preserving the original time points. It just augments or diminishes each of lengths but keeping the time locations of each note. It just ocurred to me, but maybe it´s not exactly what are you searching. All the best ! Julio

  9. How about this:

    (defun length-change-keep-pos (percent-list omn-sequence)

    "Altera a duração das notas por um percentual sem mudar sua posição no tempo."

    (let* (;; 1. Desmonta para isolar comprimentos (suporta OMN completo ou apenas ritmos) [5]

    (lengths (if (listp (car omn-sequence))

    (getf (disassemble-omn omn-sequence) :length)

    omn-sequence))

    ;; 2. Agrupa notas com suas pausas subsequentes (unidades posicionais) [3]

    (slots (length-legato (flatten lengths)))

    (num-events (length slots))

    ;; 3. Alinha a lista de percentuais ao número de eventos [4]

    (pct-list (gen-trim num-events (if (listp percent-list) percent-list (list percent-list)))))

    (loop for slot in slots

    for pct in pct-list

    append (let* ((abs-slot (abs slot))

    ;; 4. Calcula a nova duração da nota baseada no percentual

    (new-note-len (* abs-slot (/ pct 100)))

    ;; 5. Calcula o silêncio necessário para manter a posição original

    (remainder (- abs-slot new-note-len)))

    (cond

    ;; Se for uma pausa original no slot (legato de pausas)

    ((minusp slot) (list slot))

    ;; Se o percentual preencher o slot exatamente

    ((zerop remainder) (list new-note-len))

    ;; Se a nota encurtou: nota + pausa compensatória

    ((plusp remainder) (list new-note-len (* -1 remainder)))

    ;; Se a nota aumentou (ex: 200%): absorve o espaço do slot

    (t (list new-note-len)))))))

    (length-change-keep-pos '(25 50 100) '(w w h h q h))

    (1/4 -3/4 1/2 -1/2 1/2 1/8 -3/8 1/8 -1/8 1/2)

    (length-change-keep-pos '(100) '(h -h h -h q -q q -q e -e))

    (1 1 1/2 1/2 1/4)

    (length-change-keep-pos '(25 25 25 50 50 50 ) '(3h 3h 3h 3h 3h 3h))

    (1/24 -1/8 1/24 -1/8 1/24 -1/8 1/12 -1/12 1/12 -1/12 1/12 -1/12)

    (length-change-keep-pos '(25 50 500) '(w w h h q h))

    (1/4 -3/4 1/2 -1/2 5/2 1/8 -3/8 1/8 -1/8 5/2)

  10. Much better version. Really cool !!

    (defun contour-mel (sequencias contornos)

    "Função de contorno melódico com controle de densidade e direção inter-bar."

    (let* (;; 1. Desmonta a sequência para isolar os parâmetros [4, 5]

    (dis (disassemble-omn sequencias))

    (pitches (getf dis :pitch))

    (lengths (getf dis :length))

    (velocities (getf dis :velocity))

    (num-bars (length contornos))

    ;; Alinha sequências, ritmos e dinâmicas ao número de contornos [6-8]

    (p-list (gen-trim num-bars pitches))

    (l-list (gen-trim num-bars lengths))

    (v-list (gen-trim num-bars (if velocities velocities '(mf))))

    ;; Variáveis de estado para a Regra de Direção

    (prev-last-pitch nil)

    (prev-last-contour-val nil)

    (final-pitches nil)

    (final-lengths nil)

    (final-velocities nil))

    (loop for bar-p in p-list

    for bar-l in l-list

    for bar-v in v-list

    for bar-c in contornos

    do (let* ((num-notes (length bar-c))

    ;; Funcionalidade 1: Estabelece quantas notas serão processadas

    ;; Repete a sequência do começo ao fim se o contorno for maior [7, 9]

    (ext-p (gen-trim num-notes bar-p))

    (ext-l (gen-trim num-notes bar-l))

    (ext-v (gen-trim num-notes bar-v))

    ;; Processamento por Inteiros (c4 = 0) [1, 3, 10]

    (ints (pitch-to-integer ext-p))

    (pcs (mapcar (lambda (x) (mod x 12)) ints))

    ;; Reconstrução do Contorno Interno (Ranking) [1, 4]

    (pos-rank-pairs (loop for pc in pcs for rank in bar-c for pos from 0

    collect (list :pc pc :rank rank :pos pos)))

    (sorted-by-rank (sort (copy-list pos-rank-pairs) #'<

    :key (lambda (x) (getf x :rank))))

    (temp-bar-results (make-array num-notes))

    (last-val -9999))

    ;; Atribui oitavas para satisfazer o contorno interno

    (dolist (item sorted-by-rank)

    (let* ((pc (getf item :pc))

    (pos (getf item :pos))

    (oct 0)

    (val (+ (* oct 12) pc)))

    (while (<= val last-val)

    do (incf oct)

    (setf val (+ (* oct 12) pc)))

    (setf (aref temp-bar-results pos) val)

    (setf last-val val)))

    ;; Funcionalidade 2: Regra de Direção (Concatenação)

    (let* ((final-ints (coerce temp-bar-results 'list))

    (current-first-val (car bar-c))

    (shift 0))

    (when (and prev-last-pitch prev-last-contour-val)

    (let* ((target-first (car final-ints))

    ;; Calcula direção baseada no valor numérico do contorno

    (direction (cond ((> current-first-val prev-last-contour-val) 'up)

    ((< current-first-val prev-last-contour-val) 'down)

    (t 'same))))

    ;; Ajusta o bloco inteiro para satisfazer a direção em relação ao compasso anterior

    (case direction

    (up (while (<= (+ target-first shift) prev-last-pitch)

    do (incf shift 12)))

    (down (while (>= (+ target-first shift) prev-last-pitch)

    do (decf shift 12))))))

    ;; Aplica a transposição de registro (oitava) necessária

    (setf final-ints (mapcar (lambda (x) (+ x shift)) final-ints))

    ;; Atualiza estado para o próximo compasso

    (setf prev-last-pitch (car (last final-ints)))

    (setf prev-last-contour-val (car (last bar-c)))

    ;; Coleta resultados processados

    (push (integer-to-pitch final-ints) final-pitches)

    (push ext-l final-lengths)

    (push ext-v final-velocities))))

    ;; 4. Remontagem OMN Final [4, 5, 11]

    (make-omn :pitch (nreverse final-pitches)

    :length (nreverse final-lengths)

    :velocity (nreverse final-velocities)

    :articulation (getf dis :articulation))))

    EXPLANATION

    Explanation of New Features:

    Density and Repetition Control (Rule 1):

    The gen-trim function is used to force the note sublist to match the size of the contour sublist.

    If the original sequence is (c4 e4 g4) (3 notes) and the contour is (1 2 3 4 5) (5 numbers), the system expands the sequence to (c4 e4 g4 c4 e4) before applying octave ranking.

    Concatenation Direction (Rule 2):

    The algorithm stores the last contour value and the last pitch (as an integer) from the previous measure.

    When starting a new measure, it compares the first number of the new contour with the previous one. If it is higher, it applies an octave shift to all notes in the current measure until the first note is higher than the last note of the previous measure, thereby preserving the internal contour while ensuring the required directional flow.

    Octave Adjustment and Spelling:

    The process adheres to the convention where c4 = 0.

    The integer-to-pitch lookup ensures notes remain within a usable register, avoiding "zero-octave" errors when applying the system's implicit base offset of 4.

    Rhythmic and Dynamic Integrity:

    Using disassemble-omn, rhythms (durations) and dynamics (velocities) are extracted and expanded via gen-trim to match each new note generated by the contour, ensuring the final result is a perfectly valid OMN expression ready for notation or playback.

  11. Dear All,

    Here is a function I created (vibe coded) with NotebookLM/Gemini to create melodic countour of any sequence of pitches. It works with OMN expressions and also with chords. In the case of chords, you must count how many voices there is in the chords in order to create a countour. After processing (melodizing), the function puts the chords back to its place.

    Best,

    Julio

    EXAMPLE

    (setf contornos '((1 2 3) (3 1 2) (2 3 1) (1 3 2) (2 1 3) (3 2 1)))
    (setf sequencia (gen-divide 3 (gen-repeat 10 '(q c4 e4 g4))))
    (contour-mel-poly sequencia contornos)

    ORIGINAL

    image.png

    image.png

    (contour-mel-poly (gen-divide 4 (flatten sequencia)) '(0.5 0.49 2))
    ;; can be any number

    image.png

    image.png

    (defun contour-mel-poly (omn-exp contornos)
      "Ordena alturas e acordes segundo um contorno melódico (ranking), 
       ajustando as oitavas para satisfazer a hierarquia do contorno."
      (let* ((dis (disassemble-omn omn-exp))
             (pitches (getf dis :pitch))
             (num-bars (length pitches))
             ;; 1. Alinha a lista de contornos ao número de compassos [2]
             (contorno-list (gen-trim num-bars (if (listp (car contornos)) contornos (list contornos)))))
    
        (labels ((apply-contour-logic (bar-ints contour)
                   "Processa uma lista de inteiros (melodia/acordes) aplicando o contorno."
                   (let* (;; A. Melodize: trata tudo como uma sequência linear de notas
                          (flat-ints (flatten bar-ints))
                          (pcs (mapcar (lambda (x) (mod x 12)) flat-ints))
                          (num-notes (length pcs))
                          ;; B. Cria mapeamento (PC, Rank-Alvo, Posição-Original)
                          (pos-rank-pairs (loop for pc in pcs 
                                                for rank in contour 
                                                for pos from 0
                                                collect (list :pc pc :rank rank :pos pos)))
                          ;; C. Ordena pelo ranking para definir as oitavas progressivamente
                          (sorted-by-rank (sort (copy-list pos-rank-pairs) #'< 
                                                :key (lambda (x) (getf x :rank))))
                          (last-val -999)
                          (final-pos-val-pairs nil))
    
                     ;; D. Atribuição de oitavas baseada no ranking
                     (dolist (item sorted-by-rank)
                       (let* ((pc (getf item :pc))
                              (pos (getf item :pos))
                              (oct 0)
                              (candidate (+ (* oct 12) pc)))
                         ;; Garante que Rank N > Rank N-1 (satisfaz posição aberta/fechada)
                         (while (<= candidate last-val)
                            do (setf oct (1+ oct))
                               (setf candidate (+ (* oct 12) pc)))
                         (setf last-val candidate)
                         (push (cons pos candidate) final-pos-val-pairs)))
    
                     ;; E. Restaura a ordem linear e reagrupa acordes se existiam
                     (let* ((linear-ints (loop for i from 0 below num-notes
                                               collect (cdr (assoc i final-pos-val-pairs))))
                            (idx 0))
                       (mapcar (lambda (evt)
                                 (if (listp evt)
                                     (prog1 (loop repeat (length evt) collect (nth idx linear-ints) do (incf idx)) nil)
                                     (prog1 (nth idx linear-ints) (incf idx))))
                               bar-ints)))))
    
          ;; 2. Processamento por compasso
          (let ((processed-pitches
                 (mapcar (lambda (bar contour)
                           (let* ((bar-ints (pitch-to-integer bar))
                                  (new-ints (apply-contour-logic bar-ints contour)))
                             ;; Converte de volta para pitches OMN [4]
                             (integer-to-pitch new-ints)))
                         pitches contorno-list)))
    
            ;; 3. Remontagem OMN final preservando a estrutura original [5]
            (make-omn :pitch processed-pitches
                      :length (getf dis :length)
                      :velocity (getf dis :velocity)
                      :articulation (getf dis :articulation))))))

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.