Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // set properties by extracting from filename with regex;
- Items.setWithRegex("fileName", "articulation", "([^`]*)");
- Items.setWithRegex("fileName", "distance", "distance=(\\w+)[`.]");
- Items.setWithRegex("fileName", "speed", "speed=(\\w+)[`.]");
- Items.setWithRegex("fileName", "dynamic", "vl=(\\w+)[`.]");
- Items.setWithRegex("fileName", "string", "str=(\\w+)[`.]");
- Items.setWithRegex("fileName", "fret", "fret=(\\d+)[`.]");
- Items.setWithRegex("fileName", "note", "n=(.*?)[`.]");
- Items.setWithRegex("fileName", "strokedir", "stroke=(\\w+)[`.]");
- Items.setWithRegex("fileName", "rr", "rr=(\\d+)[`.]");
- // create articulation groups by translating multiple key words to one word
- ArticulationGroupTranslator = Items.createTranslator(
- "Harmonic,Mute,PalmMute,Resonance,Strum,Sustain=Core",
- "PalmMuteRel,HarmonicRel,Release=Releases",
- "FX", /*default*/
- "SlideUp,SlideDown,PullOff,HammerOn=Legato",
- );
- Items.setWithTranslator("articulation", "group");
- StringLookup = ["E1", "A1", "D2", "G2", "B2", "E3"];
- StrokeLookup = ["dn", "up"];
- DynamicLookup = ["soft", "med", "loud"];
- // calculate note from fret and string and get numerical values for properties
- for (i = 0; i < Items.count(); ++i)
- {
- item = Items.get(i);
- if (item.hasProperty("string"))
- item.stringNum = StringLookup.indexOf(item.string);
- if (item.hasProperty("strokedir"))
- item.strokedirNum = StrokeLookup.indexOf(item.strokedir);
- if (item.hasProperty("dynamic"))
- item.dynamicNum = DynamicLookup.indexOf(item.dynamic);
- if (item.hasProperty("fret"))
- item.noteNum = item.fret + Midi.num(item.stringNum);
- else if (item.hasProperty("note"))
- item.noteNum = Midi.num(item.note);
- }
- // set "new file name" property with a tag script
- Items.setWithTagScript("new_file_name",
- "<articulation>[_<speed>][_<distance>][_str<stringNum>][_<dynamic>][_<note>][_<strokedir>][_rr<rr>]");
- for (i = 0; i < Items.count(); ++i)
- {
- item = Items.get(i);
- // Set "NewName" tab to see if we are renaming correcting
- item.new_file_dir = item.fileDir+ "/" + item.group + "/" + item.articulation + "/";
- new_file_path = item.new_file_dir + item.new_file_name + "." + item.fileExt;
- item.new_file_path = new_file_path;
- // Create dummy files to test results (UNCOMMENT ONE)
- //File.createFile(item.fileDir() + "/../dummy/" + item.fileName() );
- // Move/rename files
- //item.filePath(new_file_path);
- }
- Items.setWithTagScript("new_file_name",
- "<articulation>[_<speed>][_<distance>][_str<stringNum>][_<dynamic>][_<note>][_<strokedir>][_rr<rr>]");
- // Set tree structure
- //Items.setWithTagScript("path","<group>/<articulation>/<dynamic>/<speed>/<distance>/<strokedir>/<fileName>");
- Items.setWithTagScript("path","<group>/<articulation>/<dynamic>/<strokedir>/<new_file_name>");
- // Create zones
- for (i = 0; i < Items.count(); ++i)
- {
- item = Items.get(i);
- note = item.getVal("note");
- RR = parseInt(item.rr) - 1;
- Direction = parseInt(item.strokedirNum);
- String = parseInt(item.stringNum);
- Dynamic = parseInt(item.dynamicNum);
- item.max_vel =
- item.min_vel = 1 + RR*2 + Direction + String*4 + Dynamic*24;
- // if (item.articulation != "Sustain" &&
- // item.articulation != "E1") continue;
- item.low_note =
- item.high_note = item.noteNum;
- }
Advertisement
Add Comment
Please, Sign In to add comment