def test_chord_unparse(self):
     self.assertEquals(
         Chord(ScaleNote(0, 1), descriptor='m').unparse(), '[C+m]')
     self.assertEquals(
         Chord(ScaleNote(2), other_notes=[ScaleNote(4),
                                          ScaleNote(6)]).unparse(),
         '[:EGB]')
 def test_chord_parse_and_unparse(self):
     region = as_region("[:CE-G]")
     parsed_chord = Chord.parse(region)
     self.assertEquals(parsed_chord, Chord(ScaleNote(0), other_notes=[ScaleNote(2, -1), ScaleNote(4)]))
     self.assertEquals(parsed_chord.source.value, parsed_chord.unparse())
     region = as_region("[Cm7]")
     self.assertEquals(Chord.parse(region), Chord(ScaleNote(0), descriptor="m7"))
 def test_chord_notes_midi_notes(self):
     region = as_region('[:CEG]')
     parsed_chord = Chord.parse(region)
     parsed_chord.resolve(Song())
     self.assertEquals(parsed_chord.midi_notes, [24, 28, 31])
     region = as_region('[:C+EG+]')
     parsed_chord = Chord.parse(region)
     parsed_chord.resolve(Song())
     self.assertEquals(parsed_chord.midi_notes, [25, 28, 32])
 def test_chord_notes_midi_notes(self):
     region = as_region("[:CEG]")
     parsed_chord = Chord.parse(region)
     parsed_chord.resolve(Song())
     self.assertEquals(parsed_chord.midi_notes, [24, 28, 31])
     region = as_region("[:C+EG+]")
     parsed_chord = Chord.parse(region)
     parsed_chord.resolve(Song())
     self.assertEquals(parsed_chord.midi_notes, [25, 28, 32])
    def test_chord_with_bass(self):
        region = as_region("[:DFA]")
        parsed_chord = Chord.parse(region)
        parsed_chord.resolve(Song())
        self.assertEquals(parsed_chord.bass_midi_note, 14)

        region = as_region("[:DFA/C]")
        parsed_chord = Chord.parse(region)
        parsed_chord.resolve(Song())
        self.assertEquals(parsed_chord.bass_midi_note, 12)
    def test_chord_descriptor_midi_notes(self):
        region = as_region("[B]")
        parsed_chord = Chord.parse(region)
        parsed_chord.resolve(Song())
        self.assertEquals(parsed_chord.midi_notes, [35, 39, 42])

        region = as_region("[B-]")
        parsed_chord = Chord.parse(region)
        parsed_chord.resolve(Song())
        self.assertEquals(parsed_chord.midi_notes, [34, 38, 41])
    def test_chord_descriptor_midi_notes(self):
        region = as_region('[B]')
        parsed_chord = Chord.parse(region)
        parsed_chord.resolve(Song())
        self.assertEquals(parsed_chord.midi_notes, [35, 39, 42])

        region = as_region('[B-]')
        parsed_chord = Chord.parse(region)
        parsed_chord.resolve(Song())
        self.assertEquals(parsed_chord.midi_notes, [34, 38, 41])
    def test_chord_with_bass(self):
        region = as_region('[:DFA]')
        parsed_chord = Chord.parse(region)
        parsed_chord.resolve(Song())
        self.assertEquals(parsed_chord.bass_midi_note, 14)

        region = as_region('[:DFA/C]')
        parsed_chord = Chord.parse(region)
        parsed_chord.resolve(Song())
        self.assertEquals(parsed_chord.bass_midi_note, 12)
 def test_chord_parse_and_unparse(self):
     region = as_region('[:CE-G]')
     parsed_chord = Chord.parse(region)
     self.assertEquals(
         parsed_chord,
         Chord(ScaleNote(0), other_notes=[ScaleNote(2, -1),
                                          ScaleNote(4)]))
     self.assertEquals(parsed_chord.source.value, parsed_chord.unparse())
     region = as_region('[Cm7]')
     self.assertEquals(Chord.parse(region),
                       Chord(ScaleNote(0), descriptor='m7'))
示例#10
0
 def test_song_items(self):
     region = as_region(' [C] c e | [Am] ')
     song_items = list(SongItems.parse(region))
     expected_song_items = [
         Chord(ScaleNote(0), descriptor=''),
         Note(0),
         Note(2),
         BarLine(),
         Chord(ScaleNote(5), descriptor='m')
     ]
     self.assertEquals(song_items, expected_song_items)
     self.assertEquals(song_items[0].source.value, '[C]')
     self.assertEquals(song_items[3].source.value, '|')
