예제 #1
9
def runMusicGenerator(models, songName):
    """
        Requires: models is a list of trained models
        Modifies: nothing
        Effects:  runs the music generator as following the details in the spec.
        
        Note: For the core, this should print "Under construction".
    """
    possiblePitches = KEY_SIGNATURES[random.choice(KEY_SIGNATURES.keys())]
    song = generateMusic(models,25, possiblePitches)
    pysynth.make_wav(song, fn = songName)
예제 #2
0
파일: synth.py 프로젝트: VanDavv/codesynth
def synthesize(text):
    notes = list(map(encode, text))
    if not os.path.exists('output'):
        os.makedirs('output')
    filename = os.path.join('output', uuid.uuid4().hex + '.wav')
    ps.make_wav(notes, fn=filename)
    return filename
예제 #3
0
def generateSong():

    noteList = []

    with open("./notes.txt") as f:
        text = f.read()

    text_model = markovify.NewlineText(text)

    for i in range(7):
        z = (text_model.make_short_sentence(100))
        if (z != None and len(z) > 16):
            x = z

    count = 0
    listCount = 0

    for i in x:
        if (i != " " and i != "#"):
            noteList.insert(listCount, i)
            listCount += 1
        count += 1

    if (os.path.isfile('./static/tune.wav')):
        print("Deleting old WAV file")
        os.remove("./static/tune.wav")

    tune = ((noteList[0], 4), (noteList[1], 4), (noteList[2], 4),
            (noteList[3], 4), (noteList[4], 4), (noteList[5], 4),
            (noteList[6], 4), (noteList[7], 4))
    print("Creating new WAV file")
    pysynth.make_wav(tune, fn="./static/tune.wav")
예제 #4
0
def playaudio (notes) :

	file = "bebop.wav"
	ps.make_wav(notes, fn = file)
	wave_obj = sa.WaveObject.from_wave_file(file)
	play_obj = wave_obj.play()
	play_obj.wait_done()
예제 #5
0
def runMusicGenerator(models, songName):
    """
    Requires: models is a list of trained models
    Modifies: nothing
    Effects:  uses models to generate a song and write it to the file
              named songName.wav
    """

    verseOne = []
    verseTwo = []
    chorus = []

    for i in range(4):
        verseOne.extend(generateTokenSentence(models, 7))
        verseTwo.extend(generateTokenSentence(models, 7))
        chorus.extend(generateTokenSentence(models, 9))

    song = []
    song.extend(verseOne)
    song.extend(verseTwo)
    song.extend(chorus)
    song.extend(verseOne)
    song.extend(chorus)

    pysynth.make_wav(song, fn=songName)
예제 #6
0
파일: PyPoser.py 프로젝트: WilliXL/PyPoser
 def generateWithTitle(self): # uses data from tonalito.com
                              # RAW data found in SongClassificationData.xlsx
                              # how to integrate MonkeyLearn is found:
                              # https://github.com/monkeylearn/monkeylearn-python
     title = self.title.get()
     if (title == "Snoop Dogg"):
         playMusic("easterEgg.wav")
     if (title == "Queen"):
         playMusic("easterEgg2.wav")
     if (title == "Cellphone"):
         playMusic("easterEgg3.wav")
     if (title.lower() == "112 is easy"):
         playMusic("easterEgg4.wav")
     keyMonkeyList = [title]
     moodMonkeyList = [title]
     keyMonkey = ml.classifiers.classify(key_id, keyMonkeyList, sandbox=True)
     moodMonkey = ml.classifiers.classify(mood_id, moodMonkeyList, sandbox=True)
     genres = ["Jazz","Classical","Standard"] # I had no data on titles as they 
                                              # relate to genre, so I'm just
                                              # getting a genre by random
     genre = random.choice(genres)
     key = keyMonkey.result[0][0]['label']
     mood = moodMonkey.result[0][0]['label']
     generateMusic(key,genre,mood)
     ps.make_wav(finalPieceMelody, fn="melody.wav")
     ps.make_wav(finalPieceHarmony, fn="harmony.wav")
     combine()
     playMusic("final.wav")
예제 #7
0
    def export_to_mp3(self):
        # TODO: Add evolving rhythm or random rhythm to create variation in the music
        # Delete and recreate output folder
        if (os.path.isdir('output/feasibles')
                & os.path.isdir('output/infeasibles')):
            shutil.rmtree('output/feasibles')
            shutil.rmtree('output/infeasibles')
        try:
            os.makedirs('output/feasibles')
            os.makedirs('output/infeasibles')
        except OSError as e:
            if e.errno != e.errno.EEXIST:
                raise

        # Write melodies to wav
        nr_of_notes = self.notes_per_chord * self.nr_of_chords
        rhythm = [3 for i in range(nr_of_notes)]
        fi_f = list(reversed(sorted(self.feasibles,
                                    key=self.fitness)))  # Fittest feasibles
        fi_if = list(reversed(sorted(self.infeasibles,
                                     key=self.fitness)))  # Fittest infeasibles
        for melody in fi_f:
            # Convert melody from numerical notation to string notes
            melody2 = [(self.key[melody[i]], rhythm[i])
                       for i in range(nr_of_notes)]
            pysynth.make_wav(melody2,
                             fn="output/feasibles/" +
                             str(self.feasibles.index(melody)) + ".wav")
        for melody in fi_if:
            # Convert melody from numerical notation to string notes
            melody2 = [(self.key[melody[i]], rhythm[i])
                       for i in range(nr_of_notes)]
            pysynth.make_wav(melody2,
                             fn="output/infeasibles/" +
                             str(self.infeasibles.index(melody)) + ".wav")
    def generate(self):
        
        for instrument in self.instruments:
            trackDir = "./tmp/" + self.trackName 
            if not os.path.exists(trackDir):
                os.makedirs(trackDir)

            make_wav(tuple(self.instruments[instrument]), fn = trackDir + "/" + instrument + ".wav", bpm = self.tempo)
예제 #9
0
def main():
    # get the durations and notes
    mus_data = file_to_array(sys.argv[1])
    mus_data = array_to_dict(mus_data)
    mus_data = get_direction(mus_data) 
    mus_data = get_change(mus_data)
    mus_data = get_notes(mus_data)
    mus_data = get_duration(mus_data)
    notes = get_array(mus_data)
    pysynth.make_wav(notes, fn="output.wav", bpm=TEMPO)
