Пример #1
0
    def onSaveBtnClick(self):
        dialog = QFileDialog(self)
        dialog.setFileMode(QFileDialog.AnyFile)
        dialog.setNameFilter('Audio (*.wav)')
        if dialog.exec_():
            file_name = dialog.selectedFiles()[0] + '.wav'
            ww = wave.open(file_name,'wb')
            wf = self.wf
            ww.setframerate(wf.getframerate())
            ww.setsampwidth(wf.getsampwidth())
            ww.setnchannels(wf.getnchannels())
            self.wf.rewind()
            self.chain.reset()

            data = wf.readframes(wf.getnframes())
            s = self.chain.filter(pcmToFloat(byteToPCM(data,wf.getsampwidth())))
            ww.writeframes(bytes(floatToPCM(s)))
Пример #2
0
        def callback(in_data, frame_count, time_info, status):

            data = wf.readframes(frame_count)
            if type(data) == type(''):
                data = str.encode(data)            
            if len(data) < frame_count * sampw * nchan:
                if self.loop_box.isChecked():
                    wf.rewind()                    
                    data = b''.join([data,
                                     wf.readframes(frame_count - int(len(data) / (sampw * nchan)))])
                    self.chain.reset()
                elif len(data) == 0:
                    return data, pyaudio.paComplete
 
            filtered = self.chain.filter(pcmToFloat(byteToPCM(data,sampw)))
            self.plotwin.updateSpectrum(np.fft.rfft(filtered))                
                
            return bytes(floatToPCM(filtered)), pyaudio.paContinue