elanhickler

item centric scripting engine

May 19th, 2016
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 6.39 KB | None | 0 0
  1. class Item
  2.     bool discard()
  3.  
  4.     bool online(bool on_off)
  5.     bool missing()
  6.     bool show(bool on_off)
  7.     bool selected(bool on_off)
  8.     bool hasDuplicate()
  9.  
  10.     int duplicateCounter() // 0-base counter for the item's "duplicate" id
  11.     string getFilename()
  12.     int getFileSz()
  13.     string getRelFilepath()
  14.     string getAbsFilepath()
  15.     srting getRelDir()
  16.     string getAbsDir()
  17.     string getExt()
  18.    
  19.     void export()
  20.     setExportFilepath(string path) // by default equal to original directory + itemname
  21.     setExportBitdepth(int bits) // by default equal to original bitdepth
  22.     setExportSamplerate(int rate) // by default equal to original smaplerate
  23.  
  24.     double getSourceStart()
  25.     double setSourceStart(double time, bool adjust_contents = true)
  26.     double getSourceEnd()
  27.     double setSourceEnd(double time, bool adjust_contents = false)
  28.     dougle getLength()
  29.     dougle setLength(double time, bool adjust_contents = false)
  30.  
  31.     int bitdepth()
  32.     int samplerate()
  33.  
  34.     string getName()
  35.     void setName(string name) // by default equal to filename
  36.     void setSortName // by default equal to nam
  37.     void setDisplayText // by default equal to name
  38.     Color getTextColor()
  39.     void setTextColor(Color color) // black by default
  40.    
  41.     Envelope getEnvelope(int index)
  42.     class Envelope
  43.         string getName()
  44.         setName(string name)
  45.         int id()
  46.         string getTarget()
  47.         void setTarget(string target)
  48.         class Point
  49.             int id()
  50.             void set(double pos, double val, [int shape, double tens])
  51.             double getPos()
  52.             void setPos(double p)
  53.             double getVal()
  54.             void setVal(double v)
  55.             int getShape()
  56.             void setShape(double s)
  57.             double getTens()
  58.             void setTens(double t)
  59.    
  60.     Marker getMarker(int index)
  61.     class Marker
  62.         int id()
  63.         string getName()
  64.         void setName(string name)
  65.         double getPos()
  66.         void setPos(double p)
  67.         double getLength() // marker with non-zero length becomes a region
  68.         void setLength(double len)
  69.         void embed(bool on_off) // if true, marker is embedded in the wav
  70.         void show(bool on_off)
  71.         Color getColor()
  72.         void setColor(Color color)
  73.    
  74.     void setTag(string name, string text)  
  75.     void removeTag(string name)
  76.     void setTagAlias(string name, string alias) // equal to tag name by default
  77.     string getTagText(string name)  
  78.     void setTagText(string name, string text) // equal to value by default
  79.     var getTagValue(string name)
  80.     void setTagValue(string name, var value) // 0 by default
  81.     Color getTagColor(string name)
  82.     void setTagColor(string name, Color color)
  83.    
  84.     void addMultitag(string name)
  85.     void removeMultiTag(string name)
  86.     void addToMultitag(string name, string arguments)
  87.     bool MultitagHas(string name, string tag)
  88.  
  89.     double getGain()
  90.     void setGain(double val)
  91.     double getRate()
  92.     void setRate(double val)
  93.     double getPreroll()
  94.     void setPreroll(double val)
  95.     double getPostroll()
  96.     void setPostroll(double val)
  97.     string getTree()
  98.     void setTree(string tree_directory)
  99.  
  100. class List
  101.     columns
  102.  
  103. class File
  104.     move(item, directory)
  105.     rename(item, filename)
  106.     copy(item, filepath)
  107.     item duplicate(item) // adds a copy of an item, return item
  108.     delete(item)
  109.     export(item) // reads export settings from item and renders file
  110.     exportMini(item, double minlen, double maxlen) // renders file except with render settings that produce the smallest possible file, min/max length dictates length of wav file to create.
  111.     item import(filepath) // return item
  112.     item create(filepath, length, samplerate, bitdepth, length, pitch) // return item
  113.     create(itemname) // adds an item to the project without creating a file and status is "missing/offline" and path is blank
  114.     assign(item, filepath) // assigns filepath to item. if file is not found, status of item is missing/offline
  115.     exists(filepath) // check if file exists
  116.  
  117. InstrumentValueList = createValueList("Cello=1,Violin=2");
  118.  
  119. for each (var item in ITEMS) {
  120.     item.tag("name").text = item.name;
  121.  
  122.     item.tag("note").text = GetMidiNoteFromText(item.name);
  123.     item.tag("note").value = MidiNoteToNum(item.tag("note")); // sets internal value for sorting purposes
  124.  
  125.     item.gain(10); // set item gain
  126.     item.tag("gain").text = item.gain(); // get item gain and send text value to gain tag
  127.  
  128.     item.tag("rr").value = regex.replace(item.name, "_(\d+)", "$1");
  129.  
  130.     item.tag("status").text = "discard"; // add this tag just for fun
  131.     item.tag("status").remove(); // now remove the tag... can an object remove itself like this?
  132.  
  133.     if (item.tag("instrument") == "Violin") item.multitag("quality") = "loud,bad";
  134.  
  135.     item.tag("instrument").text = regex.replace(item.name, "((.*?)_", "$1");
  136.     item.tag("instrument").value = InstrumentValueList.getValue(item.tag("instrument"));
  137.  
  138.     item.tag("project").text = "Orchestral Strings";
  139.  
  140.     item.tree("project/instrument/~rr/gain")
  141.  
  142.     if (item.multitag("quality").find("bad")) {
  143.         item.discard();
  144.         item.displaytext = item.name + " (discard)";
  145.         item.textcolor = color.red;
  146.     }
  147. }
  148.  
  149. LIST.addcolumn("Name, Instrument, gain, note, rr, multitag");
  150. LIST.displayExt(false); //false by default
  151.  
  152. MyItemList = GetItemsInTree("Violin"); // Can we search every item to see if they in the violin group?
  153. MyItemList = GetItemsInTree("Orchestral Strings/Violin"); // This is a more specific search.
  154. for each (var item : MyItemList) { item.gain = 5; } // I set all items in the violin group to have 5 gain.
  155. for each (var item : ITEMS) { if (item.gain > 5) item.tag("gain").color = color.green; } // color the text of gain column green
  156.  
  157. /*
  158. Tree view looks like this:
  159.  
  160.    project Orchestral Strings
  161. instrument   Cello
  162.         rr     2
  163.       gain       10
  164.                    Cell_C3_rr2.wav
  165. instrument   Violin
  166.       gain     5
  167.                  Violin_C4.wav
  168.  
  169. List view looks like this:
  170.  
  171. name                 |  instrument |  gain  | note  |  rr  |  quality
  172. Cello_C3_rr2              Cello        10      C3      2       
  173. Violin_C4 (discard)       Violin       5       C4            loud,bad
  174.  
  175. Internally, looks like this:
  176. name                     |  instrument |  gain  | note  |  rr  |  quality  
  177. Cello_C3_rr2.wav                1          10      48      2    
  178. Violin_C4.wav (discard)         2          5       60             loud,bad
  179. */
  180.  
  181.  
  182. //how the tree might be created in C++
  183.  
  184. void CreateTree() {
  185.     for (const auto item : items) {
  186.         for (const auto grp : groups) {
  187.             if (!grp[0] == "~" && item.getTag("grp").empty()) tag = "*ERROR*/";
  188.             else tag = item.getTag(grp) + "/";
  189.             directory += tag;
  190.             // if you try to get a tag that does not exist for the item, maybe default can be "*ERROR*"
  191.         }
  192.         AddToTree(directory, item)
  193.     }
  194. }
Advertisement
Add Comment
Please, Sign In to add comment