blc - Simple program for rendering QLC+ workspaces properly/without crashing. Developed into BLC2.

git clone https://benconnors.ca/git-repos/blc

About | Log | Files | Refs

prstore.py (1178B) - raw


      1 #!/usr/bin/env python3
      2 
      3 """Pre-render functions into a file. 
      4 
      5 Uses the pickle module to serialize the render.
      6 
      7 There are some caveats to this:
      8 
      9 - Audio filepaths are stored absolutely, so this should be run on the system that will be 
     10   running the show, or take care to ensure that the directory structure is identical
     11 - Audio lengths are ignored
     12 """
     13 
     14 import pickle
     15 import sys
     16 
     17 from blc.workspace import Workspace, PreRenderable
     18 
     19 if len(sys.argv) not in (3,4,):
     20     print("Usage: %s <workspace file> <prerenderable id> [output file]" % sys.argv[0])
     21     sys.exit(1)
     22 
     23 minnx = 10
     24 
     25 w = Workspace.load(sys.argv[1])
     26 func = w.functions[int(sys.argv[2])]
     27 if not issubclass(type(func), PreRenderable):
     28     raise ValueError("The given function may not be rendered")
     29 
     30 if len(sys.argv) == 4:
     31     ofname = sys.argv[3] 
     32 else:
     33     ofname = func.name+".pickle"
     34     print("Storing to", ofname)
     35 
     36 with open(ofname, "wb") as f:
     37     print("Rendering", func.name)
     38     p = pickle.Pickler(f)
     39     try:
     40         render = func.render_all(minnx=minnx)
     41     except ValueError:
     42         print("Cannot render", func.name)
     43     else:
     44         print("Storing render")
     45         p.dump(render)
     46         print("Done!")