Hi guys have a look at this patch seed rn.pd
When I manually bang the process, [timer] seeds [random] giving different sequences at every new start. But when I'm going to automate the start of the process adding [loadbang] it doesn't work anymore, it gives always the same sequence. Why, and how can I fix it?
I can use only vanilla objects. Thanks in advance.
Matteo
-
Things change when I loadbang the process
-
@deframmentazione-geometrica In your current patch, the right [timer] will always output 0 on startup because you're measuring time between 2 [loadbang] objects. Therefore [random] will generate the same sequence since it is always seeded with 0.
If what you want is having different sequences whenever you reopen the patch, you can just not seed the [random] at all. But still, it will generate the same sequences whenever you restart pd and then open the patch.
-
@deframmentazione-geometrica Hello,
Using [time] instead of [timer] will work........ but not Vanilla.
This will work, but you need an audio (microphone) input..... although just background noise (no actual microphone) will do if the multiplier that follows [snapshot~] is big enough.
randomer.pd
David. -
@deframmentazione-geometrica Try using [realtime]. It will give you a little bit of entropy.
-
Both solutions works. Thanks.
However I can't use them for my purpose; The patch should runs in the web browser and [time] [realtime] are not supported, also when I seed random with [adc] noise and translate the patch in the javascript file and opening it in the browser the result is just a flat frequency without changing... -
And therefore there isn't any way to do it with [timer]?
-
This works for me:
Every new opening of the patch gives another sequence. The seed is there for what you not want: Always the same random sequence. -
@ingox Not if you re-open Pd...... it will always be the same.
It will always be the same for every random, each one different according to its creation order.
So if you open the patch again.... it is the second created.... and different.
But if you re-start Pd it is always the first created..... and so always the same.
David. -
@whale-av You are right. So it has to be done with a seed and the seed must be fed by an external entropy source, like manual click, audio input or something else...
-
@ingox Yes, audio didn't work.
Well it worked in Pd, but not in a browser. The problem is compounded by translation to javascript.....!
David. -
@whale-av If there is any chance to save a value inside the patch, [random] can give a number, which is saved in the patch, used as seed the next time, another number is generated and so forth...
like this:
random.pdEdit: The number could also be saved in another file and there could be other modes to generate the number, like accumulating numbers and so on...
-
@ingox That's a good idea.
We will have to wait for @deframmentazione-geometrica to come back to find out.
I imagine they will have found a way to get the time from the web in javascript by now.
David. -
@ingox Thank you so much but I haven't had a chance to try out translation in javascript yet, the 'enzienaudio' site, which is where I do that, is down from yesterday. I'll keep you update as soon as I have been able to try it.
-
@whale-av Hi David I didn't even try to get the time from the web in javascript.. The much more viable option for me right know is do everything in pd.
-
@deframmentazione-geometrica Here is a snapshot of the heavy Pd objects page: https://web.archive.org/web/20161013051300/https://enzienaudio.com/docs/pdobjects.html
There is [table] which supports reading from and writing to a text file, at least in actual Pd. If you can do this in your compiled js patch, the above method is possible.
Otherwise maybe you can send in some midi through [notein].
-
This works in Pd. It gives an error the first time if no seed.txt is present. It generates new sequences every time Pd is restarted. If it works in your environment depends on whether you are allowed to write to a file though:
-
@ingox The translation of the patch was fine, there wasn't any error, but when I run the patch in html I have just the initial frequency without changing, the random process doesn't start
-
@deframmentazione-geometrica Maybe you can create seed.txt manually in the same directory as the patch. At the same time i would not be surprised if a weblike environment prohibits writing to a local file. From what i see [notein] is the only other object that allows external input, other than that i think we are running out of options.
-
If the code actually runs in a browser (sorry i am not familiar with heavy) it would also be possible to implement a [send] object in javascript and send values from there after the patch is loaded.
-
The patch would look like this:
And you would also need to compile a patch with a single [send] like this:
The javascript code of this send patch would be expanded so on document load javascript generates the seed and calls the function of the [send] with '__js_seed' and the seed number and thats it (hopefully).Edit: Well, that is just an idea, i am actually not sure right now if it is possible in javascript to access the encapsulated heavy functions, my javascript is a bit rusty.
-
@ingox I think all operating systems collect keystrokes, mouse movements, kernel activity etc. for encryption purposes.
But access will be different for each one probably.
This gets kernel load in a browser in JavaScript....... https://github.com/keybase/more-entropy
Maybe start it, open a socket, send to patch....... (always "maybe"..... )
David.