EditorUI package

Submodules

EditorUI.TrackAbstract module

class EditorUI.TrackAbstract.TrackAbstract(name, state, selections, analysisTypes, marks, cursorposition, height, width, smptopix, zoom, root=None)

Bases: PyQt5.QtWidgets.QWidget

TrackAbstract is the superclass from which most elements or layers of a Track inherit. That way they all share an identical interface based around Qt’s signal-slot-concept. The signals and slots all have defined connections to their respective slots and signals of the parent object. Therefore, if an object of a class inherited from TrackAbstract creates another object that is also from a class that inherits TrackAbstract, their interface will automatically be connected in the way described here. This allows for an easy layering of objects, without any boilerplate connection making code whilst not breaking encapsulation rules. See the overall documentation of SNARE for a more detailed explanation on this design-pattern.

sig_addWaveform
sig_analyze
sig_delete
sig_editSelection
sig_enableSelection
sig_endSelection
sig_finishSelection
sig_keyEnter
sig_keyRelease
sig_mouseDoubleClick
sig_mouseMove
sig_mousePress
sig_mouseRelease
sig_moveSelection
sig_playpause
sig_redraw
sig_requestMark
sig_requestWaveform
sig_selectionChange
sig_setMark
sig_setPlaying
sig_setSelection
sig_setView
sig_skipBackward
sig_skipForward
sig_startSelection
sig_update
sig_viewChanged
sig_zoomIn
sig_zoomOut
slo_addWaveform(Waveform)

Relays the signal to child-objects. The destination of this signal-path is TrackWaveform.

Parameters:Waveform – a Waveform-object.
slo_analyze()

Relays the signal to the parent object. For pressing “Analyze” at TrackButtons.

slo_delete()

Relays the signal to the parent object. A request from TrackButtons to delete this track.

slo_editSelection()

Relays the signal to the parent object. For setting the selection state to “unlocked”. (Lock symbol at TrackButtons)

slo_enableSelection(bool)

Relays the signal to child-objects. The destination of this signal-path is TrackSelection, it is one of four to control the state machine of TrackSelection

Parameters:bool – Enter False to block the selection from changes
slo_endSelection(QGraphicsSceneMouseEvent)

Relays the signal to child-objects. The destination of this signal-path is TrackSelection, it is one of four to control the state machine of TrackSelection

Parameters:QGraphicsSceneMouseEvent – A Qt-type containing at least the mouse button that was pressed and the cursor position
slo_finishSelection()

Relays the signal to the parent object. For setting the selection state to “locked”. (Lock symbol at TrackButtons)

slo_keyEnter(QKeyEvent)

Relays the signal to the parent object. Catches any keyboard event triggered on any layer of the Track and sends it through all layers to TrackManager where it will be processed.

Parameters:QKeyEvent – Qt key event type.
slo_keyRelease(QKeyEvent)

Relays the signal to the parent object. Catches any keyboard event triggered on any layer of the Track and sends it through all layers to TrackManager where it will be processed.

Parameters:QKeyEvent – Qt key event type.
slo_mouseDoubleClick(QGraphicsSceneMouseEvent)

Relays the signal to the parent object. Catches any mouse event triggered on any layer of the Track and sends it through all layers to TrackManager where it will be processed.

Parameters:QGraphicsSceneMouseEvent – Qt mouse event type.
slo_mouseMove(QGraphicsSceneMouseEvent)

Relays the signal to the parent object. Catches any mouse event triggered on any layer of the Track and sends it through all layers to TrackManager where it will be processed.

Parameters:QGraphicsSceneMouseEvent – Qt mouse event type.
slo_mousePress(QGraphicsSceneMouseEvent)

Relays the signal to the parent object. Catches any mouse event triggered on any layer of the Track and sends it through all layers to TrackManager where it will be processed.

Parameters:QGraphicsSceneMouseEvent – Qt mouse event type.
slo_mouseRelease(QGraphicsSceneMouseEvent)

Relays the signal to the parent object. Catches any mouse event triggered on any layer of the Track and sends it through all layers to TrackManager where it will be processed.

Parameters:QGraphicsSceneMouseEvent – Qt mouse event type.
slo_moveSelection(QGraphicsSceneMouseEvent)

