Jump to content
Sign in to follow this  
opmo

Opusmodus 1.2.23392

Recommended Posts

Opusmodus 1.2.23392


New functions:
rnd-sum-to-size

vector-shift (thanks to Andre Meier)

 

 

rnd-sum-to-size

This function returns a list of numbers which add up to N and a given size (list length). If total was not reached in a given size in a trial, altered numbers are append to the numbers set.

 

(rnd-sum-to-size 11 5 '(1 2 3))
=> (2 3 1 3 2)

 

Set random :seed to ensure recurring output:

 

(rnd-sum-to-size 11 5 '(1 2 3) :seed 879)
=> (1 2 2 3 3)

 

Examples:

 

(rnd-sum-to-size 45 8 '(2 3 5 7 11 13 17 19))
=> (2 11 3 5 13 2 2 7)
(rnd-sum-to-size 25 7 '(6 11 13 1 3) :seed 436)
=> (6 3 3 3 1 3 6)
(rnd-sum-to-size 25 3 '(6 11 13 1 3) :seed 436)
=> (11 13 1)
(rnd-sum-to-size 25 11 '(6 1 3) :seed 13)
=> (3 1 1 6 1 1 6 1 3 1 1)
(rnd-sum-to-size 45 22 '(1 2 3) :seed 835)
=> (3 3 3 1 2 3 1 2 2 3 1 2 3 1 1 1 1 3 2 3 2 2)

 

In the next two examples the numbers set is altered:

 

(rnd-sum-to-size 8 7 '(9 8 6) :seed 45)
=> (1 1 1 1 2 1 1)
(rnd-sum-to-size 17 7 '(1 2) :seed 234)
=> (2 3 1 3 3 3 2)

 

 

vector-shift

This function applies ‘ambitus series’ derived from wave1 and wave2 values into a list of floating-point numbers.

 

Lets examine first how wave1 and wave2 create the ambitus series (low high).

We mix the two waves first and then we apply a sort function:

 

(setf wave1 '(-5.1 -2.3 1.5 -0.8 4.6 10.6))
(setf wave2 '(1.0 1.2 -1.1 2.1 -0.3 -2.5))

(sort-asc (gen-mix wave1 wave2))
=> ((-5.1 1.0) (-2.3 1.2) (-1.1 1.5) (-0.8 2.1) (-0.3 4.6) (-2.5 10.6))

 

From the two waves above the function creates five ambitus series each with two lists: start (low high) and end (low high).

 

Start      End
((-5.1 1.0) (-2.3 1.2))
((-2.3 1.2) (-1.1 1.5))
((-1.1 1.5) (-0.8 2.1))
((-0.8 2.1) (-0.3 4.6))
((-0.3 4.6) (-2.5 10.6))

 

Next, the values list (floating-point numbers) is divided by the count of the ambitus series. In our example the count is 5:

 

 

(setf values (gen-white-noise 120))
(/ (length values) 5)
=> 24

 

 

The final process is to select randomly segment numbers for each of the 5 sublists:

 

With :type 1

 

(rnd-sum 24 '(2 3 5 7 11 13 17 19))
=> (2 7 13 2)

 

With :type 2 (length segments)

 

(rnd-sum-to-size 24 8 '(2 3 5 7 11 13 17 19))
=> (3 3 3 3 3 3 3 3)

 

Lets see the result:

 

(list-plot (vector-shift wave1 wave2 (gen-white-noise 120)))

 

Screen Shot 2018-06-06 at 19.52.52.png

 

 

A slightly different result we can achieve with optional :type 2:

 

 

(list-plot (vector-shift wave1 wave2
                         (gen-white-noise 120)
                         :type 2))

 

 

Screen Shot 2018-06-06 at 19.53.12.png

 

 

Examples:

 

 

(list-plot
 (vector-shift '(-7.1 1) '(-0.1 10)
               (gen-white-noise 356)))

 

 

Screen Shot 2018-06-06 at 19.43.36.png

 

 

 

(list-plot
 (vector-shift '(-7.1 1) '(-0.1 10)
               (gen-white-noise 356)
               :segment '(1 2 3)))

 

 

Screen Shot 2018-06-06 at 19.44.01.png

 

 

 

(list-plot
 (vector-shift '(-7.1 1) '(-0.1 10)
               (gen-white-noise 356)
               :segment '(1 2 3)
               :type 2))

 

 

Screen Shot 2018-06-06 at 19.44.19.png

 

 

(list-plot (vector-shift '(4.2456284 7.2268248 6.4440737)
                         '(3.682579 8.78879 10.000002)
                         (gen-white-noise 356)
                         :segment (primes 12)))

 

Screen Shot 2018-06-06 at 19.44.45.png

 

 

(list-plot (vector-shift '(4.2456284 7.2268248 6.4440737)
                         '(3.682579 8.78879 10.000002)
                         (gen-white-noise 356)
                         :segment (primes 12)
                         :type 2))

 

 

Screen Shot 2018-06-06 at 19.45.14.png

 

 

(setf wave1 '(-5.1 -2.3 1.5 -0.8 4.6 10.6))
(setf wave2 '(1.0 1.2 -1.1 2.1 -0.3 -2.5))

(list-plot (vector-shift wave1 wave2 (gen-white-noise 356)))

 

 

Screen Shot 2018-06-06 at 19.45.30.png

 

 

(list-plot (vector-shift wave1 wave2 (gen-white-noise 356) :type 2))

 

Screen Shot 2018-06-06 at 19.45.50.png

 

 

 

(list-plot
 (vector-shift
  (rnd 12 :low -1.0 :high 4.0 :seed 45)
  (rnd 12 :low -1.0 :high 4.0 :seed 23)
  (gen-white-noise 356)
  :segment '(1 2 3)))

 

 

Screen Shot 2018-06-06 at 19.46.10.png

 

 

 

(list-plot
 (vector-shift
  (rnd 12 :low -1.0 :high 4.0 :seed 45)
  (rnd 12 :low -1.0 :high 4.0 :seed 23)
  (gen-white-noise 356)
  :segment '(1 2 3)
  :type 2))

 

 

Screen Shot 2018-06-06 at 19.46.23.png

 

 

 

(list-plot
 (vector-shift
  (rnd 12 :low -1.0 :high 4.0 :seed 45)
  (rnd 12 :low -1.0 :high 4.0 :seed 23)
  (gen-white-noise 356)
  :segment '(3 6 9)))

 

 

Screen Shot 2018-06-06 at 19.47.22.png

 

 

 

(list-plot
 (vector-shift
  (rnd 12 :low -1.0 :high 4.0 :seed 45)
  (rnd 12 :low -1.0 :high 4.0 :seed 23)
  (gen-white-noise 356)
  :segment (primes 12)))

 

 

Screen Shot 2018-06-06 at 19.47.38.png

 

 

(setf wave3 '(.2 .1 .5 .1 .8 .5 .1 .4 .2 .3))

(list-plot
 (vector-shift
  (gen-tendency 24 wave3)
  (gen-tendency 24 wave3)
  (gen-tendency 356 wave3)
  :segment (primes 6)))

 

Screen Shot 2018-06-06 at 19.48.09.png

 

 

 

(list-plot
 (vector-shift
  (gen-tendency 24 wave3)
  (gen-tendency 24 wave3)
  (gen-tendency 356 wave3)
  :segment (primes 6)
  :type 2))

 

 

Screen Shot 2018-06-06 at 19.48.41.png

 

 

Best wishes,

JP

 


 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×