Jump to content
Sign in to follow this  
Jorvd

Change Velocity Repeating Notes

Recommended Posts

Hi Everyone,

I'm looking for a method/function which changes the velocity only for notes that are repeating.
In other words, if I have a sequence like this:

'(c4 eb4 g4 ab4 ab4 ab4 d4 eb4)

I would like to be able to create a crescendo/decrescendo or set a custom velocity for just the Ab notes.
In the past I've customised a Pattern Matching function from Stephane to change the velocity for specific note lengths:

(defun velocity-map-omn (map omn &key (otherwise '-))
  (do-verbose
      ("velocity-map-omn")
    (let ((plist (disassemble-omn omn)))
      (setf (getf plist :velocity)
            (pattern-map map (getf plist :length) :otherwise otherwise :swallow t))
      (apply 'make-omn plist))))

And I think this should be very close to what I want, however, I have no idea how to tell OM to process repeating notes only.
Is there anyone who already has a function like this or can steer me in the right direction? Hope this makes sense, any help is very welcome!

 

- Jor

Share this post


Link to post
Share on other sites

like that..?... some code...

greetings

andré

 

(defun replace-velocities-in-a-seq (omn-list &key pitch velocity-list)
  (flatten 
   (loop 
     with cnt = 0
     for i in (single-events omn-list)
     
     when (equal (cadr i) pitch)
     collect (omn-replace :velocity (nth cnt velocity-list) i)
     and do (incf cnt)
     else collect i

     when (> cnt (length velocity-list))
     do (setf cnt 0))))



(replace-velocities-in-a-seq '(e c4 ppppp d4 d4 e4 f4 d4 d4 g4 b4 d4 d4 d4 d4)
                             :pitch 'd4
                             :velocity-list '(p mp mf f ff))

;=> (e c4 ppppp e d4 p e d4 mp e e4 ppppp e f4 ppppp e d4 mf e d4 f e g4 ppppp e b4 ppppp e d4 ff e d4 ppppp e d4 p e d4 mp)

;; if there are more 'd4's then velocity-values, -> it starts again with first velocity-value (= cycle)

 

Share this post


Link to post
Share on other sites

Wow that's amazing, I've looked at this for 15 minutes now and I think I gained a few braincells. Learning a lot from these examples, exactly what I needed as well, thanks so much!

Share this post


Link to post
Share on other sites

you're welcome!!

 

i think for specific solutions it helps a lot to learn some LISP-basics (loops/conditionals/car/cons/...), then you have the possibility to make your own additional functions/libraries in OPMO. and OPMO is really great for such things!! 😎

 

greetings

andré

Share this post


Link to post
Share on other sites

Thanks André, this is still on my list, I definitely see the benefits in learning LISP.

If you have specific sources (books/links/videos) that you think are good places to start, please feel free to share 😉
- Jor

Share this post


Link to post
Share on other sites

http://www.gigamonkeys.com/book/

 

LISP-LANG.ORG

Books about Common Lisp

 

For a more music-related introduction to Common Lisp you might want to look at the following books. These books teach algorithmic composition with Common Lisp. The above books introducing only Common Lisp are far more comprehensive on that matter, but you might prefer learning some foundations first within a  musical context.

 

 

Morgan, N. & Legard, P. (2015) Parametric Composition: Computer-Assisted Strategies for Human Performance. West Yorkshire, UK: Tonality Systems Press.

Introduces Opusmodus along with some Lisp.

 

 

Taube, H. (2004) Notes from the Metalevel. London and New York: Taylor & Francis.
This book introduces the algorithmic composition system Common Music, along with Lisp fundamentals.
 
 

Algorithmic Composition: A Gentle Introduction to Music Composition Using Common LISP and Common Music

https://quod.lib.umich.edu/s/spobooks/bbv9810.0001.001/1:3/--algorithmic-composition-a-gentle-introduction-to-music?rgn=div1;view=fulltext
I have not read this one...

Share this post


Link to post
Share on other sites

The best document combining both worlds is likely the following. This was an internal textbook of the algorithmic composition teacher Paul Berg at the Sonology course at the Royal Conservatory of The Hague (the author of the composition system AC Toolbox, https://www.actoolbox.net), but it is unprinted, just a copy of a text processor document for internal use, and difficult to obtain (I only have a hard copy I got from a friend). 

 

Berg, Paul (n.d.) Elements of Design. An introduction to Programming with Common Lisp. 

Share this post


Link to post
Share on other sites

Thanks a lot, some great resources! I've started with just the very basics and working my way through

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Similar Topics

    • By spuki
      Hi there,
      i'm a excited beginner with OM!
      Just exploring and modifying the turotials.
       
      One Question:
      What would be a good approach to sort the notes which are generated from the snippet below to, say, a scale.
      In other words: The outoot below is chromatic. How can i turn it into a scale, eg. d-phrygian)
      Thank you!
       
      (setf size 60) (setf vector       (gen-sine        size 1 '(0.5 0.4 0.3 0.6)        :modulation (gen-sine size 1 0.3 :phase 180))) (setf pitchvec (vector-to-pitch '(g1 g6) vector))  
    • By torstenanders
      Revising some older code of my I noticed that the function length-divide changed its behaviour somewhat and became more likely to cause an error.
       
      In a previous version, where the arguments count and divide where given separately, it was possible to set the count to some very high number, say, 1000, simply to mean that all notes the function can split (depending on its other arguments) will be split. 
       
      Meanwhile, the function have been revised to introduce control over intervals (thank you 🙂), but since then it seems it is not possible anymore to set an arbitrarily high count value anymore. For example, the following code now results in an error. I would prefer the previous behaviour, if only because it is more forgiving and stable.
       
      (length-divide '(1000 2) '(q ab3 num1+leg c4 leg e ab3 leg g3 leg ab3 num1+leg c4 leg)) Error: The value ab3 is not of the expected type sequence.  
      In case it helps: my debugger tells me the functions gen-repeat and then maybe-section are called (perhaps within a nested function of length-divide* ?) with an argument sequence bound to ab3 (i.e. a plain pitch), and a call (length ab3) then causes this error. 
       
      Thank you!
       
      Best,
      Torsten
    • By torstenanders
      The function LENGTH-DIVIDE and friends are a useful device for introducing some rhythmic variation to some material. However, when the processed sequence is a full OMN expression (see example below), then the added notes cause all other parameters to shift forward (additional parameters are added at the end by looping). For introducing only a slight variation to some existing material (e.g., motif) these functions are therefore not so useful, because this shift of all parameters to basically "fill" the new added notes with pitches etc. greatly change the varied material for a listener.
      (length-divide 1 2 '(q f3 leg+m1 q ab3 leg e c4 leg bb3 leg ab3 leg g3))  
      Basically, this is the opposite situation of the situation addressed by swallowing. Swallowing (e.g., with GEN-SWALLOW and the swallow argument of many other functions) avoids the shift of parameters like pitch etc. that would result from removing notes and turning them into rests. For addressing the situation above properly we would need something like the opposite of swallowing, some way to fill in parameters like pitch etc. for new notes to avoid shifting existing notes. I hope my explanation makes sense and you can see why something like the opposite of swallowing would be useful for functions that add notes to some input material.
       
      Now, the tricky question is of course, what parameters (pitch etc.) should be added in such cases. Musically useful and common in the classical literature would be, e.g., repeating the parameters (pitch etc.) of the predecessor note (though that might be a bit too simplistic and annoying at times) or somehow interpolating some pitch gap between the previous and next note with a little scale or arpeggio and only repeating the other parameters like articulations (resulting in some variation that is likely most similar to the input material, so it would be good to have that as an option).  If the pitch interval between the two original notes is too small to add some pitch in between for the new now (or as an option in general for variety), it would also be good  to add some ornamentation (e.g., using PITCH-ORNAMENT), but for a close similarity between the original material and the variation it would be best as an option to apply such ornamentation only to the newly added notes, not all notes. Of course, other options could also be useful for variations that vary the input material a bit more strongly, e.g., some random pitch for the new notes within certain interval bounds.
       
      Does some function that kind of is the opposite of GEN-SWALLOW in that it adds parameters like pitches for subdivided rhythmic values (to avoid the shifting) sound like a good idea?
       
      The idea with the interpolation of gaps could be implemented by turning the original duration values and pitches into some envelope and then reading that envelope with the new rhythmic values. So, that is rather strait forward. However, that would not allow for some ornamentation, because such algorithm would not recognise which notes are new that should be ornamented.
       
      Any other idea perhaps? Thanks! 
×
×
  • Create New...