From Stefan-Tiedje at addcom.de Sat Mar 1 00:59:15 2008 From: Stefan-Tiedje at addcom.de (Stefan Tiedje) Date: Sat Mar 1 00:59:17 2008 Subject: [javascript-dev] Re: Send a list to a named bpatcher In-Reply-To: <1f955.47b65029@www.cycling74.com> References: <1f955.47b65029@www.cycling74.com> Message-ID: <47C90CD3.9040406@addcom.de> Adam Murray schrieb: > Did you ever figure this out? I don't see a way either. no... > I'd work around it by adding another named object that can be > scripted properly, and connect that to the bpatcher. I finally sent it from outside the js with a pattrforward... Stefan -- Stefan Tiedje------------x------- --_____-----------|-------------- --(_|_ ----|\-----|-----()------- -- _|_)----|-----()-------------- ----------()--------www.ccmix.com From spondoo at hotmail.com Sat Mar 1 08:17:37 2008 From: spondoo at hotmail.com (Adam) Date: Sat Mar 1 08:17:39 2008 Subject: [javascript-dev] Help!!! acceleration data peak finder Message-ID: <202e3.47c9738e@www.cycling74.com> Hi! My situation: I currently have a max msp patch that uses 2 "ctlin" objects (one for x values and one for y values) to get x and y acceleration data from an external device. The data is being transfered via osculator and is sending midi signals to the patch. My aim: I want to end up with a patch that allows x and y acceleration data to be able to control a midi file, e.g play a drum sound. However, I only want the file to be played if the incoming acceleration values satisfy a number of conditions. The java/max msp object: * I want to create java script that will be able to be used as an object in max msp. * The object should continually analyze incoming x and y acceleration values. * In the objects left inlet, I want to be able to set and adjust the trigger-range e.g. a low and high trigger threshold. The low value will be the minimum value able to trigger a midi file at a low volume and the high value will be the maximum value able to trigger a midi file at the highest volume. * Also in the left inlet, I want to be able to set and adjust the minimum-peak-gap. This will consist of two things, a value in milliseconds and another value that the acceleration data may not exceed by within that time frame. E.g. for 30 milliseconds the acceleration data may not increase by more than 20. * Therefore only data that fulfills the above conditions, will emerge from the outlet of the object, causing the midifile to play. My skills: I am not very experienced when it comes to programming and have no idea where to start or what to use? If anyone could offer help or show me some examples, I would really appreciate it! Thanks A From akinsel at tcd.ie Tue Mar 4 11:02:41 2008 From: akinsel at tcd.ie (Harrison Ford) Date: Tue Mar 4 11:02:43 2008 Subject: [javascript-dev] Max Mbrola Message-ID: <20493.47cd8ec0@www.cycling74.com> Hi, Have just been setting up MaxMbrola external object, but having a problem, when triggered, max window says 'You should set the voice first' Have loaded en1, the English male diphone database, cant seem to figure it out, been online all day looking for some help with it Any experienced users? From vboehm at gmx.ch Tue Mar 4 11:16:47 2008 From: vboehm at gmx.ch (=?ISO-8859-1?Q?volker_b=F6hm?=) Date: Tue Mar 4 11:14:52 2008 Subject: [javascript-dev] Max Mbrola In-Reply-To: <20493.47cd8ec0@www.cycling74.com> References: <20493.47cd8ec0@www.cycling74.com> Message-ID: <9C6B6ACE-FA84-4878-BFA4-A04BD14991B7@gmx.ch> On 04 Mar 2008, at 18:02, Harrison Ford wrote: > > Hi, > > Have just been setting up MaxMbrola external object, but having a > problem, when triggered, max window says 'You should set the voice > first' > > Have loaded en1, the English male diphone database, cant seem to > figure it out, been online all day looking for some help with it > > Any experienced users? Any reason you post this to the javascript forum? the regular max list would be more appropriate i guess. well, i have been making heavy use of MBROLA last summer for an interactive project. but, as far as i know the maxMbrola object is only for Max 4.5, so i couln't use it in 4.6. also i remember this object being rather buggy. so i was simply using the MBROLA command line application (osx) and controlled it through the shell object from max. this worked pretty well. hth, volker. From mattijs at smadsteck.nl Thu Mar 6 02:52:59 2008 From: mattijs at smadsteck.nl (Mattijs Kneppers) Date: Thu Mar 6 02:53:06 2008 Subject: [javascript-dev] Re: Max Mbrola In-Reply-To: <20493.47cd8ec0@www.cycling74.com> Message-ID: <20587.47cfbef6@www.cycling74.com> Moving this topic to the MaxMSP forum. From ga.paine at uws.edu.au Thu Mar 6 04:23:44 2008 From: ga.paine at uws.edu.au (Garth Paine) Date: Thu Mar 6 04:23:55 2008 Subject: [javascript-dev] setInterval In-Reply-To: <20493.47cd8ec0@www.cycling74.com> Message-ID: Hi everyone. I am using a for loop to read lines from a text file of data. I want to read one line every 20 ms. In processing or similar I would use the pause() function can I use SetInterval() to do this? What would the usual approach to timed loops for reading events like this is Javascript? --- Kind Regards Dr Garth Paine? I implement the 5 sentences policy http://five.sentenc.es/ http://www.activatedspace.com http://www.syncsonics.com http://www.meterosonics.com http://marcs.uws.edu.au/people/paine/ Senior Lecturer in Music Technology School of Communication Arts University of Western Sydney, BD 1.14 Werrington South, Locked Bag 1797 Penrith South DC, NSW, 1797, Australia http://marcs.uws.edu.au/people/paine/index.htm Member of MARCS Auditory Laboratories Coordinator VIPRE Research Lab University of Western Sydney Bankstown Campus Webpage: MARCS Ph. +61 (0)2 9772 6902 FAX +61 (0)2 9772 6040 *************************************************************** Please do not forward this message to any other person or entity not named in the recipient fields above without the express consent of the sender.? If you are not the intended recipient of this message as set out in the address field above, please contact the School of Communication Arts on +61 2 9852 5476 to advise.? Please remove the message from your system and do not forward the message to any other person or entity.? The views expressed herein are not necessarily those of the University of Western Sydney. *************************************************************** From pdelges at radiantslab.com Thu Mar 6 04:40:33 2008 From: pdelges at radiantslab.com (Patrick Delges) Date: Thu Mar 6 04:40:36 2008 Subject: [javascript-dev] setInterval In-Reply-To: References: Message-ID: On 6 mars 08, at 12:23, Garth Paine wrote: > I am using a for loop to read lines from a text file of data. I > want to > read one line every 20 ms. In processing or similar I would use the > pause() > function can I use SetInterval() to do this? What would the usual > approach > to timed loops for reading events like this is Javascript? I don't think there is such a thing. I woud use a [metro 20] in Max and send its output to the [js] object. > _____________________________ Patrick Delges Centre de Recherches et de Formation Musicales de Wallonie asbl http://www.crfmw.be/max From nick at cassiel.com Thu Mar 6 05:02:32 2008 From: nick at cassiel.com (Nick Rothwell) Date: Thu Mar 6 05:02:37 2008 Subject: [javascript-dev] setInterval In-Reply-To: References: Message-ID: On 6 Mar 2008, at 11:40, Patrick Delges wrote: > I don't think there is such a thing. I woud use a [metro 20] in Max > and send its output to the [js] object. Max's Javascript supports Task objects with timers. See the documentation, p35. -- N. Nick Rothwell / Cassiel.com Limited www.cassiel.com www.myspace.com/cassieldotcom www.last.fm/music/cassiel www.reverbnation.com/cassiel www.linkedin.com/in/cassiel www.loadbang.net From j at jasch.ch Thu Mar 6 05:02:18 2008 From: j at jasch.ch (=?ISO-8859-1?Q?jasch_=A0?=) Date: Thu Mar 6 05:02:55 2008 Subject: [javascript-dev] setInterval In-Reply-To: References: Message-ID: hello garth, use a task: this is from the Javascript in Max.pdf on page 33 and especially 35 ff.. Task Methods repeat (number, initialdelay) Repeat a task function. The optional number argument specifies the number of repetitions. If the argument is not present or is negative, the task repeats until it is cancelled. The optional initialdelay argument sets the delay in milliseconds until the first iteration. hth /*j From pdelges at radiantslab.com Thu Mar 6 07:18:36 2008 From: pdelges at radiantslab.com (Patrick Delges) Date: Thu Mar 6 07:18:40 2008 Subject: [javascript-dev] setInterval In-Reply-To: References: Message-ID: <2DE2D737-54F9-4C63-9CC1-61E0112785BB@radiantslab.com> On 6 mars 08, at 13:02, jasch wrote: > use a task: this is from the Javascript in Max.pdf on page 33 and > especially 35 ff.. Ooopps. You're right! _____________________________ Patrick Delges Centre de Recherches et de Formation Musicales de Wallonie asbl http://www.crfmw.be/max From hmutant at yahoo.com Wed Mar 12 04:16:57 2008 From: hmutant at yahoo.com (hmutant) Date: Wed Mar 12 04:17:00 2008 Subject: [javascript-dev] cursor position in windows XP Message-ID: <20893.47d7ad99@www.cycling74.com> hallo everyone, i am trying to access he mouse position in absolute screen coordinates from within a jsui object. The wind.location property returns the coordinates of the mouse cursor relative to the Left Top of the main Max/MSP application window, not the screen coordinates. The reason i need the absolute screen coordinates is that i want to lock the mouse position while drugging inside the jsui. Any suggestions ?? __George From ga.paine at uws.edu.au Fri Mar 14 00:28:12 2008 From: ga.paine at uws.edu.au (Garth Paine) Date: Fri Mar 14 00:28:19 2008 Subject: [javascript-dev] setInterval In-Reply-To: Message-ID: Thanks everyone - been away from this project for a bit - just looking at it again now - not sure I understand Tasks but will take a look and try to work it out Cheers Garth On 6/03/08 11:02 PM, "Nick Rothwell" wrote: > > On 6 Mar 2008, at 11:40, Patrick Delges wrote: > >> I don't think there is such a thing. I woud use a [metro 20] in Max >> and send its output to the [js] object. > > Max's Javascript supports Task objects with timers. See the > documentation, p35. > > -- N. > > > Nick Rothwell / Cassiel.com Limited > www.cassiel.com > www.myspace.com/cassieldotcom > www.last.fm/music/cassiel > www.reverbnation.com/cassiel > www.linkedin.com/in/cassiel > www.loadbang.net > > > > _______________________________________________ > javascript-dev mailing list > javascript-dev@cycling74.com > http://www.cycling74.com/mailman/listinfo/javascript-dev --- Kind Regards Dr Garth Paine? I implement the 5 sentences policy http://five.sentenc.es/ http://www.activatedspace.com http://www.syncsonics.com http://www.meterosonics.com http://marcs.uws.edu.au/people/paine/ Senior Lecturer in Music Technology School of Communication Arts University of Western Sydney, BD 1.14 Werrington South, Locked Bag 1797 Penrith South DC, NSW, 1797, Australia http://marcs.uws.edu.au/people/paine/index.htm Member of MARCS Auditory Laboratories Coordinator VIPRE Research Lab University of Western Sydney Bankstown Campus Webpage: MARCS Ph. +61 (0)2 9772 6902 FAX +61 (0)2 9772 6040 *************************************************************** Please do not forward this message to any other person or entity not named in the recipient fields above without the express consent of the sender.? If you are not the intended recipient of this message as set out in the address field above, please contact the School of Communication Arts on +61 2 9852 5476 to advise.? Please remove the message from your system and do not forward the message to any other person or entity.? The views expressed herein are not necessarily those of the University of Western Sydney. *************************************************************** From ga.paine at uws.edu.au Fri Mar 14 04:24:37 2008 From: ga.paine at uws.edu.au (Garth Paine) Date: Fri Mar 14 04:24:46 2008 Subject: [javascript-dev] Tasks and String manipulations In-Reply-To: Message-ID: Thanks to everyone for assistance with Tasks - got them going I am reading out of a text file recorded using the Max Text object so it looks like 0, 110 9 220 218; 1, 110 9 218 218; 2, 110 9 218 218; 3, 110 9 218 218; 4, 110 9 218 218; 5, 110 14 218 218; 6, 110 9 218 216; 7, 110 9 218 220; 8, 110 4 220 220; 9, 110 4 220 220; 10, 110 4 220 220; I want to isolate each incoming integer and send it out a different output I looked at using regular expressions re = /\(?\d{4}\)?([,])\d{2}\1\d{2}\1\d{2}\1\d{2}/; But I do not really understand them and the size of the integers could be from 0-20000, and I did not know how to provide for that in RE's The code for the entire script looks like the following - I am sure some of you experienced coders will be able to suggest a much better way of dealing with breaking up the line and directing the data to the outputs than the one I have cooked up /* *Reading through BioData Text File * * by garth paine March 2008 * http://www.activatedspace.com and http://www.syncsonics.com */ // global code inlets = 1; outlets = 5; autowatch = 1; var f = new File(); t = new Task(); fileName = "" ; newstr = ""; re = /\(?\d{4}\)?([,])\d{2}\1\d{2}\1\d{2}\1\d{2}/; function bang() { if (jsarguments.length > 0){ post("------------------------------------------------------- \n"); fileName = jsarguments[3]; post("Reding from file: "+ fileName + "\n"); f = new File(fileName); f.open (); if (f.isopen){ newstr = "start"; f.position = 0; t = new Task(readFIle, this); t.interval = jsarguments[4]; // time interval set as argument in object t.repeat(); // repeat } }} function stopTask(){ t.cancel(); } function readFIle(){ post("---------------- -------------\n" ); newstr = f.readline(); if (newstr !=null){ newstr = newstr.split(" ", 5); //post("newstr " + newstr + "\n"); //newstr = newstr.split(" ", 5); if (newstr != null){ for(i=0; i<5;i++) { outlet(i, parseInt(newstr[i])); } //newstr = re.exec(aString); possible approach using expressions } } else("the file " + fileName +" is not open."); } function list() //just incase a list is sent in { var aList = arrayfromargs(arguments); post("------ you sent me a list ---------" + "\n" +aList +"\n"); } //The End :-) --- Kind Regards Dr Garth Paine? I implement the 5 sentences policy http://five.sentenc.es/ http://www.activatedspace.com http://www.syncsonics.com http://www.meterosonics.com http://marcs.uws.edu.au/people/paine/ Senior Lecturer in Music Technology School of Communication Arts University of Western Sydney, BD 1.14 Werrington South, Locked Bag 1797 Penrith South DC, NSW, 1797, Australia http://marcs.uws.edu.au/people/paine/index.htm Member of MARCS Auditory Laboratories Coordinator VIPRE Research Lab University of Western Sydney Bankstown Campus Webpage: MARCS Ph. +61 (0)2 9772 6902 FAX +61 (0)2 9772 6040 *************************************************************** Please do not forward this message to any other person or entity not named in the recipient fields above without the express consent of the sender.? If you are not the intended recipient of this message as set out in the address field above, please contact the School of Communication Arts on +61 2 9852 5476 to advise.? Please remove the message from your system and do not forward the message to any other person or entity.? The views expressed herein are not necessarily those of the University of Western Sydney. *************************************************************** From vboehm at gmx.ch Fri Mar 14 05:26:22 2008 From: vboehm at gmx.ch (=?ISO-8859-1?Q?volker_b=F6hm?=) Date: Fri Mar 14 05:24:34 2008 Subject: [javascript-dev] Tasks and String manipulations In-Reply-To: References: Message-ID: On 14 Mar 2008, at 11:24, Garth Paine wrote: > > I am reading out of a text file recorded using the Max Text object > so it > looks like > > 0, 110 9 220 218; > 1, 110 9 218 218; > 2, 110 9 218 218; > 3, 110 9 218 218; > 4, 110 9 218 218; > 5, 110 14 218 218; > 6, 110 9 218 216; > 7, 110 9 218 220; > 8, 110 4 220 220; > 9, 110 4 220 220; > 10, 110 4 220 220; > > > I want to isolate each incoming integer and send it out a different > output > > I looked at using regular expressions > > re = /\(?\d{4}\)?([,])\d{2}\1\d{2}\1\d{2}\1\d{2}/; maybe i miss your point here. but if your data files look like this (coll format), it's much easier doing it in max using the coll object, a counter and a cycle object. trying to look at the text lines as strings in javascript and squeezing out the integers is more complex than it has to be in this case, imo. the format parsing is done by the coll object. you could try something like this: #P window setfont "Sans Serif" 9.; #P number 356 224 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0; #P number 320 224 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0; #P number 284 224 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0; #P number 248 224 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0; #P number 212 224 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0; #P number 176 224 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0; #P number 140 224 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0; #P number 104 224 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0; #P window linecount 1; #P newex 104 195 265 196617 cycle 8 1; #P toggle 104 75 19 0; #N counter 0 10; #X flags 0 0; #P newobj 104 137 68 196617 counter 0 10; #P newex 104 101 58 196617 metro 200; #N coll ; #T flags 1 0; #T 0 110 9 220 218; #T 1 110 9 218 218; #T 2 110 9 218 218; #T 3 110 9 218 218; #T 4 110 9 218 218; #T 5 110 14 218 218; #T 6 110 9 218 216; #T 7 110 9 218 220; #T 8 110 4 220 220; #T 9 110 4 220 220; #T 10 110 4 220 220; #P newobj 104 165 53 196617 coll; #P connect 1 0 2 0; #P connect 3 0 1 0; #P connect 0 0 4 0; #P connect 2 0 0 0; #P connect 4 0 5 0; #P connect 4 1 6 0; #P connect 4 2 7 0; #P connect 4 3 8 0; #P connect 4 4 9 0; #P connect 4 5 10 0; #P connect 4 6 11 0; #P connect 4 7 12 0; #P window clipboard copycount 13; From ga.paine at uws.edu.au Sun Mar 16 07:24:31 2008 From: ga.paine at uws.edu.au (Garth Paine) Date: Sun Mar 16 07:24:41 2008 Subject: [javascript-dev] Tasks and String manipulations In-Reply-To: Message-ID: Thanks Volker Yes indeed I am doing it that way at the moment, but I wanted to try it in JavaScript hence my clumsy attempts - I don't get to do much coding these days and try to give myself the odd challenge - also I don't generally see Max as good at iterative things although in this case you are right it is quite straight forward - this is my MAX solution which works fine, but any suggestions re my JavaScript version would be welcome max v2; #N vpatcher 150 138 449 597; #P inlet 28 68 15 0; #P window setfont "Sans Serif" 9.; #P newex 151 406 116 196617 print BioDataSimulation; #P newex 110 377 51 196617 zl slice 2; #P window setfont "Sans Serif" 18.; #P number 152 97 50 18 0 0 64 3 0 0 0 26 188 36 222 222 222 0 0 0; #P outlet 109 408 15 0; #P inlet 74 24 15 0; #P window setfont "Sans Serif" 9.; #P newex 111 130 52 196617 metro 20; #P toggle 111 28 52 0; #P message 210 109 14 196617 0; #P button 210 90 15 0; #N counter; #X flags 0 0; #P newobj 110 153 66 196617 counter; #P newex 111 334 34 196617 Text; #B color 5; #P message 51 257 37 196617 write; #P window setfont "Sans Serif" 12.; #P message 40 185 37 196620 read; #B color 14; #P window setfont "Sans Serif" 9.; #P comment 49 207 52 196617 File I/O:; #P message 44 307 35 196617 clear; #P comment 43 290 48 196617 Erase all; #P number 123 252 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0; #P window linecount 3; #P comment 174 310 68 196617 double-click to see the text collected; #P window setfont "Sans Serif" 20.; #P number 110 174 110 20 0 0 0 3 0 0 0 74 156 97 222 222 222 0 0 0; #P window setfont "Sans Serif" 9.; #P window linecount 1; #P message 111 208 45 196617 line \$1; #P message 23 232 28 196617 open; #P comment 69 233 150 196617 Display the text editing window; #P fasten 20 1 18 0 156 402 114 402; #P connect 16 0 12 0; #P connect 12 0 3 0; #P connect 11 0 20 0; #P connect 17 0 15 0; #P connect 15 0 16 0; #P connect 3 0 2 0; #P fasten 22 0 11 0 33 229 116 229; #P fasten 1 0 11 0 28 316 28 316 28 328 116 328; #P fasten 5 0 11 0 128 284 116 284; #P fasten 7 0 11 0 49 326 116 326; #P fasten 9 0 11 0 45 226 116 226; #P fasten 10 0 11 0 56 285 116 285; #P connect 2 0 11 0; #P connect 20 1 21 0; #P connect 14 0 12 3; #P connect 19 0 16 1; #P connect 15 0 13 0; #P connect 13 0 14 0; #P pop; Cheers Garth On 14/03/08 10:26 PM, "volker b?hm" wrote: > > On 14 Mar 2008, at 11:24, Garth Paine wrote: >> >> I am reading out of a text file recorded using the Max Text object >> so it >> looks like >> >> 0, 110 9 220 218; >> 1, 110 9 218 218; >> 2, 110 9 218 218; >> 3, 110 9 218 218; >> 4, 110 9 218 218; >> 5, 110 14 218 218; >> 6, 110 9 218 216; >> 7, 110 9 218 220; >> 8, 110 4 220 220; >> 9, 110 4 220 220; >> 10, 110 4 220 220; >> >> >> I want to isolate each incoming integer and send it out a different >> output >> >> I looked at using regular expressions >> >> re = /\(?\d{4}\)?([,])\d{2}\1\d{2}\1\d{2}\1\d{2}/; > > > maybe i miss your point here. but if your data files look like this > (coll format), it's much easier doing it in max using the coll > object, a counter and a cycle object. trying to look at the text > lines as strings in javascript and squeezing out the integers is more > complex than it has to be in this case, imo. the format parsing is > done by the coll object. > > you could try something like this: > > #P window setfont "Sans Serif" 9.; > #P number 356 224 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0; > #P number 320 224 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0; > #P number 284 224 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0; > #P number 248 224 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0; > #P number 212 224 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0; > #P number 176 224 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0; > #P number 140 224 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0; > #P number 104 224 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0; > #P window linecount 1; > #P newex 104 195 265 196617 cycle 8 1; > #P toggle 104 75 19 0; > #N counter 0 10; > #X flags 0 0; > #P newobj 104 137 68 196617 counter 0 10; > #P newex 104 101 58 196617 metro 200; > #N coll ; > #T flags 1 0; > #T 0 110 9 220 218; > #T 1 110 9 218 218; > #T 2 110 9 218 218; > #T 3 110 9 218 218; > #T 4 110 9 218 218; > #T 5 110 14 218 218; > #T 6 110 9 218 216; > #T 7 110 9 218 220; > #T 8 110 4 220 220; > #T 9 110 4 220 220; > #T 10 110 4 220 220; > #P newobj 104 165 53 196617 coll; > #P connect 1 0 2 0; > #P connect 3 0 1 0; > #P connect 0 0 4 0; > #P connect 2 0 0 0; > #P connect 4 0 5 0; > #P connect 4 1 6 0; > #P connect 4 2 7 0; > #P connect 4 3 8 0; > #P connect 4 4 9 0; > #P connect 4 5 10 0; > #P connect 4 6 11 0; > #P connect 4 7 12 0; > #P window clipboard copycount 13; > > > > > > > > > _______________________________________________ > javascript-dev mailing list > javascript-dev@cycling74.com > http://www.cycling74.com/mailman/listinfo/javascript-dev --- Kind Regards Dr Garth Paine? I implement the 5 sentences policy http://five.sentenc.es/ http://www.activatedspace.com http://www.syncsonics.com http://www.meterosonics.com http://marcs.uws.edu.au/people/paine/ Senior Lecturer in Music Technology School of Communication Arts University of Western Sydney, BD 1.14 Werrington South, Locked Bag 1797 Penrith South DC, NSW, 1797, Australia http://marcs.uws.edu.au/people/paine/index.htm Member of MARCS Auditory Laboratories Coordinator VIPRE Research Lab University of Western Sydney Bankstown Campus Webpage: MARCS Ph. +61 (0)2 9772 6902 FAX +61 (0)2 9772 6040 *************************************************************** Please do not forward this message to any other person or entity not named in the recipient fields above without the express consent of the sender.? If you are not the intended recipient of this message as set out in the address field above, please contact the School of Communication Arts on +61 2 9852 5476 to advise.? Please remove the message from your system and do not forward the message to any other person or entity.? The views expressed herein are not necessarily those of the University of Western Sydney. *************************************************************** From vboehm at gmx.ch Sun Mar 16 13:10:34 2008 From: vboehm at gmx.ch (=?ISO-8859-1?Q?volker_b=F6hm?=) Date: Sun Mar 16 13:08:31 2008 Subject: [javascript-dev] Tasks and String manipulations In-Reply-To: References: Message-ID: On 16 Mar 2008, at 14:24, Garth Paine wrote: > Thanks Volker > > Yes indeed I am doing it that way at the moment, but I wanted to > try it in > JavaScript hence my clumsy attempts - I don't get to do much coding > these > days and try to give myself the odd challenge - also I don't > generally see > Max as good at iterative things although in this case you are right > it is > quite straight forward - this is my MAX solution which works fine, > but any > suggestions re my JavaScript version would be welcome ok, if you really want to do this in javascript then i would suggest using indexOf() and slice() to get rid of the formatting (index + comma and semicolon). something along these lines should work: newstr = f.readline(); if (newstr !=null){ var komma = newstr.indexOf(","); newstr = newstr.slice(komma+2, newstr.lastIndexOf(";")); newstr = newstr.split(" "); for(i=0; i References: Message-ID: <35FFC241-4184-4C31-9203-2629B9B6BDD0@jasch.ch> here's my take on this: you need to put the result of the string splitting operation into an array. apart from that your code works: result = newstr.split(" ", 5); hth /*j max v2; #N vpatcher 825 44 1264 278; #P window setfont "Sans Serif" 9.; #P message 68 86 116 196617 setFilename testfile.txt; #P number 68 45 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0; #P message 68 65 75 196617 setInterval \$1; #P number 48 159 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0; #P number 95 159 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0; #P number 142 159 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0; #P number 189 159 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0; #P number 236 159 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0; #P button 48 25 15 0; #P newex 48 128 194 196617 js biodata_reader.js 0 0 testfile.txt 500; #P comment 66 25 35 196617 parse; #P connect 10 0 1 0; #P connect 8 0 1 0; #P connect 2 0 1 0; #P connect 1 0 7 0; #P connect 9 0 8 0; #P connect 1 1 6 0; #P connect 1 2 5 0; #P connect 1 3 4 0; #P connect 1 4 3 0; #P pop; /////////// testfile.txt /////////// 0, 110 9 220 218; 1, 110 10 218 218; 2, 110 11 218 218; 3, 110 12 218 218; 4, 110 13 218 218; 5, 110 14 218 218; 6, 110 15 218 216; 7, 110 16 218 220; 8, 110 17 220 220; 9, 110 18 220 220; 10, 110 19 220 220; /////////// biodata_reader.js /////////// /* * Reading through BioData Text File * * by garth paine March 2008 * http://www.activatedspace.com and http://www.syncsonics.com */ // global code inlets = 1; outlets = 5; autowatch = 1; var f = new File(); var t = new Task(); var myInterval = 0; var myFilename = new String(""); var newstr = new String(""); var result = new Array(); // Array to contain split string if (jsarguments.length > 0) // nada = jsarguments[1]; if (jsarguments.length > 1) // nada = jsarguments[2]; if (jsarguments.length > 2) myFilename = jsarguments[3]; if (jsarguments.length > 3) myInterval = jsarguments[4]; // re = /\(?\d{4}\)?([,])\d{2}\1\d{2}\1\d{2}\1\d{2}/; function bang() { post("------------------------------------------------------- \n"); // fileName = jsarguments[3]; post("Reding from file: "+ myFilename + "\n"); f = new File(myFilename); f.open (); if (f.isopen) { newstr = "start"; f.position = 0; t = new Task(readFile, this); // t.interval = jsarguments[4]; // time interval set as argument in object t.interval = myInterval; // time interval set as argument in object or by message t.repeat(); // repeat } } function stopTask() { t.cancel(); } function readFile() { newstr = f.readline(); if (newstr != null) { result = newstr.split(" ", 5); // read split string into result Array post("result " + result + "\n"); if (result != null) { for(i=0; i < 5; i++) { outlet(i, parseInt(result[i])); } //newstr = re.exec(aString); possible approach using expressions } } else { t.cancel(); // stops task when nothing remains to be read in textfile post("the file " + fileName +" is not open."); } } function list() //just incase a list is sent in { var aList = arrayfromargs(arguments); post("------ you sent me a list ---------" + "\n" +aList +"\n"); } function setInterval(a) { myInterval = a; post("new Interval is "+myInterval+"\n"); } function setFilename(fn) { myFilename = fn; post("new Filename is "+myFilename+"\n") } /* EOF */ From vboehm at gmx.ch Mon Mar 17 10:39:23 2008 From: vboehm at gmx.ch (=?ISO-8859-1?Q?volker_b=F6hm?=) Date: Mon Mar 17 10:37:27 2008 Subject: [javascript-dev] Tasks and String manipulations In-Reply-To: <35FFC241-4184-4C31-9203-2629B9B6BDD0@jasch.ch> References: <35FFC241-4184-4C31-9203-2629B9B6BDD0@jasch.ch> Message-ID: <809FCF87-A705-4F87-8B3E-5135F384B287@gmx.ch> On 16 Mar 2008, at 22:15, jasch wrote: > > result = newstr.split(" ", 5); oh, ja, that's better. from the example garth posted i think he wanted to exclude the index. but then again, simply outputting data starting at result[1] should do it just fine. volker. result = newstr.split(" "); for(i=1; i Message-ID: Brilliant - thanks heaps - that assists me a great deal and is soooooooo much more elegant than my attempts - I love learning Cheers Garth On 18/03/08 3:39 AM, "volker b?hm" wrote: > > On 16 Mar 2008, at 22:15, jasch wrote: >> >> result = newstr.split(" ", 5); > > oh, ja, that's better. from the example garth posted i think he > wanted to exclude the index. > but then again, simply outputting data starting at result[1] should > do it just fine. > volker. > > result = newstr.split(" "); > for(i=1; i outlet(i-1, parseInt(result[i])); > > > _______________________________________________ > javascript-dev mailing list > javascript-dev@cycling74.com > http://www.cycling74.com/mailman/listinfo/javascript-dev --- Kind Regards Dr Garth Paine? I implement the 5 sentences policy http://five.sentenc.es/ http://www.activatedspace.com http://www.syncsonics.com http://www.meterosonics.com http://marcs.uws.edu.au/people/paine/ Senior Lecturer in Music Technology School of Communication Arts University of Western Sydney, BD 1.14 Werrington South, Locked Bag 1797 Penrith South DC, NSW, 1797, Australia http://marcs.uws.edu.au/people/paine/index.htm Member of MARCS Auditory Laboratories Coordinator VIPRE Research Lab University of Western Sydney Bankstown Campus Webpage: MARCS Ph. +61 (0)2 9772 6902 FAX +61 (0)2 9772 6040 *************************************************************** Please do not forward this message to any other person or entity not named in the recipient fields above without the express consent of the sender.? If you are not the intended recipient of this message as set out in the address field above, please contact the School of Communication Arts on +61 2 9852 5476 to advise.? Please remove the message from your system and do not forward the message to any other person or entity.? The views expressed herein are not necessarily those of the University of Western Sydney. *************************************************************** From chambaz_ at hotmail.com Wed Mar 19 05:11:33 2008 From: chambaz_ at hotmail.com (Adam Chambers) Date: Wed Mar 19 05:11:41 2008 Subject: [javascript-dev] Simple JavaScript Question Message-ID: <20c3b.47e0f4e5@www.cycling74.com> Hi all. I have used JavaScript quite a lot in my web development but i cant find any explanations on the net as to the basics of JavaScript within Max MSP. All i want to know is how to set up the inlets and outlets etc once i get this I can apply my JS knowledge to it fine. If anyone could point me in the direction of a tutorial or give me a simple example of how to e.g set a number coming into the js object to a variable, perform a simple math function on that variable and then send it out the outlet i would much appreciate it. Cheers!! Adam From pdelges at radiantslab.com Wed Mar 19 05:31:29 2008 From: pdelges at radiantslab.com (Patrick Delges) Date: Wed Mar 19 05:31:37 2008 Subject: [javascript-dev] Simple JavaScript Question In-Reply-To: <20c3b.47e0f4e5@www.cycling74.com> References: <20c3b.47e0f4e5@www.cycling74.com> Message-ID: On 19 mars 08, at 12:11, Adam Chambers wrote: > I have used JavaScript quite a lot in my web development but i cant > find any explanations on the net as to the basics of JavaScript > within Max MSP. It should be on your computer. There is a PDF called "JavascriptInMax" installed with the other manuals. You can also find JS examples in the examples/javascript folder. p _____________________________ Patrick Delges Centre de Recherches et de Formation Musicales de Wallonie asbl http://www.crfmw.be/max From chambaz_ at hotmail.com Wed Mar 19 10:09:59 2008 From: chambaz_ at hotmail.com (Adam Chambers) Date: Wed Mar 19 10:10:06 2008 Subject: [javascript-dev] Re: Simple JavaScript Question In-Reply-To: Message-ID: <20c4d.47e13ad7@www.cycling74.com> Oh yea! I new about the examples but that PDF is perfect didnt even think to look there. Brilliant mate thanks a lot. Adam From adamjmurray at gmail.com Tue Mar 25 00:53:24 2008 From: adamjmurray at gmail.com (Adam Murray) Date: Tue Mar 25 00:53:28 2008 Subject: [javascript-dev] BUG: javascript can't handle large pattrstorage clientlist when overdrive is enabled Message-ID: <20f08.47e8a161@www.cycling74.com> I have a patch with 398 pattr objects in it. It's too big to post, but it's quite easy to create this number of pattrs by using a poly~ inside a poly~. I need to do some complicated state management and would like to use javascript. But first I need to make my script aware of all the pattr objects. So I'm sending getclientlist to pattrstorage and routing that to my javascript via [route clientlist] The problem is, inside the javascript a few clientlist messages randomly arrive AFTER the done message! This prevents me from building the list properly. I tried this test script: function anything() { if(messagename != "done") { post(messagename + " ") count++ } else { post("done, count = " + count + " ") count = 0 } } The count varies between about 390 and 398. It is very rarely the full 398. In my max patch I can do something like this and the value is correct every time (and "done" always arrives last if I print out the client list). #P window setfont "Sans Serif" 9.; #P window linecount 1; #P message 125 193 14 196617 1; #P newex 98 164 57 196617 route done; #P number 97 247 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0; #N counter; #X flags 0 0; #P newobj 97 221 66 196617 counter; #P button 97 193 15 0; #P newex 98 137 77 196617 route clientlist; #P message 98 89 64 196617 getclientlist; #P newex 98 111 67 196617 pattrstorage; #X client_rect 0 0 640 240; #X storage_rect 0 0 640 240; #P objectname u494000118; #P connect 7 0 4 2; #P connect 6 0 7 0; #P connect 6 1 3 0; #P connect 2 0 6 0; #P connect 4 0 5 0; #P connect 3 0 4 0; #P connect 1 0 0 0; #P connect 0 0 2 0; #P window clipboard copycount 8; I just noticed this only seems to happen when overdrive is enabled. Unfortunately I need overdrive on or my patch does not work correctly. So... what's going on here? I thought overdrive was supposed to make event timing better? I guess the messages arrive faster than the js can process it so some get deferred by the scheduler. As I finished describing this problem, I realized a solution: #P window setfont "Sans Serif" 9.; #P window linecount 1; #P newex 75 138 17 196617 js; #P message 18 81 30 196617 done; #P newex 18 104 50 196617 deferlow; #P newex 18 58 57 196617 route done; #P newex 18 31 77 196617 route clientlist; #P connect 0 0 1 0; #P connect 1 0 3 0; #P connect 3 0 2 0; #P connect 1 1 4 0; #P connect 2 0 4 0; #P window clipboard copycount 5; If anyone else is making patches with hundreds of pattrs, [deferlow] is your best friend. It has also fixed most of my patch's initialization problems (almost every loadbang is firing before the pattrs are ready). But these weird timing issues are getting scary, I don't know what else is going to randomly malfunction. Maybe I need to see if I can avoid overdrive... -- Adam Murray compusition.com From nick at cassiel.com Tue Mar 25 02:43:44 2008 From: nick at cassiel.com (Nick Rothwell) Date: Tue Mar 25 02:43:40 2008 Subject: [javascript-dev] BUG: javascript can't handle large pattrstorage clientlist when overdrive is enabled In-Reply-To: <20f08.47e8a161@www.cycling74.com> References: <20f08.47e8a161@www.cycling74.com> Message-ID: <97E47F3F-2448-4C17-B787-5C566564B98C@cassiel.com> On 25 Mar 2008, at 06:53, Adam Murray wrote: > I guess the messages arrive faster than the js can process it so > some get deferred by the scheduler. As I recall, by default, everything in JS runs outside overdrive (i.e. deferred). There are facilities to run high-priority threads, but I had stability problems when I tried doing that (a year or so ago). -- N. nick rothwell -- composition, systems, performance -- http:// www.cassiel.com From adamjmurray at gmail.com Tue Mar 25 09:27:23 2008 From: adamjmurray at gmail.com (Adam Murray) Date: Tue Mar 25 09:27:29 2008 Subject: [javascript-dev] Re: BUG: javascript can't handle large pattrstorage clientlist when overdrive is enabled In-Reply-To: <97E47F3F-2448-4C17-B787-5C566564B98C@cassiel.com> Message-ID: <20f2e.47e919db@www.cycling74.com> Quote: nick rothwell / cassiel wrote on Tue, 25 March 2008 01:43 ---------------------------------------------------- > > As I recall, by default, everything in JS runs outside overdrive > (i.e. deferred). If that's the case, why are some messages arriving out of order? Shouldn't they all get deferred in the same order? -- Adam Murray compusition.com From david.rowland at uwe.ac.uk Tue Mar 25 15:40:40 2008 From: david.rowland at uwe.ac.uk (David Rowland) Date: Tue Mar 25 15:40:46 2008 Subject: [javascript-dev] Storing Maxobj in an Array Message-ID: <20f80.47e97158@www.cycling74.com> Hi all, I'm quite new to Javascript so am learning as I go along but I can't find any reason why what I'm trying to do wont work. I basically have a load of patches that form synthesizer modules and am writing a Javascript file which will control their creation, placement, connections and removal. I have come as far as creating some units using 'bpatchers' and simply connecting them in the script but as there may be many instances of one patch I need to keep track of them. What I am trying to do is create an array to store the 'Maxobj' object returned from the 'newobject' 'patcher' method. When I use a standard variable the code works fine but when I try to access properties of the 'Maxobj' stored as an array element I get the error: • error: js: Unit Handler.js: Javascript TypeError: OSCUnit[noOSCUnits] has no properties, line 22 Here is my code so far. Note I have only implimented the array system in the "OSC Unit" case for testing purposes. autowatch = 1; //Recompile script on save editfontsize = 10; //Make the font in the text editing window 10pt //Global Variables //These are used to keep track of what units are present in the patcher and how they are created //Arrays to hold created units var OSCUnit = new Array(); //Variables to keep track of how many units have been created var noOSCUnits = 0; var noOSCFilterUnits = 0; function create(input) { switch(input) { case "OSC Unit": OSCUnit[noOSCUnits] = patcher.newobject("bpatcher", 300, 100, 300, 100, -220, -30, "OSC Unit.pat", 0); //Create new OSC Unit OSCUnit[noOSCUnits].varname = "OSC"; //Name new unit 'OSC' noOSCUnits ++; //Incriment the 'noOSCUnits' variable OSCUnit[noOSCUnits].varname = OSCUnit[noOSCUnits].varname + noOSCUnits; //Concatenate the name and the number of units break; case "OSC Filter Unit": OSCFilterUnit = patcher.newobject("bpatcher", 300, 200, 300, 200, -190, -50, "OSC Filter.pat", 0); //Create ne OSC Filter Unit OSCFilterUnit.varname = "OSCFilter"; //Name new unit 'OSCFilter' noOSCFilterUnits ++; //Incriment the 'noOSCFilterUnits' variable OSCFilterUnit.varname = OSCFilterUnit.varname + noOSCFilterUnits; //Concatenate the name and the number of units patcher.hiddenconnect(OSCUnit, 0, OSCFilterUnit, 0); break; default: post("No unit selected"); break; } } Hope someone can help me solve this problem as it's the basis of degree dissertation. Cheers, Dave. From cycling74forum at opuslocus.net Tue Mar 25 16:13:30 2008 From: cycling74forum at opuslocus.net (John Pitcairn) Date: Tue Mar 25 16:13:35 2008 Subject: [javascript-dev] Re: Storing Maxobj in an Array In-Reply-To: <20f80.47e97158@www.cycling74.com> Message-ID: <20f81.47e97909@www.cycling74.com> Quote: Dave wrote on Wed, 26 March 2008 09:40 ---------------------------------------------------- >OSCUnit[noOSCUnits].varname = "OSC"; noOSCUnits ++; OSCUnit[noOSCUnits].varname = OSCUnit[noOSCUnits].varname + noOSCUnits; You're incrementing noOSCUnits then attempting to use that as an array index, when that array element doesn't exist. The third line above is trying to use OSCUnit[1] when there is only 1 item in the array, OSCUnit[0]. But you should also be testing that you're actually getting an OSCUnit object created, and that manually-incremented noOSCUnits counter seems a little prone to trouble too, when OSCUnit.length or OSCUnit.push (to add an item) gives you the array size directly. So, assuming you want OSCUnit[0] to be named "OSC1": if(obj = patcher.newobject("bpatcher", 300, 100, 300, 100, -220, -30, "OSC Unit.pat", 0)) { noOSCUnits = OSCUnit.push(obj); // 1 obj.varname = "OSC" + noOSCUnits; // "OSC1" // note obj and OSCUnit[0] still refer to the same object } else { post("error: no OSCUnit returned"); } From david.rowland at uwe.ac.uk Tue Mar 25 18:16:31 2008 From: david.rowland at uwe.ac.uk (David Rowland) Date: Tue Mar 25 18:16:37 2008 Subject: [javascript-dev] Re: Storing Maxobj in an Array In-Reply-To: <20f81.47e97909@www.cycling74.com> Message-ID: <20f8b.47e995df@www.cycling74.com> Thanks for your reply it helped a lot. I knew the array index would mess me up (its been over a year since I have done any programming and that was in C). I have decided to use the array index as the OSC name suffix to make things simpler. Here is the code I am using at the moment. case "OSC Unit": if(newObj = patcher.newobject("bpatcher", 300, 100, 300, 100, -220, -30, "OSC Unit.pat", 0)) { noOSCUnits = OSCUnit.push(newObj); OSCUnit[noOSCUnits-1].varname = "OSC" + (noOSCUnits-1); post(" The total number of OSC Units is: ",noOSCUnits); post(" The most recent OSC Unit is: ",OSCUnit[noOSCUnits-1].varname); } else { post("No OSC Unit returned"); } break; Cheers. From peripatitis at gmail.com Wed Mar 26 19:29:07 2008 From: peripatitis at gmail.com (Greg) Date: Wed Mar 26 19:29:13 2008 Subject: [javascript-dev] js question from a newbie Message-ID: <2102f.47eaf862@www.cycling74.com> Hi i started this week to program a little bit with javascript . For starters i made a simple henon map ,which works ok , but now i'd like to be able to store these into two dimentional arrays and see if i can find the numbers that repeat to use them to trigger perhaps different sets of initial conditions . So i started reading about arrays in javascript and in my first example (filling an array and printing it reversed) there is a 'undefined ' message poping up in max window. Could anybody please let me know whats going on ? here is the simplistic code : // printing and filling an array editfontsize = 16 ; // my inlets and outlets inlets = 1 ; outlets = 1; // number of elements var x ; var myarray = new Array () ; function msg_float(r) { if (inlet == 0) { x = r ; fillarray(x) ; myreverse(); } } function fillarray(k) { var i ; for (i = k ; i > 0 ; i--) { myarray[i] = i ; post (); post(myarray[i]) ; } post(); post ("my array has a lenght of" , myarray.length) ; post(); } // trying to print a reversed array function myreverse() { var z = myarray.reverse() ; post (z) ; } From pdelges at radiantslab.com Thu Mar 27 02:11:01 2008 From: pdelges at radiantslab.com (Patrick Delges) Date: Thu Mar 27 02:11:06 2008 Subject: [javascript-dev] js question from a newbie In-Reply-To: <2102f.47eaf862@www.cycling74.com> References: <2102f.47eaf862@www.cycling74.com> Message-ID: On 27 mars 08, at 02:29, Greg wrote: > So i started reading about arrays in javascript and in my first > example (filling an array and printing it reversed) there is a > 'undefined ' message poping up in max window. > Could anybody please let me know whats going on ? > for (i = k ; i > 0 ; i--) Let say your float message was 3.0, your i variable will first be 3, then 2 then 1 and the loop will stop. So myarray[0] will remain... "undefined". Arrays in JavaScript start at index 0. Note that your array's size will never decrease. So if you send 6.0 to your code, then 3.0, myarray.length will still be 7. > _____________________________ Patrick Delges Centre de Recherches et de Formation Musicales de Wallonie asbl http://www.crfmw.be/max From mdk at relivethefuture.com Thu Mar 27 01:07:39 2008 From: mdk at relivethefuture.com (mdk) Date: Thu Mar 27 02:27:40 2008 Subject: [javascript-dev] Re: js question from a newbie In-Reply-To: <2102f.47eaf862@www.cycling74.com> Message-ID: <21042.47eb47ba@www.cycling74.com> im pretty sure array.reverse() doesnt return the array (or a copy), it just reverses it in place. try myarray.reverse(); post(myarray); also i noticed that your loop checks for > 0, and arrays start from 0, maybe you want >= 0 ? i would usually count upwards from zero for(i = 0;i Message-ID: <21054.47eb92ca@www.cycling74.com> Thanks guys for your help . Indeed i hadn't thought about arrays starting from index 0. it's also true that with this script , i can't change the array length if i send a smaller float in the input . One thing i noticed which also mdk mentioned , also in other scripts i tried to make, that the reverse works on the array itself , i would expect it to work on a copy. Is there a specific method to copy an array in js or do i have to use a loop to do so ? And another question regarding timing issues , in my henon map i trigger each iteration with a bang coming from an external object (ex train, metro) . Would i have any benefits (timewise) if i did this within the script using the task methods or is it the same thing ? thanks again cheers Greg From vboehm at gmx.ch Thu Mar 27 08:57:28 2008 From: vboehm at gmx.ch (=?ISO-8859-1?Q?volker_b=F6hm?=) Date: Thu Mar 27 08:55:21 2008 Subject: [javascript-dev] Re: js question from a newbie In-Reply-To: <21054.47eb92ca@www.cycling74.com> References: <21054.47eb92ca@www.cycling74.com> Message-ID: <7D6C816B-8873-4D9F-8876-5244F7EE8A63@gmx.ch> On 27 Mar 2008, at 13:27, Greg wrote: > > Is there a specific method to copy an array in js or do i have to > use a loop to do so ? myArr.slice(); is the preferred way i believe. vb From peripatitis at gmail.com Thu Mar 27 10:26:07 2008 From: peripatitis at gmail.com (Greg) Date: Thu Mar 27 10:26:14 2008 Subject: [javascript-dev] Re: js question from a newbie In-Reply-To: <2102f.47eaf862@www.cycling74.com> Message-ID: <2107b.47ebca9e@www.cycling74.com> hi Volker indeed i just found out about it , i probably shouldn't ask questions non max specific . thanks Greek From pdelges at radiantslab.com Fri Mar 28 02:54:34 2008 From: pdelges at radiantslab.com (Patrick Delges) Date: Fri Mar 28 02:54:39 2008 Subject: [javascript-dev] Re: js question from a newbie In-Reply-To: <21054.47eb92ca@www.cycling74.com> Message-ID: <210cd.47ecb24a@www.cycling74.com> Quote: phaethon wrote on Thu, 27 March 2008 13:27 ---------------------------------------------------- > it's also true that with this script , i can't change the array length if i send a smaller float in the input . Note that you can set the length property of an Array instance. So you can set it to the right size! p From mdk at relivethefuture.com Fri Mar 28 09:09:31 2008 From: mdk at relivethefuture.com (mdk) Date: Fri Mar 28 09:09:38 2008 Subject: [javascript-dev] Re: "immediate" crash in overdrive (Windows XP) In-Reply-To: <1458e.4539f3ae@www.cycling74.com> Message-ID: <210e9.47ed0a2b@www.cycling74.com> this is still a problem for me on 4.6.3 XP, Motu 828 FW Asio drivers. hoping its fixed in 5. :) From chambaz_ at hotmail.com Sat Mar 29 17:43:42 2008 From: chambaz_ at hotmail.com (Adam Chambers) Date: Sat Mar 29 17:43:50 2008 Subject: [javascript-dev] many floats many inlets problem. Message-ID: <211c0.47eed42d@www.cycling74.com> Im really confusing myself here although the answer is probs simple, any help would be much appreciated. I have 15 floats all constantly changing, i need to find the largest and more importantly which one of the float objects sent the largest number so i can use it to trigger a specific msg. I need it to be a constantly changing thing. I tried using an array to store all the numbers and then using sort() etc but the problem is I need to know which of the fifteen float objects sent the largest number. One idea i had was to have each float entering a different inlet but how could i have one function for all fifteen inlets or compare variables from different inlets. Any ideas? Thanks a lot in advance, From vboehm at gmx.ch Sun Mar 30 03:59:48 2008 From: vboehm at gmx.ch (=?ISO-8859-1?Q?volker_b=F6hm?=) Date: Sun Mar 30 03:57:37 2008 Subject: [javascript-dev] many floats many inlets problem. In-Reply-To: <211c0.47eed42d@www.cycling74.com> References: <211c0.47eed42d@www.cycling74.com> Message-ID: <14DDD7F5-ED34-48B0-9A99-78B4392F6024@gmx.ch> On 30 Mar 2008, at 00:43, Adam Chambers wrote: > > Im really confusing myself here although the answer is probs > simple, any help would be much appreciated. > > I have 15 floats all constantly changing, i need to find the > largest and more importantly which one of the float objects sent > the largest number so i can use it to trigger a specific msg. I > need it to be a constantly changing thing. > > I tried using an array to store all the numbers and then using sort > () etc but the problem is I need to know which of the fifteen float > objects sent the largest number. you don't have to sort the whole array. simply search the max value and output it's arrayindex. in case you are still unsure how to preceed, here is a working script. btw, Ltop from Lobjects does exactly what you want. outlets = 2; function list() { var input = arguments; var max = Number.NEGATIVE_INFINITY; var pos = 0; for(i=0; i max) { max = input[i]; pos = i; } } outlet(1, pos); outlet(0, max); } // volker. From chambaz_ at hotmail.com Sun Mar 30 05:01:38 2008 From: chambaz_ at hotmail.com (Adam Chambers) Date: Sun Mar 30 05:01:44 2008 Subject: [javascript-dev] Re: many floats many inlets problem. In-Reply-To: <14DDD7F5-ED34-48B0-9A99-78B4392F6024@gmx.ch> Message-ID: <211d9.47ef7312@www.cycling74.com> Cheers mate, The script is exactly what I was after. I had not idea about the object, is there meant to be a prefrence between scripts and objects in terms of speed? Think il probably stick with scripting because I need to know which float sent thae highest number and send specific msgs dependent on this factor. Thanks again, From chambaz_ at hotmail.com Sun Mar 30 05:09:24 2008 From: chambaz_ at hotmail.com (Adam Chambers) Date: Sun Mar 30 05:09:29 2008 Subject: [javascript-dev] Re: many floats many inlets problem. In-Reply-To: <211c0.47eed42d@www.cycling74.com> Message-ID: <211da.47ef74e3@www.cycling74.com> The LTOP object does exactley what i need it even tells me the position of the float the output the largest number. perfect! just out of interest is the a difference in speed / CPU usage between max objects and JS scripts? Thanks for your help From vboehm at gmx.ch Sun Mar 30 06:34:04 2008 From: vboehm at gmx.ch (=?ISO-8859-1?Q?volker_b=F6hm?=) Date: Sun Mar 30 06:31:56 2008 Subject: [javascript-dev] Re: many floats many inlets problem. In-Reply-To: <211da.47ef74e3@www.cycling74.com> References: <211da.47ef74e3@www.cycling74.com> Message-ID: <5960E1B1-25EE-4A4C-8AA6-66E3748DB3D5@gmx.ch> On 30 Mar 2008, at 13:09, Adam Chambers wrote: > > > just out of interest is the a difference in speed / CPU usage > between max objects and JS scripts? > yes, there is. max objects are written in C/C++ and execute much faster than anything in JS, though you'll probably not notice the speed difference in most cases. vb From peripatitis at gmail.com Mon Mar 31 15:08:57 2008 From: peripatitis at gmail.com (Greg) Date: Mon Mar 31 15:09:03 2008 Subject: [javascript-dev] Re: js question from a newbie In-Reply-To: <2102f.47eaf862@www.cycling74.com> Message-ID: <212d8.47f152e8@www.cycling74.com> Sorry for the many questions but i am new to programming generally as well as specifically in javascript . This is a new problem i am came up with : I am having an input list sent to a specific function where i save it as an array . The array is declared as a variable within the function , however it seems that i can access it through other functions as well. Is this normal behaviour ? I am wondering since this is part of a bigger program , what will happen if i have two arrays with same name . here is thecode : editfontsize = 16 ; // trying to create a function that takes an input list and create a new array taking into account the specified weights var z = new Array() ; // the array where i copy the a value from an input list var x = new Array() ; // the array where i copy the b value form an input list var v = new Array(); // the array where i copy the weighting value from an input list function sortit() // this is where i sort the input array into three distinct arrays { count1 = count2 = count3 = 0 ; // a local counter used to set the elements of the three arrays v.length = x.length = z.length = (inputweights.length / 3) // here i set the length of the three lists (perhaps not needed) var t = inputweights.slice(); // copy the initial list var i = 0; {for ( i = 0 ; i < t.length ; i ++) if (( i % 3) == 0) {z[count1] = t[i] count1++ ;} else {if ((i % 3) == 1) {x[count2] = t[i] count2++ ;} else {v[count3] = t[i] count3++ ;}}} post(); post("my a values are " , z) ; post() ; post(" my b values are " ,x) ; post(); post("my weigth values are " , v) ; } function bang () { sortit()} function weights(a) // saves the input to the weight function into an array { var inputweights = new Array ; post() ; post("the list contains",arguments.length, "elements"); if (( arguments.length % 3) != 0) // checks to see whether we have the correct number of arguments ( a b weight) {post(); post(" wrong number of arguments in the list ") ; post() ;} else {for ( i = 0 ; i < arguments.length ; i++) inputweights[i] = arguments[i]; post(); post(inputweights) ; post() ;} }