Пример #1
0
 def OnAlign(self, evt):
     reference = wx.GetSingleChoice(
         "Select a reference track",
         self.m_alignBtn.GetLabel(),
         TrackList.track_names(),
         parent=self
     )
     if reference:
         tracks = self.GetSelectedTrackNames() or TrackList.track_names()
         for path in tracks:
             TrackList.align_track(reference, path)
Пример #2
0
 def _moveItems(self, delta):
     # In order to update the list in-place, we need to:
     # - iterate forwards if delta is negative
     # - iterate backwards if delta is positive
     order = list(enumerate(TrackList.track_names()))
     if delta > 0:
         order = reversed(order)
     with TrackList.transaction():
         for i, f in order:
             if f in self.dragitems:
                 TrackList.move(i, i + delta)
Пример #3
0
 def _dragDelta(self, evt):
     # Base delta
     delta = evt.index - self.dragidx
     # Constrain delta so that the first item doesn't end up negative, and the last
     # item doesn't end up off the list
     tracks = TrackList.track_names()
     for i, f in enumerate(tracks):
         if f in self.dragitems:
             if i + delta < 0:
                 delta = -i
             elif i + delta >= len(tracks):
                 delta = len(tracks) - i - 1
     return delta
Пример #4
0
 def OnNormalize(self, evt):
     target = wx.GetNumberFromUser(
         "Enter the normalization target",
         "Target LUFS",
         self.m_normalizeBtn.GetLabel(),
         value=-23,
         min=-50,
         max=-6,
         parent=self
     )
     if target != -1:
         tracks = self.GetSelectedTrackNames() or TrackList.track_names()
         for path in tracks:
             TrackList.normalize_track(path, target)
Пример #5
0
 def OnFadeOut(self, evt):
     seconds = dialogs.GetFloatFromUser(
         "Enter the fade out duration in seconds",
         self.m_fadeOutBtn.GetLabel(),
         value=1.5,
         min=0,
         max=300,
         parent=self
     )
     if seconds is not None:
         tracks = self.GetSelectedTrackNames() or TrackList.track_names()
         for path in tracks:
             if seconds == 0:
                 TrackList.remove_filter(path, 'fade_out')
             else:
                 TrackList.set_filter(path, 'fade_out', {'duration': seconds})
Пример #6
0
 def DoDrag(self, evt):
     delta = self._dragDelta(evt)
     self._moveItems(delta)
     # reset the selection
     for i, f in enumerate(TrackList.track_names()):
         self.m_listCtrl.Select(i, f in self.dragitems)
Пример #7
0
 def GetSelectedTrackNames(self):
     """Returns a list of selected track filenames."""
     return [name for i, name in enumerate(TrackList.track_names())
             if self.m_listCtrl.IsSelected(i)]