torstenanders Posted October 22, 2017 Share Posted October 22, 2017 I sometimes like to turn certain notes into rests. The built-in function length-rest-series is great for that, but it only works with lengths, not full OMN expressions. So, I generalised that function. I can do now, e.g., the following. (setf melody '((s eb6 < leg f5 < leg c5 < leg f5 < leg) (e e6 f - -q))) (note-rest-series '(1 1) melody :swallow T :section '(0)) ; => ((-s - c5 < leg f5 < leg) (e e6 f - -q)) Note that in contrast to the original function length-rest-series, the new function note-rest-series does not only support OMN expressions, but also extra arguments like swallow and section. The definition of this function uses length-rest-series and my function edit-omn for writing such generalisations, and it can therefore be rather short. In fact, the documentation string of the function is much longer than the definition itself :) Please see below. The function edit-omn is part of my tot library, which is available at GitHub. You can see its definition at starting at (currently) line 24 at https://github.com/tanders/tot/blob/master/sources/OMN-utils.lisp. Note that with edit-omn you can also easily turn other functions that expect just a single parameter list (e.g., pitches, or lengths) into functions for OMN expressions by automatically preserving the time signature and very conveniently adding standard arguments like flat or section. Best, Torsten (defun note-rest-series (positions sequence &key (flat nil) (swallow nil) (section nil)) "This function is like the Opusmodus built-in length-rest-series, but supports arbitrary OMN expressions as input and additionally the arguments swallow and section. Args: - positions (list of ints): positions of notes to be turned into rests - sequence (list of lengths or OMN expression): music to process - flat (Boolean): whether positions count for sublists (nil) or the whole list (T) - swallow (Boolean): whether the pitches of notes turned into rests should be shifted to the next note or omitted (swallowed) - section (list of ints): positions of sublists to process. This argument is ignored if flat is T. Example: ;;; (setf melody '((s eb6 < leg f5 < leg c5 < leg f5 < leg) (e e6 f - -q))) ;;; (note-rest-series '(1 1) melody :swallow T :section '(0)) " (edit-omn :length sequence #'(lambda (ls) (length-rest-series positions ls)) :swallow swallow :section section :flat flat)) lviklund and AM 2 Quote Link to comment Share on other sites More sharing options...
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.