def test_1(self):
        midis = [C(4, 'flat'), C(4), C(4, 'sharp')]
        sf = SimpleFormat(midis=midis)
        v = sf.to_stream_voice(1)
        v.add_to_score(self.score)

        result_path = path + '_test_1'
        self.score.write(path=result_path)
    def test_2(self):
        midis = [
            D(4),
            D(4),
            D(4),
            D(4),
            C(4),
            C(4),
            C(4),
            B(3),
            C(4),
            C(4),
            C(4),
            F(4),
            E(4),
            D(4),
            F(4),
            F(4),
            F(4),
            E(4),
            D(4),
            E(4),
            F(4)
        ]

        durations = [
            2, 3, 1, 2, 3, 1, 4, 2, 4, 2, 2, 3, 1, 2, 2, 2, 2, 3, 1, 1, 4
        ]
        durations = [d / 2 for d in durations]
        sf = SimpleFormat(midis=midis, quarter_durations=durations)
        v = sf.to_stream_voice(1)
        v.add_to_score(self.score)

        result_path = path + '_test_2'
        self.score.write(path=result_path)
 def __init__(self, number=None, *args, **kwargs):
     super().__init__(name='Cello',
                      abbreviation='vc.',
                      number=number,
                      *args,
                      **kwargs)
     self.strings = {
         4: String(4, C(2)),
         3: String(3, G(2)),
         2: String(2, D(3)),
         1: String(1, A(3))
     }
     self.standard_clefs = BASS_CLEF
 def __init__(self, number=None, *args, **kwargs):
     super().__init__(name='Viola',
                      abbreviation='vla.',
                      number=number,
                      *args,
                      **kwargs)
     self.strings = {
         4: String(4, C(3)),
         3: String(3, G(3)),
         2: String(2, D(4)),
         1: String(1, A(4))
     }
     self.standard_clefs = ALTO_CLEF
Exemple #5
0
 def test_1(self):
     fm = FractalMusic(tempo=60,
                       quarter_duration=10,
                       proportions=(1, 2, 3),
                       tree_permutation_order=(3, 1, 2))
     fm.add_layer()
     midis = [B(4), A(4, 'b'), C(4, '#'), A(3), F(4)]
     fm.get_children()[0].add_layer()
     for leaf, midi in zip(fm.traverse_leaves(), midis):
         leaf.set_chord(TreeChord(midi))
     score = fm.get_score(show_fractal_orders=True)
     xml_path = path + '_test_.xml'
     score.write(path=xml_path)
 def __init__(self, number=None, *args, **kwargs):
     super().__init__(name='Viola d\'amore\n430',
                      abbreviation='vla.',
                      number=number,
                      *args,
                      **kwargs)
     # skordatura
     self.strings = {
         1: String(1, B(4)),
         2: String(2, B(4)),
         3: String(3, F(4, '#')),
         4: String(4, C(4)),
         5: String(5, G(3)),
         6: String(6, D(3)),
         7: String(7, A(2))
     }
Exemple #7
0
 def test_1(self):
     sf = SimpleFormat()
     for clef in ALL_CLEFS:
         if clef not in [SUPER_HIGH_TREBLE_CLEF, SUPER_LOW_BASS_CLEF]:
             for midi in clef.optimal_range:
                 if not midi:
                     if clef.optimal_range.index(midi) == 0:
                         midi = G(0)
                     else:
                         midi = C(8)
                 sf.add_chord(TreeChord(quarter_duration=2, midis=[midi]))
             sf.chords[-2].add_clef(clef)
     xml = path + '_test_1.xml'
     sf.to_stream_voice().add_to_score(self.score)
     self.score.finish()
     self.score.to_partwise()
     self.score.write(xml)
Exemple #8
0
        if isinstance(other, self.__class__):
            return self.sign == other.sign and self.line == other.line and self.octave_change == other.octave_change
        else:
            return False

    def __ne__(self, other):
        return not self.__eq__(other)

    def __deepcopy__(self, memodict={}):
        copy = self.__class__(sign=self.sign, line=self.line, octave_change=self.octave_change,
                              optimal_range=self.optimal_range)
        copy.number = self.number
        return copy


SUPER_HIGH_TREBLE_CLEF = TreeClef(sign='G', line=2, octave_change=2, optimal_range=[C(7), None])
HIGH_TREBLE_CLEF = TreeClef(sign='G', line=2, octave_change=1, optimal_range=[C(6), None])
TREBLE_CLEF = TreeClef(sign='G', line=2, optimal_range=[G(3), E(6)])
LOW_TREBLE_CLEF = TreeClef(sign='G', line=2, octave_change=-1, optimal_range=[G(2), E(5)])

BASS_CLEF = TreeClef(sign='F', line=4, optimal_range=[B(1), G(4)])
LOW_BASS_CLEF = TreeClef(sign='F', line=4, octave_change=-1, optimal_range=[None, B(1)])
SUPER_LOW_BASS_CLEF = TreeClef(sign='F', line=4, octave_change=-2, optimal_range=[None, G(1)])

ALTO_CLEF = TreeClef(sign='C', line=3, optimal_range=[A(2), F(5)])
TENOR_CLEF = TreeClef(sign='C', line=4, optimal_range=[F(2), D(5)])

PERCUSSION_CLEF = TreeClef('percussion')

ALL_CLEFS = [SUPER_HIGH_TREBLE_CLEF, HIGH_TREBLE_CLEF, TREBLE_CLEF, LOW_TREBLE_CLEF, BASS_CLEF, LOW_BASS_CLEF,
             SUPER_LOW_BASS_CLEF, ALTO_CLEF, TENOR_CLEF]