How to use the birdears.note_and_pitch.Pitch function in birdears

To help you get started, we’ve selected a few birdears examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github iacchus / birdears / tests / test_basic.py View on Github external
def test_sequenceclass_chords():

    c4 = Pitch('C', 4)
    e4 = Pitch('E', 4)
    g4 = Pitch('G', 4)
    b4 = Pitch('B', 4)
    d5 = Pitch('D', 5)

    sequence = Sequence([Chord([c4, e4, g4]), Chord([b4, b4, d5]),
                        Chord([c4, e4, g4])])

    sequence.play()

    assert(sequence)
github iacchus / birdears / tests / test_basic.py View on Github external
def test_intervalclass():

    a5 = Pitch('A', 5)
    c3 = Pitch('C', 3)

    a = Interval(a5, c3)

    assert(a)
github iacchus / birdears / tests / test_basic.py View on Github external
def test_sequenceclass_chords():

    c4 = Pitch('C', 4)
    e4 = Pitch('E', 4)
    g4 = Pitch('G', 4)
    b4 = Pitch('B', 4)
    d5 = Pitch('D', 5)

    sequence = Sequence([Chord([c4, e4, g4]), Chord([b4, b4, d5]),
                        Chord([c4, e4, g4])])

    sequence.play()

    assert(sequence)
github iacchus / birdears / tests / test_basic.py View on Github external
def test_sequenceclass_append():

    sequence = Sequence([Pitch('C', 3)])
    sequence.append(Chord([Pitch('C', 4), Pitch('D', 4), Pitch('E', 4)]))

    assert(sequence)
github iacchus / birdears / tests / test_basic.py View on Github external
def test_sequenceclass_notes():

    c4 = Pitch('C', 4)
    d4 = Pitch('D', 4)
    e4 = Pitch('E', 4)

    # sequence = Sequence(['C4', 'D4', 'E4'])

    sequence = Sequence([c4, d4, e4])
    sequence.play()

    assert(sequence)
github iacchus / birdears / birdears / questionbase.py View on Github external
direction = 'descending' if descending else 'ascending'

        # FIXME: maybe this should go to __main__
        self.keyboard_index = \
            tuple(KEYBOARD_INDICES['chromatic'][direction][self.mode])

        if isinstance(tonic, list) or isinstance(tonic, tuple):
            tonic = choice(tonic)
        elif isinstance(tonic, str) and ',' in tonic:
            tonic = tonic.replace(' ', '')
            tonic = choice(tonic.split(','))
        elif isinstance(tonic, str) and ('R' in tonic or 'r' in tonic):
            tonic = choice(KEYS)

        self.tonic_pitch = Pitch(note=tonic, octave=self.octave)
        self.tonic_str = str(self.tonic_pitch.note)
        self.tonic_pitch_str = str(self.tonic_pitch)

        if not chromatic:
            self.scale = DiatonicScale(tonic=self.tonic_str, mode=mode,
                                       octave=self.octave,
                                       descending=descending,
                                       n_octaves=n_octaves)
        else:
            self.scale = ChromaticScale(tonic=self.tonic_str,
                                        octave=self.octave,
                                        descending=descending,
                                        n_octaves=n_octaves)

        self.diatonic_scale = DiatonicScale(tonic=self.tonic_str, mode=mode,
                                            octave=self.octave,
github iacchus / birdears / birdears / note_and_pitch.py View on Github external
def distance(self, other):
        if isinstance(other, (Pitch, int)):
            return self.pitch_number - int(other)
github iacchus / birdears / birdears / note_and_pitch.py View on Github external
def __init__(self, iterable):
        if not all(isinstance(element, Pitch) for element in iterable):
            raise InvalidPitch
        # else:
        super(Chord, self).__init__(iterable)
github iacchus / birdears / birdears / note_and_pitch.py View on Github external
def get_pitch_by_number(numeric, accident='sharp'):

    octave, pitch_class = divmod(numeric, 12)

    if accident == 'sharp':
        note = CHROMATIC_SHARP[pitch_class]
    elif accident == 'flat':
        note = CHROMATIC_FLAT[pitch_class]
    else:
        raise Exception('accident should be \'sharp\' or \'flat\'')

    pitch = Pitch(note=note, octave=octave, accident=accident)

    return pitch