Relays the signal to child-objects. The destination of this signal-path is TrackSelection, it is one of four to control the state machine of TrackSelection

Parameters:QGraphicsSceneMouseEvent – A Qt-type containing at least the mouse button that was pressed and the cursor position
slo_playpause()

Relays the signal to the parent object. For pressing play or pause (a switch button) at TrackButtons.

slo_redraw(factor)

Relays the signal to child objects. An actual implementation can be found at TrackSelection, TrackWaveform et al.

Parameters:factor – New zoom-level
slo_requestMark()

Relays the signal to the parent object. A request from TrackButtons to place a mark on the current TrackCursor position.

slo_requestWaveform(block, widthPreScaling, height)

Relays the signal to the parent object. A signal from TrackWaveform, requesting the backend to render a specific waveform pixmap. The channel association is added at TrackManager.

Parameters:
  • block – The block to be rendered.
  • widthPreScaling – The width to fit the pixmap of one block in. Therefore the width equals the zoom-level, since the blocksize is static.
  • height – Height of the pixmap.
slo_selectionChange(selectionName, analysisType)

Relays the signal to the parent object. Triggered when one of the dropdown menus at TrackButtons changed.

Parameters:
  • selectionName – Name of the new selection.
  • analysisType – Name of the new analysis type.
slo_setMark(smp)

Relays the signal to child-objects. The destination of this signal-path is TrackMarks.

Parameters:smp – Sample on which to put a mark
slo_setPlaying(bool)

Relays the signal to child-objects. The destination of this signal-path is the play/pause-button of TrackButtons. It is necessary to display the right playback state on each channel.

Parameters:bool – True if playing.
slo_setSelection(selectionName, analysisType, selection, state)

Relays the signal to child-objects. The destination of this signal-path is TrackSelection and TrackButtons.

Parameters:
  • selectionName – Name of the selection to switch to.
  • analysisType – Name of the type of analysis associated with the current selection.
  • selection – Start and end samples of the actual selection.
  • state – Lock state of the selection
slo_setView(QRectF)

Relays the signal to child-objects. The destination of this signal-path is TrackView.

Parameters:QRectF – A rectangle describing the part of the QGraphicScene to display.
slo_skipBackward()

Relays the signal to the parent object. A request from TrackButtons to skip to the previous mark.

slo_skipForward()

Relays the signal to the parent object. A request from TrackButtons to skip to the next mark.

slo_startSelection(QGraphicsSceneMouseEvent)

Relays the signal to child-objects. The destination of this signal-path is TrackSelection, it is one of four to control the state machine of TrackSelection

Parameters:QGraphicsSceneMouseEvent – A Qt-type containing at least the mouse button that was pressed and the cursor position
slo_update(pos)

Relays the signal to child-objects. The destination of this signal-path are all objects related to the waveform display, e.g. TrackWaveform and TrackTimeline.

Parameters:pos – Position in samples around which to update the view and scene.
slo_viewChanged(QRectF)

Relays the signal to the parent object. A signal triggered when the user changed the view by scrolling or dragging.

Parameters:QRectF – The rectangle inside the scene that is now displayed by the view.
slo_zoomIn()

Relays the signal to the parent object. For pressing “+” at TrackButtons.

slo_zoomOut()

Relays the signal to the parent object. For pressing “-” at TrackButtons.

EditorUI.TrackButtons module

class EditorUI.TrackButtons.TrackButtons(name, state, selections, analysisTypes, marks, cursorposition, height, width, smptopix, zoom, parent=None)

Bases: EditorUI.TrackAbstract.TrackAbstract

Each Track is accompanied by a selection of buttons on the left side. They are implemented in this class. All signals are automatically relayed to the managing backend class by the principle described in TrackAbstract. To function properly the files “EditorUI/Lock.png”, “Marker.png” and “EditorUI/Unlock.png” need to be available.

lock()

A toggle switch for the lock symbol

resource_path(relative_path)
selectionChange()

An in between slot triggered by changing one of the dropdown-menus, gathers relevant information before triggering the sig_selectionChange that is connected to the command chain.

slo_redraw(factor)

Set the zoom level label. :param factor: New zoom factor.

slo_setPlaying(bool)

