コード例 #1
0
def test_github_issue_8_sloppy_midi():
    prog = ChordProgression.from_midi_file(
        os.path.join(os.path.dirname(__file__), "test_data", "issue_8.mid"))
    assert prog == ChordProgression([
        Chord(
            name="A#min",
            root=Note("A#", 3),
            intervals=Intervals(name="min", semitones=[0, 3, 7]),
        ),
        Chord(
            name="D#",
            root=Note("D#", 4),
            intervals=Intervals(name="", semitones=[0, 4, 7]),
        ),
        Chord(
            name="D#min",
            root=Note("D#", 4),
            intervals=Intervals(name="min", semitones=[0, 3, 7]),
        ),
        Chord(
            name="A#min/G#",
            root=Note("G#", 3),
            intervals=Intervals(name="min/b7", semitones=[0, 5, 9, 14]),
        ),
    ])
コード例 #2
0
def make_midi_file(chord_names, beats_per_chord, out_file):
    chords = []
    for name in chord_names:
        try:
            chord = Chord.from_name(name)
        except InvalidChord:
            chord = ChordProgression.DUMMY_CHORD
        chords.append(chord)

    progression = ChordProgression(chords)
    progression.to_midi(
        MidiConversionSettings(filename=out_file,
                               instrument=11,
                               beats_per_chord=beats_per_chord))
コード例 #3
0
def test_github_issue_61_progression():
    """https://github.com/jonathangjertsen/jchord/issues/61#issuecomment-777575298"""
    prog = ChordProgression.from_string("4F -- 3Am -- 4Dm7 -- 4F --")
    assert prog == ChordProgression([
        Chord(
            name="F",
            root=Note("F", 4),
            intervals=Intervals(name="major", semitones=[0, 4, 7]),
        ),
        Chord(
            name="F",
            root=Note("F", 4),
            intervals=Intervals(name="major", semitones=[0, 4, 7]),
        ),
        Chord(
            name="Am",
            root=Note("A", 3),
            intervals=Intervals(name="m", semitones=[0, 3, 7]),
        ),
        Chord(
            name="Am",
            root=Note("A", 3),
            intervals=Intervals(name="m", semitones=[0, 3, 7]),
        ),
        Chord(
            name="Dm7",
            root=Note("D", 4),
            intervals=Intervals(name="m7", semitones=[0, 3, 7, 10]),
        ),
        Chord(
            name="Dm7",
            root=Note("D", 4),
            intervals=Intervals(name="m7", semitones=[0, 3, 7, 10]),
        ),
        Chord(
            name="F",
            root=Note("F", 4),
            intervals=Intervals(name="major", semitones=[0, 4, 7]),
        ),
        Chord(
            name="F",
            root=Note("F", 4),
            intervals=Intervals(name="major", semitones=[0, 4, 7]),
        ),
    ])