# How many lines is your 'average' script



## Blackster (Mar 12, 2013)

I know that this totally depends on what you are trying to achieve. But let's talk about an average script for a normal instrument.

How big are your scripts and are there any advantages of splitting large scripts into different slots? 

With my current project I have crossed 5k lines and I would assume that this is not really large compared to 'big libraries' out there, right? 

Really looking forward to your replies!


----------



## mk282 (Mar 12, 2013)

At least 2000 lines/script. But really depends on what I do. I don't use multiple slots until really necessary (like when doing various things with note processing and you need things in certain order, example Input Quantize->Latch->Retrigger->etc.)


----------



## Mike Greene (Mar 12, 2013)

The Realivox main page script is 3000 lines, and the other slots add another 1000 or so. However, it wouldn't surprise me at all if a better scripter would have done it with far fewer lines. In fact, several times when I would add a feature or something, my script would be _shorter,_ because to make the new feature work, I'd have to make some earlier section more streamlined and efficient.

This happened in just the last couple days as I'm writing a script for a banjo instrument. I include "legato" (slide, hammer on, pull off) samples, so I had to come up with a legato section of the script. It was like 500 lines or so, because of all the possibilities. (Up/down, which string for a certain note, which fret is selected by the user, what velocity sample, etc.)

Then I wanted to add a sequencer to play back some pattern loops I made. In the on listener callback, I need to be able to play 4 1/16 notes (per beat,) with legato possibilities. This meant a copy and paste of those 500 lines for each 1/16 note. What a mess that would be! To make a long story story short, after some rethinking, the entire "on listener" callback is now maybe 200 or 300 lines total. I'm kinda pleased with myself.

Even though Mario could probably do it in 50. :mrgreen:


----------



## Raptor4 (Mar 12, 2013)

Mike Greene @ Tue Mar 12 said:


> This meant a copy and paste of those 500 lines for each 1/16 note. What a mess that would be! :


Have you thought to use a function for that ? Anyway the function usage optimizes the code for sure - its a matter of code design obviously :|


----------



## ScoringFilm (Mar 12, 2013)

My Syllable Sequencer for Voices of Prague is 2987 lines in the script editor which compiles to 15700 lines of script (from functions and macros)! At the other end of the spectrum, some of the scripts I am doing for Strezov Sampling are around 100 or so lines. I also try to avoid multiple script slot usage if possible.

Justin


----------



## Lindon (Mar 13, 2013)

Version 2 of Grid Machine//Slice is now over 10,000 lines, I realise that's not typical but nice to know you can go there if you need to...


----------



## Blackster (Mar 13, 2013)

Thanks guys, that really sounds impressive! _-)


----------



## diggler (Mar 14, 2013)

I would say from 50 lines for very simple to 5000 for a complex one. 2500 is probably average.


----------



## Sasje (Mar 14, 2013)

I aim for as little as possible. But with KSP you have to declare things a million times, so I guess many lines are unavoidable for complex GUI's. I think most I write are between 500 and a 1000. I don't like many lines of code, and try to optimize or simplify as much as KSP allows me. Simplification usually takes more time than to actually write all of it.


----------



## kb123 (Mar 14, 2013)

Blackster @ Tue Mar 12 said:


> I know that this totally depends on what you are trying to achieve. But let's talk about an average script for a normal instrument.
> 
> How big are your scripts and are there any advantages of splitting large scripts into different slots?
> 
> ...



Script sizes are very much dependent on the number of UI elements and whether Nils compiler is used in the process. So you will get wildly different answers, and it doesn't necessarily mean 1 script is "better" or more complex than another.

There are advantages to splitting functionality across multiple slots when it makes sense to do so. In a lot of instruments, functionality is pretty closely coupled to UI functionality, in which case, unless you are doing staged note processing, it makes little sense to split the script. However, if you have lots of additional processing over and above satisfying the UI, it can make sense to split the script to help with future script re-use.


----------



## Yahiaamine (Jan 31, 2017)

at the moment i just finished 1/5 of my work 

and i wrote more than 1500 lines


----------



## d.healey (Jan 31, 2017)

Yahiaamine said:


> at the moment i just finished 1/5 of my work
> 
> and i wrote more than 1500 lines


Way to resurrect a thread


----------



## Yahiaamine (Jan 31, 2017)

d.healey said:


> Way to resurrect a thread


Like The Walking Dead.

PS : i was looking for a way to deal with projects that has big size (storage)


----------



## Stiltzkin (Feb 1, 2017)

Changes all the time, though I tend to find I'm shortening scripts more and more - the script I wrote for light and sound chamber strings is under 2k lines (under 800 shorthand) and is doing some pretty fancy stuff under the hood. The added functionality is something I'm yet to explore yet though, just because people are likely less willing to update to the newest version just yet!


----------



## Lindon (Feb 2, 2017)

Orbiter has @ 14K lines of very optimised code... and I notice around this number Kontkat starts to get a little grumpy


----------



## EvilDragon (Feb 2, 2017)

Biggest I ever did was about 30K lines spread across 3 script slots, for In Session Audio Fluid Harmonics. A lot of lines went into FX swapping functionality. Can't say Kontakt got grumpy, though


----------



## Lindon (Feb 2, 2017)

oh I mean 14K in ONE script slot


----------



## EvilDragon (Feb 2, 2017)

Yep, one of 3 scripts was 26k, other two had the rest. No grumpiness  You will want to have the script editor view CLOSED and all is fine. No problem at all with scripts linked from NKR.


----------



## Mike Greene (Feb 2, 2017)

EvilDragon said:


> You will want to have the script editor view CLOSED and all is fine.


Boy, there's a lesson I get reminded about every so often! If there's any heavy lifting going on, gotta remember to close the editor when testing.


----------



## Lindon (Feb 3, 2017)

EvilDragon said:


> Yep, one of 3 scripts was 26k, other two had the rest. No grumpiness  You will want to have the script editor view CLOSED and all is fine. No problem at all with scripts linked from NKR.


Well I learn something everyday, this I DID NOT KNOW. Thanks Mario(again)


----------



## magneto538 (Feb 7, 2017)

20000-30000 lines usually, but I have been working on quite complex stuff so far and I love using macros with text replace, so I guess it might be less than that... Let's just say I like to have a few more lines if that can save me hours of copying and pasting stuff.


----------