示例#11
0
 def test_parse_chord_song_item(self):
     region = as_region('[:CE-G]')
     parsed_item = SongItem.parse(region)
     self.assertEquals(parsed_item.source, region)
     region = as_region('[:CE-G]')
     parsed_chord = Chord.parse(region)
     self.assertEquals(parsed_item, parsed_chord)
 def test_parse_chord_song_item(self):
     region = as_region("[:CE-G]")
     parsed_item = SongItem.parse(region)
     self.assertEquals(parsed_item.source, region)
     region = as_region("[:CE-G]")
     parsed_chord = Chord.parse(region)
     self.assertEquals(parsed_item, parsed_chord)
示例#13
0
    def test_parse_song(self):
        parse_string = StringToParse('test_string', self.song_lines)
        song = Song.parse(parse_string)
        self.assertEqualsDisplaying(
            song,
            Song([
                SongValuesCommand(
                    [SetSongTempoBpm(120),
                     SetSongTicksPerBeat(4)]),
                TrackValuesCommand('chord',
                                   [SetTrackOctave(2),
                                    SetTrackInstrument(40)]),
                TrackValuesCommand(
                    'bass',
                    [SetTrackOctave(1), SetTrackVolume(90)]),
                Chord(ScaleNote(0), descriptor=''),
                Note(0, duration=(1, 1)),
                Note(2, duration=(1, 1)),
                Chord(ScaleNote(3), other_notes=[ScaleNote(5),
                                                 ScaleNote(0)]),
                Note(2, duration=(1, 1)),
                Note(0, duration=(1, 2)),
                Note(0, duration=(1, 2)),
                BarLine(),
                Chord(ScaleNote(4), descriptor=''),
                Note(4, duration=(1, 1)),
                Rest((2, 1))
            ]))
        chord_track = song.tracks['chord']
        self.assertEquals(chord_track.instrument, 40)
        self.assertEquals(song.tracks['bass'].volume, 90)
        self.assertEquals(len(chord_track.items), 3)
        self.assertEquals(len(song.tracks['melody'].items), 6)

        self.assertEquals(chord_track.items[0].midi_notes, [36, 40, 43])
        self.assertEquals(chord_track.items[1].bass_midi_note, 29)
        self.assertEquals(song.bar_ticks, [0, 16, 32])
示例#14
0
    def test_subticks(self):
        song_lines = """
            *song:         tempo_bpm=120, ticks_per_beat=4, subticks_per_tick = 5
                 | [C] c 
"""
        parse_string = StringToParse('test_string', song_lines)
        song = Song.parse(parse_string)
        self.assertEqualsDisplaying(
            song,
            Song([
                SongValuesCommand([
                    SetSongTempoBpm(120),
                    SetSongTicksPerBeat(4),
                    SetSongSubTicksPerTick(5)
                ]),
                BarLine(),
                Chord(ScaleNote(0), descriptor=''),
                Note(0, duration=(1, 1))
            ]))
示例#15
0
    def test_parse_song_cut(self):
        song_lines = """
            *song:         tempo_bpm=120, ticks_per_beat=4
                 | [C] c e 
                 [:FAC] e 
                 ! c | [G] r2
"""
        parse_string = StringToParse('test_string', song_lines)
        song = Song.parse(parse_string)
        self.assertEqualsDisplaying(
            song,
            Song([
                SongValuesCommand(
                    [SetSongTempoBpm(120),
                     SetSongTicksPerBeat(4)]),
                Note(0, duration=(1, 1)),
                BarLine(),
                Chord(ScaleNote(4), descriptor=''),
                Rest((2, 1))
            ]))
示例#16
0
 def test_chord_equality(self):
     chord1 = Chord(ScaleNote(0, 1), descriptor='maj7')
     chord2 = Chord(ScaleNote(0, 1), descriptor='maj7')
     self.assertEquals(chord1, chord2)
     chord3 = Chord(ScaleNote(0, 1), descriptor='m7')
     self.assertNotEquals(chord1, chord3)
示例#17
0
 def test_parse_chord_rest(self):
     region = as_region('[]')
     parsed_chord = Chord.parse(region)
     self.assertEquals(parsed_chord, Chord(None))
 def test_parse_chord_rest(self):
     region = as_region("[]")
     parsed_chord = Chord.parse(region)
     self.assertEquals(parsed_chord, Chord(None))