def __init__(self, pktmax, vw, vh, type): self.pktmax = pktmax self.realwidth, self.realheight = vw, vh if type <> 'rgb': raise 'Incorrent video data type', type self.type = type self.width = vw self.height = vh # # Open dummy window # gl.foreground() gl.noport() self.wid = gl.winopen('DisplayVideoIn') self.x0 = 0 self.x1 = self.x0 + self.width - 1 self.y0 = 0 self.y1 = self.y0 + self.height - 1 # Compute # full lines per packet self.lpp = pktmax / self.linewidth() if self.lpp <= 0: raise 'No lines in packet', self.linewidth() self.pktsize = self.lpp*self.linewidth() self.data = None self.old_data = None self.dataoffset = 0 self.lpos = 0 self.hints = 0
def main(): gl.foreground() gl.noport() #gl.prefposition(700, 850, 950, 970) wid = gl.winopen('audio demo') # panels = panel.defpanellist('apanel.s') # XXX p = panels[0] p.playbackbutton.back = p p.recordbutton.back = p p.sample = '' # def quit(a): sys.exit(0) # p.quitbutton.downfunc = quit # def playback(a): p = a.back gain = int(255.0 * p.outputgain.val) a.val = 1.0 a.fixact() panel.drawpanel() audio.setoutgain(gain) audio.write(p.sample) audio.setoutgain(0) a.val = 0.0 a.fixact() # p.playbackbutton.downfunc = playback # def record(a): p = a.back size = int(10.0 * 8192.0 * p.recordsize.val) a.val = 1.0 a.fixact() panel.drawpanel() audio.setoutgain(0) p.sample = audio.read(size) a.val = 0.0 a.fixact() # p.recordbutton.downfunc = record # while 1: act = panel.dopanel()
# Live video input from display class.
G.drawqueue = [] # Windows that need WE_REDRAW G.windowmap = {} # Map window id to window object G.windowmap['0'] = None # For convenience G.focus = None # Input focus G.fg = BLACK # Foreground color G.bg = WHITE # Background color G.def_size = 0, 0 # Default window size G.def_pos = 0, 0 # Default window position # G.size = DEF_SIZE G.font = fm.findfont(DEF_FONT).scalefont(G.size) # Initialize GL # gl.foreground() gl.noport() dummygid = gl.winopen('') # Ask for all sorts of events # # Both REDRAW (= resize and/or redraw!) and INPUTCHANGE are implicitly queued #qdevice(REDRAW) #qdevice(INPUTCHANGE) # # Keyboard gl.qdevice(KEYBD) gl.qdevice(LEFTARROWKEY) gl.qdevice(RIGHTARROWKEY) gl.qdevice(UPARROWKEY) gl.qdevice(DOWNARROWKEY) gl.qdevice(LEFTALTKEY)
G.windowmap = {} # Map window id to window object G.windowmap["0"] = None # For convenience G.focus = None # Input focus G.fg = BLACK # Foreground color G.bg = WHITE # Background color G.def_size = 0, 0 # Default window size G.def_pos = 0, 0 # Default window position # G.size = DEF_SIZE G.font = fm.findfont(DEF_FONT).scalefont(G.size) # Initialize GL # gl.foreground() gl.noport() dummygid = gl.winopen("") # Ask for all sorts of events # # Both REDRAW (= resize and/or redraw!) and INPUTCHANGE are implicitly queued # qdevice(REDRAW) # qdevice(INPUTCHANGE) # # Keyboard gl.qdevice(KEYBD) gl.qdevice(LEFTARROWKEY) gl.qdevice(RIGHTARROWKEY) gl.qdevice(UPARROWKEY) gl.qdevice(DOWNARROWKEY) gl.qdevice(LEFTALTKEY)