예제 #10
0
def runMusicGenerator(models, songName):
    """
    Requires: models is a list of trained models
    Modifies: nothing
    Effects:  runs the music generator as following the details in the spec.
              Note: For the core, this should print "Under construction".
    """
    keylist = KEY_SIGNATURES.keys()
    randomkey = random.choice(keylist)
    tuplelist = generateMusicalSentence(models, 100, KEY_SIGNATURES[randomkey])
    pysynth.make_wav(tuplelist, fn=songName)
예제 #11
0
def runMusicGenerator(models, songName):
    """
        Requires: models is a list of trained models
        Modifies: nothing
        Effects:  runs the music generator as following the details in the spec.
        
        Note: For the core, this should print "Under construction".
    """
    possiblePitches = KEY_SIGNATURES[random.choice(KEY_SIGNATURES.keys())]
    song = generateMusic(models, 25, possiblePitches)
    pysynth.make_wav(song, fn=songName)
예제 #12
0
 def play_function(self, *data):
     #print "clicked"
     to_play = []
     for elemento in self.lista:
         #elemento[1] es y
         #y de c3 do central es 78
         #6 y entre nota
         to_play.append((self.addnota("c3", (78 - elemento[1]) / 6), 3))
     #print to_play
     pysynth.make_wav(to_play, fn="./notas.wav")
     os.system("padsp python player.py notas.wav")
     os.remove("notas.wav")
예제 #13
0
 def generateSong(self, imgpath, nnotes=20, filetype='wav', method='dark'):
     notearr = self.convertToNotes(imgpath, nnotes, method)  # get notes
     extension = str(time.time()).split('.', 1)[0]  # filename extension
     wavfilename = imgpath.split('.',
                                 1)[0] + extension + '.wav'  # wav filepath
     mp3filename = imgpath.split('.',
                                 1)[0] + extension + '.mp3'  # mp3 filepath
     ps.make_wav(notearr, fn=wavfilename)
     if filetype == 'mp3':  # convert wav to mp3 if necessary
         AudioSegment.from_wav(wavfilename).export(mp3filename,
                                                   format="mp3")
         os.remove(wavfilename)
예제 #14
0
def _generate_wavs():
    if not os.path.exists(ASSET_DIR):
        raise SystemExit(
            f"Please ensure the directory {ASSET_DIR} exists on your file system!"
        )

    for note in _generate_all_notes():
        for dur in DURATIONS:
            ps.make_wav(
                ((f'{note}', dur), ),
                fn=os.path.join(ASSET_DIR, f'{note}_{dur}.wav'),
                bpm=BPM,
            )
예제 #15
0
def main():
    expr = raw_input('Continous function: ')
    lowBound = eval(raw_input('Lower bound: '))
    upBound = eval(raw_input('Upper bound: '))
    incr = eval(raw_input('Increment: '))
    transf = raw_input('Transform function: ')
    evaluator = Evaluator(expr)
    datafier = Datafier(lowerBound=lowBound,
                        upperBound=upBound,
                        pace=incr,
                        evaluator=evaluator)
    mapper = MusicMapper()
    musicMap = mapper.transformToMusic(datafier.fillPoints())
    ps.make_wav(musicMap, fn="test.wav")
예제 #16
0
def make_wav_from_notes(notes, filename):
    """Creates a .wav file from a set of notes.
    The notes are taken in groups of 3s and a .wav file
    is created from each of those. Then these files are
    stitched together."""
    sounds = []
    filename = filename.replace(".wav", "") + ".wav"
    note_play = tuple([(n, 1) for n in itertools.chain(*notes)])

    for i in range(3):
        name = "sound_" + str(i) + ".wav"
        ps.make_wav(note_play[i::3], fn=name)
        sounds.append(AudioSegment.from_wav(name))
    combined = (sounds[0].overlay(sounds[1])).overlay(sounds[2])
    combined.export(filename, format="wav")
예제 #17
0
def write_wav(note_vals, total_dist, musicfile):  # add total_time?
    """ TO BE DEPRECATED """
    # most basic, plays all notes w/o regard for rests or relative timing
    # hard-coded for pentatonic scale:
    note_conversion = {0: 'c', 1: 'd', 2: 'e', 3: 'g', 4: 'a'}
    rests = np.zeros(len(note_vals))  # may be unnecessary
    rests[0] = note_vals[0][0][0]
    for i in range(1, len(note_vals)):
        rests[i] = note_vals[i][0][0] - note_vals[i - 1][0][0]
    # simply plays all notes as quarter notes (no rests)
    # PySynth cannot play multiple notes at the same time, which would be preferable
    notes = []
    for i in note_vals:
        notes.append((note_conversion[i[1]], 4))
    notes = tuple(notes)
    ps.make_wav(notes, fn=musicfile)
예제 #18
0
 def write(self, melody,title,times=None):
     abc_notation = []
     for i in range(len(melody)):
         if isinstance(melody[i],tuple):
             note = melody[i][0]
             note_time = melody[i][1]
         else:
             note = melody[i]
             if times:
                 note_time = times[i]
                 if note_time == 0:
                     note_time = 4
             else:
                 note_time = 4
         abc_notation.append((self.number_to_abc(note),note_time))
     print "ABC to write:",abc_notation
     pysynth.make_wav(abc_notation,fn=title)
예제 #19
0
def makeKeyChange(models, songName):
    keylist = KEY_SIGNATURES.keys()
    randomkey = random.choice(keylist)
    firstKey = KEY_SIGNATURES[randomkey]
    originalsong = generateMusicalSentence(models, 40, firstKey)
    originalCopy = []
    for x in originalsong:
        originalCopy.append(x)

    firstKeyIndex = keylist.index(randomkey)
    secondKeyIndex = keylist[firstKeyIndex + 2]
    secondKey = KEY_SIGNATURES[secondKeyIndex]
    secondSong = generateMusicalSentence(models, 20, secondKey)
    for i in secondSong:
        originalsong.append(i)
    for j in originalCopy:
        originalsong.append(j)
    pysynth.make_wav(originalsong, fn=songName)
