Csound Csound-dev Csound-tekno Search About

[Csnd] Random values

Date2019-10-06 18:54
FromRaphaelV
Subject[Csnd] Random values
Hello,

I'm quite new with CSound and I have a question regarding randomness in it.

I'm recreating the S3F algorithm made by Miller Puckette inside a  CSound
instrument. The instrument selects frequencies based on a probability
argument and compares it to a random value in order to decide if it gets
written in a table or not.

So basically, if my prabability argument is 1 (from 0 to 1), it is compared
to a rng value (also 0 to 1) and, since probability is always bigger than
rng, every value is written in the table; however, if the probability is
0.1, some of the frequencies will be written and some will not, randomly.
The idea is that any iteration of the same synthesis processes will render a
sound with a different spectrum.

I made the instrument with the rng value being generated by rnd and random,
and it partially worked: every time the same instrument was played with the
same p values, it sounded different. However, when I run the code again,
both rnd and random generated the same values, so the supposed random sounds
were actually the same from the first time it was run, loosing the whole
pourpose of it.


I would like to ask if anyone would know of a solution in which the rng
would not have the same seed every time that I would run the code (which is
what I understand is happening with the rnd and random objects)?

Thanks for your help,
Raphael



--
Sent from: http://csound.1045644.n5.nabble.com/Csound-General-f1093014.html

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2019-10-06 19:03
FromDave Seidel
SubjectRe: [Csnd] Random values
Have you tried using the "seed" opcode? With an argument of 0, it uses the value of the system clock, so it will be different on every run.

On Sun, Oct 6, 2019 at 1:55 PM RaphaelV <vilaniraphael@gmail.com> wrote:
Hello,

I'm quite new with CSound and I have a question regarding randomness in it.

I'm recreating the S3F algorithm made by Miller Puckette inside a  CSound
instrument. The instrument selects frequencies based on a probability
argument and compares it to a random value in order to decide if it gets
written in a table or not.

So basically, if my prabability argument is 1 (from 0 to 1), it is compared
to a rng value (also 0 to 1) and, since probability is always bigger than
rng, every value is written in the table; however, if the probability is
0.1, some of the frequencies will be written and some will not, randomly.
The idea is that any iteration of the same synthesis processes will render a
sound with a different spectrum.

I made the instrument with the rng value being generated by rnd and random,
and it partially worked: every time the same instrument was played with the
same p values, it sounded different. However, when I run the code again,
both rnd and random generated the same values, so the supposed random sounds
were actually the same from the first time it was run, loosing the whole
pourpose of it.


I would like to ask if anyone would know of a solution in which the rng
would not have the same seed every time that I would run the code (which is
what I understand is happening with the rnd and random objects)?

Thanks for your help,
Raphael



--
Sent from: http://csound.1045644.n5.nabble.com/Csound-General-f1093014.html

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here


--
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2019-10-06 19:21
FromRaphaelV
SubjectRe: [Csnd] Random values
I had not! Just tried and it worked perfectly, as simple as it gets.

Thank you, Dave!



--
Sent from: http://csound.1045644.n5.nabble.com/Csound-General-f1093014.html

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2019-10-06 19:56
FromDave Seidel
SubjectRe: [Csnd] Random values
Glad to hear it. I use "seed" any time I incorporate random elements.

On Sun, Oct 6, 2019 at 2:12 PM RaphaelV <vilaniraphael@gmail.com> wrote:
I had not! Just tried and it worked perfectly, as simple as it gets.

Thank you, Dave!



--
Sent from: http://csound.1045644.n5.nabble.com/Csound-General-f1093014.html

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here


--
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2019-10-06 21:04
FromVictor Lazzarini
SubjectRe: [Csnd] Random values
If you want different random sequences you need to apply a seed

https://csound.com/docs/manual/seed.html

Prof. Victor Lazzarini
Maynooth University
Ireland

On 6 Oct 2019, at 18:56, RaphaelV <vilaniraphael@gmail.com> wrote:

Hello,

I'm quite new with CSound and I have a question regarding randomness in it.

I'm recreating the S3F algorithm made by Miller Puckette inside a  CSound
instrument. The instrument selects frequencies based on a probability
argument and compares it to a random value in order to decide if it gets
written in a table or not.

So basically, if my prabability argument is 1 (from 0 to 1), it is compared
to a rng value (also 0 to 1) and, since probability is always bigger than
rng, every value is written in the table; however, if the probability is
0.1, some of the frequencies will be written and some will not, randomly.
The idea is that any iteration of the same synthesis processes will render a
sound with a different spectrum.

I made the instrument with the rng value being generated by rnd and random,
and it partially worked: every time the same instrument was played with the
same p values, it sounded different. However, when I run the code again,
both rnd and random generated the same values, so the supposed random sounds
were actually the same from the first time it was run, loosing the whole
pourpose of it.


I would like to ask if anyone would know of a solution in which the rng
would not have the same seed every time that I would run the code (which is
what I understand is happening with the rnd and random objects)?

Thanks for your help,
Raphael



--
Sent from: http://csound.1045644.n5.nabble.com/Csound-General-f1093014.html

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
       https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here