Exemplo n.º 1
0
 def __init__(
     self,
     time_signatures=None,
     divisions=None,
     rh_rhythm_maker=None,
     lh_rhythm_maker=None,
     rh_pitch_range=None,
     lh_pitch_range=None,
 ):
     SegmentMaker.__init__(self)
     time_signatures = time_signatures or []
     time_signatures = [
         indicatortools.TimeSignature(x) for x in time_signatures
     ]
     self._time_signatures = time_signatures
     self._divisions = divisions
     if rh_rhythm_maker is None:
         rh_rhythm_maker = rhythmmakertools.NoteRhythmMaker()
     assert isinstance(rh_rhythm_maker, rhythmmakertools.RhythmMaker)
     self._rh_rhythm_maker = rh_rhythm_maker
     if lh_rhythm_maker is None:
         lh_rhythm_maker = rhythmmakertools.NoteRhythmMaker()
     assert isinstance(lh_rhythm_maker, rhythmmakertools.RhythmMaker)
     self._lh_rhythm_maker = lh_rhythm_maker
     rh_pitch_range = rh_pitch_range or '[C4, C6]'
     rh_pitch_range = pitchtools.PitchRange(rh_pitch_range)
     self._rh_pitch_range = rh_pitch_range
     lh_pitch_range = lh_pitch_range or '[C2, C4)'
     lh_pitch_range = pitchtools.PitchRange(lh_pitch_range)
     self._lh_pitch_range = lh_pitch_range
Exemplo n.º 2
0
 def source_pitch_range(self, source_pitch_range):
     from abjad.tools import pitchtools
     if isinstance(source_pitch_range, str):
         source_pitch_range = pitchtools.PitchRange(source_pitch_range)
     elif isinstance(source_pitch_range, pitchtools.PitchRange):
         source_pitch_range = copy.copy(source_pitch_range)
     self._source_pitch_range = source_pitch_range
Exemplo n.º 3
0
 def __init__(self, cells=None):
     from abjad.tools import pitchtools
     self._parent_array = None
     self._pitch_range = pitchtools.PitchRange()
     self._cells = []
     cells = cells or []
     self.extend(cells)
Exemplo n.º 4
0
 def __init__(
     self,
     instrument_name=None,
     short_instrument_name=None,
     instrument_name_markup=None,
     short_instrument_name_markup=None,
     allowable_clefs=None,
     pitch_range=None,
     sounding_pitch_of_written_middle_c=None,
 ):
     from abjad.tools import scoretools
     self._do_not_format = False
     if instrument_name is not None:
         assert isinstance(instrument_name, str), repr(instrument_name)
     self._instrument_name = instrument_name
     prototype = markuptools.Markup
     if instrument_name_markup is not None:
         assert isinstance(instrument_name_markup, prototype)
     self._instrument_name_markup = instrument_name_markup
     if short_instrument_name is not None:
         assert isinstance(short_instrument_name, str)
     self._short_instrument_name = short_instrument_name
     if short_instrument_name_markup is not None:
         assert isinstance(short_instrument_name_markup, prototype)
     self._short_instrument_name_markup = short_instrument_name_markup
     allowable_clefs = allowable_clefs or ['treble']
     allowable_clefs = indicatortools.ClefInventory(allowable_clefs)
     self._allowable_clefs = allowable_clefs
     if isinstance(pitch_range, str):
         pitch_range = pitchtools.PitchRange(pitch_range)
     elif isinstance(pitch_range, pitchtools.PitchRange):
         pitch_range = copy.copy(pitch_range)
     elif pitch_range is None:
         pitch_range = pitchtools.PitchRange()
     else:
         raise TypeError(pitch_range)
     self._pitch_range = pitch_range
     sounding_pitch_of_written_middle_c = \
         sounding_pitch_of_written_middle_c or pitchtools.NamedPitch("c'")
     sounding_pitch_of_written_middle_c = \
         pitchtools.NamedPitch(sounding_pitch_of_written_middle_c)
     self._sounding_pitch_of_written_middle_c = \
         sounding_pitch_of_written_middle_c
     self._default_scope = scoretools.Staff
     self._is_primary_instrument = False
     self._performer_names = ['instrumentalist']
     self._starting_clefs = copy.copy(allowable_clefs)
