rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
for n in undo.childNodes: if n.nodeType == xml.Node.ELEMENT_NODE:
for node in undo.childNodes: if node.nodeType == xml.Node.ELEMENT_NODE:
def LoadFromFile(uri): """ Loads a project from a save file on disk. uri The filesystem location of the project file to load. Currently only file:// URIs are considered valid. """ p = Project() (scheme, domain, projectfile, params, query, fragment) = urlparse.urlparse(uri, "file") if scheme != "file": # raise "The UR...
cmdList.append(str(n.getAttribute("object"))) cmdList.append(str(n.getAttribute("function"))) cmdList.extend(LoadListFromXML(n)) p._Project__savedUndoStack.append(cmdList)
cmdList.append(str(node.getAttribute("object"))) cmdList.append(str(node.getAttribute("function"))) cmdList.extend(LoadListFromXML(node)) project._Project__savedUndoStack.append(cmdList)
def LoadFromFile(uri): """ Loads a project from a save file on disk. uri The filesystem location of the project file to load. Currently only file:// URIs are considered valid. """ p = Project() (scheme, domain, projectfile, params, query, fragment) = urlparse.urlparse(uri, "file") if scheme != "file": # raise "The UR...
for n in redo.childNodes: if n.nodeType == xml.Node.ELEMENT_NODE:
for node in redo.childNodes: if node.nodeType == xml.Node.ELEMENT_NODE:
def LoadFromFile(uri): """ Loads a project from a save file on disk. uri The filesystem location of the project file to load. Currently only file:// URIs are considered valid. """ p = Project() (scheme, domain, projectfile, params, query, fragment) = urlparse.urlparse(uri, "file") if scheme != "file": # raise "The UR...
cmdList.append(str(n.getAttribute("object"))) cmdList.append(str(n.getAttribute("function"))) cmdList.extend(LoadListFromXML(n)) p._Project__redoStack.append(cmdList) for instr in doc.getElementsByTagName("Instrument"):
cmdList.append(str(node.getAttribute("object"))) cmdList.append(str(node.getAttribute("function"))) cmdList.extend(LoadListFromXML(node)) project._Project__redoStack.append(cmdList) for instrElement in doc.getElementsByTagName("Instrument"):
def LoadFromFile(uri): """ Loads a project from a save file on disk. uri The filesystem location of the project file to load. Currently only file:// URIs are considered valid. """ p = Project() (scheme, domain, projectfile, params, query, fragment) = urlparse.urlparse(uri, "file") if scheme != "file": # raise "The UR...
id = int(instr.getAttribute("id"))
id = int(instrElement.getAttribute("id"))
def LoadFromFile(uri): """ Loads a project from a save file on disk. uri The filesystem location of the project file to load. Currently only file:// URIs are considered valid. """ p = Project() (scheme, domain, projectfile, params, query, fragment) = urlparse.urlparse(uri, "file") if scheme != "file": # raise "The UR...
i = Instrument(p, None, None, None, id) i.LoadFromXML(instr) p.instruments.append(i) if i.isSolo: p.soloInstrCount += 1 for instr in doc.getElementsByTagName("DeadInstrument"):
instr = Instrument(project, None, None, None, id) instr.LoadFromXML(instrElement) project.instruments.append(instr) if instr.isSolo: project.soloInstrCount += 1 for instrElement in doc.getElementsByTagName("DeadInstrument"):
def LoadFromFile(uri): """ Loads a project from a save file on disk. uri The filesystem location of the project file to load. Currently only file:// URIs are considered valid. """ p = Project() (scheme, domain, projectfile, params, query, fragment) = urlparse.urlparse(uri, "file") if scheme != "file": # raise "The UR...
i = Instrument(p, None, None, None, id) i.LoadFromXML(instr) p.graveyard.append(i) i.RemoveAndUnlinkPlaybackbin() return p
instr = Instrument(project, None, None, None, id) instr.LoadFromXML(instrElement) project.graveyard.append(instr) instr.RemoveAndUnlinkPlaybackbin() return project
def LoadFromFile(uri): """ Loads a project from a save file on disk. uri The filesystem location of the project file to load. Currently only file:// URIs are considered valid. """ p = Project() (scheme, domain, projectfile, params, query, fragment) = urlparse.urlparse(uri, "file") if scheme != "file": # raise "The UR...
Loads a project from a Jokosher 0.1 (ZPO) project file into the given project object using the XML document doc.
Loads a project from a Jokosher 0.1 (ZPO) project file into the given project object using the XML document doc. Parameters: project -- Jokosher 0.1 (ZPO) project file. doc -- XML document doc used to load the 0.1 Project into the given 0.2+ Project object. Returns: the loaded Project object.
def LoadFromZPOFile(project, doc): """ Loads a project from a Jokosher 0.1 (ZPO) project file into the given project object using the XML document doc. """ def LoadEventFromZPO(self, node): """ Loads event properties from a Jokosher 0.1 XML node and saves then to the given self object. """ params = node.getElementsByTa...
Loads event properties from a Jokosher 0.1 XML node and saves then to the given self object.
Loads event properties from a Jokosher 0.1 XML node and saves then to the given self object. Parameters: node -- XML node object from which to extract event properties.
def LoadEventFromZPO(self, node): """ Loads event properties from a Jokosher 0.1 XML node and saves then to the given self object. """ params = node.getElementsByTagName("Parameters")[0] LoadParametersFromXML(self, params) try: xmlPoints = node.getElementsByTagName("FadePoints")[0] except IndexError: Globals.debug("Mi...
Loads instrument properties from a Jokosher 0.1 XML node and saves then to the given self object.
Loads instrument properties from a Jokosher 0.1 XML node and saves then to the given self object. Parameters: node -- XML node object from which to extract instrument properties.
def LoadInstrFromZPO(self, node): """ Loads instrument properties from a Jokosher 0.1 XML node and saves then to the given self object. """ params = node.getElementsByTagName("Parameters")[0] LoadParametersFromXML(self, params) #work around because in 0.2 self.effects is a list not a string. self.effects = [] for ev i...
Globals.VERSION = "0.2"
""" The project structure version. Will be useful for handling old save files. """ Globals.VERSION = "0.2"
def LoadInstrFromZPO(self, node): """ Loads instrument properties from a Jokosher 0.1 XML node and saves then to the given self object. """ params = node.getElementsByTagName("Parameters")[0] LoadParametersFromXML(self, params) #work around because in 0.2 self.effects is a list not a string. self.effects = [] for ev i...
for ins in self.instruments: ins.PrepareController()
for instr in self.instruments: instr.PrepareController()
def Play(self, movePlayhead = True, recording=False): '''Set all instruments playing''' if len(self.instruments) > 0: Globals.debug("play() in Project.py") Globals.debug("current state:", self.mainpipeline.get_state(0)[1].value_name)
""" GStreamer End Of Stream handler. It is connected to eos on mainpipeline while export is taking place.
""" GStreamer End Of Stream handler. It is connected to eos on mainpipeline while export is taking place. Parameters: bus -- reserved for GStreamer callbacks, don't use it explicitly. message -- reserved for GStreamer callbacks, don't use it explicitly.
def TerminateExport(self, bus=None, message=None): """ GStreamer End Of Stream handler. It is connected to eos on mainpipeline while export is taking place. """ if not self.IsExporting: return else: self.IsExporting = False self.Stop() #NULL is required because elements will be destroyed when we delete them self.main...
""" Returns tuple with number of seconds done, and number of total seconds.
""" Returns a tuple with the number of seconds exported and the number of total seconds.
def GetExportProgress(self): """ Returns tuple with number of seconds done, and number of total seconds. """ if self.IsExporting: try: #total = self.mainpipeline.query_duration(gst.FORMAT_TIME)[0] total = self.GetProjectLength() * gst.SECOND cur = self.mainpipeline.query_position(gst.FORMAT_TIME)[0] except gst.QueryErr...
cur = self.mainpipeline.query_position(gst.FORMAT_TIME)[0]
current = self.mainpipeline.query_position(gst.FORMAT_TIME)[0]
def GetExportProgress(self): """ Returns tuple with number of seconds done, and number of total seconds. """ if self.IsExporting: try: #total = self.mainpipeline.query_duration(gst.FORMAT_TIME)[0] total = self.GetProjectLength() * gst.SECOND cur = self.mainpipeline.query_position(gst.FORMAT_TIME)[0] except gst.QueryErr...
if cur > total: total = cur
if current > total: total = current
def GetExportProgress(self): """ Returns tuple with number of seconds done, and number of total seconds. """ if self.IsExporting: try: #total = self.mainpipeline.query_duration(gst.FORMAT_TIME)[0] total = self.GetProjectLength() * gst.SECOND cur = self.mainpipeline.query_position(gst.FORMAT_TIME)[0] except gst.QueryErr...
return (float(cur)/gst.SECOND, float(total)/gst.SECOND)
return (float(current)/gst.SECOND, float(total)/gst.SECOND)
def GetExportProgress(self): """ Returns tuple with number of seconds done, and number of total seconds. """ if self.IsExporting: try: #total = self.mainpipeline.query_duration(gst.FORMAT_TIME)[0] total = self.GetProjectLength() * gst.SECOND cur = self.mainpipeline.query_position(gst.FORMAT_TIME)[0] except gst.QueryErr...
Handler for GStreamer statechange events when the pipline is changing from
Handles GStreamer statechange events when the pipline is changing from
def __PlaybackStateChangedCb(self, bus, message, movePlayhead=True): """ Handler for GStreamer statechange events when the pipline is changing from STATE_READY to STATE_PAUSED. Once STATE_PAUSED has been reached, this function will tell the transport manager to start playing. """ Globals.debug("STATE CHANGED") change_s...
Handler for GStreamer bus messages about the currently reported level
Handles GStreamer bus messages about the currently reported level
def __PipelineBusLevelCb(self, bus, message): """ Handler for GStreamer bus messages about the currently reported level for the project or any of the instruments. """ st = message.structure if st and st.get_name() == "level": if not message.src is self.levelElement: for instr in self.instruments: if message.src is ins...
""" st = message.structure if st and st.get_name() == "level":
Parameters: bus -- reserved for GStreamer callbacks, don't use it explicitly. message -- reserved for GStreamer callbacks, don't use it explicitly. """ struct = message.structure if struct and struct.get_name() == "level":
def __PipelineBusLevelCb(self, bus, message): """ Handler for GStreamer bus messages about the currently reported level for the project or any of the instruments. """ st = message.structure if st and st.get_name() == "level": if not message.src is self.levelElement: for instr in self.instruments: if message.src is ins...
instr.SetLevel(DbToFloat(st["decay"][0]))
instr.SetLevel(DbToFloat(struct["decay"][0]))
def __PipelineBusLevelCb(self, bus, message): """ Handler for GStreamer bus messages about the currently reported level for the project or any of the instruments. """ st = message.structure if st and st.get_name() == "level": if not message.src is self.levelElement: for instr in self.instruments: if message.src is ins...
self.SetLevel(DbToFloat(st["decay"][0]))
self.SetLevel(DbToFloat(struct["decay"][0]))
def __PipelineBusLevelCb(self, bus, message): """ Handler for GStreamer bus messages about the currently reported level for the project or any of the instruments. """ st = message.structure if st and st.get_name() == "level": if not message.src is self.levelElement: for instr in self.instruments: if message.src is ins...
st = message.structure
def __PipelineBusErrorCb(self, bus, message): """ Handler for GStreamer error messages. """ st = message.structure error, debug = message.parse_error() Globals.debug("Gstreamer bus error:", str(error), str(debug)) self.StateChanged("gst-bus-error", str(error), str(debug))
""" Saves the project and its children as an XML file to the path specified by file.
""" Saves the project and its children as an XML file to the path specified by file. Parameters: path -- path to the project file.
def SaveProjectFile(self, path=None): """ Saves the project and its children as an XML file to the path specified by file. """ if not path: if not self.projectfile: raise "No save path specified!" path = self.projectfile if not path.endswith(".jokosher"): path = path + ".jokosher" #sync the transport's mode with the...
e = doc.createElement("Command") e.setAttribute("object", cmd[0]) e.setAttribute("function", cmd[1]) undo.appendChild(e) StoreListToXML(doc, e, cmd[2:], "Parameter")
element = doc.createElement("Command") element.setAttribute("object", cmd[0]) element.setAttribute("function", cmd[1]) undo.appendChild(element) StoreListToXML(doc, element, cmd[2:], "Parameter")
def SaveProjectFile(self, path=None): """ Saves the project and its children as an XML file to the path specified by file. """ if not path: if not self.projectfile: raise "No save path specified!" path = self.projectfile if not path.endswith(".jokosher"): path = path + ".jokosher" #sync the transport's mode with the...
e = doc.createElement("Command") e.setAttribute("object", cmd[0]) e.setAttribute("function", cmd[1]) redo.appendChild(e) StoreListToXML(doc, e, cmd[2:], "Parameter") for i in self.instruments: i.StoreToXML(doc, head) for i in self.graveyard: i.StoreToXML(doc, head, graveyard=True)
element = doc.createElement("Command") element.setAttribute("object", cmd[0]) element.setAttribute("function", cmd[1]) redo.appendChild(element) StoreListToXML(doc, element, cmd[2:], "Parameter") for instr in self.instruments: instr.StoreToXML(doc, head) for instr in self.graveyard: instr.StoreToXML(doc, head, grave...
def SaveProjectFile(self, path=None): """ Saves the project and its children as an XML file to the path specified by file. """ if not path: if not self.projectfile: raise "No save path specified!" path = self.projectfile if not path.endswith(".jokosher"): path = path + ".jokosher" #sync the transport's mode with the...
f = gzip.GzipFile(path +"~", "w") f.write(doc.toprettyxml()) f.close()
gzipfile = gzip.GzipFile(path +"~", "w") gzipfile.write(doc.toprettyxml()) gzipfile.close()
def SaveProjectFile(self, path=None): """ Saves the project and its children as an XML file to the path specified by file. """ if not path: if not self.projectfile: raise "No save path specified!" path = self.projectfile if not path.endswith(".jokosher"): path = path + ".jokosher" #sync the transport's mode with the...
""" Appends the action specified by object onto the relevant undo/redo stack.
""" Appends the action specified by object onto the relevant undo/redo stack. Parameters: object -- action to be added to the undo/redo stack
def AppendToCurrentStack(self, object): """ Appends the action specified by object onto the relevant undo/redo stack. """ if self.__savedUndo and self.__performingUndo: self.__savedRedoStack.append(object) elif self.__savedUndo and self.__performingRedo: self.__savedUndoStack.append(object) elif self.__performingUndo: ...
"""Uses boolean self.unsavedChanges and Undo/Redo to determine if the program needs to save anything on exit
""" Uses boolean self.unsavedChanges and Undo/Redo to determine if the program needs to save anything on exit. Return: True -- there's unsaved changes, undoes or redoes False -- the Project can be safely closed.
def CheckUnsavedChanges(self): """Uses boolean self.unsavedChanges and Undo/Redo to determine if the program needs to save anything on exit """ return self.unsavedChanges or \ len(self.__undoStack) > 0 or \ len(self.__savedRedoStack) > 0
Returns True if there is another undo command in the stack that can be performed, False otherwise.
Whether it's possible to perform an undo operation. Returns: True -- there is another undo command in the stack that can be performed. False -- there are no available undo commands.
def CanPerformUndo(self): """ Returns True if there is another undo command in the stack that can be performed, False otherwise. """ return bool(len(self.__undoStack) or len(self.__savedUndoStack))
Returns True if there is another redo command in the stack that can be performed, False otherwise.
Whether it's possible to perform an redo operation. Returns: True -- there is another redo command in the stack that can be performed. False -- there are no available redo commands.
def CanPerformRedo(self): """ Returns True if there is another redo command in the stack that can be performed, False otherwise. """ return bool(len(self.__redoStack) or len(self.__savedRedoStack))
for i in self.instruments:
for instr in self.instruments:
def ExecuteCommand(self, cmdList): """ This function executes the string cmd from the undo/redo stack. Commands are made up of a list of which the first two items are the object (and it's ID if relevant), and the function to call. The 3rd, 4th, etc. items in the list are the parameters to give to the function when it i...
n = [x for x in i.events if x.id==id]
n = [x for x in instr.events if x.id==id]
def ExecuteCommand(self, cmdList): """ This function executes the string cmd from the undo/redo stack. Commands are made up of a list of which the first two items are the object (and it's ID if relevant), and the function to call. The 3rd, 4th, etc. items in the list are the parameters to give to the function when it i...
n = [x for x in i.graveyard if x.id==id]
n = [x for x in instr.graveyard if x.id==id]
def ExecuteCommand(self, cmdList): """ This function executes the string cmd from the undo/redo stack. Commands are made up of a list of which the first two items are the object (and it's ID if relevant), and the function to call. The 3rd, 4th, etc. items in the list are the parameters to give to the function when it i...
for ev in instr.events: ev.SetSelected(False)
for event in instr.events: event.SetSelected(False)
def ClearEventSelections(self): ''' Clears the selection of any events ''' for instr in self.instruments: for ev in instr.events: ev.SetSelected(False)
""" Sets the time at which the project view should start. start Start time for the view in seconds.
""" Sets the time at which the project view should start. Parameters: start -- start time for the view in seconds.
def SetViewStart(self, start): """ Sets the time at which the project view should start.
""" Sets the scale of the project view.
""" Sets the scale of the project view. Parameters: scale -- view scale in pixels per second.
def SetViewScale(self, scale): """ Sets the scale of the project view. """ self.viewScale = scale self.RedrawTimeLine = True self.StateChanged()
""" Returns the length of the project in seconds.
""" Returns the length of the project. Returns: lenght of the project in seconds.
def GetProjectLength(self): """ Returns the length of the project in seconds. """ length = 0 for instr in self.instruments: for ev in instr.events: size = ev.start + max(ev.duration, ev.loadingLength) length = max(length, size) return length
for ev in instr.events: size = ev.start + max(ev.duration, ev.loadingLength)
for event in instr.events: size = event.start + max(event.duration, event.loadingLength)
def GetProjectLength(self): """ Returns the length of the project in seconds. """ length = 0 for instr in self.instruments: for ev in instr.events: size = ev.start + max(ev.duration, ev.loadingLength) length = max(length, size) return length
""" Creates a new unique ID which can be assigned to an new project object.
""" Creates a new unique ID which can be assigned to an new Project object. Parameters: id -- an unique ID proposal. If it's already taken, a new one is generated. Returns: an unique ID suitable for a new Project.
def GenerateUniqueID(self, id = None): """ Creates a new unique ID which can be assigned to an new project object. """ if id != None: if id in self.___id_list: Globals.debug("Error: id", id, "already taken") else: self.___id_list.append(id) return id counter = 0 while True: if not counter in self.___id_list: self.___i...
"""Sets the volume of the instrument in the range 0..1
""" Sets the volume of an instrument. Parameters: volume - a value in the range [0,1]
def SetVolume(self, volume): """Sets the volume of the instrument in the range 0..1 """ self.volume = volume self.volumeElement.set_property("volume", volume)
""" Note that this sets the current REPORTED level, NOT THE VOLUME!
""" Sets the current REPORTED level, NOT THE VOLUME! Parameters: level -- a value in the range [0,1]
def SetLevel(self, level): """ Note that this sets the current REPORTED level, NOT THE VOLUME! """ self.level = level
""" Checks that the project is valid - i.e. that of the files and images that it references can be found. Returns True if the project is valid, False if not.
""" Checks that the project is valid - i.e. that the files and images it references can be found. Returns: True -- the project is valid. False -- the project contains non-existant files and/or images.
def ValidateProject(self): """ Checks that the project is valid - i.e. that of the files and images that it references can be found.
for ev in instr.events: if (ev.file!=None) and (not os.path.exists(ev.file)) and (not ev.file in unknownfiles): unknownfiles.append(ev.file) if len(unknownfiles)>0 or len(unknownimages)>0:
for event in instr.events: if (event.file!=None) and (not os.path.exists(event.file)) and (not event.file in unknownfiles): unknownfiles.append(event.file) if len(unknownfiles) > 0 or len(unknownimages) > 0:
def ValidateProject(self): """ Checks that the project is valid - i.e. that of the files and images that it references can be found.
Sets the Mode in the Transportmanager. Used to enable Undo/Redo.
Sets the Mode in the Transportmanager. Used to enable Undo/Redo. Parameters: val -- the mode to display the timeline bar: TransportManager.MODE_HOURS_MINS_SECS TransportManager.MODE_BARS_BEATS
def SetTransportMode(self, val): """ Sets the Mode in the Transportmanager. Used to enable Undo/Redo. """ self.temp = self.transport.mode self.transport.SetMode(val)
""" Error Numbers: 1) Invalid uri passed for the project file 2) Unable to unzip the project 3) Project created by a different version of Jokosher If a version string is given, it means the project file was created by another version of Jokosher. That version is specified in the string. 4) Project file doesn't exist
""" Creates a new instance of OpenProjectError. Parameters: errno -- number indicating the type of error: 1 = invalid uri passed for the project file. 2 = unable to unzip the project. 3 = Project created by a different version of Jokosher. 4 = Project file doesn't exist. info -- version of Jokosher that created the Pr...
def __init__(self, errno, info = None): """ Error Numbers: 1) Invalid uri passed for the project file 2) Unable to unzip the project 3) Project created by a different version of Jokosher If a version string is given, it means the project file was created by another version of Jokosher. That version is specified in the ...
"""Error numbers: 1) Unable to create a project object 2) Path for project file already exists 3) Unable to create file. (Invalid permissions, read-only, or the disk is full) 4) Invalid path, name or author 5) Invalid uri passed for the project file
""" Creates a new instance of CreateProjectError. Parameters: errno -- number indicating the type of error: 1 = unable to create a project object. 2 = path for project file already exists. 3 = unable to create file. (Invalid permissions, read-only, or the disk is full). 4 = invalid path, name or author. 5 = invalid ur...
def __init__(self, errno): """Error numbers: 1) Unable to create a project object 2) Path for project file already exists 3) Unable to create file. (Invalid permissions, read-only, or the disk is full) 4) Invalid path, name or author 5) Invalid uri passed for the project file """ Exception.__init__(self) self.errno=err...
"""Error numbers: 1) No recording channels found 2) Sound card is not capable of multiple simultanious inputs 3) Channel splitting element not found
""" Creates a new instance of AudioInputsError. Parameters: errno -- number indicating the type of error: 1 = no recording channels found. 2 = sound card is not capable of multiple simultaneous inputs. 3 = channel splitting element not found.
def __init__(self, errno): """Error numbers: 1) No recording channels found 2) Sound card is not capable of multiple simultanious inputs 3) Channel splitting element not found """ Exception.__init__(self) self.errno = errno
def __init__(self, missingfiles,missingimages):
def __init__(self, missingfiles, missingimages): """ Creates a new instance of InvalidProjectError. Parameters: missingfiles -- filenames of the missing files. missingimages -- filenames of the missing images. """
def __init__(self, missingfiles,missingimages): Exception.__init__(self) self.files=missingfiles self.images=missingimages
if Globals.settings.general["startupaction"] == PreferencesDialog.STARTUP_LAST_PROJECT: self.OpenLastProject() elif Globals.settings.general["startupaction"] == PreferencesDialog.STARTUP_NOTHING: pass else: WelcomeDialog.WelcomeDialog(self)
if openproject: try: (scheme, domain, path, params, query, fragment) = urlparse.urlparse(openproject, "file") if scheme != "file": raise ImportError, "Invalid URI scheme" self.SetProject(Project.LoadFromFile(path)) except (Project.OpenProjectError, ImportError), e: dlg = gtk.MessageDialog(self.window, gtk.DIALOG_MODAL ...
def __init__(self): #Find the absolute path in case we were imported from another directory Globals.SetAbsPaths() try: locale.setlocale(locale.LC_ALL, '') gettext.bindtextdomain(Globals.LOCALE_APP, Globals.LOCALE_DIR) gettext.textdomain(Globals.LOCALE_APP) gtk.glade.bindtextdomain(Globals.LOCALE_APP, Globals.LOCALE_D...
print "Starting up"
def ShowOpenProjectErrorDialog(self, error, parent=None): if not parent: parent = self.window if type(error.version) != str: message = _("The project file could not be opened.\n") else: message = "The project file was created with version \"%s\" of Jokosher.\n"%error.version + \ "Projects from version \"%s\" are incom...
self.model.append(i)
j = "\n".join(textwrap.wrap(i[0],12)) self.model.append((j,i[1],i[2]))
def __init__(self, project, parent): self.parent = parent self.project = project self.res = gtk.glade.XML(Globals.GLADE_PATH, "AddInstrumentDialog")
end = st["endtime"] / 1000000000.
end = st["endtime"] / float(gst.SECOND)
def bus_message(self, bus, message): """ Handler for the GStreamer bus messages relevant to this Event. At the moment this is used to report on how the loading progress is going. """
length = q[0] / 1000000000
length = q[0] / float(gst.SECOND)
def bus_eos(self, bus, message): """ Handler for the GStreamer End Of Stream message. Currently used when the file is loading and is being rendered. This function is called at the end of the file loading process and finalises the rendering. """ if message.type == gst.MESSAGE_EOS: # Update levels for partial events q =...
self.duration = float(q[0] / 1000000000)
self.duration = float(q[0] / float(gst.SECOND))
def bus_message_statechange(self, bus, message): """ Handler for the GStreamer statechange message. """ # state has changed try: q = self.bin.query_duration(gst.FORMAT_TIME) if self.duration == 0: self.duration = float(q[0] / 1000000000) self.SetProperties() #update position with proper duration self.MoveButDoNotOverla...
if self.settingButtons or not widget.get_active(): return
def Record(self, widget = None): '''Toggle recording''' if self.settingButtons or not widget.get_active(): return canRecord = False for i in self.project.instruments: if i.isArmed: canRecord = True
else:
else: print "can record"
def Record(self, widget = None): '''Toggle recording''' if self.settingButtons or not widget.get_active(): return canRecord = False for i in self.project.instruments: if i.isArmed: canRecord = True
self.bpmframetip = gtk.Tooltips() self.bpmframetip.set_tip(self.bpmframe, _("Beats per minute"), None)
self.bpmeventtip = gtk.Tooltips() self.bpmeventtip.set_tip(self.bpmeventbox, _("Beats per minute"), None)
def __init__(self, project, projectview, mainview): gtk.Frame.__init__(self) self.project = project self.projectview = projectview self.mainview = mainview self.timeline = TimeLine.TimeLine(self.project, self, mainview) self.Updating = False # add click / bpm / signature box self.clickbutton = gtk.ToggleButton() self...
self.bpmedit = gtk.Entry() self.bpmedit.set_width_chars(3)
self.bpmedit = gtk.SpinButton() self.bpmedit.set_range(1, 400) self.bpmedit.set_increments(1, 5)
def OnEditBPM(self, widget, event): #self.parentUpdateMethod() if event.type == gtk.gdk.BUTTON_PRESS: self.bpmframe.remove(self.bpmeventbox) self.bpmedit = gtk.Entry() self.bpmedit.set_width_chars(3) self.bpmedit.set_text(str(self.project.transport.bpm)) self.bpmedit.connect("activate", self.OnAcceptEditBPM)
newbpm = float(self.bpmedit.get_text()) if newbpm > 400: newbpm = 400.0 self.project.transport.SetBPM(newbpm)
newbpm = self.bpmedit.get_text() self.project.transport.SetBPM(float(newbpm))
def OnAcceptEditBPM(self, widget=None): if self.bpmeditPacked: self.bpmframe.remove(self.bpmedit) #FIXME: find a better way to do project.PrepareClick() it doesn't take a really long time with large bpm newbpm = float(self.bpmedit.get_text()) if newbpm > 400: newbpm = 400.0 self.project.transport.SetBPM(newbpm) self.pr...
sigstring = _("Please enter a correct time signature")
def OnAcceptEditSig(self, widget=None): if self.sigeditPacked: self.sigframe.remove(self.sigedit) sig = self.sigedit.get_text().split("/")
if not self.sigedit.get_text() or nom == 0: nom = 4 denom = 4 sigid = self.mainview.SetStatusBar(sigstring) gobject.timeout_add(1500, self.mainview.ClearStatusBar, sigid) self.sigframe.show_all() self.sigeditPacked = False
def OnAcceptEditSig(self, widget=None): if self.sigeditPacked: self.sigframe.remove(self.sigedit) sig = self.sigedit.get_text().split("/")
**kwargs -- additional parameters passed to the decorated function.
**kwargs -- dictionary of keyword:value parameters meant for the decorated function.
def UndoWrapper(funcSelf, *args, **kwargs): """ This function will wrap and take the place of the function that is being decorated. All arguments to the original function will be saved, and sent to the decorated function call. The funcSelf value must be the first parameter, because the first parameter will always be se...
the wrapped command function.
the wrapped function resulting value.
def UndoWrapper(funcSelf, *args, **kwargs): """ This function will wrap and take the place of the function that is being decorated. All arguments to the original function will be saved, and sent to the decorated function call. The funcSelf value must be the first parameter, because the first parameter will always be se...
result -- result of the failed undo command.
result -- value the wrapped function intended to return, but failed and called this exception.
def __init__(self, result): """ Creates a new instance of CancelUndoCommand. Parameters: result -- result of the failed undo command. """ Exception.__init__(self) self.result = result
if self.instrument.pixbuf != self.image:
if self.instrument.pixbuf != self.image.get_pixbuf(): print "update %s %s"%(self.instrument.pixbuf,self.image.get_pixbuf())
def Update(self): """ Called when requested by projectview.Update() to update the display in response to a change in state in any object it is listening to. In turn calls EventLaneViewer.Update() for its EventLaneViewer. """ self.Updating = True
print pad
def newPad(self, element, pad, instrument):
if change=="play" or change == "stop":
if change=="play" or (change == "stop" and self.isPlaying):
def OnStateChanged(self, obj=None, change=None): #for when undo and redo history change
for child in children: self.instrumentBox.remove(child)
orderCounter = 0
def Update(self): # Note: InstrumentViews MUST have the order that the instruments have in # Project.instruments to keep the drag and drop of InstrumentViews # consistent! children = self.instrumentBox.get_children() #Remove all instrumentviews, they will be added inside the for loop for child in children: ...
self.instrumentBox.pack_start(iv, False, False)
if iv not in children: self.instrumentBox.pack_start(iv, False, False) else: self.instrumentBox.reorder_child(iv, orderCounter)
def Update(self): # Note: InstrumentViews MUST have the order that the instruments have in # Project.instruments to keep the drag and drop of InstrumentViews # consistent! children = self.instrumentBox.get_children() #Remove all instrumentviews, they will be added inside the for loop for child in children: ...
self.imageeventbox = gtk.EventBox() self.imageeventbox.connect("button_release_event", self.OnChangeInstrumentType) self.imageeventbox.add(self.image) self.labelbox.pack_start(self.imageeventbox, False)
self.labelbox.pack_start(self.image, False)
def __init__(self, project, instrument, projectview, mainview, small = False): gtk.EventBox.__init__(self) """ project - the current active project instrument - the instrument that the event lane belongs instrumentviewer - the instrumentviewer holding the event lane projectview - the RecordingView instance that this be...
if 'GDK_CONTROL_MASK' not in event.state.value_names:
if 'GDK_CONTROL_MASK' in event.state.value_names: self.instrument.SetSelected(True) else:
def OnSelect(self, widget, event): """ Callback for "button_press_event" anywhere within InstrumentViewer Sets instrument to selected state """ if 'GDK_CONTROL_MASK' not in event.state.value_names: self.project.ClearEventSelections() self.project.SelectInstrument(self.instrument) return True
self.imageeventbox.modify_bg(gtk.STATE_NORMAL, self.SELECTED_COLOUR)
def Update(self): """ Called when requested by projectview.Update() to update the display in response to a change in state in any object it is listening to. In turn calls EventLaneViewer.Update() for its EventLaneViewer. """ self.Updating = True
self.imageeventbox.modify_bg(gtk.STATE_NORMAL, self.UNSELECTED_COLOUR)
def Update(self): """ Called when requested by projectview.Update() to update the display in response to a change in state in any object it is listening to. In turn calls EventLaneViewer.Update() for its EventLaneViewer. """ self.Updating = True
def OnChangeInstrumentType(self, widget, event): """ Callback for "button_press_event" in the instrument header icon """ if not self.instrument.isSelected: self.OnSelect(widget, event) return True AddInstrumentDialog.AddInstrumentDialog(self.project, self.mainview, self.instrument)
def OnStateChanged(self, obj, change=None, *extra): if change == "image": self.image.clear() self.image.set_from_pixbuf(self.instrument.pixbuf)
self.pan = None
self.pan = 0.0
def __init__(self, project, name, type, pixbuf, id=None): Monitored.__init__(self) self.project = project self.recordingbin = None self.path = "" # The 'audio' directory for this instrument self.events = [] # List of events attached to this instrument self.graveyard = [] # List of events that have been del...
if not firstpoint: Globals.debug("Set extra zero fade point") self.control.set("volume", 0, 0.99)
def PrepareController(self): """Fills the gst.Controller for the instrument with its list of fade times.""" Globals.debug("Preparing the controller") # set the length of the operation to be the full length of the project self.op.set_property("duration", self.project.GetProjectLength() * gst.SECOND) self.control.unset_...
files = os.walk(INSTR_PATH).next()[2] instrFiles = [x for x in files if x.endswith(".instr")] for f in instrFiles: config = ConfigParser.SafeConfigParser() config.read(os.path.join(INSTR_PATH, f)) if config.has_option('core', 'type') and config.has_option('core', 'icon'): icon = config.get('core', 'icon') type = confi...
for instr_path in INSTR_PATHS: files = os.walk(instr_path).next()[2] instrFiles = [x for x in files if x.endswith(".instr")] for f in instrFiles: config = ConfigParser.SafeConfigParser() config.read(os.path.join(instr_path, f)) if config.has_option('core', 'type') and config.has_option('core', 'icon'): icon = config.g...
def _cacheInstrumentsGenerator(): """The current list of instruments, cached""" try: #getlocale() will usually return a tuple like: ('en_GB', 'UTF-8') lang = locale.getlocale()[0] except: lang = None files = os.walk(INSTR_PATH).next()[2] instrFiles = [x for x in files if x.endswith(".instr")] for f in instrFiles: con...
INSTR_PATH = os.path.join(JOKOSHER_PATH, "Instruments")
INSTR_PATHS = (os.path.join(JOKOSHER_PATH, "Instruments"), os.path.expanduser("~/.jokosher/instruments"))
def idleCacheInstruments(): global instrumentPropertyList, _alreadyCached, _cacheGeneratorObject if _alreadyCached: #Stop idle_add from calling us again return False #create the generator if it hasnt been already if not _cacheGeneratorObject: _cacheGeneratorObject = _cacheInstrumentsGenerator() try: instrumentProperty...
INSTR_PATH = os.path.join(JOKOSHER_PATH, "..", "Instruments")
INSTR_PATHS = (os.path.join(JOKOSHER_PATH, "..", "Instruments"), os.path.expanduser("~/.jokosher/instruments"))
def idleCacheInstruments(): global instrumentPropertyList, _alreadyCached, _cacheGeneratorObject if _alreadyCached: #Stop idle_add from calling us again return False #create the generator if it hasnt been already if not _cacheGeneratorObject: _cacheGeneratorObject = _cacheInstrumentsGenerator() try: instrumentProperty...
pixxFADEMARKER_WIDTH = 30 pixyFADEMARKER_HEIGHT = 11
def OnDraw(self, widget, event): """ This function blits the waveform data onto the screen, and then draws the play cursor over it. """ c = self.cachedDrawArea e = event.area #check if the expose area is within the already cached rectangle if e.x < c.x or (e.x + e.width > c.x + c.width) or self.redrawWaveform: self.Dr...
pixxFM_left = event.area.x + x1 + 1 - pixxFADEMARKER_WIDTH pixyFM_left = event.area.y + int(event.area.height * (100-self.fadePoints[0]) / 100.0)
pixxFM_left = event.area.x + x1 + 1 - self._PIXX_FADEMARKER_WIDTH pixyFM_left = int(padded_height * (100-self.fadePoints[0]) / 100.0)
def OnDraw(self, widget, event): """ This function blits the waveform data onto the screen, and then draws the play cursor over it. """ c = self.cachedDrawArea e = event.area #check if the expose area is within the already cached rectangle if e.x < c.x or (e.x + e.width > c.x + c.width) or self.redrawWaveform: self.Dr...
pixxFADEMARKER_WIDTH, pixyFADEMARKER_HEIGHT)
self._PIXX_FADEMARKER_WIDTH , self._PIXY_FADEMARKER_HEIGHT)
def OnDraw(self, widget, event): """ This function blits the waveform data onto the screen, and then draws the play cursor over it. """ c = self.cachedDrawArea e = event.area #check if the expose area is within the already cached rectangle if e.x < c.x or (e.x + e.width > c.x + c.width) or self.redrawWaveform: self.Dr...
pixyFM_right = event.area.y + int(event.area.height * (100-self.fadePoints[1]) / 100.0)
pixyFM_right = int(padded_height * (100-self.fadePoints[1]) / 100.0)
def OnDraw(self, widget, event): """ This function blits the waveform data onto the screen, and then draws the play cursor over it. """ c = self.cachedDrawArea e = event.area #check if the expose area is within the already cached rectangle if e.x < c.x or (e.x + e.width > c.x + c.width) or self.redrawWaveform: self.Dr...
context.move_to(pixxFM_left + 1, pixyFM_left + pixyFADEMARKER_HEIGHT - 1)
context.move_to(pixxFM_left + 1, pixyFM_left + self._PIXY_FADEMARKER_HEIGHT - 1)
def OnDraw(self, widget, event): """ This function blits the waveform data onto the screen, and then draws the play cursor over it. """ c = self.cachedDrawArea e = event.area #check if the expose area is within the already cached rectangle if e.x < c.x or (e.x + e.width > c.x + c.width) or self.redrawWaveform: self.Dr...
context.move_to(pixxFM_right + 1, pixyFM_right + pixyFADEMARKER_HEIGHT - 1)
context.move_to(pixxFM_right + 1, pixyFM_right + self._PIXY_FADEMARKER_HEIGHT - 1)
def OnDraw(self, widget, event): """ This function blits the waveform data onto the screen, and then draws the play cursor over it. """ c = self.cachedDrawArea e = event.area #check if the expose area is within the already cached rectangle if e.x < c.x or (e.x + e.width > c.x + c.width) or self.redrawWaveform: self.Dr...
self.fadePoints[self.fadeBeingDragged] = 100-int((mouse.y / float(self.allocation.height)) * 100)
cur_pos = (mouse.y - (self._PIXY_FADEMARKER_HEIGHT / 2)) height = self.allocation.height - self._PIXY_FADEMARKER_HEIGHT percent = cur_pos / float(height) percent = max(0, percent) percent = min(1, percent) self.fadePoints[self.fadeBeingDragged] = 100 - int(percent * 100)
def OnMouseMove(self,widget,mouse): if not self.window: return # display status bar message if has not already been displayed if not self.messageID: self.messageID = self.mainview.SetStatusBar("To <b>Split, Double-Click</b> the wave - To <b>Select, Shift-Click</b> and drag the mouse") if self.isDraggingFade: self.fad...
print "eos"
def export_eos(self, bus=None, message=None): """ GStreamer End Of Stream handler. It is connected to eos on mainpipeline while export is taking place. """ print "eos" if not self.IsExporting: return else: self.IsExporting = False self.stop() #NULL is required because elements will be destroyed when we delete them sel...
string = _("The instruments '%s' and '%s' both have the same input selected (%s). " + \ "Please either disarm one, or connect it to a different input through " + \ "'Project -> Instrument Connections'")
string = _("The instruments '%s' and '%s' both have the same input selected (%s). Please either disarm one, or connect it to a different input through 'Project -> Instrument Connections'")
def Record(self, widget = None): '''Toggle recording''' if self.settingButtons or not widget.get_active(): return canRecord = False for i in self.project.instruments: if i.isArmed: canRecord = True
print "open project"
def OnOpenProject(self, button=None): self.window.hide() self.mainwindow.OnOpenProject(self, self.OnDialogClose) print "open project"
negInf = float("-inf") peaktotal = 0 peakcount = 0 for peak in st["peak"]: if peak != negInf: peaktotal += peak peakcount += 1 if peakcount > 0: peaktotal /= peakcount if peaktotal == 0: peaktotal = negInf self.levels.append(DbToFloat(peaktotal))
def bus_message(self, bus, message): """ Handler for the GStreamer bus messages relevant to this Event. At the moment this is used to report on how the loading progress is going. """
negInf = float("-inf") peaktotal = 0 peakcount = 0 for peak in st["peak"]: if peak != negInf: peaktotal += peak peakcount += 1 if peakcount > 0: peaktotal /= peakcount if peaktotal == 0: peaktotal = negInf self.levels.append(DbToFloat(peaktotal))
newLevel = self.__CalculateAudioLevel(st["peak"]) self.levels.append(newLevel)
def recording_bus_level(self, bus, message): """ Handler for the GStreamer bus messages relevant to this Event. At the moment this is used to report on how the loading progress is going. """ if not self.isRecording: return False st = message.structure if st and message.src.get_name() == "recordlevel": negInf = float(...
message = "A file or folder with this name already exists. Please chose a different project name and try again."
message = "A file or folder with this name already exists. Please choose a different project name and try again."
def OnOK(self, button): name = self.name.get_text() author = self.author.get_text() folder = self.folder.get_current_folder() try: project=Project.CreateNew(folder,name, author) except Project.CreateProjectError, e: if e.errno == 1: message = "Could not initialize project." elif e.errno == 2: message = "A file or fold...
self.output = "audioconvert ! vorbisenc ! oggmux ! filesink location=" + file
self.output = "audioconvert ! vorbisenc ! oggmux ! filesink location=%s" % file.replace(" ", "\ ")
def record(self): '''Record to this instrument's temporary file.'''
self.recordingbin = gst.parse_launch("bin.( " + self.input + self.effects + self.output + " )")
self.recordingbin = gst.parse_launch("bin.( %s%s%s )" % (self.input, self.effects, self.output))
def record(self): '''Record to this instrument's temporary file.'''
undo : ToggleArmed
undo : ToggleArmed : temp
def ToggleArmed(self): """Toggles the instrument to be armed for recording undo : ToggleArmed """ self.isArmed = not self.isArmed self.StateChanged()
v = gst.version() if (v[1] < 10) or (v[2] < 9):
gstVersion = gst.version() if ((gstVersion[1] <= 10 and gstVersion[2] < 9) or gstVersion[1] < 10):
def CheckGstreamerVersions(self): #Check for CVS versions of Gstreamer and gnonlin message = "" v = gst.version() if (v[1] < 10) or (v[2] < 9): message += _("You must have Gstreamer version 0.10.9 or higher.\n") gnl = gst.registry_get_default().find_plugin("gnonlin") if gnl: ignored, gnlMajor, gnlMinor = gnl.get_versio...
curses.setupterm() self._maxWidth = curses.tigetnum('cols')
try: curses.setupterm() cols = curses.tigetnum('cols') if cols > 0: self._maxWidth = cols except curses.error: pass
def __init__(self, stream, descriptions, verbosity, count=None, progress=False): self.__super_init(stream, descriptions, verbosity) self._progress = progress self._progressWithNames = False self.count = count self._testtimes = {} if progress and verbosity == 1: self.dots = False self._progressWithNames = True self._las...
path = urllib.unquote(path)
def __call__(self, request_string, handle_errors=True, form=None): # Commit work done by previous python code. commit()
Usage: defineLater('foo')
Usage: defineLayer('foo')
def defineLayer(name, zcml='test.zcml'): """Helper function for defining layers. Usage: defineLater('foo') """ globals = sys._getframe(1).f_globals globals[name] = FTestingLayer( os.path.join(os.path.split(globals['__file__'])[0], 'test.zcml'), globals['__name__'], name, )