Sets the “play”-buttons icon to represent the playback state of this channel. :param bool: True if playback is on. (Display “pause”-icon)

slo_setSelection(selectionName, analysisType, selection, state)

If the selection has been changed by the user at one track or by the program, the new state is synchronised over all tracks. This means the name of the selection, the analysis type, selection points and selection state are sent to each track. In TrackButtons the dropdown menus have to be changed accordingly. (The other endpoint of this command chain can be found at TrackSelection.) There is one special case: selectionName “Calib.” is reserved for the Calibration selection and causes the analysis type dropdown menu to grey out.

Parameters:
  • selectionName – Name of the selection to switch to. In case it doesn’t exist, a new selection is added.
  • analysisType – Name of the type of analysis associated with the current selection.
  • selection – Start and end-samples of the actual selection. Not needed here, see TrackSelection.
  • state – Lock state of the current selection

EditorUI.TrackCursor module

class EditorUI.TrackCursor.TrackCursor(name, state, selections, analysisTypes, marks, cursorposition, height, width, smptopix, zoom, parent, scene)

Bases: EditorUI.TrackAbstract.TrackAbstract

TrackCursor draws a vertical line on the scene to mark the current position of playback on the timeline. It needs to be stacked on top of a TrackView object to have the extended interface containing a scene.

setCursor(smp)

Public. The only way to set the cursor position is from outside.

Parameters:smp – Requested cursor position in samples. Automatic conversion from samples to the actual position in pixels on screen
slo_redraw(factor=1)

Adjusting the cursor position whenever the zoom-level changes.

Parameters:factor – The new zoom-factor

EditorUI.TrackData module

class EditorUI.TrackData.TrackData(selectionNames, analysisTypes, channel, track)

Bases: object

All data collected trough the Track User Interface will be stored here. This allows for easier communication with other backend objects. The TrackManager stores all invisible data in here (e.g. selections that are currently not active) and loads it back from here when needed (e.g. going back to a previously edited selection) Since everything relevant to the state of one track is concentrated in this class, it’ll make it easier to implement a save/load feature in future releases.

The full set of data for one track includes:
  • last cursor position
  • all selections, with start/end points, name, analysis type and lock state
  • all marks on the timeline
  • reference to the backend-channel it is connected to
  • reference to the user interface element
addSelection(selectionName)

Prepares the data structure for an additional selection.

Parameters:selectionName – Name of the selection. Must be unique.
getCurrentSelection()

Interface for the TrackManager to load back a selection.

Returns:a tuple of four elements containing the name, points, lock-state and the analysis type of the selection
getLastPos()

Simple getter method.

Returns:The last stored cursor position in samples.
getNextMark(smp)

Allow jumping forward from one position to the nearest mark.

Parameters:smp – position in samples from which to look for the next mark
Returns:sample position of the nearest mark in forward direction.
getPreviousMark(smp)

Allow jumping backward from one position to the nearest mark.

Parameters:smp – position in samples from which to look for the next mark
Returns:sample position of the nearest mark in backward direction.
isPlaying()

Inform caller of this channel’s playback state.

Returns:Bool, True if channel is on playback.
setCurrentSelection(selectionName)

Simple setter method.

Parameters:selectionName – Name of the selection to switch to. Must exist, otherwise untreated KeyError exceptions occur.
setLastPos(smp)

Simple setter method.

Parameters:smp – Update the last cursor position to this in samples.
setMark(smp)

Adds a mark to the list. Deleting of marks not yet available.

Parameters:smp – Position of the mark in samples
setPlaying(bool)

Remember if this channel is on playback.

Parameters:bool – True if playback is on
updateCurrentSelection(points, state=None, analysisType=None)

Stores adjustments made to the current selection. E.g. when the analysis type has been changed or the selection area (in start/end-points)

Parameters:
  • points – Updated list of start and end samples of the selection areas
  • state – Updated lock-state
  • analysisType – Updated analysis type

EditorUI.TrackManager module

class EditorUI.TrackManager.TrackManager(analyses, blockSize)

Bases: EditorUI.TrackAbstract.TrackAbstract

