Esempio n. 1
0
def make_music21_note(
    pitch_number=None,
    duration=1.0,
    staccato=False,
    tenuto=False,
    accent=False,
    falloff=False,
    plop=False,
    scoop=False,
    doit=False,
    breath_mark=False,
):
    if pitch_number == None or pitch_number == 'rest':
        n = Rest()
    elif isinstance(pitch_number, list):
        pitches = [Pitch(p) for p in pitch_number]
        for p in pitches:
            if p.accidental.name is 'natural':
                p.accidental = None
        n = Chord(pitches)
    else:
        p = Pitch(pitch_number)
        if p.accidental.name is 'natural':
            p.accidental = None
        n = Note(p)

    d = Duration()
    d.quarterLength = duration
    n.duration = d

    if staccato:
        n.articulations.append(Staccato())
    if tenuto:
        n.articulations.append(Tenuto())
    if accent:
        n.articulations.append(Accent())
    if falloff:
        n.articulations.append(Falloff())
    if plop:
        n.articulations.append(Plop())
    if scoop:
        n.articulations.append(Scoop())
    if doit:
        n.articulations.append(Doit())
    if breath_mark:
        n.articulations.append(BreathMark())

    return n
Esempio n. 2
0
def _transpose_pitch_in_scale_space(
    original_pitch: pitch.Pitch,
    steps: int,
    reference_scale: scale.ConcreteScale,
) -> pitch.Pitch:
    if steps == 0:
        return
    if steps > 0:
        direction = "ascending"
    else:
        direction = "descending"
        steps *= -1
    new_pitch = reference_scale.next(original_pitch, direction, steps)
    original_pitch.step = new_pitch.step
    original_pitch.octave = new_pitch.octave
    original_pitch.accidental = new_pitch.accidental
Esempio n. 3
0
    def testUpdateAccidentalDisplaySimple(self):
        '''Test updating accidental display.
        '''
        past = [Pitch('A#3'), Pitch('C#'), Pitch('C')]

        a = Pitch('c')
        a.accidental = Accidental('natural')
        a.accidental.displayStatus = True
        self.assertEqual(a.name, 'C')
        self.assertTrue(a.accidental.displayStatus)

        a.updateAccidentalDisplay(pitchPast=past, overrideStatus=True)
        self.assertFalse(a.accidental.displayStatus)

        b = copy.deepcopy(a)
        self.assertFalse(b.accidental.displayStatus)
        self.assertEqual(b.accidental.name, 'natural')