Function Examples
Functions, arguments, values and results
316 topics in this forum
-
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 (contour-mel-poly (gen-divide 4 (flatten sequencia)) '(0.5 0.49 2)) ;; can be any number (defun…
- 1 reply
- 187 views
-
Dear All, An useful function do make various pitch-demix operations at once. (defun poly-demix (n-list mat-omn) "Extrai as vozes especificadas em N-LIST de uma sequência OMN e as combina em um único fluxo polifônico." (let* (;; 1. Garante que n-list seja uma lista e extrai cada voz (extracted-voices (mapcar #'(lambda (n) (pitch-demix n mat-omn)) (list! n-list)))) ;; 2. Aplica merge-voices sobre a lista de vozes extraídas (apply #'merge-voices extracted-voices))) (setf mat-omn '((e. g2bb3d4f4a4 mf s -e e c4c5c5 e. g2bb3c4d4f4 s g3g4g4 -s s g2bb3d4f4a4) (q bb2db4f4…
- 6 replies
- 477 views
- 1 follower
-
A sketch: I generate noise and define a list of intervals (or pitches) that is applied to the noise pitches. Whenever one of these intervals (or pitches) is detected, its dynamic is changed to fff. This creates a form of articulation that is determined by the intervallic structure. (setf intervals '(-2 -1 1 2 5 -5)) (setf seq (loop repeat 200 with alist = (filter-repeat 1 (vector-to-pitch '(a3 g5) (gen-noise 300))) with cnt = 0 when (memberp (car (pitch-to-interval (list (nth cnt alist) (nth (1+ cnt) alist)))) intervals) append (make-omn :pitch (list (nth cnt…
- 1 reply
- 220 views
-
A simple way to send serial data to Arduino. I'm sending Data to a Servo Motor... ;; Setup TERMINAL (Mac) ;; stty -f /dev/cu.usbmodem1401 9600 raw (defparameter *arduino* (open "/dev/cu.usbmodem1401" :direction :output :if-exists :append :element-type '(unsigned-byte 8))) ;;Function (defun send-byte (n) (uiop:run-program (format nil "printf '%b' \"\\x~2,'0X\" > /dev/cu.usbmodem1401" n))) ;;Test (loop repeat 20 do (send-byte (random 100)) do (sleep 1))
-
- 0 replies
- 92 views
-
-
Hello, is there a simple range function in Opusmodus (no vector) like this?: (defun range (lis min max) " Range a list between min and max. Ex.: ;; (range '(1 2 3 4 5) 1 2) => (1.0 1.25 1.5 1.75 2.0) ;; (range '(1 3 6 7) 1 2) => (1.0 1.3333334 1.8333334 2.0) ;; (range '(2 3 6 4 5 8 6 7) 2 3) => (2.0 2.1666667 2.6666667 2.3333333 2.5 3.0 2.6666667 2.8333333) ;; (range '(0.2 0.4 0.7 0.3 0.9) 0.3 1.2) " (let ((minlis (reduce #'min lis)) (maxlis (reduce #'max lis))) (labels ((map-range (a1 a2 b1 b2 s) (* 1.0 (+ b1 (/ (* (- s a1) (- b2 b1)) (- a2 a1)))))) (loop for i in lis collect (map-range minlis maxlis min max i))))) Achim
-
- 2 replies
- 259 views
- 2 followers
-
-
Dear All, Here are a version for a diatonic (or all purpose set-transpose) function that rounds material around a collection used as reference). Please, Let me know if you find bugs. Best, Julio (defun set-transpose (n omn-sequence sets &key (round 'up)) "Realiza transposição diatônica por N passos em coleções de referência. Arredonda notas fora do set para cima ou para baixo conforme :round." (let* ((dis (disassemble-omn omn-sequence)) (pitches (getf dis :pitch)) (num-bars (length pitches)) ;; Alinha N e os Sets ao número de sublistas (compassos) (n-list (gen-trim num-bars (if (listp n) n (list n)))) (set-list…
- 3 replies
- 345 views
-
Hello, when using vector-smooth my tendencies start around 0.1 but end >0.2 (should be around 0.1 as well) How can I prevent that? (setf tend-list '(0.1 0.4 0.2 0.6 0.5 0.5 0.9 0.7 0.7 1 0.9 1.2 0.9 0.9 0.5 0.5 0.6 0.2 0.2 0.1)) (list-plot (setf dur-mults (loop for i in durlens with seed = (init-seed 123) collect (vector-smooth 0.3 (gen-tendency i tend-list :variance 0.2)))) :zero-based t :join-points t) Thanks for help, Achim
-
- 0 replies
- 195 views
- 1 follower
-
-
Ciao, Opusmoders All previous rewrite functions used in conjunction for transformations. Ciao ! https://opusmodus.com/forums/topic/4097-rewrite-len-function/#comment-14209 (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))) (rewrite-pit (rewrite-dyn (rewrite-len expressao-omn '(h -e s q -h q -q s s s)) '(pp< ff mf fff p < < fff ppp fff mf fff p)) '(c4 g5)) https://opusmodus.com/forums/topic/4097-rewrite-len-function/#comment-14209
- 2 replies
- 345 views
-
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 estru…
-
- 0 replies
- 183 views
-
-
Hey, Opusmoders Here is one more function in the style of the previous one (rewrite-dyn). This time to rewrite pitches. (defun rewrite-pit (expressao-omn pitch-list) "Substitui as alturas de uma expressão OMN por uma lista customizada, fazendo a repetição cíclica se a lista for menor que o número de notas." (let* ((dis (disassemble-omn expressao-omn)) ;; Desmonta a expressão [3, 6] (pitches (getf dis :pitch)) ;; Extrai alturas atuais (lengths (getf dis :length)) ;; Extrai durações (inclui rests) [7] (velocities (getf dis :velocity)) ;; Extrai dinâmicas [8] (articulatio…
-
- 0 replies
- 164 views
-
-
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.…
-
- 0 replies
- 182 views
-
-
Hello, Opusmoders Sometime ago I was here searching for a function to displace rhtyhms by a length amount, not just like a list rotation. Now I did this prototype. I think that this can be very useful, specially inside counterpoint dictums where patterns can be displaced ( I did not tried inside the counterpoint function but seems like it will work). Hope it can be useful to you too. All the best, Julio (defun shift-rhythm (rhythm shift-length &key span) ;"Moves rhythmic material by inserting a pause at the beginning. ;Use length-adjust to ensure the result fits within the span." (let* ((rhy (flatten rhythm)) ;;;; Ensures a linear list for processing ;; Adds the …
-
- 0 replies
- 171 views
-
-
Hello, Opusmoders I did (with a little help of Notebooklm) this cool function whose function is to concatenate 2 diferent lists with sublists, merging the first sublist of the list A with the first sublist of list B, with the options 1) to choose how many elements of each list to use; and 2) the possibility of not only mix different numbers of elements in each list but also the possibility to select the starting element of the list to pick elements. 3) The function also consider each list as a rotating element: for example, if 5 elements are required from the list (1 2 3), starting in the first element, the result will be (1 2 3 1 2), if the start is on the second eleme…
-
- 0 replies
- 199 views
-
-
Does anyone has an idea how to get rid of all successive repeated dynamics and attributes? Thanks a lot, Achim ((-w) (-w) (w cs6 <mp> -14c) (w c6 <mp> -31c) (w c6 <mp> -31c) (w c6 <mp> -31c) (w c6 <mp> -31c) (w c6 <mp> -31c) (w cs6 <mp> -49c) (w cs6 <mp> -49c) (w cs6 <mp> -49c) (w cs6 <mp> -49c) (w cs6 <mp> 5c) (w cs6 <mp> 5c) (w cs6 <mp> 5c) (w c6 <mp>) (w c6 <mp> 2c) (w c6 <mp> 2c) (w c6 <mp> 2c) (w c6 <mp> 2c) (w c6 <mp> 5c) (w c6 <mp> 5c) (w c6 <mp> 5c) (w a5 <mp> -31c) (w a5 <mp> -31c) (w a5 <mp> -31c) (w gs5 <mp> -14c…
-
- 1 reply
- 259 views
- 1 follower
-
-
Using this expression (harmonics 'a2 8 :quantize nil :type :hertz) I am getting (110.0 220.0 329.62756 440.0 546.4174 659.2551 772.751 880.0) but I am expecting (110.0 220.0 330.0 440.0 550.0 660.0 770.0 880.0) What am I understanding wrong? Best, Achim
- 11 replies
- 795 views
- 2 followers
-
Are there any examples about how to apply the different features in the :tempo keyword in def-score? Achim
-
- 4 replies
- 327 views
- 2 followers
-
-
Hi alltogether, with this post, I want to share with you my Math-N-Tonic-Library creators. They use 2 different naming shemes and are compiled in two lisp files. They have been algorithmically created in order to collect all the mathematically possible tonalities: ;; Complete Summary ;; ============================================================== ;; Ditonic‑note scales: 66 ;; Tritonic‑note scales: 220 ;; Tetratonic‑note scales: 495 ;; Pentatonic‑note scales: 792 ;; Hexatonic‑note scales: 924 ;; Heptatonic‑note scales: 792 ;; Octatonic‑note scales: 495 ;; Nonatonic‑note scales: 220 ;; Decatonic‑note scales: 66 ;; Undecatonic‑note scales: 12 ;; Total mathematical tonali…
-
- 0 replies
- 224 views
- 1 follower
-
-
Dear Friends, With the audio tools in windows can we make some breakbeats, like chopping audio files, like beat slicing and starting in different parts of the audio file, like the video below (serato sample plugin), and also sync accurately with midi parts in Opusmodus ? All the best ! Julio SOME HISTORY Here are some breakbeats (amen sample) If possible, would be great to includ a sample of the amen beat inside the documentation with an example of breakbeat. This function can also serve to launch samples of any nature for electroacoustic or mixed music.
- 12 replies
- 1.4k views
- 2 followers
-
Hi, I have a valid rhythmic notation (quarter notes, eighth notes, triplets, etc.) where only quintuplets and septuplets display incorrectly as soon as rests are included in the group (-5q, -7q). Triplets don't cause any problems, but for 5 and 7, the grouping breaks (incorrect braces), as if the engine is closing/reopening the tuplets. Is this a known limitation of how rests are handled within odd-numbered tuplets (5, 7) in OMN, or is there a strict rule to follow to avoid this behavior? Thank you for your help. (setf accent '((q -q -q ) (e -e -e e -e -e) (3q -3q -3q 3q -3q -3q 3q -3q -3q) (s -s -s s -s -s s -s -…
- 24 replies
- 1.3k views
- 2 followers
-
I am reading the documentation of "harmonics": "The coeff keyword can be used to manipulate the pitches by adjusting the coefficients of the sine waves that correspond to each note. For example, by increasing the coefficient of the sine wave that corresponds to the fundamental frequency of a note, the pitch of that note can be raised. Similarly, by decreasing the coefficient of a higher harmonic, the pitch can be lowered. The use of coefficients in music theory is a mathematical approach to analysing and manipulating the frequency of a note." I have following questions: What is "the sine wave corresponding to each note"? I cannot change the coefficient of higher harmonics…
- 3 replies
- 318 views
- 1 follower
-
You can create the infinity series from binary numbers. ones are added, zeros reverse sign. Jesper (defun inf-ser (n &optional (offset 0) &aux tmp) (loop for i to (1- n) do (setf tmp 0) (loop for bin in (decimal-to-binary i) do (setf tmp (if (zerop bin) (- tmp) (+ tmp bin)))) ;(format t "~B = ~D~%" i tmp) collect (+ tmp offset))) (integer-to-pitch (inf-ser 128)) (integer-to-pitch (inf-ser 128 12))
- 2 replies
- 406 views
- 1 follower
-
Hey, people ! I´m doing a function to extract the complementary set of notes. For example: 1) Specify a set of notes, like a chord, Dm7 (setf note-list '(d5 f5 a5 c6)) Specify a tonality, like Cmajor or D dorian (same notes) (expand-tonality '(c5 major)) Now, I want a function that gives me all the other available notes from the mode, except the chord tones (the first set of notes). So, this function gives me exactly what I need (for ONE tonality at a time and ONE chord at a time): (let ((rem (expand-tonality '(c5 major))) (super (ambitus '(c5 b5) note-list))) (loop for i in super …
- 5 replies
- 1.6k views
- 2 followers
-
Dear All, Here is a proto-function idea... If Janusz or someone are interested in transform it in a core function, I think it could be interesting... Sometimes I like to take a motive or chorale texture and use it to make a kind of accompaniment or texture ala Reich. I created my way to do it, but it could be perfected in a better function and integrated in the core system. Here is the idea: ;; Motive (setf mat '(h c4 q. d4 e e4 -q w c4 h d4 q e4 -q)) ;; small value (setf fig-value '(e)) The "proto-function". What I could not achieve was how to make it respect the rests in the motive, but it works for generating the texture, respecting the pitch and length boundar…
- 6 replies
- 561 views
-
Hello, I found a function that is missing documentation: 2d-matrix->linearized-upper-trangular. Would you mind explaining this briefly? I hope to see the documentation added to the next update. Thanks!
-
- 0 replies
- 216 views
-
-
As hobbyist I am trying to learn how Jazz works and then explore what I have learned using OM for composition. For the composers and musicians among you following might seem trivial, so this post is probably only relevant for beginners like me (except for the question at the end of the post) But for me it's all new and exploring and discovering new concepts is fascinating. OM helps me a lot as learning tool to conceptualize and reuse in a principled, reproducible manner. In Jazz for piano comping, the use of rootless shell-voicings is common as far as I have learned. I have learned in a text book (Jeremy Siskind, Jazz Band Pianist), that typically for chord comping the …
-
- 1 reply
- 599 views
- 1 follower
-