예제 #20
0
def makeatonic(models, songName, desiredlength):
    keylist = KEY_SIGNATURES.keys()
    randomkey = random.choice(keylist)
    sentence = ['^::^', '^:::^']
    firsttonic = (KEY_SIGNATURES[randomkey][0] + '4', random.choice(NOTE_DURATIONS))
    sentence.append(firsttonic)
    length = 0
    while ((not sentenceTooLong(desiredlength, length)) and (sentence[len(sentence) - 1] != '$:::$')):
        theGram = selectNGramModel(models, sentence)
        nextnote = theGram.getNextNote(sentence, KEY_SIGNATURES[randomkey])
        sentence.append(nextnote)
        if nextnote != '$:::$':
            length += 1

    sentence2 = []
    for i in sentence:
        if i != '^::^' and i != '^:::^' and i != '$:::$':
            sentence2.append(i)

    sentence2.append(sentence2[0])
    pysynth.make_wav(sentence2, fn = songName)
예제 #21
0
    def export_experiment(self):
        # TODO: Add evolving rhythm or random rhythm to create variation in the music
        # Delete and recreate output folder
        if (os.path.isdir('output/single')):
            shutil.rmtree('output/single')
        try:
            os.makedirs('output/single')
        except OSError as e:
            if e.errno != e.errno.EEXIST:
                pass  #raise

        # Write melodies to wav
        self.population = list(
            reversed(sorted(self.population,
                            key=self.fitness)))  # Sort by fitness
        nr_of_notes = self.notes_per_chord * self.nr_of_chords
        rhythm = [3 for i in range(nr_of_notes)]
        melody = self.population[0]
        melody2 = [(self.key[melody[i]], rhythm[i])
                   for i in range(nr_of_notes)]
        pysynth.make_wav(melody2, fn="output/single/nofit8.wav")
예제 #22
0
def playchord(models, songName, desiredlength):
    keylist = KEY_SIGNATURES.keys()
    randomkey = random.choice(keylist)
    thekey = KEY_SIGNATURES[randomkey]
    originalsong = generateMusicalSentence(models, desiredlength, thekey)
    pysynth.make_wav(originalsong, fn='wav/' + 'chord1' + '.wav')
    secondsong = []
    thirdsong = []
    for note in originalsong:
        thenote = note[0]
        actnote = thenote.split(thenote[-1])
        index = thekey.index(actnote[0])
        if index == 5:
            secondsong.append((thekey[0] + thenote[-1], note[1]))
        elif index == 6:
            secondsong.append((thekey[1] + thenote[-1], note[1]))
        else:
            secondsong.append((thekey[index + 2] + thenote[-1], note[1]))


    pysynth.make_wav(secondsong, fn='wav/' + 'chord2' + '.wav' )
    pysynth.mix_files('wav/' + 'chord1'+ '.wav','wav/' + 'chord2' + '.wav', songName )
예제 #23
0
async def on_message(message):
    if message.content.startswith('!piano'):
        await command_lock.acquire()
        if message.author.voice.voice_channel is None:
            await client.send_message(
                message.channel, 'Hey dumb dumb! ' +
                'You need to be in a voice channel to use this bot.')
            return

        try:
            song, bpm = parse_client_message_content(message.content)
        except:
            await client.send_message(
                message.channel,
                'Hey dumb dumb! ' + 'Your notes are malformed!')
            command_lock.release()
            return

        try:
            psb.make_wav(song, fn="out.wav", bpm=bpm)
        except:
            await client.send_message(
                message.channel,
                'Hey dumb dumb! ' + 'Your notes are malformed!')
            command_lock.release()
            return

        try:
            voice = await client.join_voice_channel(
                message.author.voice.voice_channel)

            player = voice.create_ffmpeg_player('out.wav')
            player.start()

            while not player.is_done():
                await asyncio.sleep(1)
        finally:
            await voice.disconnect()
            command_lock.release()
예제 #24
0
def mksample(note_tuple_iterable, label, bpm=BPM, dur=4):
    """
    Save a sequence of notes as a self-contained sample.

    >> seq = ('a', 'c', 'd', 'e')
    >> generate_sample(seq, 'samplename')

    >> play('samplename')
    """
    if _seq_is_all_note_tuples(note_tuple_iterable):
        sequence = note_tuple_iterable
    elif _seq_is_flat(note_tuple_iterable):
        sequence = _seq_to_notes(note_tuple_iterable)
    else:
        raise ValueError(
            f"I don't know how to make a sample out of: {note_tuple_iterable}!"
        )

    ps.make_wav(
        sequence,
        fn=os.path.join(ASSET_DIR, f'{label}.wav'),
        bpm=bpm,
    )
예제 #25
0
파일: menv.py 프로젝트: pranavrc/mcli
	def __init__(self):
		''' Constructor class. '''

		# Get the user input.
		cliInput = raw_input(">>> ")

		self.parse(cliInput)

		# Different cases of input, when optional arguments 'bpm' and 'repeat' are given.
		try:
			if self.bpmVal and self.repeatVal:
				pysynth.make_wav(self.synthParam, fn = 'temp.wav', silent = True, bpm = self.bpmVal, repeat = self.repeatVal)
			elif self.bpmVal:
				pysynth.make_wav(self.synthParam, fn = 'temp.wav', silent = True, bpm = self.bpmVal)
			elif self.repeatVal:
				pysynth.make_wav(self.synthParam, fn = 'temp.wav', silent = True, repeat = self.repeatVal)
			else:
				pysynth.make_wav(self.synthParam, fn = 'temp.wav', silent = True)
		except KeyError:
			print "Improper Syntax - Type 'help' to see usage."
			mEnv()
예제 #26
0
# Created by Xinyu Zhu on 2021/4/20, 17:58
import pysynth as ps
import numpy as np
import re

# 先限定音符12356 中国风五声调式 这样听起来比较自然
notes = np.array(["c4", "d4", "e4", "g4", "a4", ])
# 音符时值
durations = np.array([1, 2, 4, -2, -4, -8])
# 随机生成音符 重音穿插其中
sn = []
for t in range(16):
    n = np.random.randint(0, len(notes))
    note = notes[n] + "*"
    sn.append(note)
for i in range(np.random.randint(3, 5)):
    note0 = notes[np.random.randint(0, len(notes))]
    sn.append(note0)
