Custom Scale 使用music21的scale class继承"deriveAll"函数
Custom Scale using music21's scale class to inherit "deriveAll" function
我想知道定义自定义比例的正确方法是什么来继承 'scale' class 的属性?
我是否应该将 class 包含在“music21/scale/init.py'”中?
class myAbastract(AbstractScale):
'''
A pseudo my-scale.
'''
def __init__(self):
super().__init__()
self.type = 'Abstract My Name'
self.octaveDuplicating = True
self.dominantDegree: int = -1
self.buildNetwork()
当我在 main.py 中定义 myScale 时,它似乎没有继承“deriveAll()”method/function。
pitchListStrs = 'a b` c d e f g a'.split()
pitchList = [pitch.Pitch(p) for p in pitchListStrs]
myScaleA = scale.ConcreteScale(pitches=pitchList)
[str(p) for p in myScaleA.getPitches('E-5', 'G-7')]
myScale = myScaleA.abstract
mySol =scale.ConcreteScale()
mySol.tonic = pitch.Pitch('D')
但是,deriveAll 没有定义:
myScale.deriveAll(['E5', 'F5', 'G5', 'A5', 'B`5', 'C6', 'D6', 'E6'])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'AbstractScale' object has no attribute 'deriveAll'
如有任何帮助,我们将不胜感激。
deriveAll
是在 ConcreteScale
个实例上定义的例程。您试图在 AbstractScale
的实例上调用它。尝试在具体的变量 myScaleA
上调用它。
我想知道定义自定义比例的正确方法是什么来继承 'scale' class 的属性?
我是否应该将 class 包含在“music21/scale/init.py'”中?
class myAbastract(AbstractScale):
'''
A pseudo my-scale.
'''
def __init__(self):
super().__init__()
self.type = 'Abstract My Name'
self.octaveDuplicating = True
self.dominantDegree: int = -1
self.buildNetwork()
当我在 main.py 中定义 myScale 时,它似乎没有继承“deriveAll()”method/function。
pitchListStrs = 'a b` c d e f g a'.split()
pitchList = [pitch.Pitch(p) for p in pitchListStrs]
myScaleA = scale.ConcreteScale(pitches=pitchList)
[str(p) for p in myScaleA.getPitches('E-5', 'G-7')]
myScale = myScaleA.abstract
mySol =scale.ConcreteScale()
mySol.tonic = pitch.Pitch('D')
但是,deriveAll 没有定义:
myScale.deriveAll(['E5', 'F5', 'G5', 'A5', 'B`5', 'C6', 'D6', 'E6'])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'AbstractScale' object has no attribute 'deriveAll'
如有任何帮助,我们将不胜感激。
deriveAll
是在 ConcreteScale
个实例上定义的例程。您试图在 AbstractScale
的实例上调用它。尝试在具体的变量 myScaleA
上调用它。