Old 01-10-2014, 04:21 PM   #1
tomfrankly
Human being with feelings
 
Join Date: Oct 2012
Posts: 59
Default MIDI time offset / negative delay?

I've just set up a new track template for myself to use with Kontakt. One folder track with Kontakt loaded, with 16 tracks feeding into it; one for each MIDI channel. I put MIDI_Tool II on each of the child tracks to restrict them to their respective channels.

Previously I had been using separate instances of Kontakt on a separate track for each instrument because usually each one needed a specific adjustment from the time_adjustment JS effect. The time_adjustment effect doesn't seem to interact with MIDI, so putting it on each of the 16 MIDI tracks does nothing. I think to make this work I would need to give each instrument inside Kontakt its own output, add a time_adjustment for each stereo pair, then mix the channels back down to channels 1 and 2. I suppose I could do this but I think it would slow me down, and the whole point of this setup is to speed up my work flow.

Ideally there would be an effect I could put on each MIDI track, with an effect parameter that could be put onto the track control.

Does anyone know a better way of going about this?
tomfrankly is offline   Reply With Quote
Old 01-10-2014, 08:40 PM   #2
Troy
Human being with feelings
 
Troy's Avatar
 
Join Date: Jan 2012
Location: Western Hemisphere
Posts: 378
Default

Someone here helped me with this script a while ago to do exactly what you want:

Code:
desc:MIDI time adjustment

slider1:0<-2000,2000,1>delay amount (ms)
slider2:0<-3840,3840,1>          or (ticks)
slider4:0<-44100,44100,1>additional delay amount (samples)

slider6:0<-150000,150000,1>=> resulting delay (samples)
slider7:0<-150000,150000,1>                   (ticks)
in_pin:none
out_pin:none

// ------------------------------------------
@init
    ext_noinit = 1;
    bpos=0;
    ticksperbeat = 960;
    delaylenXX = 0;
    
// ------------------------------------------
@slider
    slider4 = (slider4 | 0);
    slider1 != old_s1 ? (
        old_s1 = slider1;
        slider2 = 0;
        old_s2 = 0;
        delaylenXX = (slider1 * srate * 0.001) | 0;
    ):(
    slider2 != old_s2 ? (
        old_s2 = slider2;
        slider1 = 0;
        old_s1 = 0;
        delaylenXX = (slider2 / ticksperbeat * 60 / tempoX *srate) | 0;
    ); );
    delaylen = delaylenXX + slider4;

    delaylen<0?(
        pdc_delay=-delaylen;  
        pdc_top_ch=2;
        pdc_bot_ch=0;
        delaylen=0;
        pdc_midi = 1;
    ):(
        delaylen+=pdc_delay;
        pdc_delay=0;
    );
    bufsize=srate *2.0  * 4.0; // extra in case the user wants to go over

    slider6 = delaylenXX +slider4;
    slider7 = ((slider6 / srate * tempoX / 60 * ticksperbeat) * 100 | 0) / 100;

// ------------------------------------------
@sample
    tempoX = tempo;
    midirecv(mpos, msg1, msg23) ? (
        msg = (msg1 / 16) | 0;
        channel = 1 + msg1 - (msg * 16);        // result is 01 .. 16
        msg_number = msg23 & 127;
        msg_value = (msg23 / 256) | 0;

        bpos[0] = msg1;
        bpos[1] = msg23;
    ):(
        bpos[0] = 0;
        bpos[1] = 0;
    );

    rdpos=bpos-delaylen*2;
    rdpos<0 ? rdpos+=bufsize*2;

    rdpos[0] > 0 && rdpos[1] > 0 ? (
        msg1  = rdpos[0];
        msg23 = rdpos[1];
        midisend(mpos, msg1, msg23);
    );
    bpos+=2;
    bpos>=bufsize*2 ? bpos=0;
Move the "delay" slider to the left for negative delay.

If you don't know what to do with this, PM me and I can email the file to you.
Troy is offline   Reply With Quote
Old 01-10-2014, 08:59 PM   #3
tomfrankly
Human being with feelings
 
Join Date: Oct 2012
Posts: 59
Default

Perfect! Before posting this thread I did some searching and saw something that seemed to suggest that this was impossible to do with JS. I'm very glad to find out that that was incorrect. I really appreciate your help!
tomfrankly is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 03:23 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.