# 随机生成音符时值序列 形成长短参差变幻的节奏
dn = []
for i in range(len(sn)):
    duration = durations[np.random.randint(0, len(durations))]
    nn = sn[i]
    dn.append(duration)
# 将音符和时值合并成旋律
melody = tuple(zip(sn, dn))
print(melody)
# 将乐谱合成到声音文件
ps.make_wav(melody, fn=r"right.wav")
print("ok")
예제 #27
0
# Run this file after installing pysynth and play the output file

# Importing module
import pysynth

# Writes first verse of 'Mary Had a Little Lamb' in native syntax
song = (('e', 4), ('d', 4), ('c', 4), ('d', 4), ('e', 4), ('e', 4), ('e', 2),
        ('d', 4), ('d', 4), ('d', 2), ('e', 4), ('g', 4), ('g', 2))

# Calls function to make .wav file
pysynth.make_wav(song, fn="Mary Had a Little Lamb.wav")
예제 #28
0
                new_notes.append(notes[note].split('.')[1])
            else:
                new_notes.append(notes[note].split('.')[0])

    return new_notes

if __name__ == '__main__':

    scale_grade = sys.argv[1]
    note = sys.argv[2]
    escala = pychord_module.scales(scale_grade, note)
    octave = 4

    test = prepare_for_pysynth(escala)

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

    # define stream chunk
    chunk = 1024

    # open a wav format music
    _root = ''
    _name = ''
    path = ''
    for root, dirs, files in os.walk('.'):
        for name in files:
            if 'test.wav' in name:
                _root = root
                _name = name
                path = os.path.realpath(os.path.join(root, name))
예제 #29
0
파일: read_abc.py 프로젝트: cuu508/PySynth
			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)

def main():
    print()
    print()
    print()
    print()
    print()
    print()
    print()
    print()
    # create a header
    print("WELCOME TO ______")
    # delay the next screen
    time.sleep(.5)
    print()
    print()
    print("POEM'S LIST:")
    print("1. The Cat in the Hat")
    print("2. Project For a Fainting")
    print("3. Because I Could Not Stop for Death")
    print("4. One Art")
    print("5. Wedding")
    print("6. Rain")
    print("7. Speaking in Tongues")
    print("8. And Utpictura Poeses is Her Name")
    print("9. Dry Salvages")
    print("10. Directive")
    print("11. The Idea of Order at Key West")
    print("12. Green Eggs and Ham")
    print()
    # get the user input for the text they want to convert to music
    userinput = int(input("Which poem would you like to convert to music? "))
    print("")
    # map the user input to certain text files
    if userinput == 1:
        text = open("./the_cat_in_the_hat.txt", 'r')
    elif userinput == 2:
        text = open("./projectforafainting.txt", 'r')
    elif userinput == 3:
        text = open("./becauseicouldnotstopfordeath.txt", 'r')
    elif userinput == 4:
        text = open("./oneart.txt", 'r')
    elif userinput == 5:
        text = open("./wedding.txt", 'r')
    elif userinput == 6:
        text = open("./rain.txt", 'r')
    elif userinput == 7:
        text = open("./speakingtongues.txt", 'r')
    elif userinput == 8:
        text = open("./andutpicturapoesisishername.txt", 'r')
    elif userinput == 9:
        text = open("./dry salvages.txt", 'r')
    elif userinput == 10:
        text = open("./directive.txt", 'r')
    elif userinput == 11:
        text = open("./theideaoforderatkeywest.txt", 'r')
    elif userinput == 12:
        text = open("./greeneggsandham.txt", 'r')
    else:
        print("You entered the wrong value.")
    allwords = list()
    for line in text:
        line = line.split()
        for word in line:
            newword = checkword(word)
            allwords.append(newword)
    uniquewords = set(allwords)
    #for word in uniquewords:
    #print(word)
    mapdict = {}
    notes = ['c', 'c#', 'd', 'd#', 'e', 'f', 'f#', 'g', 'g#', 'a', 'a#', 'b']
    for word in uniquewords:
        random.shuffle(notes)
        mapdict[word] = notes[0]
    if userinput == 1:
        text2 = open("./the_cat_in_the_hat.txt", 'r')
    elif userinput == 2:
        text2 = open("./projectforafainting.txt", 'r')
    elif userinput == 3:
        text2 = open("./becauseicouldnotstopfordeath.txt", 'r')
    elif userinput == 4:
        text2 = open("./oneart.txt", 'r')
    elif userinput == 5:
        text2 = open("./wedding.txt", 'r')
    elif userinput == 6:
        text2 = open("./rain.txt", 'r')
    elif userinput == 7:
        text2 = open("./speakingtongues.txt", 'r')
    elif userinput == 8:
        text2 = open("./andutpicturapoesisishername.txt", 'r')
    elif userinput == 9:
        text2 = open("./dry salvages.txt", 'r')
    elif userinput == 10:
        text2 = open("./directive.txt", 'r')
    elif userinput == 11:
        text2 = open("./theideaoforderatkeywest.txt", 'r')
    elif userinput == 12:
        text2 = open("./greeneggsandham.txt", 'r')
    else:
        print("You entered the wrong value.")
    test = []
    for line in text2:
        line = line.split()
        for word in line:
            word = word.lower()
            testaddition = []
            notetoadd = ""
            count = 0
            if "!" in word or "." in word or "," in word or "?" in word or ";" in word or "(" in word or ")" in word or ":" in word or '''"''' in word or "-" in word or "_" in word:
                count += 1
            if count != 0:
                letterlist = []
                for letter in word:
                    if letter not in [
                            "!", ".", ",", "?", ";", ")", "(", ":", '''"''',
                            "-", "_"
                    ]:
                        letterlist.append(letter)
                newword = ""
                for letter in letterlist:
                    newword += letter
                if newword == '':
                    continue
                notetoadd = mapdict[newword]
                testaddition.append(notetoadd)
                testaddition.append(8)
                testaddition = tuple(testaddition)
                test.append(testaddition)
                restaddition = ('r', 4)
                test.append(restaddition)
            else:
                newword = word
                print(newword)
                notetoadd = mapdict[newword]
                testaddition.append(notetoadd)
                testaddition.append(8)
                testaddition = tuple(testaddition)
                test.append(testaddition)
    test = tuple(test)
    songname = ""
    if userinput == 1:
        songname = "catinthehat"
    elif userinput == 2:
        songname = "projectforafainting"
    elif userinput == 3:
        songname = "becauseicouldnotstopfordeath"
    elif userinput == 4:
        songname = "oneart"
    elif userinput == 5:
        songname = "wedding"
    elif userinput == 6:
        songname = "rain"
    elif userinput == 7:
        songname = "speakingintongues"
    elif userinput == 8:
        songname = "andutpicturapoesisishername"
    elif userinput == 9:
        songname = "drysalvages"
    elif userinput == 10:
        songname = "directive"
    elif userinput == 11:
        songname = "theideaoforderatkeywest"
    elif userinput == 12:
        songname = "greeneggsandham"
    # complete the music file name
    songname += ".wav"
    # make the wav file
    ps.make_wav(test, fn=songname)
    text.close()
    text2.close()
