# what's up with quantize?

## Recommended Posts

why are there different results (have a look to the number of length values)?

...i get in troubles with my work -Â Â "phase shift" between pitch/length when i change/use QUANTIZEÂ ðŸ˜•Â

(setf rhy '(0.375 -0.625 0.25 0.375 0.125 0.125 -0.25 0.625 0.125 -0.625 0.125 0.125 -0.625 0.375 0.25 -0.25 0.625 -0.125 0.125 -0.125 0.125 0.375 0.375 0.125 0.125 0.375 0.125 -0.25 0.125 0.25 -0.25 0.625 0.125 0.375 0.375 0.375 0.375 0.125 -0.25 0.625 0.125 -0.25 0.125 0.125 -0.375 0.125 0.25 -0.375 0.25 -0.375 0.125 -0.125 0.125 -0.25 0.625 -0.5 0.25 0.375 -0.125 0.375 0.25 -0.25 0.625 0.25 -0.125 0.125 0.125 0.125 0.125 0.125 0.375 -0.125 0.125 0.125 1.25 0.375 0.25 -0.125 0.125 0.25 -2.5 0.25 0.375 3.75 0.125 0.125 -0.375 0.375 0.125 0.625 0.25 2.5 0.125 0.125 2.5 -0.125 3.75 -0.375 1.25 -0.125 0.125 0.125 0.125 0.125 0.25 0.625 0.25 -0.375))

(setf l1 (quantize (x+b rhy 0.0) '(1 2 3 5 8)))
(length l1)
=> 116

(setf l2 (quantize (x+b rhy 0.02) '(1 2 3 5 8)))
(length l2)
=> 105

Â

##### Share on other sites

Try to analyse the values ðŸ™‚Â With small change to the values you will get very much different result.

##### Share on other sites

butÂ it makes no sense to get more LENGTH-values by adding 0.02 (also by adding 0.12 what ist no such a little change...)? whats the idea behind it?

Â

in that way its not usable for many ways....Â

Â

##### Share on other sites

here is a very simple example:

Â

a sequence in 1/8-structure -> i will add 0.25 (=> + 1/16), and QUANTIZE-output-sequences are with different lengths!!

compare: (length rhy) with l1 with l2

Â

(setf rhy '(1.5 -2.5 1.0 1.5 0.5 0.5 -1.0 2.5 0.5 -2.5 0.5 0.5 -2.5 1.5 1.0 -1.0 2.5 -0.5 0.5 -0.5 0.5 1.5 1.5 0.5 0.5 1.5 0.5 -1.0 0.5 1.0 -1.0 2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3/16 7/16 7/16 7/16 7/16 3/16 -3/16 11/16 3/16 -3/16 3/16 3/16 -5/16 3/16 5/16 -5/16 5/16 -5/16 3/16 -1/16 3/16 -3/16 11/16 -7/16 5/16 7/16 -1/16 7/16 5/16 -3/16 11/16 5/16 -1/16 3/16 3/16 3/16 3/16 3/16 7/16 -1/16 3/16 3/16 21/16 7/16 5/16 -1/16 3/16 5/16 -39/16 5/16 7/16 61/16 3/16 3/16 -5/16 7/16 3/16 11/16 5/16 41/16 3/16 3/16 41/16 -1/16 61/16 -5/16 21/16 -1/16 3/16 3/16 3/16 3/16 5/16 11/16 5/16 -5/16)

(setf l1 (quantize rhy1 '(1 2 4 8)))
(get-count rhy1 :length :note)
=> 80
(setf l2 (quantize rhy2 '(1 2 4 8)))
(get-count rhy2 :length :note)
=> 80

Â

##### Share on other sites

i know, but the error/wrong output is coming up when would add (individual) float-numbers to RHY and afterwards use QUANTIZE ðŸ™‚

Â

the concret idea is: to a basic FLOAT-seq like RHY -values (above) i would like to add some little noisy-floats - 0.5 becomes 0.55 or 0.75 beomes 0.70 etc... so the precise structure beomes some fuzziness - but after quantizing, the snychronization with the pitches is wrong - because QUANTIZE doing more/less length-values

Â

Â

##### Share on other sites

This is notÂ an error and not wrong result.

(setf rhy '(1.5 -2.5 1.0 1.5 0.5 0.5 -1.0 2.5 0.5 -2.5 0.5 0.5 -2.5 1.5 1.0 -1.0 2.5 -0.5 0.5 -0.5 0.5 1.5 1.5 0.5 0.5 1.5 0.5 -1.0 0.5 1.0 -1.0 2.5 0.5 1.5 1.5 1.5 1.5 0.5 -1.0 2.5 0.5 -1.0 0.5 0.5 -1.5 0.5 1.0 -1.5 1.0 -1.5 0.5 -0.5 0.5 -1.0 2.5 -2.0 1.0 1.5 -0.5 1.5 1.0 -1.0 2.5 1.0 -0.5 0.5 0.5 0.5 0.5 0.5 1.5 -0.5 0.5 0.5 5.0 1.5 1.0 -0.5 0.5 1.0 -10.0 1.0 1.5 15.0 0.5 0.5 -1.5 1.5 0.5 2.5 1.0 10.0 0.5 0.5 10.0 -0.5 15.0 -1.5 5.0 -0.5 0.5 0.5 0.5 0.5 1.0 2.5 1.0 -1.5))

(setf l1 (quantize rhy '(1 2 4 8)))
(get-count l1 :length :note)
=> 80

(setf l2 (quantize (x+b rhy 0.25) '(1 2 4 8)))
(get-count l2 :length :note)
=> 80

Please check howÂ quantise is working. You will find many papers on the web on that.

##### Share on other sites

but with other ADD and QUANTIZE

Â

(setf l2 (quantize (x+b rhy 0.22) '(1 2 4 8)))
(get-count l2 :length :note)
=> 82

Â

(setf l2 (quantize (x+b rhy 0.22) '(1 2 3 4 5 6 7 8)))
(get-count l2 :length :note)
=> 86

so for me, quantize works a little bit like a BLACK BOX Â ðŸ™‚

Â

would absolutely GREAT if it would work always withÂ same COUNT! any idea?Â ðŸ™‚

thanx for help!!

Â

Edited by AM

##### Share on other sites

Show me short example what you are trying to do, with input and output.

##### Share on other sites

I will check the tie system in the quantiseÂ ðŸ™‚

##### Share on other sites

voilÃ :

here is a concret example - Â with 12 length-values (in my work there are about 700,Â so the problems are BIGGERÂ ðŸ™‚Â )

Â

if you evaluate a few times you get some WRONG output.Â you see it if the last pitch is not an f5, that's because there are (don't know why) from time to time (from eval to eval) more then 12 length-values in the output - should be 12 Â length and 3 rest values. this is the problem and makes the result tooÂ inconsistent for me...

Â

;;; LENGTH

(setf rhy (gen-length '(1 1 3 -2 5 7 3 -2 1 5 8 -7 3 1 2) 32))
(setf float-rhy (ratio-to-float rhy))
(setf float-rhy+fuzziness (loop for i in float-rhy
when (> i 0)
collect (+ i (rnd-pick '(0.05 0.1 0.15)))
else collect i))

(setf rhy+fuzziness (quantize float-rhy+fuzziness '(1 2 3 4 5 6 7 8)))

;;; PITCHES

(setf pitches '(fs3 bb3 c4 d4 eb4 e4 g4 gs4 a4 b4 cs5 f5))

;;; MAKE OMN + SCORE

(def-score example
(:title "example"
:key-signature 'atonal
:time-signature '(4 4)
:tempo 90)

(instr
:omn (make-omn :length rhy+fuzziness
:pitch pitches)
:span :pitch
:sound 'gm-trumpet))

Â

Â

Â

Â

##### Share on other sites

You can control the output with the two keywords: speed and trust:

#|
(setf rhy (gen-length '(1 1 3 -2 5 7 3 -2 1 5 8 -7 3 1 2) 32))
(setf float-rhy+fuzziness (loop for i in rhyÂ
Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  when (> i 0)Â
Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  collect (+ i (rnd-pick '(0.05 0.1 0.15)))
Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  else collect i))
|#
(setf float-rhy+fuzziness '(0.13125 0.08125 0.24375 -1/16 0.20625 0.26875 0.19375
-1/16 0.08125 0.30625 0.35 -7/32 0.14375 0.18125 0.1625))

(setf rhy+fuzziness (quantize float-rhy+fuzziness '(1 2 3 4 5 6 7 8) :speed -.2))
(setf pitches '(fs3 bb3 c4 d4 eb4 e4 g4 gs4 a4 b4 cs5 f5))

(setf mat (make-omn :length rhy+fuzzinessÂ :pitch pitches))
=> (3e fs3 bb3 -3q 3e c4 d4 t eb4 s e4 - t g4 s gs4 s. a4 -et -s t b4 cs5 f5 -s.)

Â

However, if the input list smallest value is smaller then the minimum quantum value then you end up with less length-notes values.

##### Share on other sites

dear janusz

Â
IT IS A BUG ðŸ™‚
Â
what a strange output you haveâ€¦?!Â
Â
with this litleÂ LOOPÂ i will never get a value like Â 0.08125â€¦ Â because the minimum will be 0.125+add (= rnd-pick) => 1/32+addâ€¦ soÂ THISÂ could not be the problem!!!!
you have to "convert" to FLOAT (you did not in YOUR example)Â -> then you have not such too-small-values -
do it likeÂ in MY example above... so NO tooÂ small value, BUT SAME QUANTIZE BUG
Â
(setf float-rhy '(0.125 0.125 0.375 -0.25 0.625 0.875 0.375 -0.25 0.125 0.625 1.0 -0.875 0.375 0.125 0.25))
(setf float-rhy+fuzziness (loop for i in float-rhy
when (> i 0)
collect (+ i (rnd-pick '(0.05 0.1 0.15)))
else collect i))

Â

Â

and you get the SAME bug with 1/16 as minimum value and much larger addsÂ -> test it ðŸ™‚

Â

;;; LENGTH

(setf rhy (gen-length (rnd-order '(1 3 2 -1 7 1 2 -1 2 1 5 -1 3 2 1)) 16))
(setf float-rhy (ratio-to-float rhy))
(setf float-rhy+fuzziness (loop for i in float-rhy
when (> i 0)
collect (+ i (rnd-pick '(0.1 0.2 0.3)))
else collect i))

(setf rhy+fuzziness (quantize float-rhy+fuzziness '(1 2 3 4 5 6 7 8)))

;;; PITCHES

(setf pitches '(fs3 bb3 c4 d4 eb4 e4 g4 gs4 a4 b4 cs5 f5))

;;; MAKE OMN + SCORE

(def-score example
(:title "example"
:key-signature 'atonal
:time-signature '(4 4)
:tempo 90)

(instr
:omn (make-omn :length rhy+fuzziness
:pitch pitches
:velocity '(pppp))
:span :pitch
:port 0
:channel 1
:sound 'gm-trumpet))

;;;

Â

Â

the speed-thing changes nothing, same BUG

Â

(setf rhy+fuzziness (quantize float-rhy+fuzziness '(1 2 3 4 5 6 7 8) :speed -.2))

Â

##### Share on other sites

"you have to "convert" to FLOAT (you did not in YOUR example)" you don'tÂ need to do that, theÂ quantizeÂ can deal with ratios, floats or both.

Â

##### Share on other sites

okay, i see... but the QUANTIZE-problem (or whatever) stays... wrong number of LENGTH values from time to time

->Â evaluate this example (with ratios and longer values)Â a few time... and you will see. so it's not possible to work correct with QUANTIZEÂ ðŸ˜¥Â

Â

greetingsÂ

Â

;;; LENGTH

(setf rhy (gen-length (rnd-order '(1 3 2 -1 7 1 2 -1 2 1 5 -1 3 2 1)) 16))
(setf float-rhy+fuzziness (loop for i in rhy
when (> i 0)
collect (+ i (rnd-pick '(0.4 0.2 0.3)))
else collect i))

(setf rhy+fuzziness (quantize float-rhy+fuzziness '(1 2 3 4 5 6 7 8) :speed -.2))

;;; PITCHES

(setf pitches '(fs3 bb3 c4 d4 eb4 e4 g4 gs4 a4 b4 cs5 f5))

;;; MAKE OMN + SCORE

(def-score example
(:title "example"
:key-signature 'atonal
:time-signature '(4 4)
:tempo 90)

(instr
:omn (make-omn :length rhy+fuzziness
:pitch pitches
:velocity '(pppp))
:span :pitch
:port 0
:channel 1
:sound 'gm-trumpet))

Â

##### Share on other sites

ThereÂ is noÂ bug in the function. In the current version the tieÂ quantumÂ is fixed to the minimum-quantum value (smallest tuplet value). I will make a possible to control theÂ tieÂ quantumÂ with an additional keyword.

Â

Example:

(setf rhy '(0.375 -0.625 0.25 0.375 0.125 0.125 -0.25 0.625 0.125 -0.625 0.125 0.125
-0.625 0.375 0.25 -0.25 0.625 -0.125 0.125 -0.125 0.125 0.375 0.375
0.125 0.125 0.375 0.125 -0.25 0.125 0.25 -0.25 0.625 0.125 0.375
0.375 0.375 0.375 0.125 -0.25 0.625 0.125 -0.25 0.125 0.125 -0.375
0.125 0.25 -0.375 0.25 -0.375 0.125 -0.125 0.125 -0.25 0.625 -0.5
0.25 0.375 -0.125 0.375 0.25 -0.25 0.625 0.25 -0.125 0.125 0.125
0.125 0.125 0.125 0.375 -0.125 0.125 0.125 1.25 0.375 0.25 -0.125
0.125 0.25 -2.5 0.25 0.375 3.75 0.125 0.125 -0.375 0.375 0.125
0.625 0.25 2.5 0.125 0.125 2.5 -0.125 3.75 -0.375 1.25 -0.125 0.125
0.125 0.125 0.125 0.25 0.625 0.25 -0.375))

(setf l1 (quantize rhy '(1 2 4 8)))
=> (s. -et s s. t t -t -t et t -t -e t t -s -s. s. s -s et -t t -t t s.
s. t t s. t -t -t t s -s et t s. s. s. s. t -s et t -s t t -s.
t s -s. s -s. t -t t -s et -s. -t s s. -t s. s -s et s -t t t t
t t s. -t t t qs s. s -t t s -e -q -q s s. h... t t -s. s. t et
s he t t he -t h... -s. qs -t t t t t s et s -t -q)

(get-count l1 :length :note)
=> 80

(setf l2 (quantize (x+b rhy 0.02) '(1 2 4 8) :tie 0.5))
=> (s. -et e e q -et t t -t -e s. t t -s et -t t -t t s. t e e t -s t
s -s q e e s. t -s s s. t -s t t -e e -s s -s. t q -e s s s e
s -s et t t -t t t t t s s. -t t t s q e s s s -e. -q -e. s s.
h..t t t t -s. s q s he t t he e h. e -e q t -t t t t t s e. s -q)

(get-count l2 :length :note)
=> 80

(setf l3 (quantize (x+b rhy 0.02) '(1 2 3 4 5 6 7 8) :tie 0.06))
=> (s. -et 7h 7h. 7q 7q -3e 3h 3e -et t t -t -e s. s -s et -t t -t t s
t_7h 7q 7q 7h. t -s t s -s 7wq 7q 7q_5q 5h 5h s. t -s et t -s t
t -3q 3e 3q -3e -s s -s. t 7q -7h 7w -e s e e s -s et t_7q -7q
7q 7q 7q 7q 7q s. -t t t qs 7h. 7h -7q 7q 5q -5w -q -e. s s.
h... t t -s. s_3e 3e 3h s he t t he -3e 3q_h.. -3q 3e_qt -t t t
t t s 7wq 7h -q)

(get-count l3 :length :note)
=> 80

Â

##### Share on other sites

okay, so i hope this will be a solution for me - thanx for your work, janusz!!

## 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

Ã—

• Lessons