The TrackManager provides the connection between the editor area of SNARE and the MainBackend. Also it defines the behaviour of the entire editor area. An editor element (TrackUI) does not contain any logic, it merely sends all input from the user to the TrackManager and receives its commands from the TrackManager. Therefore a TrackUI object without the TrackManager does not respond to any input. This way user input, processing and display are separated and the definition the editor area’s behaviour is concentrated in this class. For a more detailed explanation on the underlying design principle, see the overall documentation of SNARE.

addChannel(channel)

Called from backend. Creates a new TrackUI and TrackData for the given channel. Everything will be linked automatically.

Parameters:channel – A channel object referring to the channel to be displayed
addSelection
addTrack
closeRecordings()

A slot called from the backend to notify that the recording has been finished. The track will then display the file where the recording has been store instead of the source audio device. (To be implemented)

deleteChannel
getWaveform
newSelection()

A slot called from the backend to add a selection. It will appear on the TrackButtons’ dropdown menu and have the last added analysis widget as default selected.

playerPause
playerPlay
setPlayerPosition
setRecording(bool)

A slot called from the backend to notify of a changed recording status.

Parameters:bool – True if there is a recording ongoing.
slo_addWaveform(waveform)

This is the place where rendered waveforms from the backend are processed. They are filtered according to the channel they belong to and passed on to the corresponding Track.

Parameters:waveform – A waveform object containing a pixmap.
slo_analyze()

Triggered when the “analyze”-button was pressed. The method gathers the selection points/area (in samples) and the relevant channel-reference and passes the information to the backend via the “addSelection” signal.

slo_delete()

Triggered by pressing the “X”-button. Deletion is only possible when there is no backend processing active (playback or recording) to reduce complexity. The user interface elements are removed and the remaining objects are deleted. Then a signal is emitted to also remove this channel from the backend.

slo_editSelection()

This loops back the signal to unblock a selection. Could be changed e.g. to block all Selections with one event.

slo_finishSelection()

This loops back the signal to block a selection. Could be changed e.g. to block all Selections with one event.

slo_keyEnter(QKeyEvent)

Receives any keyboard press event from any area of the track. There are two inputs filtered at the moment: “M” to set a mark and “Shift” to enter drag mode.

Parameters:QKeyEvent – Qt type containing the key pressed.
slo_keyRelease(QKeyEvent)

Receives any keyboard release event from any area of the track. There is only one input filtered at the moment: “Shift” to leave drag mode.

Parameters:QKeyEvent – Qt type containing the key released.
slo_mouseDoubleClick(QGraphicsSceneMouseEvent)

Triggered by a double click on TrackView. Places the TrackCursor on the requested position. The received position is translated to the position on the scene and then to samples. The value is stored in the TrackData object and the signal to set the cursor is emitted.

Parameters:QGraphicsSceneMouseEvent – Qt mouse event type containing the position on the scene where the click event was triggered
slo_mouseMove(QGraphicsSceneMouseEvent)

Triggered by a mouse movement on TrackView. The signal is multiplied to all tracks and used to control the selection rectangles. It would also be possible to loop back the signal to only one track instead of having synchronised selections on all tracks.

Parameters:QGraphicsSceneMouseEvent – Qt mouse event type containing the position on the scene, where the event was triggered.
slo_mousePress(QGraphicsSceneMouseEvent)

Triggered by a mouse press on TrackView. The signal is multiplied to all tracks and used to control the selection rectangles. It would also be possible to loop back the signal to only one track instead of having synchronised selections on all tracks.

Parameters:QGraphicsSceneMouseEvent – Qt mouse event type containing the position on the scene, where the event was triggered.
slo_mouseRelease(QGraphicsSceneMouseEvent)

Triggered by a mouse release on TrackView. The signal is multiplied to all tracks and used to control the selection rectangles. It would also be possible to loop back the signal to only one track instead of having synchronised selections on all tracks.

Parameters:QGraphicsSceneMouseEvent – Qt mouse event type containing the position on the scene, where the event was triggered.
slo_playpause()

Behaviour when pressing the “play/pause” button. (Or triggering the same event possibly with a key)

slo_requestMark()

Triggered by pressing “M” or the marker button on TrackButtons. The last position/sample (the cursor position) is retrieved from TrackData for the active channel and a mark is then set on this position for all channels.

slo_requestWaveform(startBlock, dataBlocks, numberOfPixmaps)

