Skip to content

Commit

Permalink
small fix on str repr
Browse files Browse the repository at this point in the history
  • Loading branch information
cainky committed Dec 28, 2023
1 parent 969ddbc commit ab0b028
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
23 changes: 12 additions & 11 deletions example.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
from midigen.note import Note
from midigen.key import KEY_MAP
from midigen.chord import Chord, ChordProgression
from midigen.midigen import MidiGen
midi_gen = MidiGen()
from midigen.note import Note
from midigen.chord import Chord
from midigen.key import Key, KEY_MAP

dm9 = Chord([Note(pitch, 64, 480, 0) for pitch in [62, 65, 69, 74, 77]])
g7 = Chord([Note(pitch, 64, 480, 0) for pitch in [67, 71, 74, 77]])
cm9 = Chord([Note(pitch, 64, 480, 0) for pitch in [60, 64, 67, 72, 74]])
midi_gen = MidiGen(tempo=120, time_signature=(4, 4), key_signature=Key("C"))

chord_progression = ChordProgression([dm9, g7, cm9])
note_c = Note(pitch=KEY_MAP["C"], velocity=64, duration=480, time=0)
note_e = Note(pitch=KEY_MAP["E"], velocity=64, duration=480, time=0)
note_g = Note(pitch=KEY_MAP["G"], velocity=64, duration=480, time=0)

midi_gen.add_chord_progression(chord_progression)
print(midi_gen)
midi_gen.save("rnb_progression.mid")
c_major_chord = Chord([note_c, note_e, note_g])

track = midi_gen.get_active_track()
track.add_chord(c_major_chord)
print(midi_gen)
midi_gen.save("example.mid")
2 changes: 1 addition & 1 deletion midigen/midigen.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def __str__(self):
:return: A string with the track, tempo, time signature, and key signature of the MidiGen object.
"""
return (
f"Track: {self.track}\nTempo: {self.tempo}\n \
f"Track: {self.tracks}\nTempo: {self.tempo}\n \
Time Signature: {self.time_signature}\nKey Signature: {self.key_signature}"
)

Expand Down
3 changes: 0 additions & 3 deletions midigen/track.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,6 @@ def add_chord(self, chord: Chord) -> None:
Add a chord (simultaneous notes) to the track.
:param chord: A Chord object.
:param velocity: The velocity of the notes.
:param duration: The duration of the notes.
:param time: Optional, the time to schedule the chord.
"""
for note in chord.get_chord():
self.add_note(note)
Expand Down

0 comments on commit ab0b028

Please sign in to comment.