def generate_samples(self, output_folder, sample_list, tempo):
        '''
        Generates .wav-s for every given tempo from the sample.
        :param sample_list: Sample list
        :param tempo:
        :param output_folder:
        :return:
        '''

        start = tempo[0]
        end = tempo[1]
        interval = tempo[2]

        for sample in sample_list:
            for t in range(start, end, interval):
                # remove the '/' if it exists
                if output_folder.endswith('/'):
                    output_folder = output_folder[:-1]

                # if random samples add custom identifier not to override other random patterns
                filename = '{}bpm_{}bars_{}ptrn.wav'.format(
                    t, sample.bars, sample.note_length)
                file_location = '{}/without_noise/{}'.format(
                    output_folder, filename)

                # make directories if they don't exist
                if not os.path.exists(os.path.dirname(file_location)):
                    os.makedirs(os.path.dirname(file_location))
                psb.make_wav(sample.sample,
                             fn=file_location,
                             leg_stac=.7,
                             bpm=t,
                             silent=True)

                print('Created:', file_location)
 def conversion(self):
     dict = {
         1: 'c',
         2: 'd',
         3: 'e',
         4: 'f',
         5: 'g',
         6: 'a',
         7: 'b',
         8: 'c5',
         9: 'd5',
         10: 'e5',
         11: 'f5',
         12: 'g5'
     }
     music = []
     for i in range(len(self.output_note_pos)):
         if self.output_note_pos[i] == []:
             continue
         for j in range(len(self.output_note_pos[i])):
             music.append((dict[self.output_note_pos[i][j]],
                           int(self.output_note_type[i][j])))
     music = tuple(music)
     print(music)
     self.file_path = self.destination_path + '/music.wav'
     ps.make_wav(music, fn=self.file_path)
Exemple #3
0
    def mix():

        ps.make_wav(c1, fn="chord1.wav")
        ps.make_wav(c2, fn="chord2.wav")
        ps.make_wav(c3, fn="chord3.wav")
        ps.make_wav(c4, fn="chord4.wav")
        ps.make_wav(notes, fn="bebop.wav")

        sound1 = AudioSegment.from_file("chord1.wav")
        quieter_via_method = sound1.apply_gain(-10)
        quieter_via_operator = sound1 - 10

        sound2 = AudioSegment.from_file("chord2.wav")
        quieter_via_method = sound2.apply_gain(-10)
        quieter_via_operator = sound2 - 10

        sound3 = AudioSegment.from_file("chord3.wav")
        quieter_via_method = sound3.apply_gain(-10)
        quieter_via_operator = sound3 - 10

        sound4 = AudioSegment.from_file("chord4.wav")
        quieter_via_method = sound4.apply_gain(-10)
        quieter_via_operator = sound4 - 10

        melody = AudioSegment.from_file("bebop.wav")
        quieter_via_method = melody.apply_gain(+20)
        quieter_via_operator = melody + 20

        onetwo = sound1.overlay(sound2)
        onetwothree = onetwo.overlay(sound3)
        chord = onetwothree.overlay(sound4)
        combined = chord.overlay(melody)

        combined.export("combined.wav", format='wav')
Exemple #4
0
def beep():
    song2 = (('f4*', 16), ('c4', 16), ('r', 8), ('ab4*', 16), ('c4', 16),
             ('r', 8), ('g4*', 16), ('c4', 16), ('r', 8), ('f4*', 16),
             ('c4', 16), ('c5', 16), ('r', 16))

    make_wav(song2, bpm=80, repeat=3)

    #define stream chunk
    chunk = 1024

    #open a wav format music
    f = wave.open(r"out.wav", "rb")
    #instantiate PyAudio
    p = pyaudio.PyAudio()
    #open stream
    stream = p.open(format=p.get_format_from_width(f.getsampwidth()),
                    channels=f.getnchannels(),
                    rate=f.getframerate(),
                    output=True)
    #read data
    data = f.readframes(chunk)

    #paly stream
    while data != '':
        stream.write(data)
        data = f.readframes(chunk)

    #stop stream
    stream.stop_stream()
    stream.close()

    #close PyAudio
    p.terminate()
def wav_for_word(word, fn):
    score = []
    word_notes = [NOTES[ORDER.index(c)] for c in word if c in ORDER]
    n = len(word_notes) + 1
    for note in word_notes:
        score.append((note, n))
    score.append(('r', n))

    make_wav(score[:10], bpm=264, leg_stac=0.9, boost=1.1, fn=fn, silent=True)
