Esempio n. 1
0
    def dump(self):
        out = []

        for system in self.get_systems():
            old_change = None
            for change in system:

                if change == old_change:
                    out.append( u'/ ' )
                else:
                    out.append(change.get_interval_display() + change.short_extension + ' ')
                
                old_change = change
                
            out.append( u'\n' )
        
        out = u''.join(out)
        return ascii_map(out)
Esempio n. 2
0
    ('0,4,7,11,14',         'major 9th',        u'▵9'),
    ('0,3,7,10,14',         'minor 9th',        u'-9'),
    
    ('0,4,7,10,14,17',      '11th',             u'11'),
    ('0,4,7,11,14,17',      'major 11th',       u'▵11'),
    ('0,3,7,10,14,17',      'minor 11th',       u'-11'),
    
    ('0,4,7,10,14,17,21',   '13th',             u'13'),
    ('0,4,7,11,14,17,21',   'major 13th',       u'▵13'),
    ('0,3,7,10,14,17,21',   'minor 13th',       u'-13'),
)

EXTENSIONS = [(x, y) for x, y, z in EXTENSIONS_DEEP]
EXTENSIONS_DICT = dict([(x, z) for x, y, z in EXTENSIONS_DEEP])
# ascii version of extensions
REVERSE_EXTENSIONS_DICT = dict([(ascii_map(z), x) for x, y, z in EXTENSIONS_DEEP])


class ChangeManager(models.Manager):
    def with_key(self, **kwargs):
        key = kwargs.pop('key', None)
        qs = super(ChangeManager, self).get_query_set().select_related().filter(**kwargs)

        [change.get_chord(key=key) for change in qs]

        return qs


class Change(models.Model):
    def __init__(self, *args, **kwargs):
        self.chord = None # text representation of chord