예제 #31
0
	elif "4" in note:
		note_letter = re.search(r"([A-Za-z]+#?)\d?", note)
		value = [note_letter.group(1)+"5",4]
		test.append(value)
			
#print(test)
	elif "3" in note:
		note_letter = re.search(r"([A-Za-z]+#?)\d?", note)
		value = [note_letter.group(1)+"5",2]
		test.append(value)
		
#print(test)
	elif " " in note:
		value = ['r',2]
		test.append(value)
		
	else:
		note_letter = re.search(r"([A-Za-z]+#?)\d?", note)
		value = [note_letter.group(1),2]
		test.append(value)

#test = (('c', 4), ('e', 4), ('g', 4),
#		('c5', -2), ('e6', 8), ('d#6', 2))

ps.make_wav(test, fn = "test_real.wav", bpm = 360)

#Using Pydub to play the wav file generated
sound_file = "test_real.wav"
sound = AudioSegment.from_file(sound_file, format="wav")
play(sound)
예제 #32
0
파일: main2.py 프로젝트: juthor/likelion
        ('c5', 5.31487889037946), ('e5', 5.31487889037946), ('d5', 1.0),
        ('a#4', 4.0), ('d5', 4.0), ('e5', 4.0), ('f5', 4.0), ('c5', 1.0),
        ('g4', 2.0), ('a4', 0.5), ('a5', 2.0), ('e5', 1.3333333333333333),
        ('c5', 8.0), ('e5', 8.0), ('d5', 4.0), ('a#4', 8.0), ('g4', 8.0),
        ('a5', 2.0), ('e5', 1.3333333333333333), ('c5', 8.0), ('e5', 8.0),
        ('d5', 4.0), ('a#4', 8.0), ('g4', 8.0), ('g5', 2.0),
        ('d5', 1.3333333333333333), ('a#4', 8.0), ('d5', 8.0), ('c5', 4.0),
        ('a4', 8.0), ('f4', 8.0), ('g5', 2.0), ('d5', 1.3333333333333333),
        ('a#4', 8.0), ('d5', 8.0), ('c5', 4.0), ('d5', 4.0), ('a#4', 4.0),
        ('e4', 0.02580385041830461), ('a4', 4.0), ('a4', 2.0), ('a#4', 4.0),
        ('a4', 4.0), ('a4', 2.0), ('a#4', 4.0), ('a#4', 0.6666666666666666),
        ('a4', 4.0), ('a#4', 16.0), ('d5', 16.0), ('a#4', 16.0), ('a4', 4.0),
        ('g4', 4.0), ('f4', 2.0), ('a#5', 4.0), ('a4', 0.49983729252717796),
        ('a5', 4.0), ('a5', 2.0), ('a#5', 4.0), ('a#5', 2.0), ('a5', 2.0),
        ('a#5', 4.0), ('a5', 4.0), ('a#5', 16.0), ('d6', 16.0), ('a#5', 16.0),
        ('a5', 2.0), ('g5', 2.0), ('a5', 0.36355029584697357), ('a6', 1.0)]

ps.make_wav(song[:100], fn='C:/Users/seung/Desktop/ai_session_midi/first.wav')

# matrix = MusicMatrix(song)

# start_note = ['g5', 2]

# random_song = []
# for i in range(0, 100):
#     start_note = matrix.next_note(start_note)
#     random_song.append(start_note)

# # ps.make_wav(random_song, fn='examples/random_debussy.wav')
# make_midi(midi_path='C:/Users/seung/Desktop/ai_session_midi/second.mid', notes=random_song)
예제 #33
0
파일: Song.py 프로젝트: adamlind323/CSC493
musicMarkov.add(["d", 8]) #-ly
musicMarkov.add(["e", 4]) #down
musicMarkov.add(["f", 8]) #the
musicMarkov.add(["g", 2]) #stream
musicMarkov.add(["c", 8]) #mer-
musicMarkov.add(["c", 8]) #-ri-
musicMarkov.add(["c", 8]) #-ly
musicMarkov.add(["g", 8]) #mer-
musicMarkov.add(["g", 8]) #-ri-
musicMarkov.add(["g", 8]) #-ly
musicMarkov.add(["e", 8]) #mer-
musicMarkov.add(["e", 8]) #-ri-
musicMarkov.add(["e", 8]) #-ly
musicMarkov.add(["c", 8]) #mer-
musicMarkov.add(["c", 8]) #-ri-
musicMarkov.add(["c", 8]) #-ly
musicMarkov.add(["g", 4]) #life
musicMarkov.add(["f", 8]) #is
musicMarkov.add(["e", 4]) #but
musicMarkov.add(["d", 8]) #a
musicMarkov.add(["c", 2]) #dream!

markovSong = []
selNote = ["c", 4]
for i in range(0,100):
    print selNote[0] + ", " + str(selNote[1])
    selNote = musicMarkov.nextNote(selNote)
    markovSong.append(selNote)

pysynth.make_wav(markovSong, fn = "song.wav")
musicLearner.add(["c", 8])
musicLearner.add(["c", 8])
musicLearner.add(["c", 8])

musicLearner.add(["g", 8])
musicLearner.add(["g", 8])
musicLearner.add(["g", 8])

musicLearner.add(["e", 8])
musicLearner.add(["e", 8])
musicLearner.add(["e", 8])

musicLearner.add(["c", 8])
musicLearner.add(["c", 8])
musicLearner.add(["c", 8])

