/[svn]/doc/docbase/instrument_scripts/nksp/01_nksp.html
ViewVC logotype

Diff of /doc/docbase/instrument_scripts/nksp/01_nksp.html

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3061 by schoenebeck, Fri Dec 16 17:20:55 2016 UTC revision 3111 by schoenebeck, Wed Feb 15 13:06:05 2017 UTC
# Line 11  Line 11 
11        your own instrument scripts in short time. It concentrates on describing        your own instrument scripts in short time. It concentrates on describing
12        the script language. If you rather want to learn how to modify and        the script language. If you rather want to learn how to modify and
13        attach scripts to your sounds, then please refer to the gigedit manual for        attach scripts to your sounds, then please refer to the gigedit manual for
14        <a href="gigedit_scripts.html">how to manage instrument scripts with gigedit</a>.        <a href="gigedit_scripts.html">how to manage instrument scripts with gigedit</a>
15          for Gigasampler/GigaStudio format sounds, or refer to the SFZ opcode
16          <code lang="sfz">script</code> for attaching NKSP scripts with
17          SFZ format sounds.
18      </p>      </p>
19    
20      <h3>At a Glance</h3>      <h3>At a Glance</h3>
# Line 933  end on Line 936  end on
936      <p>      <p>
937        We already came across various built-in functions, which you may call        We already came across various built-in functions, which you may call
938        by your scripts to perform certain tasks or behavior which is already        by your scripts to perform certain tasks or behavior which is already
939        provided for you by the sampler. When working on larger scripts, you        provided for you by the sampler. NKSP also allows you to write your
940          own functions, which you then may call from various places of your
941          script.
942        <p>  
943        </p>
944          When working on larger scripts, you
945        may notice that you easily get to the point where you may have to        may notice that you easily get to the point where you may have to
946        duplicate portions of your script code, since there are certain things        duplicate portions of your script code, since there are certain things
947        that you may have to do again and again in different parts of your script.        that you may have to do again and again in different parts of your script.
948        Software developers usually try to avoid such code duplications to        Software developers usually try to avoid such code duplications to
949        keep the overall amount of code as small as possible, since it would        keep the overall amount of code as small as possible, since the
950          overall amount of code would bloat quickly and would
951        make the software very hard to maintain. One way for you to avoid such        make the software very hard to maintain. One way for you to avoid such
952        script code duplications with NKSP is to write so called <i>User Functions</s>.        script code duplications with NKSP is to write so called <i>User Functions</s>.
953      </p>      </p>
# Line 964  end on Line 973  end on
973      </code>      </code>
974      <p>      <p>
975        This script will run an endless loop for each note being triggered.        This script will run an endless loop for each note being triggered.
976        Every <code>200ms</code> it will turn the volume alternatingly down and        Every <code lang="none">200ms</code> it will turn the volume alternatingly down and
977        up to create the audible stuttering effect. After each <code>wait()</code>        up to create the audible stuttering effect. After each <code lang="nksp">wait()</code>
978        call it calls <code>event_status($EVENT_ID)</code> to check whether        call it calls <code>event_status($EVENT_ID)</code> to check whether
979        this note is still alive, and as soon as the note died, it will stop        this note is still alive, and as soon as the note died, it will stop
980        execution of the script instance by calling <code>exit()</code>. The latter        execution of the script instance by calling <code>exit()</code>. The latter
981        is important in this case, because otherwise the script instances would        is important in this example, because otherwise the script execution instances would
982        continue to run in this endless loop forever, even after the respectives        continue to run in this endless loop forever, even after the respectives
983        notes are gone. Which would let your CPU usage to increase with every note.        notes are gone. Which would let your CPU usage to increase with every new note
984          and would never decrease again.
985        This behavior of the sampler is not a bug, it is intended, since there may        This behavior of the sampler is not a bug, it is intended, since there may
986        also be cases where you want to do certain things by script even after the        also be cases where you want to do certain things by script even after the
987        respective notes are dead and gone. However as you can see, that script is        respective notes are dead and gone. However as you can see, that script is
# Line 997  end on Line 1007  end on
1007      </code>      </code>
1008      <p>      <p>
1009        The script became in this simple example only slightly smaller, but it also        The script became in this simple example only slightly smaller, but it also
1010        became easier to read. And in practice, with a more complex script, you can        became easier to read and behaves identically to the previous solution.
1011          And in practice, with a more complex script, you can
1012        reduce the overall amount of script code a lot this way. You can choose any        reduce the overall amount of script code a lot this way. You can choose any
1013        name for your own user functions, as long as the name is not already        name for your own user functions, as long as the name is not already
1014        reserved by a built-in function. Note that for calling a user function,        reserved by a built-in function. Note that for calling a user function,

Legend:
Removed from v.3061  
changed lines
  Added in v.3111

  ViewVC Help
Powered by ViewVC