Beispiel #1
0
 def __init__(self,file):
    if (os.path.exists(file) == False):
       v = vusionerror.vusionerror();
       v.fatal("Config","Cannot load configuration file.");
    config = cfgparser.ConfigParser();
    config.readfp(open(file));
    
    self.window = bool(config.getboolean("Window","single_mode"));
    self.midi = int(config.get("MIDI","device"));
    self.keyboard = {
       str(config.get("Keyboard","viewer_live")) : 'live',
       str(config.get("Keyboard","viewer_video")) : 'video',
       str(config.get("Keyboard","viewer_image")) : 'image',
       str(config.get("Keyboard","viewer_surface")) : 'surface',
       str(config.get("Keyboard","viewer_play_pause")) : 'playpause',
       str(config.get("Keyboard","viewer_stop")) : 'stop',
       str(config.get("Keyboard","display_quit")) : 'quit',
       str(config.get("Keyboard","display_fullscreen")) : 'fullscreen'
    }
    self.live = {
       'driver': str(config.get("Live","driver")),
       'device': str(config.get("Live","device")),
       'input': str(config.get("Live","input")),
       'freq': str(config.get("Live","freq"))
    }
    self.video = {
       'driver': str(config.get("Video","driver")),
       'seek_seconds': str(config.get("Video","seek_seconds")),
       'play_audio': bool(config.getboolean("Video","play_audio")),
       'infinite_loop': bool(config.getboolean("Video","infinite_loop")),
       'auto_start': bool(config.getboolean("Video","auto_start"))
    }
Beispiel #2
0
    def __init__(self, file):
        if (os.path.exists(file) == False):
            v = vusionerror.vusionerror()
            v.fatal("Config", "Cannot load configuration file.")
        config = cfgparser.ConfigParser()
        config.readfp(open(file))

        self.window = bool(config.getboolean("Window", "single_mode"))
        self.midi = int(config.get("MIDI", "device"))
        self.keyboard = {
            str(config.get("Keyboard", "viewer_live")): 'live',
            str(config.get("Keyboard", "viewer_video")): 'video',
            str(config.get("Keyboard", "viewer_image")): 'image',
            str(config.get("Keyboard", "viewer_surface")): 'surface',
            str(config.get("Keyboard", "viewer_play_pause")): 'playpause',
            str(config.get("Keyboard", "viewer_stop")): 'stop',
            str(config.get("Keyboard", "display_quit")): 'quit',
            str(config.get("Keyboard", "display_fullscreen")): 'fullscreen'
        }
        self.live = {
            'driver': str(config.get("Live", "driver")),
            'device': str(config.get("Live", "device")),
            'input': str(config.get("Live", "input")),
            'freq': str(config.get("Live", "freq"))
        }
        self.video = {
            'driver': str(config.get("Video", "driver")),
            'seek_seconds': str(config.get("Video", "seek_seconds")),
            'play_audio': bool(config.getboolean("Video", "play_audio")),
            'infinite_loop': bool(config.getboolean("Video", "infinite_loop")),
            'auto_start': bool(config.getboolean("Video", "auto_start"))
        }
Beispiel #3
0
    def __init__(self, dimensions, driver, seekOffset, playAudio, loop,
                 AutoPlay):
        self.dimensions = dimensions
        self.seekOffset = float(seekOffset)
        self.playAudio = bool(playAudio)
        self.InfiniteLoop = int(loop)
        self.AutoPlay = bool(AutoPlay)

        try:
            self.driver = {"pygame": "pygame"}
        except KeyError:
            v = vusionerror.vusionerror()
            v.warning("Video", "Driver not supported, defaulting to pygame")
            self.driver = "pygame"
Beispiel #4
0
 def createSurface(self,image):
    if (os.path.exists(image.split("?")[0]) == False):
       v = vusionerror.vusionerror();
       v.warning("Image","Image specified does not exist");
    else:
       if (len(image.split("?")) > 1):
          posx = int(image.split("?")[1].split("x")[0]);
          posy = int(image.split("?")[1].split("x")[1]);
          image = image.split("?")[0];
       else:
          posx = 0;
          posy = 0;
       self.surfaces[len(self.surfaces)] = (pygame.image.load(image),(posx,posy));
       return len(self.surfaces)-1;
