elanhickler

next guitar script

Sep 5th, 2016
160
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", ArticulationGroupTranslator);
  20.  
  21. // setup name-value pairs
  22. MakeValuePairsForProperty("string", "E1,A1,D2,G2,B2,E3")
  23. MakeValuePairsForProperty("strokedir", "dn,up")
  24. MakeValuePairsForProperty("dynamic", "soft,med,loud");
  25.  
  26. // calculate note from fret and string and get numerical values for properties
  27. for (i = 0; i < Items.count(); ++i)
  28. {
  29.     item = Items.get(i);
  30.  
  31.     if (item.hasProperty("fret"))
  32.         item.noteNum = item.fret + Midi.num(item.lookup("string"));
  33.     else if (item.hasProperty("note"))
  34.         item.noteNum = Midi.num(item.note);
  35. }
  36.  
  37. // set "new file name" property with a tag script
  38. Items.setWithTagScript("new_file_name",
  39.     "<articulation>[_<speed>][_<distance>][_str<string#>][_<dynamic>][_<note>][_<strokedir>][_rr<rr>]");
  40.  
  41. for (i = 0; i < Items.count(); ++i)
  42. {
  43.     item = Items.get(i);
  44.  
  45.     // Set "NewName" tab to see if we are renaming correcting
  46.     item.new_file_dir = item.fileDir + "/" + item.group + "/" + item.articulation + "/";
  47.     new_file_path = item.new_file_dir + item.new_file_name + "." + item.fileExt;
  48.     item.new_file_path = new_file_path;
  49.  
  50.     /*UNCOMMENT ONE*/
  51.     // Create dummy files to test results
  52.     //File.createFile(item.fileDir() + "/../dummy/" + item.fileName() );
  53.     // Move/rename files
  54.     //item.filePath(new_file_path);
  55. }
  56.  
  57. // Set tree structure
  58. //Tree.set("group/articulation/dynamic/speed/distance/strokedir/fileName");
  59. Tree.set("group/articulation/dynamic/strokedir/new_file_name");
  60.  
  61. // Create zones
  62. for (i = 0; i < Items.count(); ++i)
  63. {
  64.     item = Items.get(i);
  65.  
  66.     RR = parseInt(item.rr) - 1;
  67.     Direction = parseInt(item.strokedirNum);
  68.     String = parseInt(item.stringNum);
  69.     Dynamic = parseInt(item.dynamicNum);
  70.  
  71.     item.max_vel =
  72.     item.min_vel = 1 + RR*2 + Direction + String*4  + Dynamic*24;
  73.  
  74.     // if (item.articulation != "Sustain" &&
  75.     //     item.articulation != "E1") continue;
  76.  
  77.     item.low_note =
  78.     item.high_note = item.lookup("note");
  79. }
Advertisement
Add Comment
Please, Sign In to add comment