<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Manual: AudioSample</title>
	<atom:link href="http://code.compartmental.net/tools/minim/manual-audiosample/feed/" rel="self" type="application/rss+xml" />
	<link>http://code.compartmental.net</link>
	<description></description>
	<lastBuildDate>Sun, 05 Feb 2012 07:48:52 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: ddf</title>
		<link>http://code.compartmental.net/tools/minim/manual-audiosample/comment-page-1/#comment-3722</link>
		<dc:creator>ddf</dc:creator>
		<pubDate>Wed, 17 Nov 2010 04:54:40 +0000</pubDate>
		<guid isPermaLink="false">http://code.compartmental.net/?page_id=123#comment-3722</guid>
		<description>@jbonez No, AudioSample is not designed to work that way. It is meant to be a fire-and-forget method of playing a short sound. Calling trigger() is essentially the same as calling play(0) on an AudioPlayer, but as I&#039;m sure you&#039;re aware, it won&#039;t halt the playback of previous trigger calls.</description>
		<content:encoded><![CDATA[<p>@jbonez No, AudioSample is not designed to work that way. It is meant to be a fire-and-forget method of playing a short sound. Calling trigger() is essentially the same as calling play(0) on an AudioPlayer, but as I&#8217;m sure you&#8217;re aware, it won&#8217;t halt the playback of previous trigger calls.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jbonez</title>
		<link>http://code.compartmental.net/tools/minim/manual-audiosample/comment-page-1/#comment-3701</link>
		<dc:creator>jbonez</dc:creator>
		<pubDate>Sun, 14 Nov 2010 18:08:31 +0000</pubDate>
		<guid isPermaLink="false">http://code.compartmental.net/?page_id=123#comment-3701</guid>
		<description>cheerio,

I need to set my sample back to 0. something like player.play(0) or rewind or something....jsut for audioSample.

Need to use audioSample since audioPlayer has a pretty bad latency if you&#039;re trying to synchronize samples.

is there something like loop(), rewind(), or play(0)?


thanks in advance</description>
		<content:encoded><![CDATA[<p>cheerio,</p>
<p>I need to set my sample back to 0. something like player.play(0) or rewind or something&#8230;.jsut for audioSample.</p>
<p>Need to use audioSample since audioPlayer has a pretty bad latency if you&#8217;re trying to synchronize samples.</p>
<p>is there something like loop(), rewind(), or play(0)?</p>
<p>thanks in advance</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Carol</title>
		<link>http://code.compartmental.net/tools/minim/manual-audiosample/comment-page-1/#comment-3245</link>
		<dc:creator>Carol</dc:creator>
		<pubDate>Sat, 02 Oct 2010 04:08:08 +0000</pubDate>
		<guid isPermaLink="false">http://code.compartmental.net/?page_id=123#comment-3245</guid>
		<description>Hi ddf,

thank you so much for ur reply and suggestions, I will give that a go :)


Carol</description>
		<content:encoded><![CDATA[<p>Hi ddf,</p>
<p>thank you so much for ur reply and suggestions, I will give that a go <img src='http://code.compartmental.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Carol</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ddf</title>
		<link>http://code.compartmental.net/tools/minim/manual-audiosample/comment-page-1/#comment-3235</link>
		<dc:creator>ddf</dc:creator>
		<pubDate>Fri, 01 Oct 2010 02:51:57 +0000</pubDate>
		<guid isPermaLink="false">http://code.compartmental.net/?page_id=123#comment-3235</guid>
		<description>This is a great question for the Processing forum: http://forum.processing.org/

But, what you&#039;ve described is relatively simple, so try this: create an array of 9 AudioSample objects. Load a different sample into each one. When the mouse is pressed, use the &lt;code&gt;random&lt;/code&gt; function to generate a number between 0 and 8 (remember that arrays are 0 based) and use the &lt;code&gt;int&lt;/code&gt; function to turn that generated number into an int that you can index into the array with. Your code might look something like this:

&lt;pre&gt;
void mousePressed()
{
  int index = int( random(0,8) );
  sampleArray[index].trigger();
}
&lt;/pre&gt;

Good luck!</description>
		<content:encoded><![CDATA[<p>This is a great question for the Processing forum: <a href="http://forum.processing.org/" rel="nofollow">http://forum.processing.org/</a></p>
<p>But, what you&#8217;ve described is relatively simple, so try this: create an array of 9 AudioSample objects. Load a different sample into each one. When the mouse is pressed, use the <code>random</code> function to generate a number between 0 and 8 (remember that arrays are 0 based) and use the <code>int</code> function to turn that generated number into an int that you can index into the array with. Your code might look something like this:</p>
<pre>
void mousePressed()
{
  int index = int( random(0,8) );
  sampleArray[index].trigger();
}
</pre>
<p>Good luck!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Carol</title>
		<link>http://code.compartmental.net/tools/minim/manual-audiosample/comment-page-1/#comment-3234</link>
		<dc:creator>Carol</dc:creator>
		<pubDate>Fri, 01 Oct 2010 02:38:34 +0000</pubDate>
		<guid isPermaLink="false">http://code.compartmental.net/?page_id=123#comment-3234</guid>
		<description>Hi there, I am quite new to processing. I was just wondering if there is a way to generate random Audio Sample using a mousePressed? e.g. I have 9 different Audio Samples and a mousePressed function, and would like to use the random function as well so that each time the mouse is pressed 1 out of 9 of the Audio Sample would play randomly. 

Would be lovely to hear some feedback.</description>
		<content:encoded><![CDATA[<p>Hi there, I am quite new to processing. I was just wondering if there is a way to generate random Audio Sample using a mousePressed? e.g. I have 9 different Audio Samples and a mousePressed function, and would like to use the random function as well so that each time the mouse is pressed 1 out of 9 of the Audio Sample would play randomly. </p>
<p>Would be lovely to hear some feedback.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John</title>
		<link>http://code.compartmental.net/tools/minim/manual-audiosample/comment-page-1/#comment-3226</link>
		<dc:creator>John</dc:creator>
		<pubDate>Thu, 30 Sep 2010 11:30:19 +0000</pubDate>
		<guid isPermaLink="false">http://code.compartmental.net/?page_id=123#comment-3226</guid>
		<description>Thank you very much! This worked perfectly. I really appreciate all of your help - I needed to get this working for a piece that&#039;s currently being exhibited in an art gallery. Thanks again!</description>
		<content:encoded><![CDATA[<p>Thank you very much! This worked perfectly. I really appreciate all of your help &#8211; I needed to get this working for a piece that&#8217;s currently being exhibited in an art gallery. Thanks again!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ddf</title>
		<link>http://code.compartmental.net/tools/minim/manual-audiosample/comment-page-1/#comment-3094</link>
		<dc:creator>ddf</dc:creator>
		<pubDate>Thu, 16 Sep 2010 01:10:26 +0000</pubDate>
		<guid isPermaLink="false">http://code.compartmental.net/?page_id=123#comment-3094</guid>
		<description>You should be able to, but I&#039;m not surprised you&#039;re finding strange behavior with that many. Behind the scenes, each AudioSample has its own output that is running in its own thread. The was the most straightforward thing to implement, so it&#039;s what I went with. However, having large number of threads running in your app can become problematic, so it wasn&#039;t really the best implementation choice. I will probably rework it so that AudioSamples that have the same AudioFormat and buffer size will share an output, but don&#039;t expect to see that any time soon. In the meantime, if you don&#039;t absolutely need the trigger() functionality, you could load your files into FilePlayer objects and patch them all to the same AudioOutput. Then you&#039;d have only one audio processing thread running and you shouldn&#039;t find yourself with the same 32 sample limitation.

Here&#039;s an example of how you load a file into a FilePlayer and patch it to an AudioOutput (you&#039;ll need to use the current beta build to be able to do this):
&lt;pre&gt;
Minim minim;
AudioOutput mainOut;

FilePlayer player;

void setup()
{
  minim = new Minim(this);
  mainOut = minim.getLineOut();
  
  // 1024 is a buffer size.
  // true means that the file will be loaded into memory,
  // which is what you want if you&#039;re going to be constantly playing it from the beginning
  player = new FilePlayer( minim.loadFileStream( &quot;your_sample.wav&quot;, 1024, true )  );
  player.patch( mainOut );
}

void triggerPlayer()
{
  // starts player playing back from the beginning
  // you&#039;d use this in place of the trigger() method from AudioSample
  player.play(0);
}
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>You should be able to, but I&#8217;m not surprised you&#8217;re finding strange behavior with that many. Behind the scenes, each AudioSample has its own output that is running in its own thread. The was the most straightforward thing to implement, so it&#8217;s what I went with. However, having large number of threads running in your app can become problematic, so it wasn&#8217;t really the best implementation choice. I will probably rework it so that AudioSamples that have the same AudioFormat and buffer size will share an output, but don&#8217;t expect to see that any time soon. In the meantime, if you don&#8217;t absolutely need the trigger() functionality, you could load your files into FilePlayer objects and patch them all to the same AudioOutput. Then you&#8217;d have only one audio processing thread running and you shouldn&#8217;t find yourself with the same 32 sample limitation.</p>
<p>Here&#8217;s an example of how you load a file into a FilePlayer and patch it to an AudioOutput (you&#8217;ll need to use the current beta build to be able to do this):</p>
<pre>
Minim minim;
AudioOutput mainOut;

FilePlayer player;

void setup()
{
  minim = new Minim(this);
  mainOut = minim.getLineOut();

  // 1024 is a buffer size.
  // true means that the file will be loaded into memory,
  // which is what you want if you're going to be constantly playing it from the beginning
  player = new FilePlayer( minim.loadFileStream( "your_sample.wav", 1024, true )  );
  player.patch( mainOut );
}

void triggerPlayer()
{
  // starts player playing back from the beginning
  // you'd use this in place of the trigger() method from AudioSample
  player.play(0);
}
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: John</title>
		<link>http://code.compartmental.net/tools/minim/manual-audiosample/comment-page-1/#comment-3092</link>
		<dc:creator>John</dc:creator>
		<pubDate>Wed, 15 Sep 2010 21:51:49 +0000</pubDate>
		<guid isPermaLink="false">http://code.compartmental.net/?page_id=123#comment-3092</guid>
		<description>Is there a way to load more than 32 audio samples? It seems as though the trigger method fails if you have more than 32 samples loaded into memory. The first set of 32 samples work fine; the second set of 32 samples will not play. Older versions of Processing would allow for this... but I can&#039;t seem to make it work using a newer version of Processing.</description>
		<content:encoded><![CDATA[<p>Is there a way to load more than 32 audio samples? It seems as though the trigger method fails if you have more than 32 samples loaded into memory. The first set of 32 samples work fine; the second set of 32 samples will not play. Older versions of Processing would allow for this&#8230; but I can&#8217;t seem to make it work using a newer version of Processing.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

