Skip to content

Commit

Permalink
Fix spectrogram movement when resizing while paused
Browse files Browse the repository at this point in the history
  • Loading branch information
tlecomte committed Feb 7, 2016
1 parent 00b3094 commit cf24626
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions friture/imageplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ def pause(self):

def restart(self):
self.isPlaying = True
self.last_time = self.audiobackend.get_stream_time()
self.timer.restart()

def draw(self, painter, xMap, yMap, rect):
Expand Down
7 changes: 4 additions & 3 deletions friture/spectrogram_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,10 @@ def erase(self):
# resize the pixmap and update the offsets accordingly
def resize(self, width, height):
oldWidth = self.pixmap.width() / 2
self.offset = (self.offset % oldWidth) * width / oldWidth - 1 # -1 to avoid black vertical lines on resize
self.offset = self.offset % width # to handle negative values
self.time_offset = (self.time_offset % oldWidth) * width / oldWidth
if width != oldWidth:
self.offset = (self.offset % oldWidth) * width / oldWidth
self.offset = self.offset % width # to handle negative values
self.time_offset = (self.time_offset % oldWidth) * width / oldWidth
self.pixmap = self.pixmap.scaled(2 * width, height, QtCore.Qt.IgnoreAspectRatio, QtCore.Qt.SmoothTransformation)

def setcanvas_height(self, canvas_height):
Expand Down

0 comments on commit cf24626

Please sign in to comment.