Example #1
0
def main():
    timeSig = str(raw_input("Enter desired time signature (x/x): "))

    while timeSig.find("/") == -1:
        timeSig = str(
            raw_input("Time signature must contain a '/'. Please reenter: "))

    timeCount = timeSig.split("/")
    total = int(
        timeCount[0])  ##top of time signature; amount of beats to generate
    beat = int(timeCount[1]
               )  ##bottom of time signature; what constitutes a single beat
    inputKey = raw_input("Enter desired key (X Major/X Minor): ")
    note = inputKey[0:2].strip()  ##Note can be 1-2 chars.. G, G# etc..

    m = Melopy('generated_clip')

    keys = None

    ## checking if input key is minor/major and calling corresponding Melopy method
    if inputKey.upper().find("MINOR") != -1:
        keys = melopy.generateScale("melodic_minor", note)
    elif inputKey.upper().find("MAJOR") != -1:
        keys = melopy.generateScale("major", note)

    ##calling recursive method with 'curr' parameter as 0, and the list of note time values we will be using
    generated(total, 0, ["semiquaver", "quaver", "quarter", "half"], keys, m,
              beat)

    m.render()
Example #2
0
def main():
    m = Melopy('mary')
    d = os.path.dirname(__file__)
    if len(d):
        m.parsefile(d + '/scores/mary.mlp')
    else:
        m.parsefile('scores/mary.mlp')
    m.render()
Example #3
0
def main():
    m = Melopy('entertainer')
    m.tempo = 140
    d = os.path.dirname(__file__)
    if len(d):
        m.parsefile(d + '/scores/entertainer.mlp')
    else:
        m.parsefile('scores/entertainer.mlp')
    m.render()
Example #4
0
def main():
    m = Melopy('furelise')
    d = os.path.dirname(__file__)
    if len(d):
        m.parsefile(d + '/scores/furelise.mlp')
    else:
        m.parsefile('scores/furelise.mlp')
    m.render()
    m.play()
Example #5
0
def generated(total, curr, timeVals, keys, m, beat):
    print(total, curr, beat)
    timeValue = timeVals[random.randint(
        0,
        len(timeVals) - 1)]  ##picking random value from time signature list
    noteValue = keys[random.randint(0,
                                    len(keys) -
                                    1)]  ##picking random note from input key
    curr += int(addNote(timeValue, noteValue, m, beat))
    if curr < total:
        generated(total, curr, timeVals, keys, m, beat)
    elif curr > total:
        curr = 0
        m = Melopy("generated_clip")
        generated(total, curr, timeVals, keys, m, beat)
Example #6
0
def main():
    m = Melopy('menuet')
    m.parsefile(os.path.dirname(__file__) + '/scores/menuet.mlp')
    m.render()
Example #7
0
def main():
    m = Melopy('furelise')
    m.parsefile(os.path.dirname(__file__) + '/meeps/furelise.mp')
    m.parsefile(os.path.dirname(__file__) + '/meeps/furelise_left.mp', 0)
    m.render()
Example #8
0
def main():
    m = Melopy('entertainer')
    m.tempo = 140
    m.parsefile(os.path.dirname(__file__) + '/scores/entertainer.mlp')
    m.render()
Example #9
0
def main():
    m = Melopy('mary')
    m.parsefile(os.path.dirname(__file__) + '/meeps/mary.mp')
    m.render()
Example #10
0
__FILENAME__ = canon
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys; sys.path.append(sys.path[0] + '/../melopy/')

from melopy import *

if __name__ == "__main__":
    m = Melopy('canon', 50)
    melody = []

    for start in ['d4', 'a3', 'b3m', 'f#3m', 'g3', 'd3', 'g3', 'a3']:
        if start.endswith('m'):
            scale = minor_scale(start[:-1])
        else:
            scale = major_scale(start)

        scale.insert(0, scale[0][:-1] + str(int(scale[0][-1]) - 1))

        [melody.append(note) for note in scale]

    m.add_melody(melody, 0.2)
    m.add_rest(0.4)
    m.add_note('d4', 0.4)
    m.add_rest(0.1)
    m.add_note(['d4', 'a4', 'd5'], 0.8)

    m.render()

# Licensed under The MIT License (MIT)
Example #11
0
def main():
    m = Melopy('furelise')
    m.parsefile(os.path.dirname(__file__) + '/scores/furelise.mlp')
    m.render()