本文整理汇总了Python中solfege.mpd.musicalpitch.MusicalPitch.new_from_notename方法的典型用法代码示例。如果您正苦于以下问题:Python MusicalPitch.new_from_notename方法的具体用法?Python MusicalPitch.new_from_notename怎么用?Python MusicalPitch.new_from_notename使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类solfege.mpd.musicalpitch.MusicalPitch
的用法示例。
在下文中一共展示了MusicalPitch.new_from_notename方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_contructor
# 需要导入模块: from solfege.mpd.musicalpitch import MusicalPitch [as 别名]
# 或者: from solfege.mpd.musicalpitch.MusicalPitch import new_from_notename [as 别名]
def test_contructor(self):
Note(MusicalPitch.new_from_notename("c'"),
Duration.new_from_string("4."))
self.assertRaises(AssertionError,
Note, "4.", MusicalPitch.new_from_notename("c'"))
self.assertRaises(AssertionError,
Note, Duration.new_from_string("4."), "c'")
示例2: test_add_d5
# 需要导入模块: from solfege.mpd.musicalpitch import MusicalPitch [as 别名]
# 或者: from solfege.mpd.musicalpitch.MusicalPitch import new_from_notename [as 别名]
def test_add_d5(self):
a = MusicalPitch.new_from_notename("b")
b = Interval("-d5")
self.assertEquals((a+b).get_octave_notename(), "eis")
a = MusicalPitch.new_from_notename("bis")
b = Interval("-d5")
self.assertEquals((a+b).get_octave_notename(), "eisis")
a = MusicalPitch.new_from_notename("bisis")
b = Interval("-d5")
self.assertEquals((a+b).get_octave_notename(), "fisis")
示例3: test_tuplets
# 需要导入模块: from solfege.mpd.musicalpitch import MusicalPitch [as 别名]
# 或者: from solfege.mpd.musicalpitch.MusicalPitch import new_from_notename [as 别名]
def test_tuplets(self):
n1 = Note(MusicalPitch.new_from_notename("g'"),
Duration(8, 0, Rat(2, 3)))
n2 = Note(MusicalPitch.new_from_notename("g'"),
Duration(8, 0, Rat(2, 3)))
n3 = Note(MusicalPitch.new_from_notename("g'"),
Duration(8, 0, Rat(2, 3)))
self.score.voice11.append(n1)
self.score.voice11.append(n2)
self.score.voice11.append(n3)
self.score.voice11.tuplet(Rat(2, 3), const.UP, [n1, n2, n3])
示例4: test_bar_fill_skips
# 需要导入模块: from solfege.mpd.musicalpitch import MusicalPitch [as 别名]
# 或者: from solfege.mpd.musicalpitch.MusicalPitch import new_from_notename [as 别名]
def test_bar_fill_skips(self):
n1 = Note(MusicalPitch.new_from_notename("g'"),
Duration(4, 0))
self.score.voice11.append(n1)
self.score.voice11.append(Rest(Duration.new_from_string("4")))
self.bp.fill_skips()
self.assertTrue(isinstance(self.score.voice11.m_tdict[Rat(0, 1)]['elem'][0], Note))
self.assertTrue(isinstance(self.score.voice11.m_tdict[Rat(1, 4)]['elem'][0], Rest))
self.assertTrue(isinstance(self.score.voice11.m_tdict[Rat(1, 2)]['elem'][0], Skip))
self.assertTrue(isinstance(self.score.voice11.m_tdict[Rat(3, 4)]['elem'][0], Skip))
示例5: new_from_string
# 需要导入模块: from solfege.mpd.musicalpitch import MusicalPitch [as 别名]
# 或者: from solfege.mpd.musicalpitch.MusicalPitch import new_from_notename [as 别名]
def new_from_string(string):
s = string.strip()
m = re_melodic.match(s)
if m.end() < len(s) - 1:
# FIXME: raise ValueError like rest
raise Note.Exception("characters left in string", string)
return Note(
MusicalPitch.new_from_notename("%s%s" % (m.group('notename'),
m.group('octave'))),
Duration.new_from_string("%s%s" % (m.group('len'), m.group('dots')))
)
示例6: test_normalize_double_accidental
# 需要导入模块: from solfege.mpd.musicalpitch import MusicalPitch [as 别名]
# 或者: from solfege.mpd.musicalpitch.MusicalPitch import new_from_notename [as 别名]
def test_normalize_double_accidental(self):
for a, b in (("c", "c"),
("cisis", "d"),
("disis", "e"),
("eisis", "fis"),
("fisis", "g"),
("gisis", "a"),
("aisis", "b"),
("bisis", "cis'"),
("ceses", "bes,"),
("deses", "c"),
("eses", "d"),
("feses", "ees"),
("geses", "f"),
("ases", "g"),
("beses", "a"),
):
n = MusicalPitch.new_from_notename(a)
n.normalize_double_accidental()
self.assertEquals(n.get_octave_notename(), b)
示例7: refill_accidentals_info
# 需要导入模块: from solfege.mpd.musicalpitch import MusicalPitch [as 别名]
# 或者: from solfege.mpd.musicalpitch.MusicalPitch import new_from_notename [as 别名]
def refill_accidentals_info(self, key):
"""Fill the .m_accidentals_info dict with the accidentals
that exist in the key signature `key`.
"""
self.m_accidentals_info = {}
for step in range(MusicalPitch.LOWEST_STEPS, MusicalPitch.HIGHEST_STEPS + 1):
self.m_accidentals_info[step] = 0
for a in mpdutils.key_to_accidentals(key):
n = MusicalPitch.new_from_notename(a)
for octave in range(-4, 7):
n.m_octave_i = octave
if n.semitone_pitch() < 128:
if a[-4:] == 'eses':
self.m_accidentals_info[n.steps()] = -2
elif a[-2:] == 'es':
self.m_accidentals_info[n.steps()] = -1
elif a[-4:] == 'isis':
self.m_accidentals_info[n.steps()] = 2
else:
self.m_accidentals_info[n.steps()] = 1
示例8: test_single_tuplet
# 需要导入模块: from solfege.mpd.musicalpitch import MusicalPitch [as 别名]
# 或者: from solfege.mpd.musicalpitch.MusicalPitch import new_from_notename [as 别名]
def test_single_tuplet(self):
n1 = Note(MusicalPitch.new_from_notename("g'"),
Duration(8, 0, Rat(2, 3)))
self.score.voice11.append(n1)
self.score.voice11.tuplet(Rat(2, 3), const.UP, [n1])
self.assertEqual(n1.w_parent().m_tupletinfo, 'end')
示例9: test_pitch_class
# 需要导入模块: from solfege.mpd.musicalpitch import MusicalPitch [as 别名]
# 或者: from solfege.mpd.musicalpitch.MusicalPitch import new_from_notename [as 别名]
def test_pitch_class(self):
for n, i in (("c", 0), ("cis", 1), ("g", 7), ("ges", 6), ("gisis", 9),
("b", 11), ("bis", 0), ("bisis", 1), ("ces", 11)):
p = MusicalPitch.new_from_notename(n)
self.assertEquals(p.pitch_class(), i)
示例10: parse_to_score_object
# 需要导入模块: from solfege.mpd.musicalpitch import MusicalPitch [as 别名]
# 或者: from solfege.mpd.musicalpitch.MusicalPitch import new_from_notename [as 别名]
def parse_to_score_object(music):
lexer = Lexer(music)
relative_mode = None
relto = None
transpose_pitch = None
TOPLEVEL = 1#'toplevel'
NOTES = 2#'notes'
START_OF_CHORD = 3#'start-of-chord'
CHORD = 4#'chord'
context = TOPLEVEL
score = elems.Score()
chord_duration = None
cur_duration = Duration(4, 0)
tie_is_in_the_air = 0
beam = None
# None when not parsing notes in a tuplet. Item 0 is the ration and 1.. is the notes
times = None
cur_staff = None
# This variable is set to the duration of the pickup bar from we parse
# \partial nn until the bar has been created.
partial = None
for toc, toc_data in lexer:
try:
if toc_data.m_duration:
cur_duration = toc_data.m_duration.clone()
except AttributeError:
pass
if toc == Lexer.STAFF:
assert context == TOPLEVEL
cur_staff = score.add_staff(elems.Staff)
cur_voice = cur_staff.m_voices[-1]
stem_dir = const.BOTH
tuplet_dir = const.BOTH
relative_mode = None
timepos = Rat(0)
last_pos = timepos
elif toc == Lexer.RHYTHMSTAFF:
assert context == TOPLEVEL
cur_staff = score.add_staff(elems.RhythmStaff)
cur_voice = cur_staff.m_voices[-1]
stem_dir = const.BOTH
tuplet_dir = const.BOTH
relative_mode = None
timepos = Rat(0)
last_pos = timepos
elif toc == Lexer.VOICE:
if not cur_staff:
raise ParseError("Don't use \\addvoice before \\staff", lexer)
relative_mode = None
timepos = Rat(0)
cur_voice = cur_staff.add_voice()
elif toc == Lexer.RELATIVE:
assert not relative_mode
relative_mode = 1
relto = toc_data
elif toc == Lexer.TRANSPOSE:
transpose_pitch = toc_data
elif toc == Lexer.PARTIAL:
partial = toc_data
elif toc == Lexer.TIME:
if not cur_staff:
raise ParseError(u"\\time can not be used before \\staff", lexer)
# FIXME
# Also now, we only allow the first voice to change time signatures
if cur_staff.m_voices.index(cur_voice) != 0:
raise ParseError(u"only timesig in first voice", lexer)
# FIXME: we are stricter with time signatures that both solfege 3.16
# and LilyPond
if not cur_voice.is_bar_full():
raise ParseError(u"timesig change only when bar is full!", lexer)
if partial:
score.add_partial_bar(partial, toc_data)
partial = None
else:
score.add_bar(toc_data)
elif toc == Lexer.KEY:
p = MusicalPitch.new_from_notename(toc_data[0])
if transpose_pitch:
p.transpose_by_musicalpitch(transpose_pitch)
k = (p.get_notename(), toc_data[1])
if not cur_staff:
raise ParseError(u"\\key can not be used before \\staff", lexer)
cur_staff.set_key_signature(k, timepos)
elif toc == Lexer.TIMES:
if not times:
times = [toc_data]
else:
raise ParseError(r"\times nn/nn does not nest", lexer)
elif toc == Lexer.CLEF:
try:
cur_staff.set_clef(toc_data, timepos)
except elems.UnknownClefException, e:
e.m_lineno, e.m_linepos1, e.m_linepos2 = lexer.get_error_location()
raise
elif toc == '|':
if timepos != score.get_bar_at(last_pos).end():
logging.warning("Bar check failed at %s", timepos)
示例11: test_new_from_int
# 需要导入模块: from solfege.mpd.musicalpitch import MusicalPitch [as 别名]
# 或者: from solfege.mpd.musicalpitch.MusicalPitch import new_from_notename [as 别名]
def test_new_from_int(self):
for x in range(-12, 12):
i = Interval.new_from_int(x)
a = MusicalPitch.new_from_notename("bisis")
b = a + i
self.assertEquals(int(a) + x, int(b))
示例12: test_add
# 需要导入模块: from solfege.mpd.musicalpitch import MusicalPitch [as 别名]
# 或者: from solfege.mpd.musicalpitch.MusicalPitch import new_from_notename [as 别名]
def test_add(self):
n = MusicalPitch.new_from_notename('c')
n = n + 2
self.assertEquals(n.get_octave_notename(), 'd')
示例13: __init__
# 需要导入模块: from solfege.mpd.musicalpitch import MusicalPitch [as 别名]
# 或者: from solfege.mpd.musicalpitch.MusicalPitch import new_from_notename [as 别名]
def __init__(self, notename, duration, dots):
ItHasDuration.__init__(self, duration, dots)
self.m_pitch = MusicalPitch.new_from_notename(notename)
示例14: notename_to_ylinepos
# 需要导入模块: from solfege.mpd.musicalpitch import MusicalPitch [as 别名]
# 或者: from solfege.mpd.musicalpitch.MusicalPitch import new_from_notename [as 别名]
def notename_to_ylinepos(n):
n = MusicalPitch.new_from_notename(n)
return self.steps_to_ylinepos(n.steps())
示例15: test_addition
# 需要导入模块: from solfege.mpd.musicalpitch import MusicalPitch [as 别名]
# 或者: from solfege.mpd.musicalpitch.MusicalPitch import new_from_notename [as 别名]
def test_addition(self):
a = MusicalPitch.new_from_notename("c'")
b = Interval("m2")
self.assertEquals((a+b).get_octave_notename(), "des'")