Noise

Post Reply
User avatar
Keres
Posts: 466
Joined: Mon Mar 21, 2016 9:41 am
Location: N. Tulsa Ok.
Contact:

Noise

Post by Keres »

how do you make a random curve using pixilang for the modules that load curves?

i have this pixi program CurveCreator.pixi and i can UN-comment the formulas and edit them to make weird things, but if i wanted to make a straight up individual random white noise plot in that app, what would the formula line look like?

for example this one is sine:

$y = sin( $x * M_PI * 4 ) / 3 + 0.5 //Sine

sorry that i am a pixi coder newb, but i am also a coder noob...

thanks.
User avatar
NightRadio
Site Admin
Posts: 3941
Joined: Fri Jan 23, 2004 12:28 am
Location: Ekaterinburg. Russia
Contact:

Re: Noise

Post by NightRadio »

$y = rand() / 32768
User avatar
Keres
Posts: 466
Joined: Mon Mar 21, 2016 9:41 am
Location: N. Tulsa Ok.
Contact:

Re: Noise

Post by Keres »

hmm, firstly i have to apologize for not seeing that a better version of the sunvox curve editor has been included in the latest distro, i was using the original one. secondly, when i output several noise curves, they are all the same. I tried looking at the manual for pixi lang and this thread: https://warmplace.ru/forum/viewtopic.php?f=8&t=1335 but again, not being a coder i just cant follow. if i change the number that the rand() function is divided by, it just moves it up or down like DC offset. if i try to set a seed "rand_seed( seed )" then it just makes a linear plot. how do you make a different random graph each time you output with the pixi script?
User avatar
NightRadio
Site Admin
Posts: 3941
Joined: Fri Jan 23, 2004 12:28 am
Location: Ekaterinburg. Russia
Contact:

Re: Noise

Post by NightRadio »

how do you make a different random graph each time you output with the pixi script?
Just move rand_seed() outside the curve_function(), because we need to call it once at the beginning.
get_ticks() - current system tick counter (returns different value every time you call it)

Code: Select all

rand_seed( get_ticks() )
fn curve_function( $x )
{
  $y = rand() / 32768
  ret( $y )
}
Post Reply