def play(inst, songs, bPerM):
    pygame.mixer.init(48000, -16, 2, 1024)
    if inst == 0:
        import pysynth_b
        s0 = setSong(songs[0])
        s1 = setSong(songs[1])
        pysynth_b.make_wav(s0, fn="s0.wav", bpm=bPerM)
        pysynth_b.make_wav(s1, fn="s1.wav", bpm=bPerM)
        pygame.mixer.Channel(0).play(pygame.mixer.Sound('s0.wav'))
        pygame.mixer.Channel(1).play(pygame.mixer.Sound('s1.wav'))
        screen = pygame.display.set_mode((100, 100), 0, 32)
        while True:
            for event in pygame.event.get():
                if event.type == QUIT:
                    pygame.quit()
                    sys.exit()
                if event.type == KEYDOWN:
                    if event.key == K_ESCAPE:
                        pygame.quit()
                        sys.exit()
        pygame.display.update()
    elif inst == 1:
        import pysynth_s
        s0 = setSong(songs[0])
        pysynth_s.make_wav(s0, fn="s0.wav", bpm=bPerM)
        pygame.mixer.Channel(0).play(pygame.mixer.Sound('s0.wav'))
        screen = pygame.display.set_mode((100, 100), 0, 32)
        while True:
            for event in pygame.event.get():
                if event.type == QUIT:
                    pygame.quit()
                    sys.exit()
                if event.type == KEYDOWN:
                    if event.key == K_ESCAPE:
                        pygame.quit()
                        sys.exit()
        pygame.display.update()
    elif inst == 2:
        import pysynth_c
        s0 = setSong(songs[0])
        pysynth_c.make_wav(s0, fn="s0.wav", bpm=bPerM)
        pygame.mixer.Channel(0).play(pygame.mixer.Sound('s0.wav'))
        screen = pygame.display.set_mode((100, 100), 0, 32)
        while True:
            for event in pygame.event.get():
                if event.type == QUIT:
                    pygame.quit()
                    sys.exit()
                if event.type == KEYDOWN:
                    if event.key == K_ESCAPE:
                        pygame.quit()
                        sys.exit()
        pygame.display.update()
Exemple #7
0
 def create(self):
     notes = self.improvise()
     if self.instrument == "Piano":
         pysynth_b.make_wav(notes, fn=self.filename, bpm=self.tempo)
     elif self.instrument == "Plucked":
         pysynth_s.make_wav(notes, fn=self.filename, bpm=self.tempo)
     elif self.instrument == "Sawtooth":
         pysynth_c.make_wav(notes, fn=self.filename, bpm=self.tempo)
     elif self.instrument == "Square":
         pysynth_d.make_wav(notes, fn=self.filename, bpm=self.tempo)
     elif self.instrument == "Rhodes":
         pysynth_e.make_wav(notes, fn=self.filename, bpm=self.tempo)
Exemple #8
0
 def improv_or_chord():
     delay_print(
         "\nDo you want to hear the improvisation alone or with chords?\n")
     improv_chord = input("Enter 'alone' or 'chord': ")
     if str.lower(improv_chord) == "alone":
         ps.make_wav(notes, fn="bebop.wav")
         playaudio("bebop.wav")
     elif str.lower(improv_chord) == "chord":
         mix()
         playaudio("combined.wav")
     else:
         delay_print("Are you sure you entered a right command?\n")
         improv_or_chord()
Exemple #9
0
 def create(self, oid):
     notes = self.improvise()
     filename = "wav/" + str(oid) + ".wav"
     if self.instrument == "Plucked":
         pysynth_s.make_wav(notes, fn=filename, bpm=self.tempo)
     elif self.instrument == "Sawtooth":
         pysynth_c.make_wav(notes, fn=filename, bpm=self.tempo)
     elif self.instrument == "Square":
         pysynth_d.make_wav(notes, fn=filename, bpm=self.tempo)
     elif self.instrument == "Rhodes":
         pysynth_e.make_wav(notes, fn=filename, bpm=self.tempo)
     else:
         pysynth_b.make_wav(notes, fn=filename, bpm=self.tempo)
     return oid
