Jump to content
Sign in to follow this  
Stephane Boussuge

gen-pitch-line (from vector)

Recommended Posts

;;; ------------------------------------------------------------------------------
;;; GEN-PITCH-LINE
;;; Pitch generation function based on noise vectors conversion with a large choice of 
;;; types of noises, compress ratio for the vector, filtering repetitions and ambitus. 

(defun gen-pitch-line (nb-pitch &key (compress 1) (ambitus '(c4 c6)) seed filter-repeat (type :white))
  (do-verbose
      ("gen-pitch-line")
    (rnd-seed seed)
    (labels ((white  (nb-pitch &key (compress 1) (ambitus '(c4 c6)) seed filter-repeat type)
               (if filter-repeat
                 (gen-trim
                  nb-pitch
                  (filter-repeat 
                   filter-repeat
                   (vector-to-pitch ambitus (vector-smooth compress (gen-white-noise nb-pitch :seed seed :type type)))))
                 (vector-to-pitch ambitus (vector-smooth compress (gen-white-noise nb-pitch :seed seed :type type)))))
             
             (pink  (nb-pitch &key (compress 1) (ambitus '(c4 c6)) seed filter-repeat)
               (if filter-repeat
                 (gen-trim
                  nb-pitch
                  (filter-repeat 
                   filter-repeat
                   (vector-to-pitch ambitus (vector-smooth compress (gen-pink-noise nb-pitch :seed seed)))))
                 (vector-to-pitch ambitus (vector-smooth compress (gen-pink-noise nb-pitch :seed seed)))))
             )
      (cond 
       ((equal type ':white)
        (white nb-pitch :compress compress :ambitus ambitus :filter-repeat filter-repeat :seed (seed) :type :normal))
       
       ((equal type ':binary)
        (white nb-pitch :compress compress :ambitus ambitus :filter-repeat filter-repeat :seed (seed) :type :binary))
       
       ((equal type ':cauchy)
        (white nb-pitch :compress compress :ambitus ambitus :filter-repeat filter-repeat :seed (seed) :type :cauchy))
       
       ((equal type ':chi-square-2)
        (white nb-pitch :compress compress :ambitus ambitus :filter-repeat filter-repeat :seed (seed) :type :chi-square-2))
       
       ((equal type ':double-exponential)
        (white nb-pitch :compress compress :ambitus ambitus :filter-repeat filter-repeat :seed (seed) :type :double-exponential))
       
       ((equal type ':exponential)
        (white nb-pitch :compress compress :ambitus ambitus :filter-repeat filter-repeat :seed (seed) :type :exponential))
       
       ((equal type ':extreme)
        (white nb-pitch :compress compress :ambitus ambitus :filter-repeat filter-repeat :seed (seed) :type :extreme))
       
       ((equal type ':gaussian)
        (white nb-pitch :compress compress :ambitus ambitus :filter-repeat filter-repeat :seed (seed) :type :gaussian))
       
       ((equal type ':logistic)
        (white nb-pitch :compress compress :ambitus ambitus :filter-repeat filter-repeat :seed (seed) :type :logistic))
       
       ((equal type ':lognormal)
        (white nb-pitch :compress compress :ambitus ambitus :filter-repeat filter-repeat :seed (seed) :type :lognormal))
       
       ((equal type ':triangular)
        (white nb-pitch :compress compress :ambitus ambitus :filter-repeat filter-repeat :seed (seed) :type :triangular))
       
       ((equal type ':low-pass)
        (white nb-pitch :compress compress :ambitus ambitus :filter-repeat filter-repeat :seed (seed) :type :low-pass))
       
       ((equal type ':high-pass)
        (white nb-pitch :compress compress :ambitus ambitus :filter-repeat filter-repeat :seed (seed) :type :high-pass))
       
       ((equal type ':pink)
        (pink nb-pitch :compress compress :ambitus ambitus :filter-repeat filter-repeat :seed (seed)))))))


#| USAGE
(gen-pitch-line 24 :compress 0.42 :type :white :filter-repeat 1)
(gen-pitch-line 24 :compress 0.42 :type :pink :filter-repeat 1)
(gen-pitch-line 24 :compress 0.42 :type :extreme :filter-repeat 1)
(gen-eval 
 8
 '(make-omn
   :pitch (gen-pitch-line 24 :compress 0.42 :type :white :filter-repeat 1)
   :length (euclidean-rhythm 16 1 16 's :type 2)
   )
 :seed 33)
|#
;;; ------------------------------------------------------------------------------   

SB.

Share this post


Link to post
Share on other sites

SB,

Thanks. Useful function, I am sure.

 

Thought I could re-write the function slightly differently, hope you don't mind:

(defun gen-pitch-line2 (nb-pitch &key (compress 1) (ambitus '(c4 c6)) seed filter-repeat (type :white))
  (let (pitches)
    (do-verbose
      ("gen-pitch-line2")
    (rnd-seed seed)
    (labels ((white-or-pink (nb-pitch seed type)
               (if (eq type ':pink)
                 (gen-pink-noise nb-pitch :seed seed)
                 (gen-white-noise nb-pitch :seed seed :type (if (eq type ':white) :normal type))))

             (process  (nb-pitch &key (compress 1) (ambitus '(c4 c6)) seed filter-repeat type)
               (setf pitches (vector-to-pitch ambitus (vector-smooth compress (white-or-pink nb-pitch seed type)))) 
               (when filter-repeat
                 (setf pitches (gen-trim nb-pitch (filter-repeat filter-repeat pitches))))
               pitches)
             )
      (process nb-pitch :compress compress :ambitus ambitus :filter-repeat filter-repeat :seed (seed) :type type)))))

 

I hope I haven't messed up the logic!

 

Regards,

Rangarajan

Share this post


Link to post
Share on other sites

Thank you very much Rangarajan for your help.

As you can see i am more musician than programmer ;-)

Your version is more concise.

 

SB.

Share this post


Link to post
Share on other sites

I am the other way, so it helps to keep balance in the forum!

 

-Rangarajan

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 loopyc
      Audition format (excerpts) of various personal application studies for Opusmodus.
       
      ..
       
      .
    • By AM
      (defun vector-range-drift (start end input &key (spread 8)) (let ((values (gen-divide (rnd-sum (length input) (primes spread)) input)) (n-values) (a-step) (b-step)) (progn (setf n-values (1- (length values))) (setf a-step (/ (car (difference (list (car start) (car end)))) n-values)) (setf b-step (/ (car (difference (list (cadr start) (cadr end)))) n-values)) (loop for i in values for a = (car start) then (incf a a-step) for b = (cadr start) then (incf b b-step) append (vector-range a b i))))) ;;;;; EXAMPLES -> MODULATE/DRIFT white-noise - with different spreads (list-plot (vector-range-drift '(-7.1 1) '(-0.1 10) (gen-white-noise 187) :spread 10)) (list-plot (vector-range-drift '(-7.1 1) '(-0.1 10) (gen-white-noise 187) :spread 6)) (list-plot (vector-range-drift '(-7.1 1) '(-0.1 5.6) (gen-white-noise 517))) (list-plot (vector-range-drift '(-1.1 1) '(-3.1 5.6) (gen-white-noise 317)))  
    • By terekita
      Hello,
       
      I'm aware of pcs-analysis (which prints data), but I'm looking for a way to collect lists of Forte-style interval vectors into a data structure in order to query them for similarity and difference. Something like:
       
      (get-interval-vector '3-1)
      -> (2 1 0 0 0 0)
       
      Is there an easy way to do this?
       
      thanks, Michael
×
×
  • Create New...