Beispiel #1
0
    def load(self, s, save=False):
        # turn into a single line
        s = ' '.join(s.splitlines())
        # split by spaces
        s = s.split(' ')
        # remove all empty items
        s = [_s for _s in s if _s]

        change_list = []
        change = {}

        for item in s:
            if item == '/':
                # same change
                change['beats'] += 1
            else:
                # new change
                change = dict(
                    beats=1, 
                    interval=find_interval(item),
                    extension=find_extension(item))
                
                change_list.append(change)
        
        out_changes = []
        for i, change in enumerate(change_list, start=1):
            out_changes.append(Change(tune=self, order=i, **change))
        
        if save:
            [change.save() for change in out_changes]
        
        return out_changes
Beispiel #2
0
    def test_detect_intervals_extensions(self):
        from jazzchanges.tunes.utils import ascii_map, find_interval, find_extension

        # find bVII
        self.assertEquals(10, find_interval('bVII-7'))

        # find -7
        self.assertEquals('0,3,7,10', find_extension('bVII-7'))