Exemple #10
0
def createSong(highNotes, lowNotes, number):
    number = str(number)
    #piano-like sound for elevation changes that are greater than 0
    piano = tuple(highNotes)
    piano = keynote_to_keyname(piano)
    pianoName = "piano" + number + ".wav"
    pysynth_b.make_wav(piano, fn=pianoName)

    #percussion for elevation changes are less than 0
    low = tuple(lowNotes)
    low = keynote_to_keyname(low)
    percuussionName = "percussion" + number + ".wav"
    pysynth_p.make_wav(low, fn=percuussionName)

    #string for more full sound, based on elevation changes less than 0
    stringName = "string" + number + ".wav"
    pysynth_s.make_wav(low, fn=stringName)

    #mix files created (can only mix two at a time)
    firstMix = "mix" + number + ".wav"
    finalMix = "FINAL" + number + ".wav"
    mixfiles.mix_files(pianoName, percuussionName, firstMix)
    mixfiles.mix_files(stringName, firstMix, finalMix)
Exemple #11
0
			fsrange = list(range(1, fsnum + 1))
			sign = 1
			piano = piano_s
		for fs in fsrange:
			for oct in range(9):
				global_sharps_flats['%s%u' % (flats_and_sharps[fs], oct)] = sign
		#print global_sharps_flats
		measure_sharps_flats = global_sharps_flats.copy()
	if l.strip() == '' and sel:
		break
	if sel and not (l[0].isalpha() and l[1] == ':'):
		if not triptab: triptab = mk_triptab(meter)
		l2 = simp_line(list(l))
		parse_line(l2)

if do_repeat:
	song = song + second_ver

if not sel:
	print()
	print("*** Song %u not found in file %s!" % (num, fn))
	print()
else:
	print(key, unit)
	print(song)
	print()
	print(len(song))

	pysynth.make_wav(song, bpm = bpm)

Exemple #12
0
    

    # # 2) Play music output
    
    # Use pysynth to create a music output file
    
    # In[29]:
    import time
    ts = str(int(time.time()))
    www_dir = "/var/www/html/"
    sound_file = "audio_files/DNA_to_Music_"+ts+".wav"
    print('<br>')
    print('Creating Your DNA Music ....')
    print('<br>')
    print('<br>')
    pysynth_b.make_wav(song, fn = www_dir + sound_file , bpm = 360, silent=True)
    #print(sound_file, "file created!")
   
    print('<br>')
    print('<br>')
    print('<br>')
    print('<audio controls><source src="/'+sound_file+'" type="audio/ogg">Your browser does not support the audio element.</audio>')

    
    # Use Pydub to play the wav file generated
    
    # In[50]:
    
    
    #sound = AudioSegment.from_file(sound_file, format="wav")
    #play(sound)
Exemple #13
0
    ('g4', 4),
    ('a4', 8),
    ('g4', 8),
    ('e4', 16),
    ('g4', 16),
    ('e4', 16),
    ('d4', 16),
    ('c4', 4),
    ('d4', -8),
    ('e4', 16),
    ('c4', 2),
    ('c4', -8),
    ('d4', 16),
    ('e4', 8),
    ('f4', 8),
    ('g4', 8),
    ('a4', 16),
    ('b4', 16),
    ('c5', 4),
    ('c5', 8),
    ('b4', 16),
    ('a4', 16),
    ('g4', 8),
    ('f4', 8),
    ('e4', 8),
    ('d4', 8),
    ('c4', 4),
)

