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...
Stephane Boussuge Posted October 23, 2017 Share Posted October 23, 2017 Thanks Torsten, your edit-omn function is definitively super-mega useful !! I love it :-) S. Quote Link to comment Share on other sites More sharing options...
Stephane Boussuge Posted October 23, 2017 Share Posted October 23, 2017 Hi Torsten, when evaluate your OMN-utils.lisp i get a: Error: There is no package named "TU" I would like to use your last version of edit-omn but it seem i need some other files (TU). Thanks S. Quote Link to comment Share on other sites More sharing options...
torstenanders Posted October 23, 2017 Author Share Posted October 23, 2017 Dear Stephane, Did you follow the installation instructions at https://github.com/tanders/tot? Have you installed git? Unfortuantely, the installation is a bit complicated, as there are several dependencies. Therefore I explained it at the link above. The package TU is provided by the library ta-utilities, which you can install with git like everything else. If you want to only have the function you could also go directly to the library ta-utilities at GitHub and copy out the missing functions (https://github.com/tanders/ta-utilities/blob/master/my-utilities.lisp), e.g., remove-properties which then in turn depends on remove-property in the same file. Best, Torsten Quote Link to comment Share on other sites More sharing options...
Stephane Boussuge Posted October 23, 2017 Share Posted October 23, 2017 Dear Torsten, i will have a look to git installation when i will have a bit of time. Thank you for the information. best, Stéphane Quote Link to comment Share on other sites More sharing options...
Stephane Boussuge Posted October 23, 2017 Share Posted October 23, 2017 Done. It works now. Thx. S. Quote Link to comment Share on other sites More sharing options...
lviklund Posted October 24, 2017 Share Posted October 24, 2017 Works fine here to. Thx /Lasse Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.