本文整理汇总了Python中note.Note.isNote方法的典型用法代码示例。如果您正苦于以下问题:Python Note.isNote方法的具体用法?Python Note.isNote怎么用?Python Note.isNote使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类note.Note
的用法示例。
在下文中一共展示了Note.isNote方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SFM
# 需要导入模块: from note import Note [as 别名]
# 或者: from note.Note import isNote [as 别名]
#.........这里部分代码省略.........
output += " "+`a`
output += " "+`self.decay`
return output
# return tuple as string from frequency of token
# and root and suffix of token
def tuple(self, freq, root, suffix):
if suffix.find(",") > -1:
thisDuration = self.duration*(1 - self.rhythm.breath)
output = self._tuple(freq, thisDuration)
output += "\n"
output += self._tuple(0, self.duration - thisDuration)
else:
output = self._tuple(freq, self.duration)
return output
def updateRhythm(self, cmd):
self.currentBeatValue, self.duration = self.rhythm.value(cmd, self)
def emitNote(self, token):
if self.crescendoBeatsRemaining > 0:
self.amplitude = self.amplitude*self.currentCrescendoSpeed
self.crescendoBeatsRemaining -= self.currentBeatValue
freq, root, suffix = self.note.freq(token, self.transpositionSemitones, self.octaveNumber)
self.output += self.tuple(freq, root, suffix) + "\n"
# summary data
self.totalDuration += self.duration
self.currentBeat += self.currentBeatValue
if self.amplitude > self.maximumAmplitude:
self.maximumAmplitude = self.amplitude
def executeCommand(self, ops):
cmd = ops[0]
# if cmd is a rhythm symbol, change value of duration register
if self.rhythm.isRhythmOp(cmd):
self.updateRhythm(cmd)
# if cmd is a tempo command, change value of the tempo register
if self.rhythm.isTempoOp(cmd):
self.tempo = self.rhythm.tempo[cmd]
self.updateRhythm(cmd)
if cmd == "tempo":
self.tempo = float(ops[1])
self.updateRhythm(cmd)
# if cmd is an articulation command, change value of the decay register
if self.rhythm.isArticulationOp(cmd):
self.decay = self.rhythm.decay[cmd]
# if cmd is a dynamics command, change value of the amplitude register
if self.dynamics.isDynamicsConstant(cmd):
self.amplitude = self.dynamics.value[cmd]
# crescendo and decrescendo
if cmd == "crescendo" or cmd == "cresc":
self.crescendoBeatsRemaining = float(ops[1])
self.currentCrescendoSpeed = self.crescendoSpeed
if cmd == "decrescendo" or cmd == "decresc":
self.crescendoBeatsRemaining = float(ops[1])
self.currentCrescendoSpeed = 1.0/self.crescendoSpeed
# pitch transposition
if cmd == "octave":
self.octaveNumber = int(ops[1])
if cmd == "transpose":
self.transpositionSemitones = int(ops[1])
# pass special commands through
if cmd[0] == '@':
CMD = catList2(ops)
CMD = CMD[:len(CMD)]+"\n"
self.output += CMD
# tuples: returns a string of tuples from input = solfa text
def tuples(self):
# split intput into list of tokens
self.input = self.input.replace("\n", " ")
tokens = self.input.split(" ")
# make sure there are not empty list elements
tokens = filter( lambda x: len(x), tokens)
# initialize output
self.output = ""
for token in tokens:
if self.note.isNote(token):
self.emitNote(token)
else:
ops = token.split(":")
ops = filter(lambda x: len(x) > 0, ops)
if DEBUG == ON:
self.output += "cmd: "+ `ops`+"\n"
self.executeCommand(ops)
return self.output