Beispiel #5
0
   def __init__(self,dimensions,driver,interfaces):
      if len(interfaces) > 0:
         self.interfaces = interfaces;

      self.dimensions = dimensions;
       
      # Make sure its a proper driver
      try:
         self.driver = {
            'video4linux': "v4l",            
         }[driver];
      except KeyError:
         v = vusionerror.vusionerror();
         v.warning("Live","Driver not supported, defaulting to v4l");
         self.driver = "v4l";         
Beispiel #6
0
    def __init__(self, dimensions, driver, interfaces):
        if len(interfaces) > 0:
            self.interfaces = interfaces

        self.dimensions = dimensions

        # Make sure its a proper driver
        try:
            self.driver = {
                'video4linux': "v4l",
            }[driver]
        except KeyError:
            v = vusionerror.vusionerror()
            v.warning("Live", "Driver not supported, defaulting to v4l")
            self.driver = "v4l"
Beispiel #7
0
 def createSurface(self, image):
     if (os.path.exists(image.split("?")[0]) == False):
         v = vusionerror.vusionerror()
         v.warning("Image", "Image specified does not exist")
     else:
         if (len(image.split("?")) > 1):
             posx = int(image.split("?")[1].split("x")[0])
             posy = int(image.split("?")[1].split("x")[1])
             image = image.split("?")[0]
         else:
             posx = 0
             posy = 0
         self.surfaces[len(self.surfaces)] = (pygame.image.load(image),
                                              (posx, posy))
         return len(self.surfaces) - 1
Beispiel #8
0
 def __init__(self,dimensions,driver,seekOffset,playAudio,loop,AutoPlay):
    self.dimensions = dimensions;
    self.seekOffset = float(seekOffset);
    self.playAudio = bool(playAudio);
    self.InfiniteLoop = int(loop);
    self.AutoPlay = bool(AutoPlay);
    
    try:
       self.driver = {
          "pygame" : "pygame"
       }
    except KeyError:
       v = vusionerror.vusionerror();
       v.warning("Video","Driver not supported, defaulting to pygame");
       self.driver = "pygame";
Beispiel #9
0
 def __init__(self,file):
    if (os.path.exists(file) == False):
       v = vusionerror.vusionerror();
       v.fatal("Show","Cannot load Vusion show.");
    else:
       self.file = xml.dom.minidom.parse(file);
       
       # Meta Data
       for node in self.file.getElementsByTagName("metadata"):
          self.author = str(node.getElementsByTagName("author")[0].childNodes[0].data);
          self.title = str(node.getElementsByTagName("title")[0].childNodes[0].data);
          self.description = str(node.getElementsByTagName("description")[0].childNodes[0].data);
       
       # Dimensions
       for node in self.file.getElementsByTagName("dimensions"):
          self.fullscreen = {
             "true" : True,
             "false" : False
          }[node.getAttribute("fullscreen")];
          
          d = node.childNodes[0].data;
          self.dimensions = (int(d.split("x")[0]),int(d.split("x")[1]));
       
       # Defaults   
       for node in self.file.getElementsByTagName("default"):
          gamma = node.getElementsByTagName("gamma")[0];
          self.defaults["gamma"] = float(gamma.getAttribute("all")); 
       
          self.defaults["transition"] = int(node.getElementsByTagName("transition")[0].getAttribute("value"));
          
          for surface in node.getElementsByTagName("surface"): 
             if surface.getAttribute("n") == "a":
                self.defaults["surface_a"] = (str(surface.getAttribute("type")),str(surface.getAttribute("file")));
             else:
                self.defaults["surface_b"] = (str(surface.getAttribute("type")),str(surface.getAttribute("file")));
       
       # MIDI
       for node in self.file.getElementsByTagName("midi"):
          # Note On/Off commands
          for node2 in node.getElementsByTagName("note"):
               self.notes[int(node2.getAttribute("c"))][int(node2.getAttribute("n"))] = str(node2.getAttribute("action"));
          
          # CC
          for node2 in node.getElementsByTagName("cc"):
             self.cc[int(node2.getAttribute("c"))][int(node2.getAttribute("n"))] = str(node2.getAttribute("change"));
    
    self.file = None;
