Esempio n. 1
0
class csv_dtmf():
    def __init__(self):
        self.my_dtmf = DTMF()

    def read_scale(self, file_name):  # 譜面データを読み込み、配列にして返す
        scale_data = []
        csv_reader = csv.reader(open(file_name+'.csv', 'rb'), delimiter=',', quotechar=',')
        for row in csv_reader:
            scale_data.append(row)

        return scale_data

    def create_dtmf(self, data):
        wave_data = ''
        for d in data:
            wave_data += self.my_dtmf.create_dtmf(DTMF_AMPLITUDE, d[0], float(d[1]))

        return wave_data

    def save_wave(self, wave_data, file_name):
        self.my_dtmf.save(wave_data, 8000, 16, file_name)


if __name__ == '__main__':
    decorder = csv_dtmf()
    player = PLAY_WAVE()
    scale_data = decorder.read_scale(FILE_NAME)
    wave_data = decorder.create_dtmf(scale_data)
    decorder.save_wave(wave_data, FILE_NAME+'.wav')
    player.play(FILE_NAME+'.wav')
Esempio n. 2
0
            if max(spec) >= 2000 and np.argmax(spec) > 3:
                print('spec: %s' % str(max(spec)))
                max_list_num = np.argmax(spec)
                print('Max : %8.3f , %s, %s' % (
                    self.freq_list[max_list_num][0],
                    self.my_piano.octa_mark[self.freq_list[max_list_num][1]],
                    self.my_piano.onkai[self.freq_list[max_list_num][2]])
                )
                sound_data.append(phone_scale[self.freq_list[max_list_num][2]])
            else:
                print('none')
                sound_data.append('N')

            self.specItem.plot(spec, clear=True)
            QtGui.QApplication.processEvents()

        self.save_score_data(sound_data, self.chunk/float(self.fs), OUTPUT_FILE_NAME)

        self.stream.close()
        self.p.terminate()


if __name__ == '__main__':
    speana = C_spectrumAnalyzer()
    speana.setup_windo()
    speana.spectrumAnalyzer()

    w_player = PLAY_WAVE()
    w_player.play(OUTPUT_FILE_NAME+'.wav')