def test_write_waves(): writer = Writer() synthesizer = Synthesizer(osc1_waveform=Waveform.sine, osc1_volume=1.0, use_osc2=False) wave1 = synthesizer.generate_constant_wave(220.0, 3.0) wave2 = synthesizer.generate_constant_wave(440.0, 3.0) writer.write_waves("./test_waves.wav", wave1, wave2) ok_("write_waves() succeeded.")
def main(): writer = Writer() print("write chord sequence") synthesizer = Synthesizer(osc1_waveform=Waveform.sine, osc1_volume=1.0, use_osc2=False) chord = [ BASE * 2.0**(2 / 12.0), BASE * 2.0**(5 / 12.0), BASE * 2.0**(9 / 12.0), BASE * 2.0**(12 / 12.0) ] wave1 = synthesizer.generate_chord(chord, 1.0) chord = [ BASE * 2.0**(2 / 12.0), BASE * 2.0**(7 / 12.0), BASE * 2.0**(11 / 12.0) ] wave2 = synthesizer.generate_chord(chord, 1.0) chord = [ BASE, BASE * 2.0**(4 / 12.0), BASE * 2.0**(7 / 12.0), BASE * 2.0**(12 / 12.0) ] wave3 = synthesizer.generate_chord(chord, 1.0) writer.write_waves(os.path.join(DIR, "test.wav"), wave1, wave2, wave3)
def generate_wave_from_chord_objects( chords: List[object], filepath: str, ) -> None: synthesizer = Synthesizer(osc1_waveform=Waveform.triangle, osc1_volume=1.0, use_osc2=False) note_length: int = 2 root_pitch: int = 3 chord_waves: list = [] for chord in chords: if type(chord) is list: for c in chord: notes: list = c.components_with_pitch(root_pitch=root_pitch) chord_waves.append( synthesizer.generate_chord(notes, note_length / len(chord))) else: notes: list = chord.components_with_pitch(root_pitch=root_pitch) chord_waves.append(synthesizer.generate_chord(notes, note_length)) writer = Writer() writer.write_waves(filepath, *chord_waves)