This is the slot used by TrackWaveform to request all needed waveforms for the current position and zoom level. Since a Track element does not know its channel, this information is added here, before the signal gets relayed to the backend.

Parameters:
  • block – The requested block.
  • widthPreScaling – The width of the requested pixmap, equalling the zoom level.
  • height – Height of the pixmap
slo_selectionChange(selectionName, analysisType)

Triggered when the user has made a change to one of the dropdown menus on TrackButtons. The selection areas of each track are stored in TrackData, the new selection areas are loaded and the state of the dropdown-menus is synchronized.

Parameters:
  • selectionName – Name of the selection to switch to.
  • analysisType – Name of the analysis type to switch to.
slo_skipBackward()

Request from a TrackUI object to move the cursor the next mark in backward direction. Positions are all read from the corresponding TrackData object.

slo_skipForward()

Request from a TrackUI object to move the cursor the next mark in forward direction. Positions are all read from the corresponding TrackData object.

slo_viewChanged(QRectF)

Triggered by any change on TrackView, e.g. by dragging or scrolling in the view widget. The changes are simply synchronised. The signal is not sent back to the sender object to avoid an infinite loop.

Parameters:QRectF – Portion of the scene to display.
slo_zoomIn()

Triggered by pressing the “+”-button. The zoom range is limited and the steps are selected in a way that they are equal in both directions: (1.25)^-1 = 0.8 and one can always return to exactly one step no rounding errors.

slo_zoomOut()

Triggered by pressing the “-“-button. The zoom range is limited and the steps are selected in a way that they are equal in both directions: (1.25)^-1 = 0.8 and one can always return to exactly one step no rounding errors.

updateFromRecorder(smp)

When recording, the backend will update the TrackManager on the currently recorded position. E.g. to keep scrolling with the recording progress.

Parameters:smp – Last recorded sample/position
updateRecording(int)

Legayc interface. Required. Not used anymore.

Parameters:int – not elefant
updateSmp(smp, channel)

A slot to be called from the backend. When the Audioplayer is running it regularly send an update containing which sample on which channel was played. The last position is saved in the corresponding TrackData object ans the cursor is moved accordingly.

Parameters:
  • smp – Playback position in samples on update time.
  • channel – A channel-object referring to the channel currently on playback.

EditorUI.TrackMark module

class EditorUI.TrackMark.TrackMark(name, state, selections, analysisTypes, marks, cursorposition, height, width, smptopix, zoom, parent, scene)

Bases: EditorUI.TrackAbstract.TrackAbstract

TrackMark draws red, dotted, vertical lines on the scene to mark position that the user selected by pressing “M”. It needs to be stacked on top of a TrackView object to have the extended interface containing a scene. The drawing process works in a similar way to TrackWaveform and TrackTimeline. See slo_update.

paintBlock(block)

Evaluates which marks are inside the requested block and draws them as QLineF on the scene.

Parameters:block – Number of the block to paint.
slo_redraw(factor=1)

A zoom-event will reset the object and trigger a full repaint.

Parameters:factor – New zoom-factor
slo_setMark(smp)

Slot to set a mark at the specified position. After storing the position, the pixmap will be renewed.

Parameters:smp – Position in samples, converted automatically to the actual pixel/on-screen position
slo_update(pos)

The class treats the painting area as divided into blocks. From the given position the next three blocks in each direction are calculated. Then, if a block has not been already painted, it will be painted. This way only the visible portion of the scene has to be painted.

Parameters:pos – position in pixels around which to paint blocks.

EditorUI.TrackOverview module

class EditorUI.TrackOverview.TrackOverview(name, state, selections, analysisTypes, marks, cursorposition, height, width, smptopix, zoom, parent)

Bases: EditorUI.TrackAbstract.TrackAbstract

mouseEvent(QGraphicsSceneMouseEvent)
setArea(start, width)
slo_mouseDoubleClick(QGraphicsSceneMouseEvent)
slo_mouseMove(QGraphicsSceneMouseEvent)
slo_mousePress(QGraphicsSceneMouseEvent)
slo_mouseRelease(QGraphicsSceneMouseEvent)
slo_redraw(factor)
slo_setView(QRectF)
updateMaxLength(smp)
updateRectangle()

EditorUI.TrackSelection module