musicLearner.add(["g", 4])
musicLearner.add(["f", 8])
musicLearner.add(["e", 4])
musicLearner.add(["d", 8])
musicLearner.add(["c", 2])

random_score = []
current_note = ["c", 4]
for i in range(0,100):
    print current_note[0] + ", " + str(current_note[1])
    current_note = musicLearner.next_note(current_note)
    random_score.append(current_note)

pysynth.make_wav(random_score, fn = "first_score.wav")
예제 #35
0
def composer(filename,narray,bpmd,raganum,outfilename):
	fileObject = open(filename,'r')
	net = pickle.load(fileObject)
	j=0;
	test=narray
	test[j:j+4]+test[j+1:j+5]
	ran=[]
	for i in xrange(8):	
		ran.append(random.randrange(0, 14, 1))
	while(j<50):
		ran.append(random.randrange(0, 14, 1))
		if(j<8):
			result=net.activate(test[j:j+3]+ran[j:j+5])
		else:
			result=net.activate(test[j-8:j-4]+ran[j:j+4])
		if(result>14):
			result=result%12;
		j+=1
		test.append(result)

	i=0
	newarr=[]
	raganum=2
	for r in test:
		newarr.append(int(round(abs(r))))
	i=i+1;
	tunes=['r','c3','d#3','f3','g3','a#3','c3','c3','a#3','a3','g3','f3','d#3','d3','c3','c3']
	tunes2=['c5','d#5','f5','g5','a#5','c5','c5','a#5','a5','g5','f5','d#5','d5','c5','c5']
	mayamg=['c', 'c#', 'e', 'f', 'g', 'g#', 'b','c', 'b', 'g#', 'g', 'f', 'e','c#','c']
	shanmukhapriya=['c', 'd', 'd#', 'f#', 'g', 'g#', 'a#', 'c5', 'a#', 'g#', 'g', 'f#', 'd#','d','c']
	anandab=['r','c', 'd#', 'd', 'd#', 'f', 'g', 'a', 'g', 'c', 'a#', 'a', 'g', 'f', 'd#','c']
	abhogi=['c', 'd', 'd#', 'f', 'a', 'c5', 'a', 'f', 'd#', 'd', 'c', 'd', 'd#', 'f','a', 'c5', 'a']
	sree=['c', 'd', 'f', 'g', 'a#', 'c5', 'a#', 'a', 'g', 'f', 'd#', 'd', 'c', 'd','c', 'd', 'f',]
	sankara=['c', 'd', 'e', 'f', 'g', 'a', 'b', 'c5', 'c5', 'b', 'a', 'g', 'f', 'e','c', 'd']
	if(raganum==1):
		raga=sree;
	elif(raganum==2):
		raga=sankara;
	elif(raganum==3):
		raga=mayag;
	elif(raganum==4):
		raga=anandab;
	else:
		raga=sree;
	

	t=()
	t2=();
	t3=();
	t4=();
	inc =1;
	for r in newarr:
		rx=int(abs(round(math.sin(inc)*10)))%4
		print rx
		if(rx==0):
			m=-1
			l=2
		elif(rx==3):
			m=1
			l=8
		elif(rx==2):
			m=-1
			l=4
		elif(rx==1):
			m=1
			l=4
			if(newarr.index(r)>10):
				r=r-int(abs(round(math.sin(inc)*10)))
		
		inc+=1;
		
		
		t=t+((raga[r],l),)
		t3=t3+((raga[r*-1],l/2),)
		t2=t2+((raga[r],l*2),)
		t4=t2+((raga[r*-1],l),)
	pysynth.make_wav(t, bpm=bpmd, fn = "f"+outfilename)
	pysynth.make_wav(t3, bpm=bpmd, fn = "s"+outfilename)
	pysynth_s.make_wav(t2, bpm=bpmd, fn = "l"+outfilename)
	pysynth_s.make_wav(t4, bpm=bpmd, fn = "l2"+outfilename)
	pysynth.mix_files("f"+outfilename,"s"+outfilename,"k"+outfilename);
	pysynth.mix_files("l"+outfilename,"l2"+outfilename,"k2"+outfilename);
	pysynth.mix_files("k"+outfilename,"k2"+outfilename,outfilename);
	return t
