<?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: HOWTO: Manipulate an AudioSample in Minim 2.0</title>
	<atom:link href="http://code.compartmental.net/2008/10/12/howto-manipulate-an-audiosample-in-minim-20/feed/" rel="self" type="application/rss+xml" />
	<link>http://code.compartmental.net/2008/10/12/howto-manipulate-an-audiosample-in-minim-20/</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: scape</title>
		<link>http://code.compartmental.net/2008/10/12/howto-manipulate-an-audiosample-in-minim-20/comment-page-1/#comment-645</link>
		<dc:creator>scape</dc:creator>
		<pubDate>Sat, 15 Nov 2008 19:51:07 +0000</pubDate>
		<guid isPermaLink="false">http://code.compartmental.net/2008/10/12/howto-manipulate-an-audiosample-in-minim-20/#comment-645</guid>
		<description>i&#039;m looking to extend what kyle did into the original source, without recompiling it; is it possible to do so? I need a way to push an array of float samples to a channel for playback, and it looks like it&#039;s on a todo list from ddf, but I&#039;m not sure.</description>
		<content:encoded><![CDATA[<p>i&#8217;m looking to extend what kyle did into the original source, without recompiling it; is it possible to do so? I need a way to push an array of float samples to a channel for playback, and it looks like it&#8217;s on a todo list from ddf, but I&#8217;m not sure.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kyle</title>
		<link>http://code.compartmental.net/2008/10/12/howto-manipulate-an-audiosample-in-minim-20/comment-page-1/#comment-633</link>
		<dc:creator>Kyle</dc:creator>
		<pubDate>Thu, 16 Oct 2008 23:20:19 +0000</pubDate>
		<guid isPermaLink="false">http://code.compartmental.net/2008/10/12/howto-manipulate-an-audiosample-in-minim-20/#comment-633</guid>
		<description>I implemented the above, adding:

minim.createSample(float[] samples, int sampleRate);
minim.createSample(float[] samples, int bufferSize, int sampleRate);
minim.saveSample(AudioSample sample, String filename);

Source is here: http://www.rpi.edu/~mcdonk/random/minim-2.02.zip</description>
		<content:encoded><![CDATA[<p>I implemented the above, adding:</p>
<p>minim.createSample(float[] samples, int sampleRate);<br />
minim.createSample(float[] samples, int bufferSize, int sampleRate);<br />
minim.saveSample(AudioSample sample, String filename);</p>
<p>Source is here: <a href="http://www.rpi.edu/~mcdonk/random/minim-2.02.zip" rel="nofollow">http://www.rpi.edu/~mcdonk/random/minim-2.02.zip</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kyle</title>
		<link>http://code.compartmental.net/2008/10/12/howto-manipulate-an-audiosample-in-minim-20/comment-page-1/#comment-632</link>
		<dc:creator>Kyle</dc:creator>
		<pubDate>Thu, 16 Oct 2008 20:52:16 +0000</pubDate>
		<guid isPermaLink="false">http://code.compartmental.net/2008/10/12/howto-manipulate-an-audiosample-in-minim-20/#comment-632</guid>
		<description>The above idea doesn&#039;t work since splitter in AudioSource is private rather than protected. So I made this really, really terrible hack. I added this to AudioSource:

public void nrtDump(float[] inputSamples) {
	for(int i = 0; i &lt; inputSamples.length; i += bufferSize()) {
		float[] cur = new float[bufferSize()];
		int remaining = inputSamples.length - i;
		int curLength = Math.min(remaining, bufferSize());
		System.arraycopy(inputSamples, i, cur, 0, curLength);
		splitter.samples(cur);
	}
}

And then in my main code I wrote this:

audio = minim.loadSample(&quot;audiofile.wav&quot;, 512);
float[] leftChannel = audio.getChannel(BufferedAudio.LEFT);
float[] reversed = reverse(leftChannel);	  
AudioRecorder recorder = minim.createRecorder(audio, &quot;data/output.wav&quot;, true);
recorder.beginRecord();
audio.nrtDump(reversed);
recorder.endRecord();
recorder.save();

With that said, something like: minim.createSample(float[] samples); (returning an AudioSample) and minim.saveSample(AudioSample sample); would be amazing.</description>
		<content:encoded><![CDATA[<p>The above idea doesn&#8217;t work since splitter in AudioSource is private rather than protected. So I made this really, really terrible hack. I added this to AudioSource:</p>
<p>public void nrtDump(float[] inputSamples) {<br />
	for(int i = 0; i &lt; inputSamples.length; i += bufferSize()) {<br />
		float[] cur = new float[bufferSize()];<br />
		int remaining = inputSamples.length &#8211; i;<br />
		int curLength = Math.min(remaining, bufferSize());<br />
		System.arraycopy(inputSamples, i, cur, 0, curLength);<br />
		splitter.samples(cur);<br />
	}<br />
}</p>
<p>And then in my main code I wrote this:</p>
<p>audio = minim.loadSample(&#8220;audiofile.wav&#8221;, 512);<br />
float[] leftChannel = audio.getChannel(BufferedAudio.LEFT);<br />
float[] reversed = reverse(leftChannel);<br />
AudioRecorder recorder = minim.createRecorder(audio, &#8220;data/output.wav&#8221;, true);<br />
recorder.beginRecord();<br />
audio.nrtDump(reversed);<br />
recorder.endRecord();<br />
recorder.save();</p>
<p>With that said, something like: minim.createSample(float[] samples); (returning an AudioSample) and minim.saveSample(AudioSample sample); would be amazing.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kyle</title>
		<link>http://code.compartmental.net/2008/10/12/howto-manipulate-an-audiosample-in-minim-20/comment-page-1/#comment-631</link>
		<dc:creator>Kyle</dc:creator>
		<pubDate>Wed, 15 Oct 2008 13:38:53 +0000</pubDate>
		<guid isPermaLink="false">http://code.compartmental.net/2008/10/12/howto-manipulate-an-audiosample-in-minim-20/#comment-631</guid>
		<description>I just noticed that if I want to save this audio to disk, I need to fake out Minim into thinking I&#039;m doing it in real time. The best solution I have right now involves: extending AudioSample with a class that has a method dump(), which will just call samples() with all the BufferedAudio samples on all the AudioListeners attached to it. Is there a better way?

It&#039;d be really great if AudioSample had a constructor that just allowed you to pass a float[] to it, and then a method that allowed you to save the AudioSample.</description>
		<content:encoded><![CDATA[<p>I just noticed that if I want to save this audio to disk, I need to fake out Minim into thinking I&#8217;m doing it in real time. The best solution I have right now involves: extending AudioSample with a class that has a method dump(), which will just call samples() with all the BufferedAudio samples on all the AudioListeners attached to it. Is there a better way?</p>
<p>It&#8217;d be really great if AudioSample had a constructor that just allowed you to pass a float[] to it, and then a method that allowed you to save the AudioSample.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ddf</title>
		<link>http://code.compartmental.net/2008/10/12/howto-manipulate-an-audiosample-in-minim-20/comment-page-1/#comment-625</link>
		<dc:creator>ddf</dc:creator>
		<pubDate>Sun, 12 Oct 2008 22:29:52 +0000</pubDate>
		<guid isPermaLink="false">http://code.compartmental.net/2008/10/12/howto-manipulate-an-audiosample-in-minim-20/#comment-625</guid>
		<description>Yes, the one limitation here is that you can&#039;t make the array longer. You can effectively make it shorter by having a bunch of zeros at the end of the existing array, but that will be problematic if you are trying to loop it. I will probably add the ability to set new sample arrays for existing AudioSamples, there&#039;s no particular reason not to.</description>
		<content:encoded><![CDATA[<p>Yes, the one limitation here is that you can&#8217;t make the array longer. You can effectively make it shorter by having a bunch of zeros at the end of the existing array, but that will be problematic if you are trying to loop it. I will probably add the ability to set new sample arrays for existing AudioSamples, there&#8217;s no particular reason not to.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kyle</title>
		<link>http://code.compartmental.net/2008/10/12/howto-manipulate-an-audiosample-in-minim-20/comment-page-1/#comment-624</link>
		<dc:creator>Kyle</dc:creator>
		<pubDate>Sun, 12 Oct 2008 20:30:45 +0000</pubDate>
		<guid isPermaLink="false">http://code.compartmental.net/2008/10/12/howto-manipulate-an-audiosample-in-minim-20/#comment-624</guid>
		<description>Excellent -- this is very helpful. In my case, this should be perfect; but if I wanted to increase the length of the float[] during processing would there be any way to get it all back into the AudioSample? Obviously the arraycopy() would crash.

Also, I was concerned about length constraints, but I think you should run into memory problems first. Java arrays can be 2^27 elements long, or about 50 minutes at 44.1kHz.</description>
		<content:encoded><![CDATA[<p>Excellent &#8212; this is very helpful. In my case, this should be perfect; but if I wanted to increase the length of the float[] during processing would there be any way to get it all back into the AudioSample? Obviously the arraycopy() would crash.</p>
<p>Also, I was concerned about length constraints, but I think you should run into memory problems first. Java arrays can be 2^27 elements long, or about 50 minutes at 44.1kHz.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Code Log &#187; Blog Archive &#187; Bug Fix: Minim 2.0.1</title>
		<link>http://code.compartmental.net/2008/10/12/howto-manipulate-an-audiosample-in-minim-20/comment-page-1/#comment-623</link>
		<dc:creator>Code Log &#187; Blog Archive &#187; Bug Fix: Minim 2.0.1</dc:creator>
		<pubDate>Sun, 12 Oct 2008 18:22:30 +0000</pubDate>
		<guid isPermaLink="false">http://code.compartmental.net/2008/10/12/howto-manipulate-an-audiosample-in-minim-20/#comment-623</guid>
		<description>[...] Code Log Prototypes and Other Bits of Code      &#171; HOWTO: Manipulate an AudioSample in Minim 2.0 [...]</description>
		<content:encoded><![CDATA[<p>[...] Code Log Prototypes and Other Bits of Code      &laquo; HOWTO: Manipulate an AudioSample in Minim 2.0 [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>

