Jump to content

torstenanders

Members
  • Content count

    222
  • Joined

  • Last visited

  • Days Won

    42

torstenanders last won the day on August 2

torstenanders had the most liked content!

About torstenanders

  • Rank
    Advanced Member

Contact Methods

  • Website URL
    www.torsten-anders.de/
  • Skype
    torsten_anders

Profile Information

  • Gender
    Male

Recent Profile Visitors

1,048 profile views
  1. torstenanders

  2. Members Map

    I can confirm that it works with Vivaldi, except that I cannot find the link Add Location there. How to sign up? Best, Torsten
  3. merge-rests-with-preceeding-note

    Ah, thanks -- indeed length-legato does the same. So, I will simply remove my new but redundant function again :) BTW, this function could be useful also for implementing Beethoven-like motif condensation, where (less important) notes are removed from a motif. Here is a simple example motif. (setf my-motif '((q. c4 e d4 q. e4 e f4) (h g4 -h))) Lets turn all the eighths notes in this motif into rests, and then extend the notes preceding the rests by the duration of the rests. The eighths notes occur at every 2nd position, and I am using a variant of length-rest-series to turn them into rests. While length-rest-series returns a list of lengths, this variant returns an OMN expression that retains all parameters. (setf my-motif2 (length-rest-series-omn '(2 2) my-motif)) => ((q. c4 -e q. d4 -e) (h e4 -)) (length-legato my-motif2) => ((h c4 d4) (w e4)) Of course, the tricky bit here is to determine which notes to "remove", i.e. which notes are less important. Above, these notes are selected by hand in the argument to length-rest-series-omn. An alternative approach would be to select these notes with a test. In the example below, all notes that are shorter than a quarter note are automatically removed and turned into rests. (length-legato (filter-notes-if #'(lambda (dur pitch &rest other-args) (> (omn-encode dur) 1/4)) my-motif)) => ((h c4 e4) (w g4)) filter-notes-if is defined at For completeness, below is the definition of length-rest-series-omn. It is defined with a (revision of) edit-omn that I reported before at Best, Torsten (defun length-rest-series-omn (rest-distances sequence) "Same as length-rest-series, but works on OMN expressions retaining all parameters. See doc of length-rest-series for more details." (edit-omn :length sequence #'(lambda (ls) (length-rest-series rest-distances ls)))) (defun edit-omn (type notation fun &key (flat T)) "Use function `fun', defined for transforming individual OMN parameters of `type' (e.g., :length, or :velocity) to transform omn expression `notation'. This function is intended as a convenient way to generalise functions your functions to support omn notation as input. Args: - type: a keyword like :length, :pitch, :velocity, :duration, or :articulation (any keyword supported by function omn or make-omn). - fun: a function expecting a parameter sequence of given type. It is sufficient to support only a flat input list, support for nested lists is added implicitly. - notation: a omn sequence or a plain parameter list (can be nested). - flat (default T): whether or not `fun' expects a flat input list. Example: roll your own transposition supporting omn input first aux def supporting only pitches ;;; (defun my-transposition-aux (interval pitches) ;;; (midi-to-pitch (loop for p in (pitch-to-midi pitches) ;;; collect (+ p interval)))) test ;;; (my-transposition-aux 7 '(c4 e4 g4)) ;;; => (g4 b4 d5) variant supporting also omn expressions ;;; (defun my-transposition (interval omn) ;;; (edit-omn :pitch omn ;;; #'(lambda (ps) (my-transposition-aux interval ps)))) test with nested OMN including a rest ;;; (my-transposition 7 '((q c4 mp -q q e4 q f4) (h g4 tr2))) ;;; => ((q g4 mp - b4 c5) (h d5 mp tr2)) More information at {https://opusmodus.com/forums/topic/799-user-functions-supporting-arbitrary-omn-input-–-defining-them-more-easily/}." (if (omn-formp notation) (copy-time-signature notation (let ((params (omn nil notation)) (type-is-length? (equal type :length))) (apply #'make-omn (append (list type (funcall fun (if flat (flatten (getf params type)) (getf params type)))) (remove-properties (if type-is-length? '(:length :duration) type) params) )))) ;; notation is plain parameter list (span notation (funcall fun (if flat (flatten notation) notation))))) (defun copy-time-signature (music-with-time-signature music-to-rebar) "Rebars `music-to-rebar' so that it fits the meter of `music-with-time-signature'." ;; only rebar if music-with-time-signature is nested (if (every #'listp music-with-time-signature) (omn-to-time-signature music-to-rebar (get-time-signature music-with-time-signature)) music-to-rebar)) (defun remove-properties (properties property-list) "Removes all properties and their values out of a property list" (reduce #'(lambda (list val) (remove-property val list)) properties :initial-value property-list))
  4. merge-rests-with-preceeding-note

    Thanks, but no, filter-tie does not change those rests, nor does it lengthen the notes preceding a rest. (merge-rests-with-preceeding-note '(e g6 f stacc -e e ab5 mp ten e c4 mf ten)) ;; the rest is gone, and the first note is longer so that the start time of the next note is unchanged=> (1/4 g6 f stacc e ab5 mp ten e c4 mf ten) (filter-tie '(e g6 f stacc -e e ab5 mp ten e c4 mf ten)) => (e g6 f stacc - ab5 mp ten c4 mf ten) Best, Torsten
  5. Members Map

    Thank you. Interesting to see how far spread the users are globally. Unfortunately, I still have some technical problems seeing the data, perhaps my software is too old. On Safari (version 9.1.3 on OS X 10.9.5) I only see a blank page with some links at https://opusmodus.com/forums/membermap/. The Link "Add Location" does not seem to do anything. When following the link "Browse Markers" and then clicking a few more times until I am actually visiting the individual users, then I can indeed see the user's location as pins on a map, but only the individual user. By contrast, with Firefox (version 54.0 (64-bit)) I do see a map at https://opusmodus.com/forums/membermap/, but without any users marked. However, I cannot at all see the link "Add Location", and when following the link "Browse Markers" the link "Group" seems inactive. Finally, with Chrome (version 36.0.1985.125) there is again no map shown, the link "Add Location" is missing, and when following the link "Browse Markers" the link "Group" seems inactive. Torsten
  6. Opusmodus 1.2.22479

    Thanks again! Torsten
  7. :opusmodus in *features*?

    BTW: very easy to do. Somewhere in your code do the following. (setf *features* (cons :opusmodus *features*)) And there should not be any side effects, as long as you do not remove any symbol from *features*, because no-one will have tested for :opusmodus in that list before (except it is a typo :) See also http://www.lispworks.com/documentation/lw50/CLHS/Body/v_featur.htm and http://www.cliki.net/features Torsten
  8. Sometimes you want to remove rests in an OMN expression without changing the actual rhythm, but instead lengthening the notes followed by a rest. The following function does that. (merge-rests-with-preceeding-note '(e g6 f stacc -e e ab5 mp ten e c4 mf ten)) => (1/4 g6 f stacc e ab5 mp ten e c4 mf ten) The definition is below. Best, Torsten (defun merge-rests-with-preceeding-note (sequence) "Remove all rests in sequence without changing the actual rhythm: extends the length of each note followed by that rest value, so that the overall duration remains as before. Args: - sequence: OMN expression, can be nested. Examples: ;;; (merge-rests-with-preceeding-note '(e g6 f stacc -e e ab5 mp ten e c4 mf ten)) ;;; => (1/4 g6 f stacc e ab5 mp ten e c4 mf ten)" (do-verbose ("") (let* ((nested? (every #'listp sequence)) (events (single-events (omn-merge-rests (if nested? (flatten sequence) sequence)))) (result (append (tu:mappend ;; mappend consecutive pairs #'(lambda (n1 n2) (cond ((length-restp (first n1)) nil) ((length-restp (first n2)) ;; add dur of n2 to n1 (cons (+ (omn-encode (first n1)) (abs (omn-encode (first n2)))) (rest n1))) (T n1))) (butlast events) (last events (1- (length events)))) (let ((last-event (first (last events)))) (if (length-restp (first last-event)) nil last-event))))) (if nested? (copy-time-signature sequence result) result))))
  9. :opusmodus in *features*?

    Dear Janusz, Would it be possible to add a symbol like :opusmodus to the variable *features*? I am writing a cross-platform library, and for Opusmodus-specific features it would be good to be able check for that platform. Currently, I am instead checking for Clozure CL and then assume Opusmodus as shown below, but it would be better to have some check specifically for Opusmodus. (cond #+clozure ; opusmodus ((om:omn-formp x) <do some fancy processing>) ...) Best, Torsten
  10. In case someone is interested, I just put some of my libraries online. Fenv is a library of highly flexible envelopes for algorithmic composition. The software represents envelopes as numerical functions, called fenvs. It provides a rich set of functions to generate, combine and transform these envelopes. You can find the code at https://github.com/tanders/fenv, together with some information how to install and use. Best, Torsten
  11. Opusmodus 1.2.22292

    Do you have your divisi strings represented as chords and what to split them into separate parts? You could do that with the polyphonic representation I was talking about. For the definition of preview-score please see https://opusmodus.com/forums/topic/902-polyphonic-preview/. (setf my-score '(:vl1 (h g4b4 g4a4) :vl2 (h e4 d4) :vla (h c4 b3) :vlc (h c3 g3))) ; test (preview-score my-score) (setf divisi-part (single-events (pitch-melodize (get-part-omn :vl1 my-score)))) (setf result-score (split-part :vl1 my-score `(:vl1_div1 ,(flatten (at-even-position divisi-part)) :vl1_div2 ,(flatten (at-odd-position divisi-part)))))) ; test (preview-score result-score) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; I am using above various other functions I have in my libraries, and I am copying their definition below. Hope I did not forget any... ;;; (defun get-part-omn (instrument score) "Returns the part (OMN expression) of `instrument' in `score', a headerless score (see {defun preview-score} for its format)." (getf score instrument)) (defun split-part (instrument orig-score score-to-insert) "Replaces part of `instrument' in `orig-score' with `score-to-insert'." (let ((instr-position (position instrument orig-score))) (append (subseq orig-score 0 instr-position) score-to-insert (subseq orig-score (+ instr-position 2))))) (defun at-even-position (in-list) (at-position in-list 2 0)) (defun at-odd-position (in-list) (at-position in-list 2 1)) (defun at-position (in-list factor offset) "Returns a list containing every factor-th elements of in-list starting at offset" (mapcar #'(lambda (i) (nth i in-list)) (arithmeric-series factor offset (ceiling (/ (length in-list) factor))))) (defun arithmeric-series (factor offset length) (let (result) (reverse (dotimes (i length result) (push (+ (* i factor) offset) result))))) Best, Torsten
  12. Polyphonic preview?

    Dear Janusz, To be clear: I do not expect that there will be a keyboard shortcut for every user added to Opusmodus. Instead, if you just share an example of code how to add a short key (and ideally a menu entry) to the Hemlock editor, that would be great. Thanks again! Best, Torsten
  13. I am interested in controlling musical textures, i.e., relations between polyphonic parts. I defined a bunch of functions that use the simple polyphonic music representation used also by my function preview-score that I presented shortly (see https://opusmodus.com/forums/topic/902-polyphonic-preview/#comment-2686). Apologies that this post is a bit longer. Here is a particularly flexible function: map-parts transforms a polyphonic score. It is a variant of the standard Lisp function mapcar, where a function is applied to every part in a score, but each instrument/part can be given its own function arguments for the transformation. One argument is the respective part of the score. This argument is marked by an underscore (_) in the argument lists. In the following example, the function pitch-transpose is applied to a score with two very simple parts consisting of only a single note each. This function has two required arguments, a transposition interval (measured in semitones), and the pitch sequence or OMN to transpose. The transposition interval for the first part is 4 (major third upwards), and the underscore marks the position of the violin part to transpose, etc. Note that you can always see and hear the resulting score by wrapping preview-score around each example. Hopefully these examples sufficiently demonstrate my need to have some shortcut for preview-score :) (map-parts '(:vln ((h e4)) :vlc ((h c3))) #'pitch-transpose '(:vln (4 _) :vlc (12 _))) -> (:vln ((h gs4)) :vlc ((h c4))) Here are a few more relatively simple application examples. I am first defining some musical material to reduce the length of the remaining definitions. (setf material '((-3h fs4 pp eb4 <) (q e4 < fs4 <) (3h gs4 mp> a4 > bb4 >) (q a4 pp -) (-5h - g4 pp leg eb4 < leg d4 < leg) (q bb4 < e4 <) (5h g4 mp> leg b4 > leg a4 > leg bb4 > leg d4 > leg) (q gs4 pp -))) Now, the next example creates a strict canon formed with the given material -- but without following any counterpoint rules :) For different parts the material is metrically shifted and transposed. This example also shows that map-parts calls can be nested (naturally). The function metric-shift appends some rest before some musical material, but preserves its rhythmical structure, i.e. metrically shifts the material. (map-parts (map-parts `(:vl1 ,material :vl2 ,material :vla ,material :vlc ,material) #'metric-shift '(:vl1 :skip ;; :skip means to leave part unchanged :vl2 (-q _) :vla (-h _) :vlc (-h. _))) #'pitch-transpose '(:vl1 (6 _) :vl2 (4 _) :vla (2 _) :vlc :skip)) The next examples shows some simple homorhythmic texture created by randomised transpositions. Each part shares a similar overall pitch profile. Note also that calls can be more concise with a (lambda) function that nests calls to transformation functions -- instead of nesting map-parts as shown above. (map-parts `(:vl1 ,material :vl2 ,material :vla ,material :vlc ,material) #'(lambda (transpose seq) ;; static transposition for moving parts into different registers (pitch-transpose transpose ;; randomised transposition of notes in parts (pitch-transpose-n (rnd 10 :low -2 :high 2) seq))) '(:vl1 (7 _) :vl2 (0 _) :vla (-10 _) :vlc (-20 _))) Finally, here is a homophonic texture created by random pitch variants (retrograde, inversion etc.). The global pitch profiles of parts differ here, in contrast to the previous example. (map-parts `(:vl1 ,material :vl2 ,material :vla ,material :vlc ,material) #'pitch-variant `(:vl1 (_ :transpose 7 :seed 10) :vl2 (_ :transpose 0 :seed 20) :vla (_ :transpose -10 :seed 30) :vlc (_ :transpose -20 :seed 40)) :shared-args '(:variant ?)) All these examples demonstrate very conventional textures, as such textures are more easy to explain. For completeness, below is the definition of map-parts. There are various dependencies that I tried all to add as well. Please let me know if I missed any definition, and apologies in advance. Best, Torsten (defun map-parts (score fn part-args &key (parameter nil) (shared-args nil)) "Create or transform a polyphonic score. The original purpose is for creating/transforming musical textures, i.e., relations between polyphonic parts. Applies function `fn' to parts in `score': this function is a variant of the standard Lisp function `mapcar', but specialised for scores. A score is represented in the format discussed in the documentation of the function `preview-score'. Additional arguments for `fn' can be specified in `part-args', and these argument lists can be different for each part. However, one argument is the part of the score. This argument is marked by an underscore (_) in the argument lists. In the following example, the function `pitch-transpose' is applied to a score with two parts. This function has two required arguments, a transposition interval (measured in semitones), and the pitch sequence or OMN to transpose. The transposition interval for the first part is 4 (major third upwards), and the underscore marks the position of the violin part to transpose, etc. ;;; (map-parts '(:vln ((h e4)) ;;; :vlc ((h c3))) ;;; #'pitch-transpose ;;; '(:vln (4 _) ;;; :vlc (12 _))) Args: - score (headerless score): See {defun preview-score} for format description. - fn: A function that expects and returns an OMN sequence or a sequence of parameter values (e.g., lengths, or pitches) as specified in the argument `parameter'. - part-args (plist): Alternating instrument keywords (same as in `score') followed by arguments list for `fn' for that instrument/part. If arguments is :skip, then that part is returned unchanged. - parameter (omn parameter, e.g., :length or :pitch, default nil means processing full OMN expression): If `fn' expects only single parameter to process, then it can be set here. - shared-args (list): For all instruments/parts, these arguments are appended at end end of its part-specific arguments. They are useful, e.g., for keyword arguments. " ;; catching hard-to-find user error... (let* ((instruments (get-instruments score)) (missing-instruments (remove-if #'(lambda (arg-instr) (member arg-instr instruments)) (get-instruments part-args)))) (assert (not missing-instruments) (part-args) "map-parts: Some instruments in `part-args' don't have a matching instrument in `score'. ~A.~%" missing-instruments)) (let ((parts (make-hash-table :test #'equal))) ;; fill hash table, using leading keywords as keys (loop for part in (tu:plist->pairs score) do (setf (gethash (first part) parts) part)) (tu:pairs->plist (loop for instrument-arg-pair in (tu:plist->pairs part-args) for instrument = (first instrument-arg-pair) for part = (gethash instrument parts) for part-omn = (second part) for fn-args = (second instrument-arg-pair) collect (if (equal fn-args :skip) part ; no processing (cons instrument (let ((result (apply fn (append (substitute (if parameter (omn parameter part-omn) part-omn) '_ fn-args) shared-args)))) (list (if parameter (omn-replace parameter result part-omn) result))))) )))) (defun metric-shift (l lengths) "Appends `l' (a length or omn) before `lengths' (a list of lengths or omn), but maintains the metric structure, i.e., the function shifts `lengths' metrically 'to the right' by `l'. Returns an OMN form if lengths is an OMN form, otherwise a length form. Related: assemble-seq (but that does not shift across bars)" (let* ((time-sigs (get-time-signature lengths)) (result (omn-to-time-signature (cons l (flatten lengths)) time-sigs))) (if (omn-formp lengths) result (omn :length result)))) ; (metric-shift '-h '((q q q q) (q q q q))) ; (metric-shift '(h g4) '((q c4 q d4 q e4 q f4) (q c4 q d4 q e4 q f4))) (defun get-instruments (score) "Returns all instruments of `score', a headerless score (see {defun preview-score} for its format)." (at-even-position score)) (defun at-even-position (in-list) (at-position in-list 2 0)) (defun at-position (in-list factor offset) "Returns a list containing every factor-th elements of in-list starting at offset" (mapcar #'(lambda (i) (nth i in-list)) (arithmeric-series factor offset (ceiling (/ (length in-list) factor))))) (defun arithmeric-series (factor offset length) (let (result) (reverse (dotimes (i length result) (push (+ (* i factor) offset) result))))) (defun plist->pairs (plist) (loop :for (key val) :on plist :by #'cddr :collect (list key val))) (defun pairs->plist (pairs) (one-level-flat pairs)) (defun one-level-flat (list) "flatens one level of the given form. Example: (one-level-flat '(((note) (note)) ((pause) (pause)) ((note)))) -> ( (note) (note) (pause) (pause) (note))" (apply #'append list))
  14. Polyphonic preview?

    Sorry, I am using multiple libraries of own functions in the background. Easy to miss one :) EDIT: Sorry, the function one-level-flat was still missing and has been added now. I also removed the package prefix above. (defun plist->pairs (plist) (loop :for (key val) :on plist :by #'cddr :collect (list key val))) ; (plist->pairs '(:length 1/16 :pitch 60 :velocity 30)) ; -> ((:LENGTH 1/16) (:PITCH 60) (:VELOCITY 30)) (defun pairs->plist (pairs) (one-level-flat pairs)) ; (pairs->plist '((:LENGTH 1/16) (:PITCH 60) (:VELOCITY 30))) ; -> (:LENGTH 1/16 :PITCH 60 :VELOCITY 30) (defun one-level-flat (list) "flatens one level of the given form. Example: (one-level-flat '(((note) (note)) ((pause) (pause)) ((note)))) -> ( (note) (note) (pause) (pause) (note))" (apply #'append list))
  15. Opusmodus 1.2.22292

    Below is a generalised version that expects a test function instead of a static parameter. That way you can, e.g., filter out all notes above a certain pitch threshold or arbitrary other conditions that you can express with a function. Demonstration examples are contained in the doc string below. Best, Torsten (defun filter-notes-if (test OMN &key (remain T) (section nil)) "Extracts events in OMN for which a given test function returns true (or keeps only events for which the test function returns nils). All other notes are turned into rests. Args: - test: Boolean function expecting individual parameters of each note in `OMN' - OMN: An OMN sequence - remain: Boolean expressing whether only matching notes (T) or non-matching notes (nil) should be kept. - section: an integer or list of integers. Selected list or lists to process. The default is NIL. See also Opusmodus builtin `filter-events'. Examples: Keep only notes above middle C and turn other notes into rests (filter-notes-if #'(lambda (dur pitch &rest other-args) (> (pitch-to-midi pitch) 60)) '(e c4 mp -e fermata e. d4 -h e. c4 e e4)) Do the opposite with :remain nil. (filter-notes-if #'(lambda (dur pitch &rest other-args) (> (pitch-to-midi pitch) 60)) '(e c4 mp -e fermata e. d4 -h e. c4 e e4) :remain nil) This also works with nested lists and you can process only selected bars (other bars are kept unchanged). (filter-notes-if #'(lambda (dur pitch &rest other-args) (> (pitch-to-midi pitch) 60)) '((e c4 mp -e fermata e. d4 -s) (-q.. e. c4 e e4)) :section 1) " (if section (maybe-section #'(lambda (seq) (filter-notes-if test seq :remain remain)) OMN section) (copy-time-signature OMN (flatten (mapcar #'(lambda (params) (if (length-notep (first params)) (if (if remain (apply test params) (not (apply test params))) params ;; turn non-matching note into rest ;;; TODO: preserve params relevant for rests (e.g., fermatas) (- (omn-encode (first params)))) ;; leave rests unchanged params)) (single-events (flatten OMN))))))) (defun copy-time-signature (music-with-time-signature music-to-rebar) "Rebars `music-to-rebar' so that it fits the meter of `music-with-time-signature'." ;; only rebar if music-with-time-signature is nested (if (every #'listp music-with-time-signature) (omn-to-time-signature music-to-rebar (get-time-signature music-with-time-signature)) music-to-rebar))
×