Beispiel #10
0
 def createSurface(self, video, surface, rect):
     if (os.path.exists(video) == False):
         v = vusionerror.vusionerror()
         v.warning("Video", "Video specified does not exist")
         return False
     else:
         self.surfaces[len(self.surfaces)] = pygame.movie.Movie(video)
         i = len(self.surfaces) - 1
         self.surfaces[i].set_display(surface, rect)
         self.surfaces[i].stop()
         self.surfaces[i].rewind()
         if self.AutoPlay == True:
             if self.InfiniteLoop == True:
                 self.surfaces[i].play(-1)
             else:
                 self.surfaces[i].play()
         if self.playAudio == False:
             self.surfaces[i].set_volume(0.0)
         return i
Beispiel #11
0
 def createSurface(self,video,surface,rect):
    if (os.path.exists(video) == False):
       v = vusionerror.vusionerror();
       v.warning("Video","Video specified does not exist");
       return False;
    else:
       self.surfaces[len(self.surfaces)] = pygame.movie.Movie(video);
       i = len(self.surfaces) - 1;
       self.surfaces[i].set_display(surface,rect);
       self.surfaces[i].stop();
       self.surfaces[i].rewind();
       if self.AutoPlay == True:
          if self.InfiniteLoop == True:
             self.surfaces[i].play(-1);
          else:
             self.surfaces[i].play();
       if self.playAudio == False:
          self.surfaces[i].set_volume(0.0);
       return i;
Beispiel #12
0
 def process_data(self):
     # Open /tmp/vusion.PID
     if os.path.exists("/tmp/vusion." + str(self.pid)):
         # read and do action
         action = file("/tmp/vusion." + str(self.pid), 'r')
         for line in action:
             l = line.strip()
             if l.split(":")[0] == "surface":
                 if int(l.split(":")[1]) < 4:
                     self.surfaces['active'] = int(l.split(":")[1])
                 else:
                     v = vusionerror.vusionerror()
                     v.warning('GUI', 'Surface out of range')
             if l.split(":")[0] == "live":
                 i = self.live.createSurface(int(l.split(":")[1]))
                 self.surfaces[self.surfaces['active']] = ("live", i)
         action.close()
         action = file("/tmp/vusion." + str(self.pid), 'w')
         action.write("")
         action.close()
Beispiel #13
0
 def process_data(self):
    # Open /tmp/vusion.PID
    if os.path.exists("/tmp/vusion." + str(self.pid)):
       # read and do action
       action = file("/tmp/vusion." + str(self.pid),'r');
       for line in action:
          l = line.strip();
          if l.split(":")[0] == "surface":
             if int(l.split(":")[1]) < 4:
                self.surfaces['active'] = int(l.split(":")[1]);
             else:
                v = vusionerror.vusionerror();
                v.warning('GUI','Surface out of range');
          if l.split(":")[0] == "live":            
             i = self.live.createSurface(int(l.split(":")[1]));
             self.surfaces[self.surfaces['active']] = ("live",i);
       action.close();
       action = file("/tmp/vusion." + str(self.pid),'w');
       action.write("");
       action.close();
