当前位置: 首页>>代码示例>>Python>>正文


Python Note.step方法代码示例

本文整理汇总了Python中note.Note.step方法的典型用法代码示例。如果您正苦于以下问题:Python Note.step方法的具体用法?Python Note.step怎么用?Python Note.step使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在note.Note的用法示例。


在下文中一共展示了Note.step方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test

# 需要导入模块: from note import Note [as 别名]
# 或者: from note.Note import step [as 别名]
def test():
    n1 = Note()
    
    CMajor = ConcreteMajorScale(n1)
    
    assert CMajor.name == "C major"
    assert CMajor.scaleList[6].step == "B"
    
    CScale = CMajor.getConcreteMajorScale()
    
    assert CScale[7].step == "C"
    assert CScale[7].octave == 5
    
    CScale2 = CMajor.getAbstractMajorScale()
    
    for note1 in CScale2:
        assert note1.octave == 0
        assert note1.duration.type == ""
    assert [note1.name for note1 in CScale] == ["C", "D", "E", "F", "G", "A", "B", "C"]
    
    seventh = CMajor.getScaleDegree(7)
    assert seventh.step == "B"
    
    dom = CMajor.getDominant()
    assert dom.step == "G"
    
    n2 = Note()
    n2.step = "A"
    
    aMinor = CMajor.getRelativeMinor()
    assert aMinor.name == "A minor", "Got a different name: " + aMinor.name
    
    notes = [note1.name for note1 in aMinor.scaleList]
    assert notes == ["A", "B", "C", "D", "E", "F", "G"]
    
    n3 = Note()
    n3.name = "B-"
    n3.octave = 5
    
    bFlatMinor = ConcreteMinorScale(n3)
    assert bFlatMinor.name == "B- minor", "Got a different name: " + bFlatMinor.name
    notes2 = [note1.name for note1 in bFlatMinor.scaleList]
    assert notes2 == ["B-", "C", "D-", "E-", "F", "G-", "A-"]
    assert bFlatMinor.scaleList[0] == n3
    assert bFlatMinor.scaleList[6].octave == 6
    
    harmonic = bFlatMinor.getConcreteHarmonicMinorScale()
    niceHarmonic = [note1.name for note1 in harmonic]
    assert niceHarmonic == ["B-", "C", "D-", "E-", "F", "G-", "A", "B-"]
    
    harmonic2 = bFlatMinor.getAbstractHarmonicMinorScale()
    assert [note1.name for note1 in harmonic2] == niceHarmonic
    for note1 in harmonic2:
        assert note1.octave == 0
        assert note1.duration.type == ""
    
    melodic = bFlatMinor.getConcreteMelodicMinorScale()
    niceMelodic = [note1.name for note1 in melodic]
    assert niceMelodic == ["B-", "C", "D-", "E-", "F", "G", "A", "B-", "A-", "G-", \
                           "F", "E-", "D-", "C", "B-"]
    
    melodic2 = bFlatMinor.getAbstractMelodicMinorScale()
    assert [note1.name for note1 in melodic2] == niceMelodic
    for note1 in melodic2:
        assert note1.octave == 0
        assert note1.duration.type == ""
    
    cNote = bFlatMinor.getScaleDegree(2)
    assert cNote.name == "C"
    fNote = bFlatMinor.getDominant()
    assert fNote.name == "F"
    
    bFlatMajor = bFlatMinor.getParallelMajor()
    assert bFlatMajor.name == "B- major"
    scale = [note1.name for note1 in bFlatMajor.getConcreteMajorScale()]
    assert scale == ["B-", "C", "D", "E-", "F", "G", "A", "B-"]
    
    dFlatMajor = bFlatMinor.getRelativeMajor()
    assert dFlatMajor.name == "D- major"
    assert dFlatMajor.getTonic().name == "D-"
    assert dFlatMajor.getDominant().name == "A-"
开发者ID:bewest,项目名称:music21-bewest.clone,代码行数:83,代码来源:scale_test.py


注:本文中的note.Note.step方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。