Jump to content
Sign in to follow this  
AM

gen-rotate extension

Recommended Posts

perhaps OPMO could extend its GEN-ROTATE like that (or use this CODE for it)... not only single-steps, also a list of steps...

 

;;; SIMPLE FUNCTION

(defun gen-rotate* (alist seq)
  (loop 
    for i in alist
    collect (setf seq (gen-rotate i seq))))

;;; EXAMPLES

(list-plot 
 (flatten 
  (gen-rotate* '(1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18) '(1 2 3 4 5 6 7 8 9 10)))
   :join-points t :point-radius 0 :style :fill)

(list-plot 
 (gen-rotate* '(9 8 7 6 5 4 3 2 1) '(1 2 3 4 5 6 7 8 9 10))
   :join-points t :point-radius 0 :style :fill)

(list-plot 
 (flatten 
  (gen-rotate* '(1 2 3 4 5 4 3 2 1) '(1 2 3 4 5 6 7 8 9 10)))
   :join-points t :point-radius 0 :style :fill)

(list-plot 
 (gen-rotate* '(1 2 3 4 5 4 3 2 1) '(1 2 3 4 5 6 7 8 9 10))
 :join-points t :point-radius 0 :style :fill)

 

Share this post


Link to post
Share on other sites

I agree that this is useful, and therefore I also implemented a similar functionality in my function rotate-omn 🙂  You can find its documentation at https://tanders.github.io/tot/sources/form.html#_g229430 and download the whole library at https://github.com/tanders/tot.

 

BTW: You meanwhile should also have quite a sizeable collection of custom functions for Opusmodus. While not sharing them together in some kind of library as well? 

 

Best,

Torsten

 

Share this post


Link to post
Share on other sites
9 hours ago, torstenanders said:

BTW: You meanwhile should also have quite a sizeable collection of custom functions for Opusmodus. While not sharing them together in some kind of library as well? 

 

yes, of course - from "BOTs" to a lot of small simple FUNCTIONS... but: not very well/smart coded (🙄) - i'm musician but only an "amateur programmer" with few experience -  and it's really NOT well documentated for other users. and another point, i have no idea how do that professionally with GUTHUB and these installation-things 😕

 

as ORDINARY text - no problem. perhaps i will share it like that on my website...

 

 

Share this post


Link to post
Share on other sites

> i'm musician but only an "amateur programmer" 

 

I think the most important part is the musical knowledge encoded, and that your definitions work as described. How that is implemented is secondary for its use for others. (Clean implementations can make a big difference, though, for the maintainability of your code.) 

 

> I have no idea how to do that professionally with GitHub

 

I am pretty busy at this stage of the academic year, but in a few weeks, I would be happy to help you with that, if you want. What I cannot do, is documenting your definitions, but I can also show you, once you added some documentation in the form of doc strings added to your function etc. defs, how to automatically turn that into HTML docs. 

 

as ORDINARY text - no problem. perhaps i will share it like that on my website...

 

If such a straightforward approach makes you feel you are more in control, then why not? However, in your place, I would add some doc strings that explain what a function is supposed to do. That makes it also more easy for yourself to re-use these functions at some later time. 

 

Best,

Torsten

 

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 AM
      ;;;;perhaps you could/would extend the "rnd-sample-seq" function by: ;;;;(also with OMN-format) ... regards andré ;;;;SUBFUNCTIONS (defun pick-sample-from-center (list span) (let ((center (if (evenp (length list)) (/ (length list) 2) (/ (1+ (length list)) 2))) (span (if (> span (length list)) (length list) (append span)))) (loop repeat span with startpoint = (if (evenp span) (- center (/ span 2)) (- center (/ (1+ span) 2))) for i = startpoint then (incf startpoint) collect (nth i list)))) ;;;;MAINFUNCTION ;;;;sampling-machine (defun sampling-seq-machine (&key seq (type 'rnd) (sample-lengths 'rnd)) (let ((span (if (equal sample-lengths 'rnd) (1+ (random (length seq))) (rnd-pick sample-lengths)))) (cond ((equal type 'rnd) (rnd-sample-seq span seq)) ((equal type 'from-center) (loop repeat span with center = (center-position-in-list (omn :length seq)) with startpoint = (if (evenp span) (- center (/ span 2)) (- center (/ (1+ span) 2))) for i = startpoint then (incf startpoint) append (position-filter i seq))) ((equal type 'from-start) (loop repeat span for i = 0 then (incf i) append (position-filter i seq))) ;;; don't ((equal type 'from-end) (loop repeat span for i = (- (length (omn :length seq)) span) then (incf i) append (position-filter i seq)))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (sampling-seq-machine :seq '(1 2 3 4 5 6 7 8 9) :type 'from-end :sample-lengths '(3 5 7)) (sampling-seq-machine :seq '(t bb3 pppp a3 ppp g3 pp eb3 p gs2 mp cs2 mf fs1 mp d1 p c1 pp) :type 'rnd :sample-lengths '(3 5 7)) (sampling-seq-machine :seq '(t bb3 pppp a3 ppp g3 pp eb3 p gs2 mp cs2 mf fs1 mp d1 p c1 pp) :type 'from-start :sample-lengths '(3 5 7)) (sampling-seq-machine :seq '(t bb3 pppp a3 ppp g3 pp eb3 p gs2 mp cs2 mf fs1 mp d1 p c1 pp) :type 'from-center :sample-lengths '(3 5 7)) (sampling-seq-machine :seq '(t bb3 pppp a3 ppp g3 pp eb3 p gs2 mp cs2 mf fs1 mp d1 p c1 pp) :type 'from-end :sample-lengths '(3 5 7)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;  
    • By Rangarajan
      Hi,
      I have a set of utility functions in a file called "Utils.opmo". These functions have been tested and have no errors. In order to load these functions at start up, I copied this file to my Extensions folder. When I launch OM, what I notice is that some of the functions in this file are loaded correctly, but some others are not loaded at all (I get error when I call them from the console) even though all are in the same source file. I do not get any error messages at load time.
       
      I then included the call "(load "<path>/Utils.opmo"), where <path> is the location of the file, in "Quicklisp Start.lisp". Now, when I start OM, as part of Quicklisp initialisation, my "Utils.opmo" gets loaded correctly.
       
      I cannot figure out what the problem could be. Any guesses?
       
      Regards,
      Rangarajan
×
×
  • Create New...