# A little looping script



## Thonex (Sep 20, 2006)

Hi there, 

I wrote a little script to loop sustains.... it worked great with slow attack sustains and then when I wrote it to work with attacked notes... I was getting loop cross-fade problems and whatnot... this is where Nils worked his magic and helped solve the niggles.

So... thanks Nils for helping me out on this one.

Here is the Code.... hope you find it useful.... it must be compiled in Nils editor first.


```
{          Auto Looper V1         
 Written by Andrew Keresztes and Nils Liberg}

on init
  declare polyphonic id
  declare polyphonic last_id    
  declare ui_knob Wait_Time(1,5000,1)
  declare ui_knob FadeInMS (0,5000,1)
  declare ui_knob FadeOutMS(0,5000,1)  
  set_knob_unit(Wait_Time, KNOB_UNIT_MS)
  set_knob_unit(FadeInMS,  KNOB_UNIT_MS)
  set_knob_unit(FadeOutMS, KNOB_UNIT_MS)
  Wait_Time := 1000
  FadeInMS  := 300
  FadeOutMS := 300
  
  make_persistent(Wait_Time)
  make_persistent(FadeInMS)
  make_persistent(FadeOutMS)  
end on

on note
  ignore_event(EVENT_ID)
  last_id := play_note(EVENT_NOTE, EVENT_VELOCITY, 0, -1)      
  wait(Wait_Time*1000)
  while (NOTE_HELD=1)            
    id := play_note(EVENT_NOTE, EVENT_VELOCITY, 0, -1)        
    fade_in(id, FadeInMS*1000)
    fade_out(last_id, FadeOutMS*1000, 1)       
    last_id := id
    wait(Wait_Time*1000)        
  end while
end on
```

Cheers,

T


----------



## Thonex (Sep 20, 2006)

I just want to say... we might be on to some gold here... I just put the script BEFORE SIPS and it works veeerrrrryyy well... with some veeerrryyyy interesting side effects when you hold on to 2 note intervals..... it keeps playing the interval over and over as long as both notes are held. If the loop was sped up... it could in essence become a trill or measured trem or something like that.

Definitely something to be explored... although I don't have the time for i right now... too many deadlines.


Cheers,

T


----------



## Patrick de Caumette (Sep 20, 2006)

T. , I am totally amazed at the fact that a while back you were just starting with scripts and that you manage to handle your jobs and this at the same time... :shock:


----------



## Thonex (Sep 20, 2006)

Patrick de Caumette @ Wed Sep 20 said:


> T. , I am totally amazed at the fact that a while back you were just starting with scripts and that you manage to handle your jobs and this at the same time... :shock:



Necessity is the mother of invention. :wink:


----------



## Big Bob (Sep 20, 2006)

Cool Andrew,

I haven't had a chance to play with it yet but, just out of curiosity; when you use knob names like 'Wait_Time' do all the characters display for you? Mine cuts off in the middle of the 'm' in time. Doesn't seem to matter whether I use the large or small font option. 

The reason I ask is that I'm always fighting to keep knob names short so they'll display without cutting off. Is it just my system or do the rest of you experience this same problem? Is it different on a PC (which I am) or on a Mac?

God Bless,

Bob


----------



## Thonex (Sep 20, 2006)

Big Bob @ Wed Sep 20 said:


> Cool Andrew,
> 
> I haven't had a chance to play with it yet but, just out of curiosity; when you use knob names like 'Wait_Time' do all the characters display for you? Mine cuts off in the middle of the 'm' in time. Doesn't seem to matter whether I use the large or small font option.
> 
> ...



No... the names get cut off here too.... this was just a quicky utilitarian script.... but I thought it might be useful for others... they can come up with their own cool short KNOB names :lol:


----------



## Alex W (Sep 20, 2006)

cooool


----------



## Fernando Warez (Feb 14, 2007)

Thonex @ Wed Sep 20 said:


> Hi there,
> 
> I wrote a little script to loop sustains.... it worked great with slow attack sustains and then when I wrote it to work with attacked notes... I was getting loop cross-fade problems and whatnot... this is where Nils worked his magic and helped solve the niggles.
> 
> ...



Would this work with VSL legatos? Probably not right?


----------



## Thonex (Feb 15, 2007)

I don't think it would work with VLS Legatos, but it may work with VLS plain sustains.


T


----------



## José Herring (Feb 15, 2007)

Thonex @ Thu Feb 15 said:


> I don't think it would work with VLS Legatos, but it may work with VLS plain sustains.
> 
> 
> T



Hey T. 

Tried the script and it works well. I hope this isn't too daft of a question, but what could be some possible uses for this script? So far the only use I can come up with is to add some life and motion to a regular old sustain. It seems to fill it out quite a bit especially when I play chords. Just wondering what else I could use this for.

best,

Jose


----------



## Thonex (Feb 15, 2007)

Hey Jose,

No, it's not a bad question. THis script is really just a simple script to loop sustained strings.

I never really though abut doing anything else with it.

T


----------



## Fernando Warez (Feb 15, 2007)

Thonex @ Thu Feb 15 said:


> I don't think it would work with VLS Legatos, but it may work with VLS plain sustains.
> 
> 
> T



Thanks! This will come in handy I'm sure. If only i can figure out how to load it? :lol: :(


----------



## zaster (Jun 10, 2007)

Can someone explain to me how to use these controls? Wait time/ Fade-in/ Fade-out? I'm new to all this and I have a long violin note sample I'm trying to turn into a sus violin. I can get pretty close, but there's a beating and I don't know which way to go with the controls to minimize that. I've figured out how to get it to work with SIPS legato, with SIPS first, not after the looper, as had been suggested. But I'm not having success trying to chain this with SIPS Vibrato. With the loop script activated, the vibrato disappears, even at the most drastic settings. I've tried putting the vibrato both before AND after. Basically, I'm just trying to turn this long note into a sus/legato note with variable vibrato. I would appreciate any tips anyone might have.