예제 #36
0
naly=['f', 'c#', 'c', 'g#', 'g#', 'a#', 'g', 'f', 'c#', 'c', 'g#', 'a#', 'g#', 'g', 'f', 'c', 'g#', 'f', 'g#', 'f', 'c', 'g#', 'd#', 'c#', 'a#', 'g#', 'a#', 'a#', 'g', 'c', 'a#', 'g#', 'g#', 'a#', 'c#', 'c', 'c', 'g#', 'f', 'c#', 'g', 'd#', 'c', 'a#', 'c#', 'g', 'a#', 'g', 'd#', 'a#', 'd#', 'c', 'a#', 'g#', 'g#', 'f', 'c#', 'f', 'c#', 'c#', 'c', 'g#', 'g', 'f', 'd#', 'f', 'g#', 'f', 'c#', 'c', 'g#', 'a#', 'g', 'c', 'g#', 'f', 'g#', 'f', 'f', 'c#', 'c', 'g#', 'g#', 'c', 'g#', 'f', 'a#', 'c#', 'c', 'c', 'g#', 'd#', 'c#', 'c#', 'c', 'g', 'a#', 'g', 'd#', 'g#', 'f', 'c#', 'a#', 'd#', 'c', 'a#', 'a#', 'g#', 'f', 'c#', 'g', 'd#', 'c', 'a#', 'g#', 'a#', 'a#', 'g#', 'g', 'f', 'd#', 'f', 'g#', 'f', 'c#', 'c', 'g#', 'f', 'g#', 'f', 'c#', 'f', 'd#', 'c', 'd#', 'c#', 'a#', 'g', 'd#', 'a#', 'a#', 'g#', 'a#', 'a#', 'g#', 'a#', 'a#', 'g#', 'g', 'g', 'c', 'g#', 'f', 'f', 'd#', 'g#', 'a#', 'g#', 'a#', 'g#', 'c', 'a#', 'a#', 'g#', 'g', 'c', 'c', 'a#', 'c', 'f', 'g', 'a#', 'g#', 'f', 'd#', 'g#', 'a#', 'g', 'a#', 'g#', 'a#', 'g#', 'g', 'f', 'a#', 'g', 'd#', 'a#', 'g#', 'g#', 'f', 'c#', 'g', 'd#', 'c', 'c', 'g#', 'f', 'g#', 'f', 'c#', 'g', 'd#', 'c', 'a#', 'g#', 'g', 'g', 'f', 'f', 'd#', 'f', 'g#', 'f', 'c#', 'f', 'c', 'c#', 'a#', 'c', 'g#', 'f', 'f', 'g#', 'f', 'c#', 'a#', 'g#', 'g#', 'f', 'c#', 'a#', 'g', 'd#', 'g#', 'f', 'c#', 'c', 'c', 'g', 'd#', 'c', 'a#', 'c', 'c#', 'd#', 'd#', 'c#', 'c#', 'c', 'a#', 'g#', 'a#', 'c#', 'c', 'c', 'a#', 'g', 'd#', 'c', 'g#', 'f', 'g#', 'f', 'c#', 'g', 'd#', 'c', 'f', 'a#', 'a#', 'a#', 'g#', 'a#', 'g#', 'g', 'f', 'd#', 'a#', 'c#', 'a#', 'g#', 'c', 'c', 'a#', 'c#', 'a#', 'c#', 'c', 'g#', 'f', 'c#', 'g', 'd#', 'c', 'a#', 'g#', 'a#', 'g#', 'g', 'f', 'd#', 'f', 'f', 'd#', 'c', 'g#', 'a#', 'g', 'd#', 'c#', 'g', 'f', 'g', 'f', 'g', 'c#', 'f', 'c', 'c', 'g', 'f', 'e', 'c', 'a#', 'g', 'd#', 'f', 'c', 'c', 'a#', 'a#', 'c', 'g#', 'f', 'g#', 'a#', 'g#', 'a#', 'g#', 'g#', 'f', 'c#', 'g#', 'a#', 'c', 'c', 'g#', 'f', 'a#', 'g#', 'g', 'a#', 'g', 'd#', 'g#', 'f', 'c#', 'a#', 'c', 'a#', 'g#', 'f', 'c#', 'g', 'e', 'c', 'g', 'd#', 'c', 'd#', 'f', 'a#', 'g', 'd#', 'g#', 'f', 'c#', 'c', 'd#', 'c', 'a#', 'g#', 'a#', 'g', 'a#', 'g#', 'g', 'f', 'g#', 'f', 'c#', 'g', 'c', 'g#', 'f', 'g#', 'f', 'c#', 'g', 'd#', 'c', 'f', 'd#', 'a#', 'g', 'd#', 'g', 'c', 'a#', 'g#', 'g', 'f', 'g#', 'g', 'f', 'g', 'a#', 'g#', 'a#', 'g#', 'a#', 'c', 'a#', 'g#', 'a#', 'g#', 'f', 'c#', 'g', 'd#', 'c', 'a#', 'g#', 'f', 'c#', 'f', 'd#']
nlen="880408888088040888808804088880880408888040880888808888040404088080804088040880408888088040880408804088880880408888040808080880"
t=()
for r in range(0,100):
	if(nlen[r]=='0'):
		t=t+(('r',8),)
	else:
		l=int(nlen[r])
		t=t+((naly[r],l),)
print t
import pysynth
pysynth.make_wav(t, bpm=150 ,fn = "output2.wav")
##map PDB 3-character amino codes to 1-character codes
threeToOne = {"GLY" : "G", "PRO" : "P","ALA" : "A","VAL" : "V","LEU" : "L",
"ILE" : "I","MET" : "M","CYS" : "C","PHE" : "F","TYR" : "Y","TRP" : "W",
"HIS" : "H","LYS" : "K","ARG" : "K","TYR" : "Y","TRP" : "W","HIS" : "H",
"LYS" : "K","ARG" : "R","GLN" : "Q","ASN" : "N","GLU" : "E","ASP" : "D",
"SER" : "S","THR" : "T"}

##specify a protein path
proteinPath = "5E6E.pdb"
proteinSoup = pdbatoms.Soup(proteinPath)
atomList  = rmsd.get_superposable_atoms(proteinSoup,None,['CA'])

#functionally generate single-character codes from a pdb
atomCodes = map (lambda y: threeToOne[y],map(lambda x: x.res_type,atomList))

#generate sublists for the music functions, best done with a for loop as far as i know
sublists = []
for index in range(0, len(atomCodes) - 10):
        sublists.append(atomCodes[index:index+10])

#make a music box: feed in the sublists and process them with motifTune
whereIComeFromTheBirdsSingAPrettySong = map(lambda x: motifTune(x),sublists)

#read the notes of each sublist tune into a single tune
andTheresAlwaysMusicInTheAir = []
for item in whereIComeFromTheBirdsSingAPrettySong:
    for note in item:
        andTheresAlwaysMusicInTheAir.append(note)
giorgio.make_wav(andTheresAlwaysMusicInTheAir,bpm=300,fn=proteinPath[:len(proteinPath)-4] + ".wav")
예제 #38
0
import pysynth

marioSong = (
	('e5', 8), ('e5', 8), ('e5', 8), ('c5', 8), ('e5', 8),
	('g5', 4), ('g4', 4),
	('c5', 4), ('g4', 4), ('e4', 4), 
	('a4', 4), ('b4', 4), ('bb4', 8), ('a4', 4),
	('g4', 4), ('e5', 4), ('g5', 4), ('a5', 4), ('f5', 8), ('g5', 8),
	('e5', 8), ('c5', 8), ('d5', 8), ('b4', 8) 
)
##test = (('c5', 8), ('c5', 8), ('c5', 8), ('g5', 8), ('e5', 4), ('d5', 8), ('c5', 4) )
##pysynth.make_wav(test, fn = "test.wav")
pysynth.make_wav(marioSong, bpm = 200, fn = "marioSong.wav")
예제 #39
0
M7 = makeArray(M7)
Mpent = makeArray(Mpent)
mpent = makeArray(mpent)


rhyArr = []
rhyArr.append([8,8,8,8])
rhyArr.append([4,4])
rhyArr.append([8,8,4])
rhyArr.append([8,4,8])
rhyArr.append([0,0,4,0,0])