Beispiel #14
0
    def __init__(self, file):
        if (os.path.exists(file) == False):
            v = vusionerror.vusionerror()
            v.fatal("Show", "Cannot load Vusion show.")
        else:
            self.file = xml.dom.minidom.parse(file)

            # Meta Data
            for node in self.file.getElementsByTagName("metadata"):
                self.author = str(
                    node.getElementsByTagName("author")[0].childNodes[0].data)
                self.title = str(
                    node.getElementsByTagName("title")[0].childNodes[0].data)
                self.description = str(
                    node.getElementsByTagName("description")
                    [0].childNodes[0].data)

            # Dimensions
            for node in self.file.getElementsByTagName("dimensions"):
                self.fullscreen = {
                    "true": True,
                    "false": False
                }[node.getAttribute("fullscreen")]

                d = node.childNodes[0].data
                self.dimensions = (int(d.split("x")[0]), int(d.split("x")[1]))

            # Defaults
            for node in self.file.getElementsByTagName("default"):
                gamma = node.getElementsByTagName("gamma")[0]
                self.defaults["gamma"] = float(gamma.getAttribute("all"))

                self.defaults["transition"] = int(
                    node.getElementsByTagName("transition")[0].getAttribute(
                        "value"))

                for surface in node.getElementsByTagName("surface"):
                    if surface.getAttribute("n") == "a":
                        self.defaults["surface_a"] = (
                            str(surface.getAttribute("type")),
                            str(surface.getAttribute("file")))
                    else:
                        self.defaults["surface_b"] = (
                            str(surface.getAttribute("type")),
                            str(surface.getAttribute("file")))

            # MIDI
            for node in self.file.getElementsByTagName("midi"):
                # Note On/Off commands
                for node2 in node.getElementsByTagName("note"):
                    self.notes[int(node2.getAttribute("c"))][int(
                        node2.getAttribute("n"))] = str(
                            node2.getAttribute("action"))

                # CC
                for node2 in node.getElementsByTagName("cc"):
                    self.cc[int(node2.getAttribute("c"))][int(
                        node2.getAttribute("n"))] = str(
                            node2.getAttribute("change"))

        self.file = None
Beispiel #15
0
class VusionMIDI:
    notes = None
    MidiIn = None
    parent = None
    v = vusionerror.vusionerror()

    def __init__(self, parent, device, notes, cc):
        pypm.Initialize()
        pypm.CountDevices()
        self.MidiIn = pypm.Input(device)
        self.parent = parent
        self.notes = notes
        self.cc = cc

    def terminate(self):
        pypm.Terminate()

    def listen(self):
        while self.MidiIn.Poll():
            MidiData = self.MidiIn.Read(1)

            self.v.notice(
                "MIDI In", "channel: " + str(MidiData[0][0][0]) + " note:" +
                str(MidiData[0][0][1]) + " value: " + str(MidiData[0][0][2]))

            # Note Data
            try:
                action = self.notes[MidiData[0][0][0] - 143][MidiData[0][0][1]]
                print action
                if action.split("(")[0] == "quit":
                    self.parent.quit()
                elif action.split("(")[0] == "live.capture_video":
                    self.parent.live.capture_video()
                elif action.split("(")[0] == "video.control_playpause":
                    self.parent.video.control_playpause(
                        action.split("(")[1].replace(")", "").replace(
                            "?",
                            str(self.parent.surfaces[
                                self.parent.trigger.surface][1])))
                elif action.split("(")[0] == "video.control_stop":
                    self.parent.video.control_stop(
                        action.split("(")[1].replace(")", "").replace(
                            "?",
                            str(self.parent.surfaces[
                                self.parent.trigger.surface][1])))
                elif action.split("(")[0] == "video.control_seek_forward":
                    self.parent.video.control_seek_forward(
                        action.split("(")[1].replace(")", "").replace(
                            "?",
                            str(self.parent.surfaces[
                                self.parent.trigger.surface][1])))
                elif action.split("(")[0] == "video.control_seek_backward":
                    self.parent.video.control_seek_backward(
                        action.split("(")[1].replace(")", "").replace(
                            "?",
                            str(self.parent.surfaces[
                                self.parent.trigger.surface][1])))
                elif action.split("(")[0] == "trigger.live":
                    self.parent.trigger.live(
                        action.split("(")[1].replace(")", ""))
                elif action.split("(")[0] == "trigger.video":
                    self.parent.trigger.video(
                        action.split("(")[1].replace(")", ""))
                elif action.split("(")[0] == "trigger.image":
                    self.parent.trigger.live(
                        action.split("(")[1].replace(")", ""))
                elif action.split("(")[0] == "trigger.select_surface_a":
                    self.parent.trigger.select_surface_a()
                elif action.split("(")[0] == "trigger.select_surface_b":
                    self.parent.trigger.select_surface_b()
            except KeyError:
                pass

            # CC Data
            try:
                action = self.cc[MidiData[0][0][0] - 175][MidiData[0][0][1]]
                if action == "transition":
                    self.parent.transition(MidiData[0][0][2])
                elif action == "gamma":
                    self.parent.gamma_all(MidiData[0][0][2])
            except KeyError:
                pass