<?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: Changing my object from handling floats to lists</title>
		<atom:link href="http://cycling74.com/forums/topic/changing-my-object-from-handling-floats-to-lists/feed" rel="self" type="application/rss+xml" />
		<link>http://cycling74.com/forums/topic/changing-my-object-from-handling-floats-to-lists/feed</link>
		<description></description>
		<pubDate>Tue, 18 Jun 2013 18:24:28 +0000</pubDate>
		<generator>http://bbpress.org/?v=2.2.4</generator>
		<language></language>

		
														
					
				<item>
					<guid>http://cycling74.com/forums/topic/changing-my-object-from-handling-floats-to-lists/#post-49779</guid>
					<title><![CDATA[Changing my object from handling floats to lists]]></title>
					<link>http://cycling74.com/forums/topic/changing-my-object-from-handling-floats-to-lists/#post-49779</link>
					<pubDate>Wed, 14 Apr 2010 21:21:58 +0000</pubDate>
					<dc:creator>yns</dc:creator>

					<description>
						<![CDATA[
						<p>Probably it&#8217;s quite trivial but since I&#8217;m a newcomer to Java I can&#8217;t figure it out.</p>
<p>I have made this mxj object wich takes floats and measures the time between those incoming floats and puts them into a variable which is List of doubles (List is an object from the java.util package wich can add up items to a list without first declaring its size).</p>
<p>Now i want to make the object handle lists and put those incoming lists followed by the delta-time (since the previous list) into that variable instead of floats.</p>
<p>It would be nice if somebody could take a look:</p>
<p>import com.cycling74.max.*;<br />
import java.util.*;</p>
<p>public class ynsListTest  extends MaxObject {</p>
<p>	private boolean isRecording = false;<br />
	private List<double []> storage = new ArrayList</double><double []>();<br />
	private double time = -1;</double></p>
<p>	public ynsListTest() {<br />
		declareIO(2,1);<br />
	}</p>
<p>	public void record(boolean b) {<br />
		isRecording = b;<br />
		if (b) {<br />
			storage.clear();<br />
			time = -1;<br />
		}<br />
	}</p>
<p>	public void inlet(float value) {<br />
		if (getInlet() == 1 &#038;&#038; isRecording) {<br />
			double currentTime = MaxClock.getTime();<br />
			double delta;<br />
			if (time == -1) {<br />
				delta = 0;<br />
			} else {<br />
				delta = currentTime &#8211; time;<br />
			}<br />
			storage.add(new Double[] {(double)value, delta});<br />
			time = currentTime;<br />
		}<br />
	}<br />
}</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/changing-my-object-from-handling-floats-to-lists/#post-178743</guid>
					<title><![CDATA[Re: Changing my object from handling floats to lists]]></title>
					<link>http://cycling74.com/forums/topic/changing-my-object-from-handling-floats-to-lists/#post-178743</link>
					<pubDate>Wed, 14 Apr 2010 21:24:40 +0000</pubDate>
					<dc:creator>Jesse</dc:creator>

					<description>
						<![CDATA[
						<p>Take a look at the Atom class in the com.cycling74.max package.</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/changing-my-object-from-handling-floats-to-lists/#post-178744</guid>
					<title><![CDATA[Re: Changing my object from handling floats to lists]]></title>
					<link>http://cycling74.com/forums/topic/changing-my-object-from-handling-floats-to-lists/#post-178744</link>
					<pubDate>Wed, 14 Apr 2010 21:33:38 +0000</pubDate>
					<dc:creator>yns</dc:creator>

					<description>
						<![CDATA[
						<p>I don&#8217;t really get what you mean, do you suggest I replace the List of Double[] with a List of Atom[]?</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/changing-my-object-from-handling-floats-to-lists/#post-178745</guid>
					<title><![CDATA[Re: Changing my object from handling floats to lists]]></title>
					<link>http://cycling74.com/forums/topic/changing-my-object-from-handling-floats-to-lists/#post-178745</link>
					<pubDate>Wed, 14 Apr 2010 23:13:08 +0000</pubDate>
					<dc:creator>Jesse</dc:creator>

					<description>
						<![CDATA[
						<p>lists can be represented as Atom[] in the mxj environment.  I&#8217;d make a wrapper class that contains an Atom[] and a double timestamp, and then store those in your List.  The usefulness of the Atom[] construct is that you don&#8217;t need to know the length of the list you are receiving.</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/changing-my-object-from-handling-floats-to-lists/#post-178746</guid>
					<title><![CDATA[Re: Changing my object from handling floats to lists]]></title>
					<link>http://cycling74.com/forums/topic/changing-my-object-from-handling-floats-to-lists/#post-178746</link>
					<pubDate>Thu, 15 Apr 2010 00:44:22 +0000</pubDate>
					<dc:creator>yns</dc:creator>

					<description>
						<![CDATA[
						<p>so make the List a list of Atom[] like this?: </p>
<p>private List<atom []> storage = new ArrayList</atom><atom []>(); </atom></p>
<p>and then instead of filling it with a Double[] fill it with a wrapper class (that i&#8217;d have to make) which contains an Atom[] (which would be the list coming in) and a double timestamp(don&#8217;t know what that is actually?) like this?:</p>
<p>storage.add(new Wrapper(value, delta};</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/changing-my-object-from-handling-floats-to-lists/#post-178747</guid>
					<title><![CDATA[Re: Changing my object from handling floats to lists]]></title>
					<link>http://cycling74.com/forums/topic/changing-my-object-from-handling-floats-to-lists/#post-178747</link>
					<pubDate>Thu, 15 Apr 2010 06:32:13 +0000</pubDate>
					<dc:creator>Jesse</dc:creator>

					<description>
						<![CDATA[
						<p>Yes, but the declaration for the List would be:</p>
<p>private List<wrapper> storage = new ArrayList</wrapper><wrapper>();</wrapper></p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/changing-my-object-from-handling-floats-to-lists/#post-178748</guid>
					<title><![CDATA[Re: Changing my object from handling floats to lists]]></title>
					<link>http://cycling74.com/forums/topic/changing-my-object-from-handling-floats-to-lists/#post-178748</link>
					<pubDate>Thu, 15 Apr 2010 08:04:37 +0000</pubDate>
					<dc:creator>yns</dc:creator>

					<description>
						<![CDATA[
						<p>Thanks alot.</p>
<p>I hope it&#8217;s not to time consuming though, making an object every time I need to add something to the List. The addition&#8217;s will be done with a speed up to 10 ms.</p>
<p>Would there be a way without needing the wrapper object but maybe converting some values so they can go into List<array []> ?</array></p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/changing-my-object-from-handling-floats-to-lists/#post-178749</guid>
					<title><![CDATA[Re: Changing my object from handling floats to lists]]></title>
					<link>http://cycling74.com/forums/topic/changing-my-object-from-handling-floats-to-lists/#post-178749</link>
					<pubDate>Thu, 15 Apr 2010 17:24:04 +0000</pubDate>
					<dc:creator>Jesse</dc:creator>

					<description>
						<![CDATA[
						<p>In the example you posted above you&#8217;re creating a Double[] each time you add to the List.  I wouldn&#8217;t worry about speed &#8211;  the bigger issue would be memory usage, depending on how many objects you&#8217;re storing.</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/changing-my-object-from-handling-floats-to-lists/#post-178750</guid>
					<title><![CDATA[Re: Changing my object from handling floats to lists]]></title>
					<link>http://cycling74.com/forums/topic/changing-my-object-from-handling-floats-to-lists/#post-178750</link>
					<pubDate>Thu, 15 Apr 2010 21:34:53 +0000</pubDate>
					<dc:creator>yns</dc:creator>

					<description>
						<![CDATA[
						<p>I tried your suggestion and it works like a charm. Thanks for that one.</p>
<p>But you think that the Wrapper object would take less memory than an array of doubles?</p>
<p>Could i skip the Wrapper object, convert the data coming from the MaxClock form double to float and create a List of float[]?</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/changing-my-object-from-handling-floats-to-lists/#post-178751</guid>
					<title><![CDATA[Re: Changing my object from handling floats to lists]]></title>
					<link>http://cycling74.com/forums/topic/changing-my-object-from-handling-floats-to-lists/#post-178751</link>
					<pubDate>Thu, 15 Apr 2010 22:15:54 +0000</pubDate>
					<dc:creator>Jesse</dc:creator>

					<description>
						<![CDATA[
						<p>The conversion would likely take more memory, and would slow things down.  If it ain&#8217;t broke don&#8217;t fix it.</p>
						]]>
					</description>

					
					
				</item>

					
		
	</channel>
	</rss>

