MFL : Scene name search

Aug 27, 2012 at 4:56pm

MFL : Scene name search

I made this patch to perform keyword based search in the names of the scenes of a liveset and select the first scene containing that keyword. I came with something that seems to work but I’m pretty new to max and this live api stuff. If such a device can appeal to you, can you please test it and, for those who know this kind of stuff, can you please comment on mistakes or possible improvements. I struggled to make this one and would like to start on solid ground !
Thanks !

– Pasted Max Patch, click to expand. –
#64121
Aug 28, 2012 at 9:26am

For now the search is case sensitive, is there a way to make that this is not the case ? (not sure about the english version for this…). [coll] maybe ?

New version btw…

– Pasted Max Patch, click to expand. –
#231286
Aug 30, 2012 at 6:23am

Anyone ?

#231287
Aug 31, 2012 at 7:43am

bump for the ‘case sensitive’ question at least…

#231288
Sep 17, 2012 at 9:34am

New version 1.12 : http://www.maxforlive.com/library/device/1281
The case sensitive question is solved, btw.
Please comment patching.

#231289
Sep 18, 2012 at 8:42pm

Personally, I find iterating over Live API properties (tracks, scenes, devices, paramaters, etc) in Max like pulling teeth. I tend to go to javascript and use the LiveAPI js object in these cases.

The following patch will give you the ‘scene indexes’ (starting from 0) for all scenes with names containing the provided saerch string.

– Pasted Max Patch, click to expand. –

Save the following as ‘sceneSearch.js’:

autowatch = 1;
var api;

function getApi()
{
if (undefined === api) {
api =new LiveAPI();
}
return api;
}

function sceneSearch(searchString)
{
var api = getApi();
api.path = ‘live_set’;
var sceneCount = api.getcount(‘scenes’);
var foundScenes = new Array();

for (var sceneIndex = 0; sceneIndex < sceneCount; sceneIndex++) {
api.path = ‘live_set scenes ‘ + sceneIndex;
var sceneName = new String(api.get(‘name’));

if (-1 !== sceneName.toLowerCase().indexOf(searchString.toLowerCase())) {
foundScenes.push(sceneIndex);
}
}

if (0 === foundScenes.length) {
foundScenes.push(‘-’);
}

outlet(0, foundScenes);
}

I am aware that this js doesn’t do as thorough a search as your max implementation (e.g. no regex replacements of underscores/dashes into spaces), but I really wanted to demonstrate how much more succinct the API iteration side of things can be…

#231290
Sep 20, 2012 at 5:54am

Thanks WillyC, This looks pretty concise ! But I don’t know anything about Javascript. What should I do with these lines of code ? I tried to paste them in a text editor but it didn’t let me save it with a .js extension.

#231291
Sep 24, 2012 at 3:29pm

There’s a strange behaviour with this and I can’t understand why : after making a search, if I copy / paste or duplicate scenes, the second time I do one of these actions, the device selects back the scene I previously searched. I looked at the patch but can’t understand why. So I thought maybe this could be a bug in the api, even if I know I just start working with live.api. Can somenone please confirm this, and maybe tell me where this comes from ? You can DL it here : http://www.maxforlive.com/library/device.php?id=1281.

#231292

You must be logged in to reply to this topic.