----------



## Big Bob (Jun 10, 2007)

Hi zaster,

I can't give you any magic settings for the knobs but I can explain to you what they do. I also need to mention that Andrew's Auto-Looper script will interfere with SIPS and vice versa. That doesn't mean you can't use them together and get some interesting effects, it just means that the scripts are not designed to cooperate in any way and therefore will mostly adversely affect each other.

The way Andrew's script works is as follows. When you hit a key to play a note and hold it down, periodically the note is retriggered and the old note is faded out while the newly triggered note is faded in. It's possible (but not very likely) that you may find some combination of fade-in and fade-out time such that the sound during the crossfade can be made to match the normal sustained sound of a single note. Although in actual practice, a simple linear crossfade like this script provides usually results in a non even volume level during the crossfade and for most kinds of sample material, some phasing effects can usually be heard. This is why I say its possible but not very likely that you can find some magic combination that will produce a perfectly smooth sustain sound.

The FadeInMS knob sets the time interval in milliseconds over which the newly triggered sample fades in from silence to full volume. The FadeOutMS knob sets the time in milliseconds over which the old sample fades out from full volume to silence. The Wait_Time knob, sets the time interval (again in milliseconds) between each retrigger of a new note. Thus you would usually want to set the fade-in/out times shorter than Wait_Time to avoid buildup.

Hope this helps.

God Bless,

Bob


----------



## zaster (Jun 10, 2007)

Thank you kindly, Bob- I will resist the temptation to pick your brain further on this since it's obvious you're like the overworked saint around here  
but if anyone knows of an obvious (non-script) way through the envelopes or something to get the string sound to sustain, please let me know- I'd be grateful.


----------



## Thonex (Jun 10, 2007)

Bob did a great job explaining the script... better than I could have :lol: 

The traditional way of looping stings without involving a script is to use K2's built-in looping feature.

You need to set the loop start and loop end points in the sample and then choose how many samples you want x-fades between the start and end of the loop.

With a fairly large x-fade... it is really quite easy to find a good loop for sustained strings. Doing the looping in K2's loop editor is a little fatiguing, but the dividends are worth it.

Hope this helps.

Cheers,

T


----------



## zaster (Jun 11, 2007)

Thanks Thonex-
So if I'm correctly understsnding what you're saying-
except for scripts, you have to delve down to the sample by sample level- you can't loop somehow on a group basis, using an envelope or modulator or some other magic?
I _think_ that's what you're saying?
Sounds like a PITA, but if that's where the technology is, I guess I'll have to deal with it like everyone else!


----------



## Thonex (Jun 11, 2007)

zaster @ Mon Jun 11 said:


> Thanks Thonex-
> So if I'm correctly understsnding what you're saying-
> except for scripts, you have to delve down to the sample by sample level- you can't loop somehow on a group basis, using an envelope or modulator or some other magic?
> I _think_ that's what you're saying?
> Sounds like a PITA, but if that's where the technology is, I guess I'll have to deal with it like everyone else!



That is 100% correct.

I really wish K2 would allow you to type in a value in a field... and if any zones are selected (orange) then all those zones get those attributes.... This doesn't work with sample loop points or sample start points.... man it would be a HUGE times saver if it could globally assign start points.

Cheers,

T


----------



## Ed (Jun 11, 2007)

zaster @ Mon Jun 11 said:


> T
> *Sounds like a PITA,*!



Sorry to change the subject but why do people write this? I see it every now and then, in the place where you'd normall write "pity", but why write pitA, and why CAPS?


----------



## Patrick de Caumette (Jun 11, 2007)

Pain In The Abdomen


----------



## polypx (Jun 13, 2007)

> I really wish K2 would allow you to type in a value in a field... and if any zones are selected (orange) then all those zones get those attributes.... This doesn't work with sample loop points or sample start points.... man it would be a HUGE times saver if it could globally assign start points.
> 
> T



There is a command in the sample looping section "To All Selected Zones = Copy Current Loop Settings" ... this is very good for copying basic loop setups to all your zones in one go.

cheers
Dan


----------



## Fernando Warez (Jun 13, 2007)

Patrick de Caumette @ Mon Jun 11 said:


> Pain In The Abdomen



More like pain in the ass. :wink:


----------



## Fernando Warez (Jun 13, 2007)

polypx @ Wed Jun 13 said:


> > I really wish K2 would allow you to type in a value in a field... and if any zones are selected (orange) then all those zones get those attributes.... This doesn't work with sample loop points or sample start points.... man it would be a HUGE times saver if it could globally assign start points.
> >
> > T
> 
> ...



Thats a good tip! o-[][]-o


----------



## zaster (Jun 13, 2007)

I thought of that, but in investigating a typical sustain looped patch, say Violin, from an arbitrary library, it became clear that loop points were radically different every 2 or 3 scale notes. Obviously, the higher you go the shorter the segment after the attack and before the decay. So it really _does_ look like it takes sample by sample editing to get a whole set of sustains.


----------



## Thonex (Jun 13, 2007)

polypx @ Wed Jun 13 said:


> > I really wish K2 would allow you to type in a value in a field... and if any zones are selected (orange) then all those zones get those attributes.... This doesn't work with sample loop points or sample start points.... man it would be a HUGE times saver if it could globally assign start points.
> >
> > T
> 
> ...



I'm not at my studio right now... but I wonder if there is such a command for sample start points.... if not.... there should be... that is one of the biggest drags (for me) regarding K2.

T


----------

