<?xml version="1.0" encoding="UTF-8"?>
	<rss version="2.0"
		xmlns:content="http://purl.org/rss/1.0/modules/content/"
		xmlns:wfw="http://wellformedweb.org/CommentAPI/"
		xmlns:dc="http://purl.org/dc/elements/1.1/"
		xmlns:atom="http://www.w3.org/2005/Atom"

			>

	<channel>
		<title>Cycling 74  &#187;  Topic: RNG in C-external instances</title>
		<atom:link href="http://cycling74.com/forums/topic/rng-in-c-external-instances/feed" rel="self" type="application/rss+xml" />
		<link>http://cycling74.com/forums/topic/rng-in-c-external-instances/feed</link>
		<description></description>
		<pubDate>Wed, 19 Jun 2013 21:45:06 +0000</pubDate>
		<generator>http://bbpress.org/?v=2.2.4</generator>
		<language></language>

		
														
					
				<item>
					<guid>http://cycling74.com/forums/topic/rng-in-c-external-instances/#post-62099</guid>
					<title><![CDATA[RNG in C-external instances]]></title>
					<link>http://cycling74.com/forums/topic/rng-in-c-external-instances/#post-62099</link>
					<pubDate>Fri, 02 Mar 2012 16:44:34 +0000</pubDate>
					<dc:creator>11olsen</dc:creator>

					<description>
						<![CDATA[
						<p>hallo, i&#8217;m trying to generate a different random number in different instances of an external. can you give me some advise</p>
<p>i&#8217;m using the normal rand(). Is the sdk offering something else/better?</p>
<p>the number is generated at object initialization. could it happen, if i use time as seed, that two instances generate the same number because initialization of both objects happens faster than 1ms?? if so, what can give me faster seeds?</p>
<p>Thanbks O.</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/rng-in-c-external-instances/#post-224309</guid>
					<title><![CDATA[Re: RNG in C-external instances]]></title>
					<link>http://cycling74.com/forums/topic/rng-in-c-external-instances/#post-224309</link>
					<pubDate>Fri, 02 Mar 2012 17:18:01 +0000</pubDate>
					<dc:creator>nicolas danet</dc:creator>

					<description>
						<![CDATA[
						<p>Hello, </p>
<p>AFAIK class is loaded once (&#8220;main&#8221; method of your external) ; so isn&#8217;t it possible to seed the RNG there ?</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/rng-in-c-external-instances/#post-224310</guid>
					<title><![CDATA[Re: RNG in C-external instances]]></title>
					<link>http://cycling74.com/forums/topic/rng-in-c-external-instances/#post-224310</link>
					<pubDate>Fri, 02 Mar 2012 17:48:51 +0000</pubDate>
					<dc:creator>11olsen</dc:creator>

					<description>
						<![CDATA[
						<p>hey, not sure if i get what you mean. &#8220;class is loaded once&#8221;?<br />
i&#8217;m using the &#8220;new&#8221; function to generate the number. it doesn&#8217;t matter where i seed it. Interessting for me is what happens if i load a patch with two instances of the ext, how can i make sure both instances are generating a different random number when they are created.<br />
with different seeds, right? how do i get different seeds so fast?</p>
<p>i don&#8217;t want to do intance to instance messages for this simple task.</p>
<p>tell me if it&#8217;s still hard to understand my question.<br />
O.</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/rng-in-c-external-instances/#post-224311</guid>
					<title><![CDATA[Re: RNG in C-external instances]]></title>
					<link>http://cycling74.com/forums/topic/rng-in-c-external-instances/#post-224311</link>
					<pubDate>Fri, 02 Mar 2012 18:06:46 +0000</pubDate>
					<dc:creator>nicolas danet</dc:creator>

					<description>
						<![CDATA[
						<p>Hello,</p>
<p>for example in case of a [flop] external you can seed the RNG there &#8230;</p>
<pre><code>int main (void)
{
t_class	*c = NULL;

c = class_new ("flop", (method)flop_new, (method)flop_free, (long)(sizeof(t_flop)), 0L, A_GIMME, 0);

class_addmethod	(c, (method)flop_assist, "assist", A_CANT, 0);
class_addmethod (c, (method)flop_bang,	 "bang", 0);

srand ((unsigned int)time(NULL));

class_register (CLASS_BOX, c);

flop_class = c;

return 0;
}</code></pre><p>&#8230; instead of in the flop_new() function as  the main() method is called only one time (for the FIRST created [flop] object). You can still use rand() function in flop_new() to get your random number. Problem occurs if you seed the RNG in flop_new() with time if instantiation occurs in the same millisecond ; but as you instantiate it only the first time it will be OK.</p>
<p>Is it clear ? I don&#8217;t think so ;-)</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/rng-in-c-external-instances/#post-224312</guid>
					<title><![CDATA[Re: RNG in C-external instances]]></title>
					<link>http://cycling74.com/forums/topic/rng-in-c-external-instances/#post-224312</link>
					<pubDate>Fri, 02 Mar 2012 18:19:28 +0000</pubDate>
					<dc:creator>11olsen</dc:creator>

					<description>
						<![CDATA[
						<p>do you mean main() is only called once even if a second and third instance is created?  so that rand_s in instance 2 will create random number 2 of the seed? i&#8217;ll try that out.<br />
thanks for your help so far..</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/rng-in-c-external-instances/#post-224313</guid>
					<title><![CDATA[Re: RNG in C-external instances]]></title>
					<link>http://cycling74.com/forums/topic/rng-in-c-external-instances/#post-224313</link>
					<pubDate>Fri, 02 Mar 2012 18:52:33 +0000</pubDate>
					<dc:creator>nicolas danet</dc:creator>

					<description>
						<![CDATA[
						<p>Hello,</p>
<p>that&#8217;s exactly what i mean ;-)</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/rng-in-c-external-instances/#post-224314</guid>
					<title><![CDATA[Re: RNG in C-external instances]]></title>
					<link>http://cycling74.com/forums/topic/rng-in-c-external-instances/#post-224314</link>
					<pubDate>Fri, 02 Mar 2012 19:39:08 +0000</pubDate>
					<dc:creator>11olsen</dc:creator>

					<description>
						<![CDATA[
						<p>cool, it works. and learned something..<br />
thanks, bye</p>
						]]>
					</description>

					
					
				</item>

					
		
	</channel>
	</rss>

