Esempio n. 1
0
def write_chord(f, note_freq, sound_leveler):
    writer = Writer()
    synthesizer = Synthesizer(osc1_waveform=Waveform.sine,
                              osc1_volume=sound_leveler(note_freq),
                              use_osc2=False)
    wave = synthesizer.generate_chord([note_freq], 3.0)
    writer.write_wave(f, wave)
Esempio n. 2
0
def play(chord):
    player = Player()
    player.open_stream()
    synthesizer = Synthesizer(osc1_waveform=Waveform.sine,
                              osc1_volume=0.4,
                              use_osc2=False)
    player.play_wave(synthesizer.generate_chord(chord, 1))
Esempio n. 3
0
def play_beat(t):
    player = Player()
    player.open_stream()
    synthesizer = Synthesizer(osc1_waveform=Waveform.sawtooth,
                              osc1_volume=1.0,
                              use_osc2=False)
    for i in range(int(t / RATE)):
        player.play_wave(synthesizer.generate_chord(['A3'], 0.1))
        time.sleep(float(RATE - 0.1))
Esempio n. 4
0
def main():
    player = Player()
    player.open_stream()

    print("play major chord")
    synthesizer = Synthesizer(osc1_waveform=Waveform.sine,
                              osc1_volume=1.0,
                              use_osc2=False)
    chord = [BASE, BASE * 2.0**(4 / 12.0), BASE * 2.0**(7 / 12.0)]
    player.play_wave(synthesizer.generate_chord(chord, 3.0))
    time.sleep(0.5)

    print("play minor chord")
    chord = [BASE, BASE * 2.0**(3 / 12.0), BASE * 2.0**(7 / 12.0)]
    player.play_wave(synthesizer.generate_chord(chord, 3.0))
    time.sleep(0.5)

    print("play sus4 chord")
    chord = [BASE, BASE * 2.0**(5 / 12.0), BASE * 2.0**(7 / 12.0)]
    player.play_wave(synthesizer.generate_chord(chord, 3.0))
    time.sleep(0.5)

    print("play 7th chord")
    chord = [
        BASE, BASE * 2.0**(4 / 12.0), BASE * 2.0**(7 / 12.0),
        BASE * 2.0**(10 / 12.0)
    ]
    player.play_wave(synthesizer.generate_chord(chord, 3.0))
    time.sleep(0.5)

    print("play add9 chord")
    chord = [
        BASE, BASE * 2.0**(4 / 12.0), BASE * 2.0**(7 / 12.0),
        BASE * 2.0**(14 / 12.0)
    ]
    player.play_wave(synthesizer.generate_chord(chord, 3.0))
    time.sleep(0.5)

    print("play chord sequence")
    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)
    ]
    player.play_wave(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)
    ]
    player.play_wave(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)
    ]
    player.play_wave(synthesizer.generate_chord(chord, 1.0))
Esempio n. 5
0
def play_progression(progression):
    player = Player()
    player.open_stream()
    synthesizer = Synthesizer(osc1_waveform=Waveform.sine,
                              osc1_volume=10.0,
                              use_osc2=False)
    for measure in progression:
        for chord in measure:
            player.play_wave(
                synthesizer.generate_chord(chord[0], abs(chord[1])))
Esempio n. 6
0
def playPiece(lines: List[TemporalisedLine]):
    mapping, indexLines = asUniqueValues(lines)

    lowerLines = indexLines[0:-1]
    upperLine = indexLines[-1]

    sm = makeSimMap(lowerLines, upperLine)

    player = Player()
    player.open_stream()
    synthesizer = Synthesizer(osc1_waveform=Waveform.triangle, osc1_volume=1.0, use_osc2=False)

    for k in upperLine[0][:-1]:
        toPlay = [synth(mapping[n]) for n in sm[k].union([k])]
        player.play_wave(synthesizer.generate_chord([n for n in toPlay], 1 / len(lines)))

    # Play last note longer
    k = upperLine[0][-1]
    toPlay = [synth(mapping[n]) for n in sm[k].union([k])]
    player.play_wave(synthesizer.generate_chord([n for n in toPlay], 2 / len(lines)))
