Example #1
0
def main():
    """
    Main method of the command line interface
    """
    parser = argparse.ArgumentParser(
        description="Convert drum tabs to midi files.")
    parser.add_argument("tab_filename")
    parser.add_argument("midi_output_file", type=argparse.FileType('w'))
    args = parser.parse_args()
    tab_file = codecs.open(args.tab_filename, "r", "utf-8")
    tab_text = tab_file.read()
    tab = Tab(tab_text, note_name_to_number_map=defaultdict(int))
    tab = Tab(tab_text)
    tab.write_midi_file(args.midi_output_file)
Example #2
0
def test_generated_midi_matches_expected_midi(tmpdir, tab, expected_midi):
    actual_midi = tmpdir.join("actual.mid").strpath

    tab = Tab(codecs.open(tab, "r", "utf-8").read())
    tab.write_midi_file(open(actual_midi, "wb"))
    assert filecmp.cmp(actual_midi, expected_midi)
Example #3
0
def test_walk_notes_works_with_unknown_note_types():
    # This should not throw an exception.
    tab = Tab(file('testdata/simple_4_4_beat.txt').read(),
              note_name_to_number_map = {})
    with py.test.raises(UnmappableNoteNamesException):
        tab.write_midi_file(open(os.devnull, 'w'))