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
-
@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.