pickBassBeat(rhyArr)
num_notes=0
music = []
for i in range(size_rhythm):
    for j in rhyArr[i]:
        tmp_note = 0
        if j != 0:
            tmp_note = getNote(mpent)
        else:
            j=16
        music.append([tmp_note,j])

let_notes = ['r', 'c', 'c#', 'd', 'd#', 'e', 'f', 'f#', 'g', 'g#', 'a', 'a#', 'b', 'c5']
for note_rhy in music:
    note_rhy[0] = let_notes[note_rhy[0]]

import pysynth as pysynth
pysynth.make_wav(music, fn='out.wav')
예제 #40
0
import pysynth as ps

freqs = ps.getfreq()
notes = freqs[0].keys()
for n in notes:
    outfile = 'wav/%s.wav' % n
    ps.make_wav( ((n, 4),), fn=outfile)
    print( 'Wrote note %s to %s' %(n, outfile) )
예제 #41
0
def makeAndPlay(song):
    ps.make_wav(song, fn=TEMP_NAME)
    sp.check_output(['/bin/sh', '-c', '%s %s' % (PLAYER, TEMP_NAME)])
예제 #42
0
	if len(sys.argv) > 3:
		filename = sys.argv[3]
	else:
		filename = "midi.wav"
	print()
	print("Track first notes")
	for t, n in enumerate(m.tracks):
		if len(n) > 0:
			print(t, n[0], len(n))
	song = []
	last1, last2 = -1, 0
	for n in m.tracks[tracknum]:
		nn = str(n).split()
		start, stop = float(nn[2]), float(nn[3])
		# PySynth is monophonic:
		if start == last1:
			continue
		# Add rests:
		if last2 > -1 and start - last2 > 0:
			song.append(('r', getdur(last2, start)))

		last1 = start
		last2 = stop
		song.append((nn[0].lower(), getdur(start, stop)))
	print()
	print("Song")
	print(song)
	import pysynth
	pysynth.make_wav(song, fn = filename, bpm = m.tempo)

예제 #43
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)
##
예제 #44
0
    a = n // 16
    if (a == 0):
        return 8
    elif (a == 1):
        return 12
    elif (a == 3 or a == 2):
        return 16
    elif (a == 5 or a == 4):
        return 8
    elif (a > 5 and a < 10):
        return 4
    elif (a == 10 or a == 11):
        return 8
    elif (a == 12 or a == 13):
        return 12
    elif (a == 14):
        return 2
    elif (a == 15):
        return 1
    else:
        return 4


for i in range(testImage.size[0]):
    for j in range(testImage.size[1]):
        r, g, b = testImage.getpixel((i, j))
        noteList.append((numNoteOct(r, g), numLength(b)))

imageSound = tuple(noteList)
pysynth.make_wav(imageSound, fn="mode1.wav")
예제 #45
0
파일: main5.py 프로젝트: juthor/likelion
    ('g#3', 16.0), ('e4', 16.0), ('d#4', 16.0), ('d4', 16.0), ('d#4', 16.0),
    ('r', 16.0), ('c#4', 16.0), ('b3', 16.0), ('a#3', 16.0), ('r', 16.0),
    ('g#3', 16.0), ('g3', 16.0), ('g#3', 16.0), ('r', 16.0), ('d#3', 16.0),
    ('e3', 16.0), ('d#3', 16.0), ('e3', 16.0), ('d#3', 16.0), ('d3', 16.0),
    ('d#3', 16.0), ('g3', 16.0), ('b3', 16.0), ('a#3', 16.0), ('g#3', 16.0),
    ('r', 16.0), ('g#3', 16.0), ('a#3', 16.0), ('b3', 16.0), ('r', 16.0),
    ('a#3', 16.0), ('b3', 16.0), ('c#4', 16.0), ('r', 16.0), ('b3', 16.0),
    ('a#3', 16.0), ('g3', 16.0), ('r', 16.0), ('g3', 16.0), ('a#3', 16.0),
    ('b3', 16.0), ('r', 16.0), ('a#3', 16.0), ('g#3', 16.0), ('d#3', 16.0),
    ('r', 16.0), ('d#3', 16.0), ('e3', 16.0), ('d#3', 16.0), ('e3', 16.0),
    ('d#3', 16.0), ('d3', 16.0), ('d#3', 16.0), ('g3', 16.0), ('b3', 16.0),
    ('a#3', 16.0), ('g#3', 16.0), ('r', 16.0), ('g#3', 16.0), ('g3', 16.0),
    ('g#3', 16.0), ('r', 16.0), ('g#4', 16.0)
]

song = list(song1 * 2) + list(song2)

matrix = MusicMatrix(song)

pprint(matrix._markov._matrix)
pprint(matrix._timings._matrix)

start_note = ['e3', 8]

random_song = []
for i in range(0, 500):
    start_note = matrix.next_note(start_note)
    random_song.append(start_note)

ps.make_wav(random_song, fn='C:/Users/main5music.wav')
#make_midi(midi_path='C:/Users/seung/Desktop/ai_session_midi//random_mix.mid', notes=random_song)
예제 #46
0
def singIt(song):
    pysynth.make_wav(song, fn = 'test.wav')
    play_wav.Sound().playFile('test.wav')
예제 #47
0
import re

def parse(song):
    result = []
    for match in re.findall(r"[a-gA-G ][#*]*\d*",song):
        match = match.replace(' ','r').lower()
        if len(match) == 1:
            result.append((match,1))
        elif len(match) == 3:
            result.append((match[:2],int(match[2])))
        elif re.match(r".\d",match):
            result.append((match[0],int(match[1])))
        else:
            result.append((match,1))
    return result

#print parse("A4BCD3F*3 3F3DEFC#3FF")

if __name__ == "__main__":
    song = parse("A4BCD3F*3 3F3DEFC#3FF")
    print song
    
    import pysynth
    pysynth.make_wav(song)
예제 #48
0
import pysynth
song = (
                       ('c', 4),
  ('d#', 4), ('f', 4), ('g', 4),
  ('a#', 4), ('c5', 4),('c5', 4),('a#', 4),('a', 4),('g', 4),('f', 4),('d#', 4),('d', 4),('c', 4)
   
)
pysynth.make_wav(song, bpm = 250,  fn = "test.wav")
예제 #49
0
def makeRecord(song, name):
    pysynth.make_wav(song, fn = name + '.wav')