Esempio n. 7
0
def sheet_to_wave(path: str, synthesizer: Synthesizer) -> np.ndarray:
    sheet = open(path, "r")
    lines = sheet.readlines()

    wave = np.array([])

    for line in lines:
        info = line.strip().split(";")
        notes = info[0].split()
        duration = float(info[1])

        wave = np.hstack((wave, synthesizer.generate_chord(notes, duration)))

    return wave
Esempio n. 8
0
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)
Esempio n. 9
0
def main():
    args = parse_args()
    chords = ChordProgression(args.chord)

    player = Player()
    player.open_stream()
    synthesizer = Synthesizer(osc1_waveform=Waveform.triangle,
                              osc1_volume=1.0,
                              use_osc2=False)

    for chord in chords:
        notes = chord.components_with_pitch(root_pitch=3)
        print("Play {}".format(chord))
        player.play_wave(synthesizer.generate_chord(notes, 1.0))
Esempio n. 10
0
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)
Esempio n. 11
0
def main():
    player = Player()
    player.open_stream()

    print("play major chord")
    synthesizer = Synthesizer(osc1_waveform=Waveform.sine,
                              osc1_volume=1.0,
                              use_osc2=False)
    chord = ["C4", "E4", "G4"]
    player.play_wave(synthesizer.generate_chord(chord, 3.0))
    time.sleep(0.5)

    print("play minor chord")
    chord = ["C4", "Eb4", "G4"]
    player.play_wave(synthesizer.generate_chord(chord, 3.0))
    time.sleep(0.5)

    print("play sus4 chord")
    chord = ["C4", "F4", "G4"]
    player.play_wave(synthesizer.generate_chord(chord, 3.0))
    time.sleep(0.5)

    print("play 7th chord")
    chord = ["C4", "E4", "G4", "Bb4"]
    player.play_wave(synthesizer.generate_chord(chord, 3.0))
    time.sleep(0.5)

    print("play add9 chord")
    chord = ["C4", "E4", "G4", "D5"]
    player.play_wave(synthesizer.generate_chord(chord, 3.0))
    time.sleep(0.5)

    print("play chord sequence")
    chord = ["D4", "F4", "A4", "C5"]
    player.play_wave(synthesizer.generate_chord(chord, 1.0))
    chord = ["D4", "G4", "B4"]
    player.play_wave(synthesizer.generate_chord(chord, 1.0))
    chord = ["E4", "G4", "C5"]
    player.play_wave(synthesizer.generate_chord(chord, 1.0))
Esempio n. 12
0
class AudioDebug:
    def __init__(self, pre=["C3", "E3", "G3"], post=["C3", "D3", "F3"]):
        self.pre = pre
        self.post = post
        self.player = Player()
        self.player.open_stream()
        self.synthesizer = Synthesizer(osc1_waveform=Waveform.sine,
                                       osc1_volume=1.0,
                                       use_osc2=False)

    def play_chord(self, chord):
        self.player.play_wave(self.synthesizer.generate_chord(chord, 0.5))

    def __call__(self, func):
        def logic(*args, **kwargs):
            print('pre')
            self.play_chord(self.pre)
            result = func(*args, **kwargs)
            print('post')
            self.play_chord(self.post)
            return result

        return logic
instrument1 = osc1_waveform = Waveform.sine  #main instrument
instrument2 = osc1_waveform = Waveform.sawtooth  #diff instrument
volume1 = osc1_volume = 0.5  #nonpolar
volume2 = osc1_volume = 1.0  #polar
length = [0.1, 0.2, 0.3]  #based on size from smallest to largest

