#!/usr/bin/python # # Copyright (C) 2011 Nils Liberg (mail: kotorinl at yahoo.co.uk) # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this program. If not, see . # # # New in version 0.2: # better handling of accidentals in keys with many flats and sharps from midi.MidiOutStream import MidiOutStream from midi.MidiInFile import MidiInFile from fractions import Fraction import os import os.path import sys import getopt import math from simple_abc_parser import get_best_key_for_midi_notes, get_accidentals_for_key from io import StringIO num_quarter_notes_per_bar = 3 bars_per_line = 4 usage = '''PyMidi2Abc version 0.1 May 30 2008, usage: python pymidi2abc.py [-f] -o -k key name, or -6 to 6 sharps -l -m