How do I change loop start/end points when clip isnt looping

Learn about building and using Max for Live devices.
Post Reply
Gravis
Posts: 104
Joined: Sat Jul 28, 2007 4:47 am

How do I change loop start/end points when clip isnt looping

Post by Gravis » Tue Jul 20, 2010 10:15 pm

Ok so i have a clip that's playing and i want to change the loop start and end points, how do i do this when the clip ISNT in looping mode?

Currently using Javascript i have ...

Code: Select all

function incrementLoopStart() {
    if (clip_slot_grid[currentlySelectedTrackNumber][scene].get("has_clip") == TRUE &&
        clip_grid[currentlySelectedTrackNumber][scene].get("looping") == TRUE) {
        
        var loopStart = clip_grid[currentlySelectedTrackNumber][scene].get("loop_start");

        if (loopStart % LOOP_CHANGE_SIZE == 0) {
            clip_grid[currentlySelectedTrackNumber][scene].set("loop_start", Math.round(parseInt(loopStart, 10)+LOOP_CHANGE_SIZE));
        }
        else {
            // This will ensure that we move to the closest bar of LOOP_CHANGE_SIZE
            clip_grid[currentlySelectedTrackNumber][scene].set("loop_start", Math.round(parseInt(loopStart, 10)+(loopStart % LOOP_CHANGE_SIZE)));
        }
    }
}


function decrementLoopStart() {      
    if (clip_slot_grid[currentlySelectedTrackNumber][scene].get("has_clip") == TRUE &&
        clip_grid[currentlySelectedTrackNumber][scene].get("looping") == TRUE) {
            
        var loopStart = clip_grid[currentlySelectedTrackNumber][scene].get("loop_start");
        if (loopStart >=4) {
            if (loopStart % LOOP_CHANGE_SIZE == 0) {
                clip_grid[currentlySelectedTrackNumber][scene].set("loop_start", Math.round(parseInt(loopStart, 10)-LOOP_CHANGE_SIZE));
            }
            else {
                clip_grid[currentlySelectedTrackNumber][scene].set("loop_start", Math.round(parseInt(loopStart, 10)-(loopStart % LOOP_CHANGE_SIZE)));
            }
        }
    }
}

You can see in both functions i have a check ...

clip_grid[currentlySelectedTrackNumber][scene].get("looping") == TRUE


The problem is that the clip must be in looping mode, otherwise the start and end point of the clip (NOT the loop) are affected, this is extremely annoying and not what im after, so can someone please help.

Cheers
iMac G5 2.16 | Echo AudioFire12 | Xone 92 | Live 8 + M4L | Trigger Finger | Monome 256 | Kenton Killamix Mini | Truth 3031A

Crubier
Posts: 51
Joined: Thu Nov 05, 2009 8:37 am
Location: Toulouse, France

Re: How do I change loop start/end points when clip isnt looping

Post by Crubier » Wed Jul 21, 2010 9:21 am

I think that this should work :

Code: Select all

function incrementLoopStart() {
    if (clip_slot_grid[currentlySelectedTrackNumber][scene].get("has_clip") == TRUE) {


// MODIFICATION
        var temp = clip_grid[currentlySelectedTrackNumber][scene].get("looping");
// MODIFICATION
        clip_grid[currentlySelectedTrackNumber][scene].set("looping","1");     

        var loopStart = clip_grid[currentlySelectedTrackNumber][scene].get("loop_start");

        if (loopStart % LOOP_CHANGE_SIZE == 0) {
            clip_grid[currentlySelectedTrackNumber][scene].set("loop_start", Math.round(parseInt(loopStart, 10)+LOOP_CHANGE_SIZE));
        }
        else {
            // This will ensure that we move to the closest bar of LOOP_CHANGE_SIZE
            clip_grid[currentlySelectedTrackNumber][scene].set("loop_start", Math.round(parseInt(loopStart, 10)+(loopStart % LOOP_CHANGE_SIZE)));
        }

// MODIFICATION
        clip_grid[currentlySelectedTrackNumber][scene].set("looping",temp);


    }
}

Gravis
Posts: 104
Joined: Sat Jul 28, 2007 4:47 am

Re: How do I change loop start/end points when clip isnt looping

Post by Gravis » Thu Jul 22, 2010 9:26 pm

Well it works, its mental, and I really shouldnt have to do this, but that's a work around that gets me what i'm after, even if it is a bit slow.

Cheers Crubier, much appreciated :)
iMac G5 2.16 | Echo AudioFire12 | Xone 92 | Live 8 + M4L | Trigger Finger | Monome 256 | Kenton Killamix Mini | Truth 3031A

Crubier
Posts: 51
Joined: Thu Nov 05, 2009 8:37 am
Location: Toulouse, France

Re: How do I change loop start/end points when clip isnt looping

Post by Crubier » Fri Jul 23, 2010 9:12 am

I totally agree with you, some parts of the Live Object Model are really weird.

There should be "clip_start" and "clip_end" properties, instead of accessing them trough "loop_start" and "loop_end".

I think I will open a new thread soon, something like "Live Object Model Whishlist" because there are many thing to improve with this.

Cheers

S4racen
Posts: 5822
Joined: Fri Aug 24, 2007 4:08 pm
Location: Dunstable
Contact:

Re: How do I change loop start/end points when clip isnt looping

Post by S4racen » Sun Aug 08, 2010 6:58 pm

Umm, noob question, how do i turn your js code above into M4L to paste in a device??

Cheers
D

pid
Posts: 354
Joined: Thu Nov 05, 2009 9:51 am

Re: How do I change loop start/end points when clip isnt looping

Post by pid » Sun Aug 08, 2010 7:36 pm

just think of it as an abstraction. the easy way for noobs: so, copy it, then paste it into a text editor (i use textedit on a mac). but, make sure textedit is set to "Make Plain Text" .txt file format, NOT .rtf file format. then, save it as "blahblah.js". the '.js' is important - THIS should be the extension, NOT '.txt' or whatever. then open a new max patcher, then make a new object called (in this case) [js blahblah.js]. voila.

of course 1: thinking of it like an abstraction means that it must be saved either into your max search path or the same folder as the patch/device you are making. of course 2: if you have a brand new device/patcher, it does not 'exist' until you save it, so your [js blahblah.js] object might not work until it is saved.

this method is the same for all max objects that 'read' things, whether it is the [text] object, the [poly~], a .jxs jitter shader, the [vst~] object, etc etc etc. even mxj objects, but that is slightly more complicated.

good luck. for what it is worth, i am a javascript noob too - i have got to the stage where i can read and modify, and that has taken ages! maybe my own js from scratch is not far off round the corner...

good luck.
3dot... wrote: in short.. we live in disappointing times..

Crubier
Posts: 51
Joined: Thu Nov 05, 2009 8:37 am
Location: Toulouse, France

Re: How do I change loop start/end points when clip isnt looping

Post by Crubier » Tue Aug 10, 2010 11:38 am

You can use the max patcher in the following thread too :
http://forum.ableton.com/viewtopic.php?f=35&t=147654
If you want to change start and stop points, just go into the patcher object (in blue) and change the "get loop_start" by "set loop_start xx".

If you want to use the javascript code above in the present thread, paste it into a text file, rename it "yourname.js", save it into your M4L device folder, and in your M4L device, create an object with the following name : "js yourname.js" that's all !

Post Reply