Beispiel #1
0
 def __init__(self, song, title="Song", transpose=0, blank = False, path = None, instruments = None, instrument_name=None):
     self.blank = blank
     if instruments == None:
         self.instruments = chordprobook.instruments.Instruments()
     else:
         self.instruments = instruments
     self.local_instruments = None
     # Look-up
     self.instrument_name = instrument_name
     self.local_instrument_names = []
     self.text = song
     self.key = None
     self.pages = 1
     self.original_key = None
     self.path = path
     self.notes_md = ""
     self.transpose = transpose
     self.transposer = chords.transposer(transpose)
     self.standard_transpositions = [0]
     self.title = ""
     self.grids = None
     self.parse()
     self.md = ""
     self.formatted_title = ""
     if self.title == "":
         self.title = title
Beispiel #2
0
    def get_key_string(self, trans=None):
        if trans:
            self.transpose = trans
        if self.original_key and self.transpose:
            self.transposer = chords.transposer(self.transpose)
            self.key = self.transposer.transpose_chord(self.original_key)

        return "(%s)" % self.key if self.key != None else ""
Beispiel #3
0
 def get_key_string(self, trans = None):
     if trans:
         self.transpose = trans
     if self.original_key and self.transpose:
         self.transposer = chords.transposer(self.transpose)
         self.key = self.transposer.transpose_chord(self.original_key)
         
     return "(%s)" % self.key if self.key != None else ""
def generate_defs():
    transposer = chords.transposer()
    parser = argparse.ArgumentParser()
    parser.add_argument('tuning',  default=None, help='tuning')
    args = vars(parser.parse_args())
    tuning = args["tuning"]
    chordpro_definitions = "";
    for note_index  in range(0,12):
        for variant in ["", "7","6","sus4","m" ,"maj7" ,"m7","Add9","dim"]:
            chord_name = transposer.get_note(note_index) + variant
            defs = generate_grids(chord_name, tuning)
            grids = chords.ChordChart()
            grids.load(defs)
            norm_chord_name = grids.normalise_chord_name(chord_name)
            grids.sort_by_playability(norm_chord_name)
            chordpro_definitions += "{c: %s}\n%s\n" % (norm_chord_name,  str(grids.to_chordpro(norm_chord_name)))
            
    open("%s_chords.cho" % tuning.replace(" ",""), 'w').write(chordpro_definitions)  
Beispiel #5
0
    def __init__(self,
                 song,
                 title="Song",
                 transpose=0,
                 blank=False,
                 path=None,
                 instruments=None,
                 instrument_name=None,
                 nashville=False,
                 major_chart=False,
                 lefty=False):
        self.blank = blank
        self.lefty = lefty
        if instruments == None:
            self.instruments = chordprobook.instruments.Instruments()
        else:
            self.instruments = instruments

        self.local_instruments = None
        # Look-up
        self.instrument_name = instrument_name
        self.local_instrument_names = []
        self.text = song
        self.key = None
        self.pages = 1
        self.original_key = None
        self.path = path
        self.dir = "."
        if self.path:
            self.dir, _ = os.path.split(self.path)

        self.notes_md = ""
        self.nashville = nashville
        self.major_chart = nashville and major_chart
        self.transpose = transpose if not nashville else False
        self.transposer = chords.transposer(transpose)
        self.standard_transpositions = [0]
        self.title = ""
        self.grids = None
        self.parse()
        self.md = ""
        self.formatted_title = ""
        if self.title == "":
            self.title = title
Beispiel #6
0
 def test_transpose(self):
   c = chords.transposer(2)
   self.assertEqual(c.transpose_note("C"), "D")
   c = chords.transposer(1)
   self.assertEqual(c.transpose_note("B"), "C")
   c = chords.transposer(2)
   self.assertEqual(c.transpose_chord("C"), "D")
   c = chords.transposer(1)
   self.assertEqual(c.transpose_chord("C7"), "C#7")
   c = chords.transposer(1)
   self.assertEqual(c.transpose_chord("Asus4"), "Bbsus4")
   c = chords.transposer(-1)
   self.assertEqual(c.transpose_chord("C#7"), "C7")
   self.assertEqual(c.transpose_chord("Cm"), "Bm")
   self.assertEqual(c.transpose_chord("G#m/B"), "Gm/Bb")
 def test_transpose(self):
     c = chords.transposer(2)
     self.assertEqual(c.transpose_note("C"), "D")
     c = chords.transposer(1)
     self.assertEqual(c.transpose_note("B"), "C")
     c = chords.transposer(2)
     self.assertEqual(c.transpose_chord("C"), "D")
     c = chords.transposer(1)
     self.assertEqual(c.transpose_chord("C7"), "C#7")
     c = chords.transposer(1)
     self.assertEqual(c.transpose_chord("Asus4"), "Bbsus4")
     c = chords.transposer(-1)
     self.assertEqual(c.transpose_chord("C#7"), "C7")
     self.assertEqual(c.transpose_chord("Cm"), "Bm")
     self.assertEqual(c.transpose_chord("G#m/B"), "Gm/Bb")
Beispiel #8
0
def generate_defs():
    transposer = chords.transposer()
    parser = argparse.ArgumentParser()
    parser.add_argument('tuning', default=None, help='tuning')
    args = vars(parser.parse_args())
    tuning = args["tuning"]
    chordpro_definitions = ""
    for note_index in range(0, 12):
        for variant in [
                "", "7", "6", "sus4", "m", "maj7", "m7", "Add9", "dim"
        ]:
            chord_name = transposer.get_note(note_index) + variant
            defs = generate_grids(chord_name, tuning)
            grids = chords.ChordChart()
            grids.load(defs)
            norm_chord_name = grids.normalise_chord_name(chord_name)
            grids.sort_by_playability(norm_chord_name)
            chordpro_definitions += "{c: %s}\n%s\n" % (
                norm_chord_name, str(grids.to_chordpro(norm_chord_name)))

    open("%s_chords.cho" % tuning.replace(" ", ""),
         'w').write(chordpro_definitions)