Пример #1
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.
    """
    key = random.choice(KEY_SIGNATURES.keys())
    possiblePitches = KEY_SIGNATURES[key]
    desiredLength = 100
    line = generateMusicalSentence(models, desiredLength, possiblePitches)
    pysynth.make_wav(line, fn=songName)
Пример #2
0
def runMusicGeneratorMelody(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
    """
    print("key signature is: {}".format(KEY_SIG))
    possiblePitches = KEY_SIGNATURES[KEY_SIG]
    tuplesList = generateMusicalSentence(models, 50, possiblePitches)
    pysynth.make_wav(tuplesList, fn=songName)
    """
Пример #3
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.
    """
    list = KEY_SIGNATURES.keys()
    desiredLength = 200
    value = random.choice(list)
    possiblePitches = KEY_SIGNATURES[value]
    tuplesList = generateMusicalSentence(models, desiredLength,
                                         possiblePitches)
    pysynth.make_wav(tuplesList, fn=songName)

    pass
def create_wav(number,scale,name):
    '''
    creates a .wav file
    number= the number which is to be converted to music
    scale= scale to be used
    name= name of the .wav file to be saved
    '''
    number=str(number)
    elements=[]
    for element in  number:
        elements.append(int(element))
    keys=[]
    for i in range(len(elements)-1):

        number=elements[i]
        next_number=elements[i+1]
        note=scale[number][0]
        duration=scale[next_number][1]
        key=(note,duration)
        keys.append(key)
    
    keys=tuple(keys)
    pysynth.make_wav(keys, fn = name+".wav")
Пример #5
0
def runMusicGeneratorBass(models, songName):
    print("key signature is: {}".format(KEY_SIG))
    possiblePitches = KEY_SIGNATURES[KEY_SIG]
    pentatonicScale = possiblePitches[0:2] + possiblePitches[4:5]
    tuplesList = generateMusicalSentence(models, 50, pentatonicScale)
    pysynth.make_wav(tuplesList, fn=songName)