Function Examples
Functions, arguments, values and results
271 topics in this forum
-
Has anybody an idea how to formalize the following task? A list of 4 sublists with 2 elements: '((1 2) (3 4) (5 6) (7 8))) ==> All the possible combinations of either one or the other number in the sublist: '( (1 3 5 7) (1 4 5 7) (1 3 6 7) (1 4 6 7) (1 3 5 8) (1 4 5 8) (1 3 6 8) (1 4 6 8) (2 3 5 7) (2 4 5 7) (2 3 6 7) (2 4 6 7) (2 3 5 8) (2 4 5 8) (2 3 6 8) (2 4 6 8) ) Did I miss a combination? Thanks for help. Achim
-
- 2 replies
- 481 views
- 2 followers
-
-
There are 10 functions that have a key parameter :assoc. None of the documentation is particularly clear on what it is or what it does. Most of the functions just list that it is an integer and that it defaults to 12. The only other description that is sometimes added is "row size," but that description is also attached to the :mod key parameter for a number of the functions. I ran the following code to generate a report of how :assoc impacts the row-variants function when run on ordered intervals under various levels of transposition: (pprint-expression (loop for x from 1 upto 11 collect (list (concatenate 'string "Set: (0 " (write-…
-
- 2 replies
- 306 views
- 2 followers
-
-
Hi, I don't understand the result of harmonic-path, as I understand it, it should be (something like): (eb4 g4 bb4 d4 gs4 c4 eb4 fs5 b5 bb5 ds5 fs5 b5 d5 g4 b4 eb4 g4 bb4 g4) below is the evaluation and I don't understand it, what am I missing..? (harmonic-path '(eb3g3bb3d4 gs3c4ds4fs4 b3ds4fs4bb4 g3b3d4fs4)
 '(c4 d4 e4 f4 g4 a4 b4 c5 d5 e5 f5 e5 d5 c5 b4 a4 g4 f4 e4 d4))
 ==>(eb4 g4 bb4 d4 gs4 c4 eb4 fs5 b5 bb5 eb5 g5 bb5 d5 gs4 c4 eb4 fs4 b4 bb4) It seems that I am overlooking something obvious, so I'am greatful for some help! Thanks!
- 2 replies
- 2.3k views
-
Dear All, It´is possible to initialize sublists all at once as setf variables ? To transform a list like this: ((c4 ds4 e4)(c4 d4 f4)(c4 d4 g4)(cs4 d4 e4)), automatically into a list of setf materials, like v1 = (c4 d4 e4) v2 = (c4 d4 f4) v3 = (c4 d4 g4) v4 = (cs4 d4 e4) OBS.: v1 can be any letter, like p1, p2 or maybe mat1, mat2, etc... Thank you
- 2 replies
- 1k views
-
Hi, In the docs it says that arp-adlib makes an arpeggio up or down randomly, but there are only arps upward, what am I missing? thanks! (setf arp '(c4d4e4g4a4b4d5fs5 arp-adlib c4d4e4g4a4b4d5fs5 arp-adlib c4d4e4g4a4b4d5fs5 arp-adlib c4d4e4g4a4b4d5fs5 arp-adlib c4d4e4g4a4b4d5fs5 arp-adlib c4d4e4g4a4b4d5fs5 arp-adlib c4d4e4g4a4b4d5fs5 arp-adlib c4d4e4g4a4b4d5fs5 arp-adlib c4d4e4g4a4b4d5fs5 arp-adlib))
- 2 replies
- 2.4k views
-
Dear Friends, I have this recurrent problem with lists... Please, help... ;;; I have this TWO lists (setf list1 '(v1rp0 v1rp1 v1rp2 v1rp3 v1rp4) (setf list2 '(melch1-0 melch1-1 melch1-2 melch1-3 melch1-4) ;;;AND ;;; I need a list like this (alternating the list) (v1rp0 melch1-0 v1rp1 melch1-1 v1rp2 melch1-2 v1rp3 melch1-3 v1rp4 melch1-4) How can I proceed ? Thanks a lot Best, Julio (a desperate quarantine composer) OBS. help in combining THREE lists are also greatly appreciated, as well as how to combine parts of the lists. Thank you... my brain is ruined for now (I´m doing so…
- 2 replies
- 1.1k views
- 1 follower
-
Hi, What am I missing? (pitch-demix '(3 2) '(c3e4g5b6 d3f4a5c6 e3g4b5d6)) =>(e4 f4 g4) I would expect this: =>((e4 f4 g4)(g5 a5 b5)) thanks for an answer!
-
- 2 replies
- 913 views
- 1 follower
-
-
LISP... any solution? i want to DIVIDE a seq into sublists -> when it's asc into a list, "rest" into single-listed values - thanx a lot for some help 🙂 ;;; input (divide* '(14 12 3 13 15 8 4 10 17 2 16 0 1 6 7 5 11 9)) ;;; output => ((14) (12) (3 13 15) (8) (4 10 17) (2 16) (0 1 6 7) (5 11) (9))
- 2 replies
- 1.6k views
-
Below is a function that might be interesting for others as well. When I starting writing this function it was much more complicated, but it got more simple by and by 🙂 A formatted version as an RTF file of the documentation is attached, below is a plain text version. For completeness I also attached the documentation of the function circle-repeat, used by the function below. Unfortunately, the file names are destroyed by the software of this forum, sorry. Best, Torsten alternate-omns ids omns Arguments and Values ids a list of integers, indicating the position of OMN expressions in omns. omns a li…
-
- 2 replies
- 2k views
-
-
Dear All, I´m creating some permutations and I´d like to assign a text under each note to make clear the use of certain intervals. substitute-map '(T 2M 3M 4J 5J 6M 7M) '(c3 d3 e3 f3 g3 a3 b3) '(c3 d3 e3 f3 g3 c3 c3 c3 g3 c3 c3 d3)) But in the evaluation, I get this: (t 2m 3m 4j 5j t t t 5j t t 2m) With lowercase letters, I get 2m , 3m and 5J instead of 2M, 3M and 5J (uppercase names of intervals). Since I want it for pedagogical reasons, can it be generated with the corresponding UPPERCASE letters ? Thanks in advance. All the best, Julio
- 2 replies
- 2.4k views
-
Hello! I've been coding in python for two weeks for work and I'm now having trouble figuring out what I'm doing wrong in my lisp loops. Cursor.ai isn't helping debug my lisp at all. I'm trying to loops through scales such as (setf a-pitches (loop for note in scalea collect (list note (+ note 4)))) And it's not evaluating. I was hoping to do this in OpusModus with a little help from cursor for lisp but that's not yielding good results. There's probably an OM function I'm not thinking of. Here's the whole set of functional code. Any advice is appreciated. ;;;---------------------------------------------…
- 2 replies
- 303 views
-
Hi, Is it possible to write a function which gives the following result: ((1)(1 2 2)(1 2 2 3 3 3)(1 2 2 3 3 3 4 4 4 4)(1 2 2 3 3 3 4 4 4 4 5 5 5 5 5))etc. Thanks for any suggestions!
- 2 replies
- 335 views
-
Dear All, How can I get controlled seeds in a expression like this? (let ((r-lis nil)) (dotimes (i 4) (push (rnd-unique 5 '(1 2 3 4 5)) r-lis)) r-lis) This will result four different seeds (one for each loop iteration), like this: rnd-unique :seed 361914 rnd-unique :seed 275956 rnd-unique :seed 883737 rnd-unique :seed 46981 ((3 1 4 5 2) (4 2 1 5 3) (2 5 4 1 3) (1 3 5 4 2)) And this will result the same seed for all four iterations: (let ((r-lis nil)) (dotimes (i 4) (push (rnd-unique 5 '(1 2 3 4 5):seed 1) r-lis)) r-lis) Like this: rn…
- 2 replies
- 927 views
- 1 follower
-
OMers, I wrote this function and use it in my composition work. Please feel free to steal use it. It returns the "polarity" of a sequence, defined as the ratio of consecutive uneven and even interval classes (IC) in a sequence. I use this as a way of testing if a generated sequence contains a balanced mix of even or uneven ICs. (defun polarity (in-seq) (when (equal (length in-seq) 0) return 0 ) (let((accum 0) (int-pairs (interval-class in-seq))) (mapcar (lambda (x) (when (evenp x) (incf accum) )) int-pairs) (/ (* accum 1.0) (- (length in-seq) 1)) ) ) Some examples: ;; The polarity of a chromatic scale…
- 2 replies
- 488 views
- 1 follower
-
Hi, Does anyone know of a good way to sort a list of pitches so I get a list of all the quartertones and another list of all the semitones? Or maybe a function that tests if a pitch is within the twelve semitones or not? Thank you Anders
- 2 replies
- 399 views
- 2 followers
-
dear all, i have a basic lisp-question to FORMAT and i did not find a solution... INPUT (setf alist '((/player "12" 1.0 1.0 1.0) (/player "23" 1.0 1.0 1.0) (/player "12" 1.0 1.0 1.0) (/player "23" 1.0 1.0 1.0))) ;; with FORMAT to => /player "12" 1.0 1.0 1.0, /player "23" 1.0 1.0 1.0, /player "12" 1.0 1.0 1.0, /player "23" 1.0 1.0 1.0 by FORMAT => i will save it in a TXT-file on desktop (that works (with-open-file...)), but i have a format-problems with the commatas and the () thanx for such basic-lisp-help andré
- 2 replies
- 578 views
-
Dear All, I don´t know what happens in Mac, but in Windows, sometimes the code color highligth is changing. I have to press enter to get the code colors again... Maybe a bug ?
- 2 replies
- 386 views
- 1 follower
-
Hi, would it be possible to get the same result as harmonic-progression with the diatonic-chord function? thanks for your help (setf a (harmonic-progression '(1 6 2 5 3 6 2 5 1) scale :base 1 :size 3 :step '((2 2)))) (setf cad1 (diatonic-chord '(:c I vi ii V III vi ii v I)))
-
- 2 replies
- 206 views
- 1 follower
-
-
Below is a function for creating durational accents on the beginning of bars. Many musical styles pay careful attention to how their rhythmic language expresses accents. Certain rhythmic events are perceived as stronger emphasised than others. Such accents do not need to be forced by a performer, e.g., by a dynamic accent. Instead, music theorists identified various musical factors that express accents. Durational accents (expressed by inter-onset intervals) are particularly effective. They are caused by relatively long durations following one or more shorter durations. The function definition is below. Here are two demo calls, showing multiple solutions. …
- 2 replies
- 3.6k views
- 1 follower
-
Hello i would like to divide a series of lengths into bar measure signature like 4/4 or 6/8 etc... But i would like to cut the overlapping lengths over the bar measure if any . I tested omn-to-measure but it doesn't cut oeverlap lengths over the measure Thank you Patrick
- 2 replies
- 161 views
- 1 follower
-
I've shared a video here on CHORD-DICTUM function and you will find here the code from the video. Enjoy ! The Score: ;;;-------------------------------------------------------- ;;; SCORE 186 ;;; VARIATIONS POUR PIANO ;;; Etude de la fonction "chord-dictum" ;;; S.BOUSSUGE ;;; WIEN - 27.01.2024 ;;;-------------------------------------------------------- ;;; LEARN OPUSMODUS: WWW.COMPOSERWORKSHOP.COM ;;;-------------------------------------------------------- ;;; To view the score press the Cmd-Option-1 keys. ;;;-------------------------------------------------------- ;;; UTILITY ;;; REA-MARK (defun rea-mark (omn-exp) "Add rehearsal marks…
- 2 replies
- 1k views
- 2 followers
-
Dear All, From the example below I suppose that choralis function applyes some voice-leading in the progression provided. Maybe to generate some more singable sequence ? (maybe not...) For example, here I provide my classic test-debuggin harmony: (setf chords2 (gen-trim 31 '(a3b3e4gs4 gs3eb4g4bb4 cs3a3b3e4 gs2f3bb3d4 gs2e3b3eb4 eb3b3cs4fs4 a2e3eb4b4 fs2cs3c4gs4 d3gs3b3g4 b3e4fs4a4 fs3cs4f4c5 b3cs4fs4bb4 g2d3cs4a4 g2fs3b3cs4 e2fs3g3d4 f2eb3bb3d4 b2g3a3d4 bb2gs3eb4g4 e3c4g4d5 cs3a3e4b4 gs3bb3eb4g4 fs3gs3cs4f4 fs2e3b3eb4 cs3a3b3e4 b2gs3cs4f4 eb3a3d4fs4 d3bb3f4c5 e3eb4gs4bb4 f3cs4gs4eb5 b2fs3f4cs5 eb3b3cs4fs4 eb3gs3b3g4 e3g3d4fs4 a2bb3eb4g4 d…
- 1 reply
- 1.2k views
- 1 follower
-
I have two brief examples taken from a piano piece. In the first one, I'd like to attach the piano pedal marking on every octave, hold it and reattach at the next octave. (setf ex1 '((-q a2a1 a2a1) (-q a3a2) (-wq q b2b1) (-wq q b2b1) (-q a2a1 - g3g2) (-q f3f2 a2a1) (q f3f2) (q f2f1) (-wq q f3f2) (-q g2g1) (-q g2g1 - g2g1) (-q f2f1 e3e2) (-q f2f1 d3d2) (-w q d3d2))) In the second, I'd like to attach the piano pedal on every octave - not single pitches - and hold it until the next octave appears, and reattach it again. (setf ex2 '((-q) (q g4 mp -) (q a4 mp - a4a3) (q cs4 mp - cs4cs3 -) (q f4 mp - f4f3) (q f4 mp - f4f3 -) (q e4 mp - …
-
- 1 reply
- 455 views
- 1 follower
-
-
Hi, (setf test-flatten (flatten '((q a4 -e gs4 e4 -) (q a4 e - e4 d4) (-e g4 e4 - q a4) (-h.) (-q e a4 gs4 - g4)))) (setf por (length-rest-position test-flatten)) ==>(1 4 7 10 13 15 16 19) (setf sr (position-filter por test-flatten)) ==>(-e - - -) ;should be this: ; (-e - - - - -h. -q -e) ;or do I miss something? Thanks for assistance!
-
- 1 reply
- 619 views
- 1 follower
-
-
Hi, attached is a function I wrote for a piece. Does anybody have an idea how to extend this with a seed functionality. I have tried a few things but so far without any real success ... The other thing: It can take quite a while until a possible solution ist found. Does anybody have an idea to improve the calculation speed? Thanks and best, Achim fill-space.opmo
- 1 reply
- 721 views
- 2 followers