Esempio n. 1
0
 def loadSound(self, sndPath, force=False):
     if sndPath:
         if os.path.isfile(sndPath):
             self.sndPath = sndPath
             self.parent.sg_audio.loadSnd(self.sndPath)
             chnls, samprate, dur = soundInfo(self.sndPath)
             self.sndDur = dur
             self.chnls = chnls
             self.sndInfoStr = u'Loaded sound: %s,  Sr: %i Hz,  Channels: %s,  Duration: %.3f sec' % (
                 self.sndPath, int(samprate), chnls, dur)
             if self.parent.draw:
                 if not self.sndPath in self.surface.bitmapDict.keys(
                 ) or force:
                     self.parent.log("Drawing waveform...")
                     self.surface.analyse(self.sndPath)
                 else:
                     self.surface.list = self.surface.bitmapDict[
                         self.sndPath]
                     self.surface.create_bitmap()
             self.logSndInfo()
         elif os.path.isfile(
                 os.path.join(self.parent.currentPath,
                              os.path.split(sndPath)[1])):
             self.loadSound(
                 os.path.join(self.parent.currentPath,
                              os.path.split(sndPath)[1]), force)
         elif ":\\" in sndPath:
             # Handle windows path...
             self.loadSound(
                 os.path.join(self.parent.currentPath,
                              sndPath.split("\\")[-1]), force)
         else:
             self.parent.log('Sound file "%s" does not exist!' % sndPath)
     else:
         self.parent.log("")
Esempio n. 2
0
 def loadSound(self, sndPath, force=False):
     if sndPath:
         if os.path.isfile(sndPath):
             self.sndPath = sndPath
             self.parent.sg_audio.loadSnd(toSysEncoding(self.sndPath))
             chnls, samprate, dur = soundInfo(toSysEncoding(self.sndPath))
             self.sndDur = dur
             self.chnls = chnls
             self.sndInfoStr = u'Loaded sound: %s,    Sr: %s Hz,    Channels: %s,    Duration: %s sec' % (self.sndPath, samprate, chnls, dur)
             if self.parent.draw:
                 if not self.sndPath in self.surface.bitmapDict.keys() or force:
                     self.parent.log("Drawing waveform...")
                     self.surface.analyse(self.sndPath)
                 else:
                     self.surface.list = self.surface.bitmapDict[self.sndPath]
                     self.surface.create_bitmap()
             self.logSndInfo()
         elif os.path.isfile(os.path.join(self.parent.currentPath, os.path.split(sndPath)[1])):
             self.loadSound(os.path.join(self.parent.currentPath, os.path.split(sndPath)[1]), force)
         elif ":\\" in sndPath:
             # Handle windows path...
             self.loadSound(os.path.join(self.parent.currentPath, sndPath.split("\\")[-1]), force)
         else:
             self.parent.log('Sound file "%s" does not exist!' % sndPath)
     else:
         self.parent.log("")
Esempio n. 3
0
 def insertSound(self, sndPath, force=False):
     if not self.sndPath:
         self.loadSound(sndPath)
         return
     if sndPath:
         if os.path.isfile(sndPath):
             self.sndPath = "Mixed sound " + str(random.randint(0, 10000))
             chnls, samprate, dur = soundInfo(sndPath)
             dlg = InsertDialog(self,
                                -1,
                                'Insert sound settings',
                                actual_dur=self.sndDur,
                                snd_dur=dur)
             refpos = self.surface.GetPosition()
             refsize = self.surface.GetSize()
             dlgsize = dlg.GetSize()
             X = refpos[0] + (refsize[0] / 2 - dlgsize[0] / 2)
             Y = refpos[1] + (refsize[1] / 2 - dlgsize[1] / 2)
             dlg.SetPosition((X, Y))
             if dlg.ShowModal() == wx.ID_OK:
                 start, end, point, cross = dlg.getValues()
                 ok = True
             else:
                 ok = False
             dlg.Destroy()
             if not ok:
                 return
             self.parent.sg_audio.insertSnd(sndPath, start, end, point,
                                            cross)
             self.sndDur = self.parent.sg_audio.getTableDuration()
             self.sndInfoStr = u'Loaded sound: %s,    Sr: %s Hz,    Channels: %s,    Duration: %s sec' % (
                 self.sndPath, samprate, self.chnls, self.sndDur)
             if self.parent.draw:
                 if not self.sndPath in self.surface.bitmapDict.keys(
                 ) or force:
                     self.parent.log("Drawing waveform...")
                     self.surface.analyse(self.sndPath)
                 else:
                     self.surface.list = self.surface.bitmapDict[
                         self.sndPath]
                     self.surface.create_bitmap()
             self.logSndInfo()
         elif os.path.isfile(
                 os.path.join(self.parent.currentPath,
                              os.path.split(sndPath)[1])):
             self.insertSound(
                 os.path.join(self.parent.currentPath,
                              os.path.split(sndPath)[1]), force)
         elif ":\\" in sndPath:
             # Handle windows path...
             self.insertSound(
                 os.path.join(self.parent.currentPath,
                              sndPath.split("\\")[-1]), force)
         else:
             self.parent.log('Sound file "%s" does not exist!' % sndPath)
Esempio n. 4
0
 def insertSound(self, sndPath, force=False):
     if not self.sndPath:
         self.loadSound(sndPath)
         return
     if sndPath:
         if os.path.isfile(sndPath):
             self.sndPath = "Mixed sound " + str(random.randint(0, 10000))
             chnls, samprate, dur = soundInfo(toSysEncoding(sndPath))
             dlg = InsertDialog(self, -1, 'Insert sound settings', actual_dur=self.sndDur, snd_dur=dur)
             refpos = self.surface.GetPosition()
             refsize = self.surface.GetSize()
             dlgsize = dlg.GetSize()
             X = refpos[0] + (refsize[0] / 2 - dlgsize[0] / 2)
             Y = refpos[1] + (refsize[1] / 2 - dlgsize[1] / 2)
             dlg.SetPosition((X,Y))
             if dlg.ShowModal() == wx.ID_OK:
                 start, end, point, cross = dlg.getValues()
                 ok = True
             else:
                 ok = False
             dlg.Destroy()
             if not ok:
                 return
             self.parent.sg_audio.insertSnd(toSysEncoding(sndPath), start, end, point, cross)
             self.sndDur = self.parent.sg_audio.getTableDuration()
             self.sndInfoStr = u'Loaded sound: %s,    Sr: %s Hz,    Channels: %s,    Duration: %s sec' % (self.sndPath, samprate, self.chnls, self.sndDur)
             if self.parent.draw:
                 if not self.sndPath in self.surface.bitmapDict.keys() or force:
                     self.parent.log("Drawing waveform...")
                     self.surface.analyse(self.sndPath)
                 else:
                     self.surface.list = self.surface.bitmapDict[self.sndPath]
                     self.surface.create_bitmap()
             self.logSndInfo()
         elif os.path.isfile(os.path.join(self.parent.currentPath, os.path.split(sndPath)[1])):
             self.insertSound(os.path.join(self.parent.currentPath, os.path.split(sndPath)[1]), force)
         elif ":\\" in sndPath:
             # Handle windows path...
             self.insertSound(os.path.join(self.parent.currentPath, sndPath.split("\\")[-1]), force)
         else:
             self.parent.log('Sound file "%s" does not exist!' % sndPath)