class EditorUI.TrackSelection.TrackSelection(name, state, selections, analysisTypes, marks, cursorposition, height, width, smptopix, zoom, parent, scene)

Bases: EditorUI.TrackAbstract.TrackAbstract

TrackSelection provides an intuitive way for the user to select areas in the waveform view. The user can simply draw by holding the left mouse button a green rectangle, which is added to the selection or by holding the right mouse button a red rectangle, which is subtracted from the existing selection area (where there is an intersection) The Object needs to be stacked on top of a TrackView object to have the extended interface containing a scene.

The implementation models the desired behaviour with a state machine. State transitions are triggered by several control slots.

EndToIdle()

State transition. Cleaning up variables and returning the machine to the “Idle” state.

FinishToIdle()

State transition. Returning from the “Blocked” state to the “Idle” state. The cross pattern of the selection will be removed.

IdleToFinish()

State transition. Setting the machine to the blocked state. The selection will be marked as blocked by applying a pattern. It will not respond to any mouse input until set back to “Idle”

IdleToStart(x, type)

State transition. Starts the rectangle by defining the type and start point.

Parameters:
  • x – Position of start
  • type – “Add” or “Remove” type of selection rectangle
MoveToEnd(x)

State transition. Triggered by releasing the mouse button. The last provisional end point of the selection becomes a definite one. Subsequently the fully defined input rectangle will be processed to intersect with the existing selection rectangles and sets the machine to the “End” state.

Parameters:x – Last position of the end point.
MoveToMove(x)

State transition. Updates the provisional end point of the rectangle for each mouse move event. Also redraws the rectangle accordingly.

Parameters:x – Updated position of the provisional end point.
StartToIdle()

State transition. Returns the machine to “Idle” state when no movement has occurred to draw a rectangle

StartToMove(x)

State transition. After the start point has been set, now after one mouse move event, an provisional end point is known, which is enough to draw the rectangle for the first time. The type has been set by a previous transition.

Parameters:x – Position of the provisional end point.
addSelection(start, end, type)

This processes the rectangle drawn by the user to intersect with the existing selection areas. For an explanation on the intersect-algorithm, see the overall documentation of SNARE.

Parameters:
  • start – Start point of the rectangle, already sorted to be the smaller number.
  • end – End point of the rectangle, already sorted to be the bigger number
  • type – “Add” or “Remove” from existing selection areas.
clear()

Cleans up all selection areas in the objects list as well as the painted objects on the scene.

getSelectionPoints()

Getter method.

Returns:A tuple of two elements: start and end points of selection areas and lock-state of the selection
redrawSelection()

After the points list has been conditioned by addSelection to be meaningful an alternate series of start and end points, the points can be put together to form the selection areas/rectangles.

slo_enableSelection(bool)

Control Slot. Trigger transition from “Finish” to “Idle” or “Idle” to “Finish”. This transition enables the user to block the selection from unwanted changes.

Parameters:bool – Set blocked or not.
slo_endSelection(QGraphicsSceneMouseEvent)

Control Slot. Triggers transition from “Move” to “End” or “Start” to “Idle” if no mouse movement happened since the button was pressed.

Parameters:QGraphicsSceneMouseEvent – Qt-type from which to get the mouse position on the scene.
slo_moveSelection(QGraphicsSceneMouseEvent)

Control Slot. Trigger transition from “Move” to “Move” or “Start” to “Move”. This models the dragging of the rectangle size.

Parameters:QGraphicsSceneMouseEvent
slo_redraw(factor)

Removes all selection rectangels and redraws them after setting the new zoom-level.

Parameters:factor – The new zoom-level
slo_setSelection(selectionName, analysisType, selection)

Replace the current selection.

Parameters:
  • selectionName – Name of the new selection. Not relevant here. See TrackButtons for other end of this command chain
  • analysisType – Type of analysis of the new selection. Not relevant here.
  • selection – Start and end points of selection areas of new selection
slo_startSelection(QGraphicsSceneMouseEvent)

Control Slot. Triggers transition from “Idle” to “Start”. Determines the selection type (Add to or subtract from selection) by the mouse button pressed and also send the position where the user pressed.

Parameters:QGraphicsSceneMouseEvent – Qt-type from which to get the pressed mouse button and mouse position on the scene.
updateSelection()

