def setUp(self): self.i = Instrument() self.p = Piano() self.g = Guitar() self.notes = NoteContainer(["A", "B", "C", "D", "E"]) self.noteslow = NoteContainer(["C-0", "D-0", "E-0"]) self.noteshigh = NoteContainer(["A-12", "B-12", "C-12", "D-12", "E-12"])
def setUp(self): self.i = Instrument() self.p = Piano() self.g = Guitar() self.notes = NoteContainer(['A', 'B', 'C', 'D', 'E']) self.noteslow = NoteContainer(['C-0', 'D-0', 'E-0']) self.noteshigh = NoteContainer( ['A-12', 'B-12', 'C-12', 'D-12', 'E-12'])
def setUp(self): self.i = Instrument() self.p = Piano() self.g = Guitar() self.notes = NoteContainer(['A', 'B', 'C', 'D', 'E']) self.noteslow = NoteContainer(['C-0', 'D-0', 'E-0']) self.noteshigh = NoteContainer(['A-12', 'B-12', 'C-12', 'D-12', 'E-12'])
class test_Instrument(unittest.TestCase): def setUp(self): self.i = Instrument() self.p = Piano() self.g = Guitar() self.notes = NoteContainer(["A", "B", "C", "D", "E"]) self.noteslow = NoteContainer(["C-0", "D-0", "E-0"]) self.noteshigh = NoteContainer( ["A-12", "B-12", "C-12", "D-12", "E-12"]) def test_note_in_range(self): for x in self.notes: self.assertTrue(self.i.note_in_range(x)) self.assertTrue(self.p.note_in_range(x)) self.assertTrue(self.g.note_in_range(x)) for x in self.noteslow + self.noteshigh: self.assertEqual( False, self.p.note_in_range(x), "%s should not be able to be played by a Piano" % x, ) self.assertEqual( False, self.g.note_in_range(x), "%s should not be able to be played by a Guitar" % x, ) def test_can_play_notes(self): self.assertTrue(self.i.can_play_notes(self.notes)) self.assertTrue(self.p.can_play_notes(self.notes)) self.assertTrue(self.g.can_play_notes(self.notes)) self.assertEqual(False, self.p.can_play_notes(self.noteslow)) self.assertEqual(False, self.g.can_play_notes(self.noteslow)) self.assertEqual(False, self.p.can_play_notes(self.noteshigh)) self.assertEqual(False, self.g.can_play_notes(self.noteshigh)) self.assertEqual( False, self.g.can_play_notes( NoteContainer([ "A", "B", "C", "D", "E", "F", "G", ])), )
class test_Instrument(unittest.TestCase): def setUp(self): self.i = Instrument() self.p = Piano() self.g = Guitar() self.notes = NoteContainer(['A', 'B', 'C', 'D', 'E']) self.noteslow = NoteContainer(['C-0', 'D-0', 'E-0']) self.noteshigh = NoteContainer( ['A-12', 'B-12', 'C-12', 'D-12', 'E-12']) def test_note_in_range(self): for x in self.notes: self.assert_(self.i.note_in_range(x)) self.assert_(self.p.note_in_range(x)) self.assert_(self.g.note_in_range(x)) for x in self.noteslow + self.noteshigh: self.assertEqual( False, self.p.note_in_range(x), '%s should not be able to be played by a Piano' % x) self.assertEqual( False, self.g.note_in_range(x), '%s should not be able to be played by a Guitar' % x) def test_can_play_notes(self): self.assert_(self.i.can_play_notes(self.notes)) self.assert_(self.p.can_play_notes(self.notes)) self.assert_(self.g.can_play_notes(self.notes)) self.assertEqual(False, self.p.can_play_notes(self.noteslow)) self.assertEqual(False, self.g.can_play_notes(self.noteslow)) self.assertEqual(False, self.p.can_play_notes(self.noteshigh)) self.assertEqual(False, self.g.can_play_notes(self.noteshigh)) self.assertEqual( False, self.g.can_play_notes( NoteContainer([ 'A', 'B', 'C', 'D', 'E', 'F', 'G', ])))
class test_Instrument(unittest.TestCase): def setUp(self): self.i = Instrument() self.p = Piano() self.g = Guitar() self.notes = NoteContainer(['A', 'B', 'C', 'D', 'E']) self.noteslow = NoteContainer(['C-0', 'D-0', 'E-0']) self.noteshigh = NoteContainer(['A-12', 'B-12', 'C-12', 'D-12', 'E-12']) def test_note_in_range(self): for x in self.notes: self.assert_(self.i.note_in_range(x)) self.assert_(self.p.note_in_range(x)) self.assert_(self.g.note_in_range(x)) for x in self.noteslow + self.noteshigh: self.assertEqual(False, self.p.note_in_range(x), '%s should not be able to be played by a Piano' % x) self.assertEqual(False, self.g.note_in_range(x), '%s should not be able to be played by a Guitar' % x) def test_can_play_notes(self): self.assert_(self.i.can_play_notes(self.notes)) self.assert_(self.p.can_play_notes(self.notes)) self.assert_(self.g.can_play_notes(self.notes)) self.assertEqual(False, self.p.can_play_notes(self.noteslow)) self.assertEqual(False, self.g.can_play_notes(self.noteslow)) self.assertEqual(False, self.p.can_play_notes(self.noteshigh)) self.assertEqual(False, self.g.can_play_notes(self.noteshigh)) self.assertEqual(False, self.g.can_play_notes(NoteContainer([ 'A', 'B', 'C', 'D', 'E', 'F', 'G', ])))
def setUp(self): self.i = Track(Instrument()) self.p = Track(Piano()) self.g = Track(Guitar()) self.tr = Track()
def __init__(self): super(GuitarTrack, self).__init__(Guitar())
from mingus.containers import Note from mingus.containers import NoteContainer from mingus.containers import Bar from mingus.containers import Track from mingus.containers.instrument import Instrument, Piano, Guitar from mingus.containers import Composition from mingus.midi.midi_file_out import write_Composition eb = Note("Eb", 4) g = Note("G", 4) bb = Note("Bb", 4) n = NoteContainer([eb, g, bb]) c = Composition() c.set_author('Dusty Carver', '*****@*****.**') c.set_title('Late Nights') t = Track(Guitar()) b = Bar('Eb', (4, 4)) b.place_notes(n, 4) b.place_notes(n, 4) b.place_notes(n, 4) b.place_notes(None, 4) t.add_bar(b) c.add_track(t) write_Composition("one.mid", c)