Exemple #1
0
    def test_low_range(self):
        ranges = PitchRange.create("A:0", "C:5")
        for modality_type in SYSTEM_MODALITIES:
            for validTone in ModalityFactory.create_modality(modality_type).get_valid_root_tones():
                tonality = Tonality.create(modality_type, DiatonicFoundation.get_tone(validTone))
        
                pitch_scale = PitchScale(tonality, ranges)
                print('Scale {0} {1} on {2}: {3}'.format(validTone, modality_type.name, ranges,
                                                         ','.join(map(get_symbol, pitch_scale.pitch_scale))))

                scale_check(pitch_scale, tonality)
    def test_book_examples(self):
        modality = ModalityFactory.create_modality(ModalityType.Major)
        assert modality is not None

        modality = ModalityFactory.create_modality(
            ModalityType.MajorPentatonic, 1)
        assert modality is not None

        my_modality = 'my_modality'
        modality_type = ModalityType(my_modality)
        incremental_interval_strs = [
            'P:1', 'm:2', 'M:3', 'm:2', 'm:2', 'M:2', 'A:2'
        ]
        modality_spec = ModalitySpec(modality_type, incremental_interval_strs)
        ModalityFactory.register_modality(modality_type, modality_spec)
        modality = ModalityFactory.create_modality(ModalityType(my_modality))
        assert modality is not None

        tones = modality.get_tonal_scale(DiatonicFoundation.get_tone('Eb'))
        print('[{0}]'.format(','.join(
            str(tone.diatonic_symbol) for tone in tones)))
Exemple #3
0
 def create(modality_type, diatonic_tone, modal_index=0):
     """
     Constructor.
     :param modality_type: ModalityType being used.
     :param diatonic_tone: DiatonicTone being used as root.
     :param modal_index: (origin 0), which of the tonality's tone is the actual root_tone.
     """
     if isinstance(diatonic_tone, str):
         base_diatonic_tone = DiatonicToneCache.get_tone(diatonic_tone)
     else:
         base_diatonic_tone = diatonic_tone
     return Tonality(ModalityFactory.create_modality(modality_type, modal_index), base_diatonic_tone)
Exemple #4
0
    def test_pentatonic_minor_key(self):
        pentatonic_modality = ModalityFactory.create_modality(
            ModalityType.MinorPentatonic)

        for key in pentatonic_modality.get_valid_root_tones():
            scale = pentatonic_modality.get_tonal_scale(DiatonicTone(key))
            print('{0} scale for {1} is [{2}]'.format(
                pentatonic_modality.get_modality_name, key,
                ', '.join(dt.diatonic_symbol for dt in scale)))

            incremental_intervals = build_incremental_intervals(scale)
            assert incremental_intervals == pentatonic_modality.incremental_intervals
        print('End test_pentatonic_minor_key')
Exemple #5
0
    def test_for_book(self):
        tonality_a = Tonality(
            ModalityFactory.create_modality(ModalityType.Major, 1), 'E')
        tonality_b = Tonality.create(ModalityType.Major, 'E', 1)
        tonality_c = Tonality.create_on_basis_tone('D', ModalityType.Major, 1)

        print('{0}:  [{1}]'.format(
            tonality_a,
            ','.join(tone.diatonic_symbol for tone in tonality_a.annotation)))
        print('{0}:  [{1}]'.format(
            tonality_b,
            ','.join(tone.diatonic_symbol for tone in tonality_b.annotation)))
        print('{0}:  [{1}]'.format(
            tonality_c,
            ','.join(tone.diatonic_symbol for tone in tonality_c.annotation)))
Exemple #6
0
    def create_on_basis_tone(basis_tone, modality_type, modal_index=0):
        diatonic_tone = DiatonicToneCache.get_tone(basis_tone) if isinstance(basis_tone, str) else basis_tone

        raw_modality = ModalityFactory.create_modality(modality_type, 0)
        scale = raw_modality.get_tonal_scale(diatonic_tone)
        return Tonality.create(modality_type, scale[modal_index], modal_index)