Cleans up all selection areas in the objects list as well as the painted objects on the scene. Subsequently triggers a redraw.

EditorUI.TrackTimeline module

class EditorUI.TrackTimeline.TrackTimeline(name, state, selections, analysisTypes, marks, cursorposition, height, width, smptopix, zoom, parent, scene)

Bases: EditorUI.TrackAbstract.TrackAbstract

TrackTimeline adds a equidistant vertical lines to the waveform view and appends time strings to them. This allows for an easier navigation through the audio data. It needs to be stacked on top of a TrackView object to have the extended interface containing a scene. The drawing process works in a similar way to TrackWaveform and TrackTimeline.

formatTag(pos)

Calculates the time for the requested position and formats it according to a set of rules about units and rounding.

Parameters:pos – Position to calculate time at
Returns:a formatted string containing the time e.g. “1:20 + 20ms”
paintBlock(block)

Draws 10 lines per block and then appends a text on the bottom of each line to display the time.

Parameters:block – Number of block to paint.
slo_redraw(factor=1)

A zoom-event will reset the object and trigger a full repaint.

Parameters:factor – New zoom-factor
slo_update(pos)

The class treats the painting area as divided into blocks. From the given position the next three blocks in each direction are calculated. Then if a block has not been already painted, it will be painted. This way only the visible portion of the scene has to be painted.

Parameters:pos – position in pixels around which to paint blocks.

EditorUI.TrackUI module

class EditorUI.TrackUI.TrackUI(name, state, selections, analysisTypes, marks, cursorposition, height, width, smptopix, zoom, parent=None)

Bases: EditorUI.TrackAbstract.TrackAbstract

The TrackUI forms the bottom layer of one channel strip user interface element. It combines the TrackButtons and the waveform viewer (TrackWaveform) to one row with a QHBoxLayout. Apart from its layout functionality it relays the interface to its child objects.

enableDrag(bool)

Relay to TrackView

Parameters:bool – see TrackView
enableScrollbar(bool)

Relay to TrackView

Parameters:bool – see TrackView
getSelectionPoints()

Relay to TrackView

setCursor(smp)

Relay to TrackView

Parameters:smp – see TrackView
setView(QRectF)

Relay to TrackView

Parameters:QRectF – see TrackView

EditorUI.TrackView module

class EditorUI.TrackView.TrackScene(root)

Bases: PyQt5.QtWidgets.QGraphicsScene

TrackScene is a helper class. A QGraphicsScene object is necessary to give classes like TrackWaveform something to paint on. Ideally one could describe a class that inherits from TrackAbstract to keep the automated signal lines and from QGraphicsScene to have the paint functionality, but the Qt framework does not support multiple inheritance. Therefore TrackScene inherits from QGraphicsScene and the missing functionality is added manually.

mouseDoubleClickEvent(QGraphicsSceneMouseEvent)

Override method to grab and relay QGraphicsSceneMouseEvent to parent object.

Parameters:QGraphicsSceneMouseEvent – MouseEvent to relay
mouseMoveEvent(QGraphicsSceneMouseEvent)

Override method to grab and relay QGraphicsSceneMouseEvent to parent object.

Parameters:QGraphicsSceneMouseEvent – MouseEvent to relay
mousePressEvent(QGraphicsSceneMouseEvent)

Override method to grab and relay QGraphicsSceneMouseEvent to parent object.

Parameters:QGraphicsSceneMouseEvent – MouseEvent to relay
mouseReleaseEvent(QGraphicsSceneMouseEvent)

Override method to grab and relay QGraphicsSceneMouseEvent to parent object.

Parameters:QGraphicsSceneMouseEvent – MouseEvent to relay
class EditorUI.TrackView.TrackView(name, state, selections, analysisTypes, marks, cursorposition, height, width, smptopix, zoom, parent=None)

Bases: EditorUI.TrackAbstract.TrackAbstract

TrackView provides the user interface elements necessary to display the waveform, allow the user to make selections, place a cursor etc.

enableDrag(bool)

Turning on and off the manual dragging mode of the view widget, which is one way to navigate.

Parameters:bool – True means manual dragging is enabled
enableScrollbar(bool)