##For loop plays out each individual chords or notes from transcribed music
count = 0
for music in music_sheet:
    if music in chord_freq and aa_sequence[count] in small and aa_sequence[
            count] in nonpolar:  #Chords A-G & small
        print(aa_sequence[count])
        synthesizer = Synthesizer(instrument1, \
                                  volume1,use_osc2=False)
        player.play_wave(
            synthesizer.generate_chord(chord_freq[music], length[0]))
        count += 1
    elif music in chord_freq and aa_sequence[count] in small and aa_sequence[
            count] in polar:  #Chords A-G & small
        print(aa_sequence[count])
        synthesizer = Synthesizer(instrument1, \
                                  volume2,use_osc2=False)
        player.play_wave(
            synthesizer.generate_chord(chord_freq[music], length[0]))
        count += 1
    elif music in chord_freq and aa_sequence[count] in medium and aa_sequence[
            count] in nonpolar:  #Chords A-G & medium
        print(aa_sequence[count])
        synthesizer = Synthesizer(instrument1, \
                                  volume1,use_osc2=False)
        player.play_wave(
#iterate
while True:
    a = psutil.cpu_percent() / 100
    b = psutil.virtual_memory()[2] / 100

    pitch1 = a * (pitches[1] - pitches[0]) + pitches[
        0]  #changes every cycle with no lingering weight
    pitch2 = (1 - weight) * (pitch2) + (
        weight
    ) * pitch1  #weighted average of last n of pitches from pitch1 where n is (1/weight). makes a drone
    pitch3 = np.log(5 * np.exp(pitch2) *
                    (1 / 6))  #makes a minor third below the drone of pitch2
    tempo = b * (tempos[1] - tempos[0]) + tempos[0]  #define tempo from range

    leng = 60 / tempo
    chord = synthesizer.generate_chord(
        [np.exp(pitch1), np.exp(pitch2),
         np.exp(pitch3)], leng)  #second arg is length

    #make chord not clip on or off, fade first and last values
    lengthFade = int(fadeParam * len(chord))

    fadeVec = np.linspace(0, 1, num=lengthFade)
    chord[:lengthFade] = chord[:lengthFade] * fadeVec

    fadeVec = np.linspace(1, 0, num=lengthFade)
    chord[-lengthFade:] = chord[-lengthFade:] * fadeVec

    player.play_wave(chord)
Esempio n. 15
0
    note = 2**((note_num-69)/12.0)*440

    if(midi_dat[0][0] != 144):
        return list_in, num_list
    if(midi_dat[0][2] == 0):
        try:
            while(True):
                ind = num_list.index(note_num)
                if ind != -1:
                    list_in.pop(ind)
                    num_list.pop(ind)
        except: 
            return list_in, num_list
    else:
        list_in += [note]
        num_list += [note_num]
    return list_in, num_list
    

while(True):
    if(i.poll()):
        # read = midi.device.read(1)[0];
        read = i.read(10)[0]
        # print(read)
        # if(read[0][0] == 144 and read[0][1] != 0):
        #     val = int(read[0][1]);

        note_list, num_list = update_list(note_list, num_list, read)
    if(len(note_list) > 0):
        player.play_wave(synthesizer.generate_chord(note_list, 0.1)) # using chord to be able to play more notes as once
Esempio n. 16
0
def play():
    ####################
    player = Player()
    player.open_stream()
    synthesizer = Synthesizer(osc1_waveform=Waveform.sine, osc1_volume=1.0, use_osc2=False)
    #####################
    chordOrNot = [0,0,0,1]

    #SCALING_FACTOR = 7.0/255 #TODO
    durations = (0.25,0.5)#,0.5,0.75,1.0)
    # TODO: Gaussian

    # Part 0: Chord dictionary
    freq_update = {}
    freq = {'A0': 27.5, 'A#0': 29.14, 'B0': 30.87, 'C1': 32.7, 'C#1': 34.65, 'D1': 36.71, 'D#1': 38.89, 'E1': 41.2, 'F1': 43.65, 'F#1': 46.25, 'G1': 49.0, 'G#1': 51.91, 'A1': 55.0, 'A#1': 58.27, 'B1': 61.74, 'C2': 65.41, 'C#2': 69.3, 'D2': 73.42, 'D#2': 77.78, 'E2': 82.41, 'F2': 87.31, 'F#2': 92.5, 'G2': 98.0, 'G#2': 103.83, 'A2': 110.0, 'A#2': 116.54, 'B2': 123.47, 'C3': 130.81, 'C#3': 138.59, 'D3': 146.83, 'D#3': 155.56, 'E3': 164.81, 'F3': 174.61, 'F#3': 185.0, 'G3': 196.0, 'G#3': 207.65, 'A3': 220.0, 'A#3': 233.08, 'B3': 246.94, 'C4': 261.63, 'C#4': 277.18, 'D4': 293.66, 'D#4': 311.13, 'E4': 329.63, 'F4': 349.23, 'F#4': 369.99, 'G4': 392.0, 'G#4': 415.3, 'A4': 440.0, 'A#4': 466.16, 'B4': 493.88, 'C5': 523.25, 'C#5': 554.37, 'D5': 587.33, 'D#5': 622.25, 'E5': 659.26, 'F5': 698.46, 'F#5': 739.99, 'G5': 783.99, 'G#5': 830.61, 'A5': 880.0, 'A#5': 932.33, 'B5': 987.77, 'C6': 1046.5, 'C#6': 1108.73, 'D6': 1174.66, 'D#6': 1244.51, 'E6': 1318.51, 'F6': 1396.91, 'F#6': 1479.98, 'G6': 1567.98, 'G#6': 1661.22, 'A6': 1760.0, 'A#6': 1864.66, 'B6': 1975.53, 'C7': 2093.0, 'C#7': 2217.46, 'D7': 2349.32, 'D#7': 2489.02, 'E7': 2637.02, 'F7': 2793.83, 'F#7': 2959.96, 'G7': 3135.96, 'G#7': 3322.44, 'A7': 3520.0, 'A#7': 3729.31, 'B7': 3951.07, 'C8': 4186.01}
    for k,v in freq.items():
        note = k[:-1]
        octave = int(k[-1])
        freq = v
        if octave == 4:
            freq_update[note] = freq
    freq = freq_update

    # Part 1: Choose a scale. Extract the notes and chords from that scale.
    #all_possible_scales = list(Scale.all('major'))
    m = 'major'
    all_possible_scales = [Scale('C4',m), Scale('A4',m), Scale('F4',m), Scale('G4',m)]
    choice_of_scale = random.choice(all_possible_scales)
    notes = [choice_of_scale[i] for i in range(len(choice_of_scale))]

    # Part 2: Choose a permutation of chords and notes from the list.

    ## Once it is over, pick a new random permutation and keep going unless stopped.

    # Part 3: Go through the image and based on pixed values, play the permutation.
    # Part 3 -->

    image = cv2.imread('images/nature.jpg', 0)

    #image = str(request.get('img'))

    image = skimage.measure.block_reduce(image, (150,150), np.mean)
    image = image.flatten()
    # pooling stuff happens here

    image = np.random.permutation(image)


    for px in image: #px is the pixel value
        if px == 255:
            px = px-1
        isChord = random.choice(chordOrNot)
        note = math.trunc(px*len(notes)/255.0)
        duration = random.choice(durations)
        if note >= len(notes):
            continue
        note = str(notes[note])

        if note not in freq:
            flatOrSharp = note[-1]
            if flatOrSharp == '#':
                note = chr(ord(note[0])+1)
            else:
                note = chr(ord(note[0])-1)
        
        if note not in freq:
            continue
        fr = freq[note]
        if(isChord):
            # play a chord
            notes_in_chord = Chord(Note(note), 'M').notes
            freq_list = []
            for n in notes_in_chord:
                a = str(n)
                if a not in freq:
                    flatOrSharp = a[-1]
                    if flatOrSharp == '#':
                        a = chr(ord(a[0])+1)
                    else:
                        a = chr(ord(a[0])-1)
                        if a not in freq:
                            break
                freq_list.append(freq[a])
            player.play_wave(synthesizer.generate_chord(freq_list, duration))
        else:
            # play a note
            player.play_wave(synthesizer.generate_constant_wave(fr, duration))
    return "Successfully vocalized image";
Esempio n. 17
0
def digitalChime(number_of_notes):
    player = Player()
    synthesizer = Synthesizer(osc1_waveform=Waveform.sawtooth,
                              osc1_volume=0.1,
                              use_osc2=False)
    player.open_stream()

    #find base note
    base = random.randint(1, 6)
    time = random.randint(1, 4) * 0.25

    octive = 1
    sig = 3

    #play this many notes
    for i in range(0, number_of_notes):
        next = random.randint(1, 6)

        print('|  ', end='')

        if i % sig == 0:
            base = random.randint(1, 6)
            if base == 1:
                base = Notes['C4']
                print('Cv ', end='♪ ')
            elif base == 2:
                base = Notes['D4']
                print('Dv ', end='♪ ')
            elif base == 3:
                base = Notes['F4']
                print('Fv ', end='♪ ')
            elif base == 4:
                base = Notes['G4']
                print('Gv ', end='♪ ')
            elif base == 5:
                base = Notes['A4']
                print('Av ', end='♪ ')
            else:
                base = Notes['C5']
                print('C  ', end='♪ ')
            base = (base / 2) * octive
        else:
            print('"  ', end='♫ ')

        if next == 1:
            next = Notes['C4']
            print('C  ', end='')
        elif next == 2:
            next = Notes['D4']
            print('D  ', end='')
        elif next == 3:
            next = Notes['F4']
            print('F  ', end='')
        elif next == 4:
            next = Notes['G4']
            print('G  ', end='')
        elif next == 5:
            next = Notes['A4']
            print('A  ', end='')
        else:
            next = Notes['C5']
            print('C^ ', end='')

        if i % (int)(8 / (time)) == 0:
            print(' | ', end='♫ ')
            sig = random.randint(2, 8)
            time = random.randint(2, 10) * 0.125
            octive = random.randint(0, 2)
            if octive == 0:
                octive = 0.5
            elif octive < 0:
                octive = 0.25
            print(octive * 4, end=' ♪ ')
            print(time, end=' ♪\n')
        else:
            print(' |')

        next *= octive
        chord = [next, base]

        #print(octive)
        #print(time)

        player.play_wave(synthesizer.generate_chord(chord, time))
        # player.play_wave(synthesizer.generate_constant_wave(next,0.5))

    player.play_wave(synthesizer.generate_chord(chord, time * sig - 1))
Esempio n. 18
0
"""
    Synthesize a simple sound of a given frequency.
"""
from synthesizer import Player, Synthesizer, Waveform, Writer
import scales

player = Player()
player.open_stream()
synthesizer = Synthesizer(osc1_waveform=Waveform.sine, osc1_volume=1.0, use_osc2=False)

# Play A4
player.play_wave(synthesizer.generate_constant_wave(440.0, 1.0))

# Play C major
chord = [261.626,  329.628, 391.996]
player.play_wave(synthesizer.generate_chord(chord, 1.0))

# Play exemplary "almost" chord
# C_4
chord = [270.000,  329.628, 370.000]
player.play_wave(synthesizer.generate_chord(chord, 2.0))

# write
writer = Writer()

chord = [170.000,  329.628, 570.000]
wave = synthesizer.generate_chord(chord, 3.0)
writer.write_wave("output_records/synth.wav", wave)

# # generate the sound of a full scale of notes
# scale_dict = scales.fit_frequencies(scales.full_scale)
Esempio n. 19
0
instrument1 = osc1_waveform = Waveform.square  #main instrument
instrument2 = osc1_waveform = Waveform.triangle  #diff instrument
volume1 = osc1_volume = 0.5  #nonpolar
volume2 = osc1_volume = 1.0  #polar
length = [0.1, 0.2, .3]  #based on size from smallest to largest

##For loop plays out each individual chords or notes from transcribed music
count = 0
for music in music_sheet:
    if music in chord_freq and aa_sequence[count] in small and aa_sequence[
            count] in nonpolar:  #Chords A-G & small
        print(aa_sequence[count])
        synthesizer = Synthesizer(instrument1, \
                                  volume1,use_osc2=False)
        player.play_wave(
            synthesizer.generate_chord(chord_freq[music], length[0]))
        count += 1
    elif music in chord_freq and aa_sequence[count] in small and aa_sequence[
            count] in polar:  #Chords A-G & small
        print(aa_sequence[count])
        synthesizer = Synthesizer(instrument1, \
                                  volume2,use_osc2=False)
        player.play_wave(
            synthesizer.generate_chord(chord_freq[music], length[0]))
        count += 1
    elif music in chord_freq and aa_sequence[count] in medium and aa_sequence[
            count] in nonpolar:  #Chords A-G & medium
        print(aa_sequence[count])
        synthesizer = Synthesizer(instrument1, \
                                  volume1,use_osc2=False)
        player.play_wave(
from synthesizer import Player, Synthesizer, Waveform

from common.tones import Chord, Intervals, Tones

from common import tones

player = Player()
player.open_stream()
synthesizer = Synthesizer(osc1_waveform=Waveform.sine,
                          osc1_volume=1.0,
                          use_osc2=False)
# Play A4
player.play_wave(synthesizer.generate_constant_wave(Tones.A4_freq, 1.0))

player.play_wave(
    synthesizer.generate_chord(
        tones.Chord.freqs_mult(Tones.A4_freq, Chord.Type.major), 2.0))
player.play_wave(
    synthesizer.generate_chord(
        tones.Chord.freqs_mult(Tones.A4_freq, Chord.Type.minor), 2.0))
player.play_wave(
    synthesizer.generate_chord(
        tones.Chord.freqs_mult(Tones.A4_freq, Chord.Type.dim), 2.0))
player.play_wave(
    synthesizer.generate_chord(
        tones.Chord.freqs_mult(Tones.A4_freq, Chord.Type.aug), 2.0))

# Play C major
player.play_wave(synthesizer.generate_chord(Chord.C_major_chord, 3.0))
Esempio n. 21
0
H = 'D'
L = 'E'
T = 'F'
P = 'G'
'''

# MVHLTPEE into chords, chords in pyaudio are in the form of frequencies
# Link to frequency chart: http://pages.mtu.edu/~suits/notefreqs.html
B = [493.88, 311.13,
     369.99]  # B major consists of the notes B, D#, F# with these given freq.
C = [261.63, 329.63,
     392.00]  # C major consists of C, E, G with these given frequencies
D = [293.66, 369.99, 440.00]  # D major consists of D, F#, A
E = [329.63, 415.30, 493.88]  # etc...
F = [349.23, 440.00, 261.63]
G = [392.00, 493.88, 293.66]
A = [440.00, 277.18, 329.63]

# So our major chord sequence for our amino acid sequence is: BCDEFGAA

major_chords = [B, C, D, E, F, G, A, A]  # List the major chords sequence
for letter in major_chords:  # For each major chord, play the sound of that major chord using the
    # listed frequencies from earlier^
    player = Player()
    player.open_stream()
    synthesizer = Synthesizer(osc1_waveform=Waveform.sawtooth,
                              osc1_volume=1.0,
                              use_osc2=False)
    chord = letter
    player.play_wave(synthesizer.generate_chord(chord, 0.5))
Esempio n. 22
0
# https://github.com/yuma-m/synthesizer
from synthesizer import Synthesizer, Waveform, Writer

writer = Writer()
synthesizer = Synthesizer(osc1_waveform=Waveform.sine,
                          osc1_volume=1.0,
                          use_osc2=False)

chord = [261.626, 329.628, 391.996]
writer.write_wave("../audio/output/synthtest.wav",
                  synthesizer.generate_chord(chord, 5.0))
def second(player):
    while True:
        synthesizer = Synthesizer(osc1_waveform=Waveform.sine, osc1_volume=1.0, use_osc2=False)
        player.play_wave(synthesizer.generate_chord(['D6'], 0.1))
def first(player):
    t1 = time.time()
    while True:
        synthesizer = Synthesizer(osc1_waveform=Waveform.sine, osc1_volume=1.0, use_osc2=False)
        player.play_wave(synthesizer.generate_chord(['D5', 'A5', 'F#5'], 1))