Exemplo n.º 5
0
 def coerce_(expr):
     if isinstance(expr, str):
         range_ = pitchtools.PitchRange(expr)
     elif isinstance(expr, tuple):
         range_ = pitchtools.PitchRange.from_pitches(*expr)
     elif isinstance(expr, pitchtools.PitchRange):
         range_ = copy.copy(expr)
     else:
         raise TypeError(expr)
     return range_
Exemplo n.º 6
0
 def __init__(
     self,
     source_pitch_range='[A0, C8]',
     target_octave_start_pitch=0,
 ):
     from abjad.tools import pitchtools
     if isinstance(source_pitch_range, pitchtools.PitchRange):
         source_pitch_range = copy.copy(source_pitch_range)
     else:
         source_pitch_range = pitchtools.PitchRange(source_pitch_range)
     target_octave_start_pitch = pitchtools.NumberedPitch(
         target_octave_start_pitch)
     self._source_pitch_range = source_pitch_range
     self._target_octave_start_pitch = target_octave_start_pitch
Exemplo n.º 7
0
    def pitch_range(self):
        r'''Gets pitch range of octave.

        ..  container:: example

            >>> abjad.Octave(5).pitch_range
            PitchRange('[C5, C6)')

        Returns pitch range.
        '''
        from abjad.tools import pitchtools
        return pitchtools.PitchRange('[C{}, C{})'.format(
            self.number,
            self.number + 1,
        ))
Exemplo n.º 8
0
def create_pitch_contour_reservoir():
    r'''Creates pitch contour reservoir.
    '''

    scale = tonalanalysistools.Scale('a', 'minor')
    pitch_ranges = {
        'First Violin': pitchtools.PitchRange('[C4, A6]'),
        'Second Violin': pitchtools.PitchRange('[A3, A5]'),
        'Viola': pitchtools.PitchRange('[E3, A4]'),
        'Cello': pitchtools.PitchRange('[A2, A3]'),
        'Bass': pitchtools.PitchRange('[C3, A3]'),
    }

    reservoir = {}
    for instrument_name, pitch_range in pitch_ranges.items():
        pitch_set = scale.create_named_pitch_set_in_pitch_range(pitch_range)
        pitches = sorted(pitch_set, reverse=True)
        pitch_descents = []
        for i in range(len(pitches)):
            descent = tuple(pitches[:i + 1])
            pitch_descents.append(descent)
        reservoir[instrument_name] = tuple(pitch_descents)

    return reservoir
Exemplo n.º 9
0
    def pitch_range(self):
        r'''Pitch range of octave.

        ::

            >>> pitchtools.Octave(5).pitch_range
            PitchRange(range_string='[C5, C6)')

        Returns pitch range.
        '''
        from abjad.tools import pitchtools
        return pitchtools.PitchRange('[C{}, C{})'.format(
            self.octave_number,
            self.octave_number + 1,
        ))
Exemplo n.º 10
0
    def create_named_pitch_set_in_pitch_range(self, pitch_range):
        r'''Creates named pitch-set in `pitch_range`.

        Returns pitch-set.
        '''
        if not isinstance(pitch_range, pitchtools.PitchRange):
            pitch_range = pitchtools.PitchRange(
                float(pitchtools.NamedPitch(pitch_range[0])),
                float(pitchtools.NamedPitch(pitch_range[1])))
        low = pitch_range.start_pitch.octave_number
        high = pitch_range.stop_pitch.octave_number
        pitches = []
        octave = low
        while octave <= high:
            for x in self:
                pitch = pitchtools.NamedPitch(x, octave)
                if pitch_range.start_pitch <= pitch and \
                    pitch <= pitch_range.stop_pitch:
                    pitches.append(pitch)
            octave += 1
        return pitchtools.PitchSet(
            items=pitches,
            item_class=pitchtools.NamedPitch,
        )