The scrollbar of the view widget can be turned on or off. It is only necessary to display the scrollbar of the bottom view widget if all tracks are synchronized.

Parameters:bool – True means the scrollbar is visible
getSelectionPoints()

Relay to TrackSelection

Returns:see TrackSelection
setCursor(smp)

Relay to TrackCursor

Parameters:smp – see TrackCursor
slo_redraw(factor)
Slightly extends the base class’ slo_redraw. Child classes will draw their content scaled when the slo_redraw
has been triggered, but before thar happens, the scene has to be emptied.
Parameters:factor – New zoom-level
slo_setView(QRectF)

Display the specified portion of the scene in the view widget. Then let the base class handle further treatment of the signal (avoid breaking the chain of command)

Parameters:QRectF – Position/rectangle to display
slo_update(pos)

TrackManager triggers slo_update without a meaningful position. This method extracts a meaningful posiiton from the currently displayed portion of the scene and leaves it to the base class to relay the signal to all child classes

Parameters:pos – Not relevant here.
viewChanged()

Slot for signal triggered by the view widget. The signal should only be relayed to the parent if this is the active track. The dimensions of the currently by the view widget displayed portion of the scene is extracted and sent with the signal.

viewChangedByScrollbar(int)

Slot for signal triggered by the view widget. The dimensions of the currently by the view widget displayed portion of the scene is extracted and sent with the signal.

Parameters:int – Not elefant.
class EditorUI.TrackView.TrackViewWidget(scene, root)

Bases: PyQt5.QtWidgets.QGraphicsView

TrackViewWidget is a helper class. A QGraphicsView object is necessary to display a QGraphicsScene. Ideally one could describe a class that inherits from TrackAbstract to keep the automated signal lines and from QGraphicsView to have the display functionality, but the Qt framework does not support multiple inheritance. Therefore TrackViewWidget inherits from QGraphicsView and the missing functionality is added manually.

keyPressEvent(QKeyEvent)

Override method to grab and relay QKeyEvent to parent object.

Parameters:QKeyEvent – KeyEvent to relay :
keyReleaseEvent(QKeyEvent)

Override method to grab and relay QKeyEvent to parent object.

Parameters:QKeyEvent – KeyEvent to relay :

EditorUI.TrackWaveform module

class EditorUI.TrackWaveform.TrackWaveform(name, state, selections, analysisTypes, marks, cursorposition, height, width, smptopix, zoom, parent, scene)

Bases: EditorUI.TrackAbstract.TrackAbstract

TrackWaveform takes the currently displayed position of the scene and the zoom-level and requests the corresponding waveforms for the area surrounding this position. The creation of the waveform-points list is handled in the backend (see WaveformBuffer and WaveformThread) and the results are sent to TrackWaveform through a slot. Requesting and receiving waveform-points list is therefore independent or asynchronous. There are several zoom levels for which new waveforms will be requested. In between these zoom levels the pixmaps will be stretched to fit instead of a new render. Only the currently displayer pixmaps are stored in this object, but all rendered points lists are stored in the backend (WaveformBuffer). For a detailed overview of the waveform rendering and display, see the overall documentation of SNARE.

getClosestWaveformZoomLevel()

Defines the available zoom-levels for pixmaps and returns the one closest to the current actual zoom level.

Returns:closest available zoom level
slo_addWaveform(waveform)

Requested waveforms return after rendering in the backend by means of this slot. The points list itself and all information needed to place the pixmap on the right spot with the right size is part of the Waveform-object. E.g. if a waveform took too long to render (because the user has already set a new zoom level again) it will simply be filtered here and not used. The pixmap is either rendered for exactly the requested zoom level or it will be stretched to some extent.

Parameters:waveform – A Waveform-object containing a pixmap to place on the scene.
slo_redraw(factor=1)

A zoom-event will reset the object and trigger a full repaint. There is a distinction between the width of a pixmap before scaling, which represents the zoom-levels for which a new pixmap will be rendered and the width of a pixmap after scaling, which, if it differs from the width before scaling, accounts for a stretching of the pixmap. The zoom levels for which new pixmaps will be rendered are defined in this method.

Parameters:factor – New zoom-factor
slo_update(pos)

Creates the requests for waveforms to the backend.

Parameters:pos – Position around which to render

Module contents