elanhickler

guitar samples SALT script

Jul 5th, 2016
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // set properties by extracting from filename with regex;
  2. Items.setWithRegex("fileName", "articulation", "([^`]*)");
  3. Items.setWithRegex("fileName", "distance",     "distance=(\\w+)[`.]");
  4. Items.setWithRegex("fileName", "speed",        "speed=(\\w+)[`.]");
  5. Items.setWithRegex("fileName", "dynamic",      "vl=(\\w+)[`.]");
  6. Items.setWithRegex("fileName", "string",       "str=(\\w+)[`.]");
  7. Items.setWithRegex("fileName", "fret",         "fret=(\\d+)[`.]");
  8. Items.setWithRegex("fileName", "note",         "n=(.*?)[`.]");
  9. Items.setWithRegex("fileName", "strokedir",    "stroke=(\\w+)[`.]");
  10. Items.setWithRegex("fileName", "rr",           "rr=(\\d+)[`.]");
  11.  
  12. // create articulation groups by translating multiple key words to one word
  13. ArticulationGroupTranslator = Items.createTranslator(
  14.     "Harmonic,Mute,PalmMute,Resonance,Strum,Sustain=Core",
  15.     "PalmMuteRel,HarmonicRel,Release=Releases",
  16.     "FX", /*default*/
  17.     "SlideUp,SlideDown,PullOff,HammerOn=Legato",
  18.     );
  19. Items.setWithTranslator("articulation", "group");
  20.  
  21. StringLookup = ["E1", "A1", "D2", "G2", "B2", "E3"];
  22. StrokeLookup = ["dn", "up"];
  23. DynamicLookup = ["soft", "med", "loud"];
  24.  
  25. // calculate note from fret and string and get numerical values for properties
  26. for (i = 0; i < Items.count(); ++i)
  27. {
  28.     item = Items.get(i);
  29.  
  30.     if (item.hasProperty("string"))
  31.         item.stringNum = StringLookup.indexOf(item.string);
  32.     if (item.hasProperty("strokedir"))
  33.         item.strokedirNum = StrokeLookup.indexOf(item.strokedir);
  34.     if (item.hasProperty("dynamic"))
  35.         item.dynamicNum = DynamicLookup.indexOf(item.dynamic);  
  36.     if (item.hasProperty("fret"))
  37.         item.noteNum = item.fret + Midi.num(item.stringNum);
  38.     else if (item.hasProperty("note"))
  39.         item.noteNum = Midi.num(item.note);
  40. }
  41.  
  42. // set "new file name" property with a tag script
  43. Items.setWithTagScript("new_file_name",
  44.     "<articulation>[_<speed>][_<distance>][_str<stringNum>][_<dynamic>][_<note>][_<strokedir>][_rr<rr>]");
  45.  
  46. for (i = 0; i < Items.count(); ++i)
  47. {
  48.     item = Items.get(i);
  49.  
  50.     // Set "NewName" tab to see if we are renaming correcting
  51.     item.new_file_dir = item.fileDir+ "/" + item.group + "/" + item.articulation + "/";
  52.     new_file_path = item.new_file_dir + item.new_file_name + "." + item.fileExt;
  53.     item.new_file_path = new_file_path;
  54.  
  55.     // Create dummy files to test results (UNCOMMENT ONE)
  56.     //File.createFile(item.fileDir() + "/../dummy/" + item.fileName() );
  57.     // Move/rename files
  58.     //item.filePath(new_file_path);
  59. }
  60.  
  61. Items.setWithTagScript("new_file_name",
  62.     "<articulation>[_<speed>][_<distance>][_str<stringNum>][_<dynamic>][_<note>][_<strokedir>][_rr<rr>]");
  63.  
  64. // Set tree structure
  65. //Items.setWithTagScript("path","<group>/<articulation>/<dynamic>/<speed>/<distance>/<strokedir>/<fileName>");
  66. Items.setWithTagScript("path","<group>/<articulation>/<dynamic>/<strokedir>/<new_file_name>");
  67.  
  68.  
  69. // Create zones
  70. for (i = 0; i < Items.count(); ++i)
  71. {
  72.     item = Items.get(i);
  73.  
  74.     note = item.getVal("note");
  75.  
  76.     RR = parseInt(item.rr) - 1;
  77.     Direction = parseInt(item.strokedirNum);
  78.     String = parseInt(item.stringNum);
  79.     Dynamic = parseInt(item.dynamicNum);
  80.  
  81.     item.max_vel =
  82.     item.min_vel = 1 + RR*2 + Direction + String*4  + Dynamic*24;
  83.  
  84.     // if (item.articulation != "Sustain" &&
  85.     //     item.articulation != "E1") continue;
  86.  
  87.     item.low_note =
  88.     item.high_note = item.noteNum;
  89. }
Advertisement
Add Comment
Please, Sign In to add comment