pysynth_b.make_wav(test, fn="小小音乐家.wav")
Exemple #14
0
'''
import pysynth_b as ps
import pyaudio
import wave

test = (('c', 4), ('d', 4), ('e', 4), ('f', 4), ('g', 4), ('a', 4), ('b', 4),
        ('c5', 4), ('d5', 4), ('e5', 4), ('d', 4), ('e', 4), ('e', -4),
        ('d', 8), ('d', 2), ('e', 4), ('e', 4), ('f', 4), ('g', 4), ('g', 4),
        ('f', 4), ('e', 4), ('d', 4), ('c', 4), ('c', 4), ('d', 4), ('e', 4),
        ('d', -4), ('c', 8), ('c', 2), ('d', 4), ('d', 4), ('e', 4), ('c', 4),
        ('d', 4), ('e', 8), ('f', 8), ('e', 4), ('c', 4), ('d', 4), ('e', 8),
        ('f', 8), ('e', 4), ('d', 4), ('c', 4), ('d', 4), ('g3', 4), ('e', 4),
        ('e', 4), ('f', 4), ('g', 4), ('g', 4), ('f', 4), ('e', 4), ('d', 4),
        ('c', 4), ('c', 4), ('d', 4), ('e', 4), ('d', -2), ('c', 8), ('c', 2))

ps.make_wav(test, fn="test.wav")

chunk = 1024

f = wave.open("test.wav", "rb")
#instantiate PyAudio
p = pyaudio.PyAudio()
#open stream
stream = p.open(format=p.get_format_from_width(f.getsampwidth()),
                channels=f.getnchannels(),
                rate=f.getframerate(),
                output=True)
#read data
data = f.readframes(chunk)

#paly stream
Exemple #15
0
			old = getnote(notes)
			if old != None:
				if notes[old] != start:
					song.append((old, getdur(notes[old], start)))
				notes[old] = -1
			elif start - gettotal() > 0:
				song.append(('r', getdur(gettotal(), start)))
				print("r3")
			notes[nn[0].lower()] = start
	print()
	print("Song")
	print(song)
	if "--syn_b" in sys.argv:
		import pysynth_b as pysynth
	elif "--syn_s" in sys.argv:
		import pysynth_s as pysynth
	elif "--syn_e" in sys.argv:
		import pysynth_e as pysynth
	elif "--syn_c" in sys.argv:
		import pysynth_c as pysynth
	elif "--syn_d" in sys.argv:
		import pysynth_d as pysynth
	elif "--syn_p" in sys.argv:
		import pysynth_p as pysynth
	elif "--syn_samp" in sys.argv:
		import pysynth_samp as pysynth
	else:
		import pysynth
	pysynth.make_wav(song, fn = filename, bpm = m.tempo)

Exemple #16
0
        if c_note == n_note:
            print c_note, n_note
            dur = 2 if c_duration > 2 else 1
            new_section.append((c_note, dur))
            skip = True
        else:
            new_section.append((c_note, c_duration))

    return tuple(new_section)


def arrange_song_into_aaba(a, b):
    return a + a + b + a


if __name__ == "__main__":
    a = run_genetic_algo()
    b = run_genetic_algo()
    dna = arrange_song_into_aaba(a, b)

    tune = dnaToPsSong(dna)
    massaged_tune = massage(tune)
    print tune
    print
    print massaged_tune

    rest_lists = [('r', 4)]
    tune_plus_rest = tuple(list(massaged_tune) + rest_lists)

    pysynth_b.make_wav(massaged_tune, fn="output.wav", leg_stac=.7, bpm=180)
Exemple #17
0
import pysynth_b as ps
import simpleaudio as sa
import random
import sys
import copy
import os
import time
from pydub import AudioSegment

note1 = [("g4", -2)]
ps.make_wav(note1, fn = "chord1.wav")

note2 = [("b4", -2)]
ps.make_wav(note2, fn = "chord2.wav")

note3 = [("c", -2)]
ps.make_wav(note3, fn = "chord3.wav")

note4 = [("e", -2)]
ps.make_wav(note4, fn = "chord4.wav")

sound1 = AudioSegment.from_file("chord1.wav")
sound2 = AudioSegment.from_file("chord2.wav")
sound3 = AudioSegment.from_file("chord3.wav")
sound4 = AudioSegment.from_file("chord4.wav")

onetwo = sound1.overlay(sound2)
onetwothree = onetwo.overlay(sound3)
combined = onetwothree.overlay (sound4)

combined.export("combined.wav", format='wav')
Exemple #18
0
import pysynth_b

theList = []

with open('notes.txt') as thefile:

	for line in thefile:
			#line = line[:-2]
			theList.append((line[:-1], 4))

thefile.close()

print theList[0]


song = tuple(theList)
print song

#print isinstance(theList[0], tuple)

pysynth_b.make_wav(song, fn = "GB.wav")


##musicNotes = []

##for line in temp:
	##musicNotes.append(line)
	##print line + "\n"

Exemple #19
0
import pysynth_b
import pygame
import time

#notes to create
notes = ('f3', 'g3', 'a3', 'b3', 'c4', 'd4', 'e4', 'f4', 'g4', 'a4', 'b4')
#use pysynth to make notes
for note in notes:
    synth = ((note, 3), ('r', 50))
    pysynth_b.make_wav(synth, fn='notes/' + note + '.wav')
Exemple #20
0
Mpentb = makeArray(Mpent, 0.9, 0.08, 0.02)
mpentb = makeArray(mpent, 0.9, 0.08, 0.02)
n1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
nM3 = [0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1]
nM7 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1]
nm3 = [0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
nm7 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1]


pick_prog = the_progs[random.randint(0, len(the_progs) - 1)]

# for i in range(size_rhythm):
musicb = GetLine(Bass_beat, pick_prog, notes, Mpentb, mpentb, 8)
musicb2 = GetLine(Bass_beat2, pick_prog, notes, Mpentb, mpentb, 8)
musicg = GetMelody(Guitar_beat, pick_prog, notes, M7, m7, 32)
r1 = GetLine(Rhythm_beat, pick_prog, notes, n1, n1, 20)
r3 = GetLine(Rhythm_beat, pick_prog, notes, nM3, nm3, 20)
r7 = GetLine(Rhythm_beat, pick_prog, notes, nM7, nm7, 20)

import pysynth as A_synth
import pysynth_b as B_synth
import pysynth_e as E_synth

B_synth.make_wav(musicb, fn="bassb.wav", bpm=120)
B_synth.make_wav(musicb2, fn="basse.wav", bpm=120)
E_synth.make_wav(musicg, fn="guitar.wav", bpm=120)
A_synth.make_wav(r1, fn="r1.wav", bpm=120)
A_synth.make_wav(r3, fn="r3.wav", bpm=120)
A_synth.make_wav(r7, fn="r7.wav", bpm=120)
##
Exemple #21
0
				global_sharps_flats['%s%u' % (flats_and_sharps[fs], oct)] = sign
		#print global_sharps_flats
		measure_sharps_flats = global_sharps_flats.copy()
	if l.strip() == '' and sel:
		break
	if sel and not (l[0].isalpha() and l[1] == ':'):
                print "Other, Time: " + str(time.time() - cur_time)
                cur_time = time.time()
		if not triptab: triptab = mk_triptab(meter)
		l2 = simp_line(list(l))
		parse_line(l2)
		print "Other done, Time: " + str(time.time() - cur_time)
                cur_time = time.time()

if do_repeat:
	song = song + second_ver
f.close()

if not sel:
	print
	print "*** Song %u not found in file %s!" % (num, fn)
	print
else:
	# print key, unit
	# print song
	# print
	# print len(song)

	pysynth.make_wav(song, bpm = bpm, fn = outfile_name)

Exemple #22
0
			sign = 1
			piano = piano_s
		for fs in fsrange:
			for oct in range(9):
				global_sharps_flats['%s%u' % (flats_and_sharps[fs], oct)] = sign
		#print global_sharps_flats
		measure_sharps_flats = global_sharps_flats.copy()
	if l.strip() == '' and sel:
		break
	if sel and not (l[0].isalpha() and l[1] == ':'):
		if not triptab: triptab = mk_triptab(meter)
		l2 = simp_line(list(l))
		parse_line(l2)

if do_repeat:
	song = song + second_ver
f.close()

if not sel:
	print
	print "*** Song %u not found in file %s!" % (num, fn)
	print
else:
	print key, unit
	print song
	print
	print len(song)

	pysynth.make_wav(song, bpm = bpm)

Exemple #23
0
import pysynth
import numpy
import pysynth_b

test = (('g#4', 2), ('r', 4))

pysynth_b.make_wav(test, fn = "g#42.wav")
Exemple #24
0
import pysynth_p as p  # ...
import pysynth_s as s  # ...

song = (('g', -8), ('e', 16), ('c', 4), ('e', 4), ('g', 4), ('c5', 2),
        ('e5', -8), ('d5', 16), ('c5', 4), ('e', 4), ('f#', 4), ('g', 2),
        ('g', 8), ('g', 8), ('e5', -4), ('d5', 8), ('c5', 4), ('b', 2),
        ('a', -8), ('b', 16), ('c5', 4), ('c5', 4), ('g', 4), ('e', 4), ('c',
                                                                         4))

# if you go to the website it has more full descriptions of all the synths and what they are made to represent.

#synth a (default, piano-ish)
a.make_wav(song, fn='a.wav')

# synth b (slighly more accurate piano)
b.make_wav(song, fn='b.wav')

# synth c (made to emulate bowed string (violin, cello, etc.))
c.make_wav(song, fn='c.wav')

# synth d (subtractive synth, woodwind (flute, clarinet etc.))
d.make_wav(song, fn='d.wav')

# synth e (takes significantly longer than the other to process, made to emulate electric piano)
e.make_wav(song, fn='e.wav')

# synth p (a percussion synth, no pitch, made to emulate drum. Probably wouldn't be used in our project.)
p.make_wav(song, fn='p.wav')

# synth s (made to emulate plucked strings, (guitar, ukelele)
s.make_wav(song, fn='s.wav')
Exemple #25
0
ORDER = 'vpwfclhsiaetonrdumygb'

with open(sys.argv[1], 'r') as fp:
    text = fp.read()

wav_filename = sys.argv[1].split('.')[0] + '.wav'

NOTES = (
    'c3', 'd3', 'e3', 'f3', 'g3', 'a4', 'b4',
    'c4', 'd4', 'e4', 'f4', 'g4', 'a5', 'b5',
    'c5', 'd5', 'e5', 'f5', 'g6', 'a6', 'b6',
)

def generate_music(text):
    paragraphs = text.lower().split('\n')
    for p in paragraphs:
        for word in p.split():
            yield [NOTES[ORDER.index(c)] for c in word if c in ORDER]
            
score = []
for word_notes in generate_music(text):
    n = len(word_notes) + 1
    #print(word_notes)
    for note in word_notes:
        score.append((note, n))
    score.append(('r', n))

sys.path.append('pysynth')
from pysynth_b import make_wav
make_wav(score[:500], bpm = 264, leg_stac = 0.9, boost=1.1, fn=wav_filename)
Exemple #26
0
import pyaudio
import wave
from pysynth_b import make_wav

song2 = (('f4*', 16), ('c4', 16), ('r', 8), ('ab4*', 16), ('c4', 16), ('r', 8),
         ('g4*', 16), ('c4', 16), ('r', 8), ('f4*', 16), ('c4', 16),
         ('c5', 16), ('r', 16))

make_wav(song2, bpm=80, repeat=3)

#define stream chunk
chunk = 1024

#open a wav format music
f = wave.open(r"out.wav", "rb")
#instantiate PyAudio
p = pyaudio.PyAudio()
#open stream
stream = p.open(format=p.get_format_from_width(f.getsampwidth()),
                channels=f.getnchannels(),
                rate=f.getframerate(),
                output=True)
#read data
data = f.readframes(chunk)

#paly stream
while data != '':
    stream.write(data)
    data = f.readframes(chunk)

#stop stream
                nn[0].lower(), -1) == -1:  # note ends because of new note
            old = getnote(notes)
            if old != None:
                if notes[old] != start:
                    song.append((old, getdur(notes[old], start)))
                notes[old] = -1
            elif start - gettotal() > 0:
                song.append(('r', getdur(gettotal(), start)))
                print("r3")
            notes[nn[0].lower()] = start
    print()
    print("Song")
    print(song)
    if "--syn_b" in sys.argv:
        import pysynth_b as pysynth
    elif "--syn_s" in sys.argv:
        import pysynth_s as pysynth
    elif "--syn_e" in sys.argv:
        import pysynth_e as pysynth
    elif "--syn_c" in sys.argv:
        import pysynth_c as pysynth
    elif "--syn_d" in sys.argv:
        import pysynth_d as pysynth
    elif "--syn_p" in sys.argv:
        import pysynth_p as pysynth
    elif "--syn_samp" in sys.argv:
        import pysynth_samp as pysynth
    else:
        import pysynth
    pysynth.make_wav(song, fn=filename, bpm=m.tempo)
Exemple #28
0
# coding=utf-8

import pysynth_b

test = (('e4', 4), ('e4', 8), ('g4', 8),
        ('a4', 8), ('c5', 8), ('c5', 8), ('a4', 8), 
        ('g4', 4), ('g4', 8), ('a4', 8),
        ('g4', 2),
        ('e4', 4), ('e4', 8), ('g4', 8),
        ('a4', 8), ('c5', 8), ('c5', 8), ('a4', 8), 
        ('g4', 4), ('g4', 8), ('a4', 8),
        ('g4', 2),
        ('g4', 4), ('g4', 4),
        ('g4', 4), ('e4', 8), ('g4', 8),
        ('a4', 4), ('a4', 4),
        ('g4', 2),
        ('e4', 4), ('d4', 8), ('e4', 8),
        ('g4', 4), ('e4', 8), ('d4', 8),
        ('c4', 4), ('c4', 8), ('d4', 8),
        ('c4', 2)
        )

pysynth_b.make_wav(test, fn = "茉莉花.wav")