can a device detect if it's moved to another track?

Learn about building and using Max for Live devices.
Post Reply
11olsen
Posts: 157
Joined: Wed Jul 29, 2009 9:12 pm
Location: germany

can a device detect if it's moved to another track?

Post by 11olsen » Tue Aug 24, 2010 11:21 pm

i use the M4L.api.ObserveDeviceTrackIndex abstraction but it needs a bang to get the index...

11olsen
Posts: 157
Joined: Wed Jul 29, 2009 9:12 pm
Location: germany

Re: can a device detect if it's moved to another track?

Post by 11olsen » Thu Aug 26, 2010 12:05 pm

firstly thanks for your engagement.
i played around with your approach and i think there is a little problem.
if the device is the only device on the track, and then moved, the observer outputs nothing.

greets

11olsen
Posts: 157
Joined: Wed Jul 29, 2009 9:12 pm
Location: germany

Re: can a device detect if it's moved to another track?

Post by 11olsen » Thu Aug 26, 2010 8:08 pm

ShelLuser wrote:(empty) list one doesn't contain the id of the object (list two) so its moved.
there is the problem, the observer does not output an "emty list", it simply outputs nothing if there is no device left in the track. so the zl won't output anything.

11olsen
Posts: 157
Joined: Wed Jul 29, 2009 9:12 pm
Location: germany

Re: can a device detect if it's moved to another track?

Post by 11olsen » Thu Aug 26, 2010 9:32 pm

and thats the case, the message isn't updated if you move the device away to another track (only if it's was the last device left in the track)

amounra93
Posts: 432
Joined: Sat Jan 24, 2009 8:16 pm
Location: Arcata, CA
Contact:

Re: can a device detect if it's moved to another track?

Post by amounra93 » Thu Aug 26, 2010 9:45 pm

If you guys use closebang in conjuction with change, I think you guys will be able to come up with what you are looking for.

Cheers
http://www.aumhaa.com for Monomod and other m4l goodies.

amounra93
Posts: 432
Joined: Sat Jan 24, 2009 8:16 pm
Location: Arcata, CA
Contact:

Re: can a device detect if it's moved to another track?

Post by amounra93 » Thu Aug 26, 2010 10:00 pm

Closebang works when the window closes....not when the patch closes. It always closebangs when you move it from one place to another, I checked it.

Cheers.
http://www.aumhaa.com for Monomod and other m4l goodies.

amounra93
Posts: 432
Joined: Sat Jan 24, 2009 8:16 pm
Location: Arcata, CA
Contact:

Re: can a device detect if it's moved to another track?

Post by amounra93 » Thu Aug 26, 2010 10:17 pm

Here ya go:

Code: Select all

<pre><code>
----------begin_max5_patcher----------
396.3ocwU9saBCBEF+51mBBW6LP+m5ta60XwXpsL8XZglB5by369.Zcqt3HM
ZidCIbNGfuue8.8fuGdoXOShQOidC44cv2yyFxDvqctGtLceVQpzVFly9Prb
CdTSJEauxFtBpXn.BgbJCeaoXqpforKi1F8cAWIguX1Xjwj1vMUp9rh0HELF
MuMUUpJaMvWsnlkoZxRiBzqDMI1LFmXFoSGS9YIPtURZY9DMA24j4ok1C.+R
MjVfdUTj2Qt.+jZCLwN56aFFciboF3Jj1DquLXHtAy+6dZTj09SbZ+3qw9zg
y9ajnRwN1hb1NHiMdi790dPIVzLyc+Q3CFPYEBIaYJe0v.F6N0C3Da1CTBwI
aBtF1PFN1TB4f1gC0EmnoV2Rs.Hx48lfGbWgw4.eXZIzu+3rinAKgMTwcCws
RE6lhK.9e+kiUVl3miJoXac1Iezp.zuRKmIU.OUABdmZBNql0PdNi2sgQy1J
gFJsR.M+he15shB6gjLOCeO0TPezTx8USI8QSg2flzSN5+MOppfv
-----------end_max5_patcher-----------
</code></pre>

You'll need this:

Code: Select all

autowatch=1;

var finder=new LiveAPI(this.patcher, "live_set");
var selected=[];

function anything()
{
    if(!finder)
    {
        finder=new LiveAPI(this.patcher, "live_set");
    }
    finder.goto("live_set", "this_device");
	if(finder.path!=selected)
	{
		outlet(0, finder.path);
		selected=finder.path;
	}
}
Let me know if that throws any errors, I can fix them pretty quicklike.

Cheers :)
http://www.aumhaa.com for Monomod and other m4l goodies.

11olsen
Posts: 157
Joined: Wed Jul 29, 2009 9:12 pm
Location: germany

Re: can a device detect if it's moved to another track?

Post by 11olsen » Thu Aug 26, 2010 11:22 pm

another one by amounra, it seems to work, i'm getting the closebang if it's moved to another track
but also if the device is in view and then out of view. this is causing some unnecessary api calls
but seems not to be a problem.

is this js getting the devicetrackindex with the same methode as the m4l.api.abstraction?
fascinating to see this little script opposed to the big abtraction


ShelLuser wrote:It does for me. If I have the following setup: Beat Repeat, TrackMove (patch) and Corpus on one track it lists 3 ID's. I move the TrackMove onto another track and I end up with 2 ID's. It updates over here.
your just not getting what i'm trying to tell you.
delete your beat repeat and corpus, now move the trackMove patch! is the message updated? no?
i needed a solution that'll work in every case.

amounra93
Posts: 432
Joined: Sat Jan 24, 2009 8:16 pm
Location: Arcata, CA
Contact:

Re: can a device detect if it's moved to another track?

Post by amounra93 » Thu Aug 26, 2010 11:31 pm

yeppers, its using the same objects, I'm just accessing them through js. I'd have written it for you in pure Max, but I'm at work and it takes me like 5 times longer to do stuff in Max.

You just need a [change] to prevent unnecessary triggering in Max. I did something similar in the js, so it should only output when the track actually changes, not just when closebang fires.

Its funny...I've been using Max for 10 years probably, and now that I know js its so much faster. It works great for everything that's not timing-critical, so I try to use it as much as possible for UI types stuff, and pure Max for actual instruments and audio processing.

The js is being called more often than when the track changes, but it won't (in my experience) make much of a CPU hit. YMMV. Unfortunately there is no way to avoid it. If it makes you feel any better, putting something in an observer still polls the system just as much, you just don't see it. Someone correct me if I'm wrong, please ;)

Cheers.
http://www.aumhaa.com for Monomod and other m4l goodies.

11olsen
Posts: 157
Joined: Wed Jul 29, 2009 9:12 pm
Location: germany

Re: can a device detect if it's moved to another track?

Post by 11olsen » Fri Aug 27, 2010 12:03 am

ShelLuser wrote: Yes it is. When I do that and move it to another track I end up with an empty "track id's" message.
Ok, to be fair i checked it again and you were right. it outputs an emty list.
that means your way will also work. i must have checked it in preview.

nice, now i have 2 answers to choose from.

greets

amounra93
Posts: 432
Joined: Sat Jan 24, 2009 8:16 pm
Location: Arcata, CA
Contact:

Re: can a device detect if it's moved to another track?

Post by amounra93 » Fri Aug 27, 2010 9:01 pm

This is a pretty simple js. I could have done a couple of things to make it a little more self-contained, but I was short on time when I wrote it. I mainly just wanted to show that you could do what you needed with a closebang.

The delay (I use pipe, just because I constantly get into trouble when I place a delay in a patch after a bang, and then go back later and try to throw a number through it and get an error...I've just kind of started using pipes instead, since they essentially do the same thing) is for the reasons you noted above. If you try to access certain API elements when the Live set is changing, it can completely bugger things up. I've found that when trying to get data from API objects that if you don't need it right away, then don't try to get it right away. It saves trouble. That's why I only use js for stuff that isn't timing sensitive. I wasted a lot of time building patches around js only to find out they were too laggy to use, then had to convert everything over to pure Max.

That said, js is really convenient for making calls to the API: you only need to create one object instead of two, and you can easily reassign those objects at a later time if you need to. There's no real difference in how they act (since they are accessing the same objects internally) except for that the js code is always deffered (which in many cases is what we want anyway).

Cheers :)
http://www.aumhaa.com for Monomod and other m4l goodies.

Palmer Eldritch
Posts: 525
Joined: Thu Jun 23, 2005 9:47 pm
Location: Universe>Earth>Europe>Germany

Re: can a device detect if it's moved to another track?

Post by Palmer Eldritch » Fri Aug 27, 2010 10:57 pm

Hi Guys,

I have worked on a similar problem and have had come to this solution (seems to be the third way :wink: )
(a device that knows all the time where it is - except - when it is grouped :? :cry: )

:

<pre><code>
----------begin_max5_patcher----------
2163.3oc2b01baZDD9y1+JtnoeHYpq68Nbcl7g1+FIcxfQmsoUB7.n75j+6k
61CYIaAbGPHVcxDKsHvZ2G18Ye4N72t7hU2T7Yc0JzefdG5hK91kWbg8PlCb
gS9hUaS9b5ljJ6osJsX6Vcd8pqfOqV+4Z6wIns5j7JT88ZzsYkU0n5xjz+82
Wq+XVpF857BzW0kEuo8B2jkqSK1kauZp6fOjTmdeV9cenTmVCZkLhcM9JDUI
MuPHwfz0Xze6tn7cayx2nqs5Gwcvr0Vsp3l+42HhUOdlE6paOUr6n2VjWmmr
Uauf+rLKYC5uJ1rd0AebU1WseLAeM1bzue4klebkmXVt9SMJxyfrJ8FDYU2l
NWYrUlBdwBCFy+zFN84FNM9zFN0OCGth5u7fFTmU2jje2pqPqVsWC9wgMq02
pK2T7odfGB15KDYcLDz9gmS3WPImFdHiDdVBXoFcCZSeXRDwhChHWXhHPPQc
95xTixPY8FNY8TXQP7DMXrYlCmxLrnvKyI5zEAcVdVciN07KGY4c0knjaM+j
fpzonWWju4KnbcUptpJ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zHb2r4nVpnHJL
2tikhbka.A9QpYoUM1P9lpPWko3qoJkJN9p1mU6H3Iw8IRwtR9AJ3X07P5NT
mm7PMGXiPwvvpFisc.XklZwH9TpWniKwodt+XUfE6klnxF6wroYA1frn8gN.
J8Dld1okfQAaklACYP13PG6CfybvuVz9PTbjD7GYMEU8bIn+G2rijO0DaD99
k+Gv2c+gr
-----------end_max5_patcher-----------
</code></pre>

cheers, palmer
Live 8_3_4 + 4b7_32+64 -Suite- Max4Live 5_1_9 _ core2DuoMacBook 2*2,16 Ghz + external FW HD _ OSX 10.6.8 _ 3G RAM _ M.H. MIO 2882 + 5.4d208 Driver _ Faderfox LV1 _ Akai MPK25 _ Logitec wheel mouse _______ PeacE will be the SOLution of LIVE

Post Reply