os.time() in milliseconds?

Home Forums General Programming os.time() in milliseconds?

Tagged: 

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #69588
    Possemo
    Participant
    • Topics: 14
    • Replies: 638
    • Total: 652
    • ★★★

    Is there a way to get the time in milliseconds? 1/100 seconds would be ok too but the one second resolution of os.time and os.clock is just not enough for math.randomseed I would like to use. Or is there another way to get good random numbers? They have to be in a specific range.

    #69590
    Possemo
    Participant
    • Topics: 14
    • Replies: 638
    • Total: 652
    • ★★★

    For some reason this gives better results. It will do the trick for now:

    	local t=os.time()
    	local c=os.clock()
    
    	math.randomseed(t*c)
    #72228
    human fly
    Participant
    • Topics: 124
    • Replies: 1070
    • Total: 1194
    • ★★★★

    😉 nice one Possemo !

    #72231
    Possemo
    Participant
    • Topics: 14
    • Replies: 638
    • Total: 652
    • ★★★

    some time ago I found an even better one. There is a hirescounter available (RTFM = look in the f*cking demos made by atom):

    math.randomseed(os.clock()*Time.getMillisecondCounterHiRes())

    for some reason a bigger number will do better, that’s why I multiply with os.clock()

    #72232
    human fly
    Participant
    • Topics: 124
    • Replies: 1070
    • Total: 1194
    • ★★★★

    in fact i did try the hires counter first, and that’s
    the one giving strange results – very sequential; at
    least on a short range: 0,15.
    so it’s producing better results with t*c

    basically ‘random’ will be a pseudo-random (i recall) and
    the key is to get seeding that makes it more genuinely
    random, so if you use the os clock you’re not going to
    get the same seed value each time.

    maybe ‘hires’ was too fine for my application.
    you can check out how it’s doing by having a row of
    faders, say 16, and applying the random. if it delivers
    a repeating pattern, that isn’t what you want.

    the other thing i was doing with random was to bias it:
    say you have an envelope polarity control: you don’t want
    ‘inverted’ to come up as often as ‘positive’, so i think
    i set an adjustable comparator until i got the kind of
    ratio i wanted.

    (incidentally, i’m not even sure i want random in my panel,
    as i don’t really think it offers much to synth programmers
    – unless you want to rinse it and get rid of it quickly – but
    i’m interested in how it works, and it’s always useful as a
    feature)

    #72233
    human fly
    Participant
    • Topics: 124
    • Replies: 1070
    • Total: 1194
    • ★★★★

    edit: both methods are in the major and minor random
    methods in that panel but the clock*time line is ren’ed.

    #72234
    Possemo
    Participant
    • Topics: 14
    • Replies: 638
    • Total: 652
    • ★★★

    I find a randomizer a nice feature. For example you have a vcf/vca/env setting and want to know how different osc settings will sound with it. Or you have a nice patch and you want to know how it will sound with slightly altered values (minor rnd).

    #72235
    human fly
    Participant
    • Topics: 124
    • Replies: 1070
    • Total: 1194
    • ★★★★

    yes, although i think it works best if you can split the
    parameters into groups – i think that’s what you did there,
    wasn’t it? i’ve done it with synthedit plugins when i found
    ‘full-randomize’ turned up junk 8/10. keeping a VCA adsr
    and changing all the osc settings etc. is very useful.

    and yes, it can be very nice via sysex to a crappy old
    digital module 🙂

    i saw you did minor and major but i haven’t fully figured
    out how that works, or tried it. i think the minor bit
    must be where you have a value of 5?

    anyway: found some demos i had in a different folder,
    data handling. much more to look at when i have some
    energy(…!) – lots of interesting tricks.

    so when you say rtfm – we should be saying from the
    start that the ‘manual’ exists partly in existing
    panels. because it is very hard to ‘discuss’ methods
    really, i can see that: visual recognition is much
    faster.

Viewing 8 posts - 1 through 8 (of 8 total)
  • The forum ‘Programming’ is closed to new topics and replies.
There is currently 0 users and 37 guests online
No users are currently active
Forum Statistics
Threads: 2,495, Posts: 17,374, Members: 77,605
Most users ever online was 12 on January 22, 2019 3:47 pm
Ctrlr