Jump to content
Sign in to follow this  
Jorvd

Scaling Velocity Vectors

Recommended Posts

I'm probably over-complicating things but I'm trying to find the best approach to create 8 bars of random velocity values scaled to a certain range.

This is what I have so far, I hope it makes sense:
 

(setf rh-a-dynamics (gen-eval 8
                      (vector-range 0.55 0.69
                     '(vector-to-velocity (random* 0.7) (random* 0.9)) 
                        (gen-white-noise 5 :seed 12))))

Result:

> Error: Too many arguments in call to #<Compiled-function vector-range #x30000113FC4F>:
>        4 arguments provided, at most 3 accepted. 

I also tried making one list to insert into Vector-Range, which results to:
 

> Error: The value (gen-white-noise 5 :seed 12) is not of the expected type real.


Could anyone point me into the right direction?
Thank you!

 

- Jor

Share this post


Link to post
Share on other sites

This way you have control over seed in INIT-SEED if used:

 

(setf rh-a-dynamics
      (gen-eval 8 '(vector-to-velocity 0.55 0.67 (gen-white-noise 5)) :seed 12))

 

Share this post


Link to post
Share on other sites

Thank you Janusz, will look into INIT-SEED, I have seen it being used in a couple of examples already (including one massively impressive score by yourself)
I also noticed that the code snippet from above gives me values outside of the defined range as well. I'm guessing that's because the vector-to-velocity gets evaluated after the vector-range?
 

(setf rh-a-dynamics (gen-eval 8
                    '(vector-to-velocity (random* 0.7) (random* 0.9) 
                        (vector-range 0.55 0.69 (gen-white-noise 5 :seed 12)))))

>> ((ppppp pppp ppppp ppppp pppp) (mp ff mp mf fff) (ppppp ppp ppppp pppp ppp)
    (mp p mp p p) (p ppp p pp ppp) (pp fff ppp p ffff) (ppp f pppp pp ff) (pp p pp p p))

 

Share this post


Link to post
Share on other sites

As you can see all values staying with in the range: 0.55 and 0.67

Simple test:

(setf rh-a-dynamics
      (gen-eval 8 '(vector-to-velocity 0.55 0.67 (gen-white-noise 5) :type :float)
                :seed 12))
=> ((0.56 0.67 0.55 0.58 0.67) (0.67 0.61 0.65 0.57 0.55) (0.67 0.63 0.55 0.65 0.6)
    (0.67 0.55 0.58 0.67 0.62) (0.62 0.67 0.57 0.55 0.58) (0.65 0.55 0.67 0.61 0.62)
    (0.55 0.58 0.67 0.62 0.63) (0.67 0.57 0.55 0.58 0.66))

 

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  

×