def runTest (tc, intoput, output):
    try:
        notes = text2notes (intoput)
    except:
        print ('Test %d failed - exception caught.' % tc)
        return 0
    
    if len (notes) != len (output):
        print ('Test %d failed - expecting a note list of length %d, got %d instead.' % (tc, len (output), len (notes)))
        return 0

    n = len (output)
    for i in range (n):
        if notes [i] != output [i]:
            print ('Test %d failed - notes at position %d do not match.' % (tc, i))
            return 0

    print ('Test %d passed.' % tc)
    return 1
Example #2
0
def runTest(tc, intoput, output):
    try:
        notes = text2notes(intoput)
    except:
        print('Test %d failed - exception caught.' % tc)
        return 0

    if len(notes) != len(output):
        print(
            'Test %d failed - expecting a note list of length %d, got %d instead.'
            % (tc, len(output), len(notes)))
        return 0

    n = len(output)
    for i in range(n):
        if notes[i] != output[i]:
            print('Test %d failed - notes at position %d do not match.' %
                  (tc, i))
            return 0

    print('Test %d passed.' % tc)
    return 1
from FileUtilities import openFileReadRobust
from csc220a3 import text2notes
from music import *

source = openFileReadRobust ()
notes = text2notes (source.read ())
source.close ()
rhythms = [SN] * len (notes)

theme = Phrase ()   
theme.addNoteList (notes, rhythms)

Write.midi (theme, 'mysong.mid')
Play.midi (theme)
Example #4
0
from FileUtilities import openFileReadRobust
from csc220a3 import text2notes
from music import *

source = openFileReadRobust()
notes = text2notes(source.read())
source.close()
rhythms = [SN] * len(notes)

theme = Phrase()
theme.addNoteList(notes, rhythms)

Write.midi(theme, 'mysong.mid')
Play.midi(theme)