本文整理汇总了Python中note.Note.freq方法的典型用法代码示例。如果您正苦于以下问题:Python Note.freq方法的具体用法?Python Note.freq怎么用?Python Note.freq使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类note.Note
的用法示例。
在下文中一共展示了Note.freq方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SFM
# 需要导入模块: from note import Note [as 别名]
# 或者: from note.Note import freq [as 别名]
class SFM(object):
# pitch registers
transpositionSemitones = 0
octaveNumber = 3
# tempo registers
tempo = 60
currentBeatValue = 60.0/tempo
currentBeat = 0
totalDuration = 0.0
# dynamics registers
crescendoSpeed = 1.1
currentCrescendoSpeed = crescendoSpeed
crescendoBeatsRemaining = 0.0
maximumAmplitude = 0.0
# tuple registers
duration = 60.0/tempo
amplitude = 1.0
decay = 1.0
# I/O
input = ""
#########################################################
# initialize Note, Rhythm, and Dynamics objects
def __init__(self, SCALE):
NOTES, FREQ_DICT = SCALE
self.note = Note(NOTES, FREQ_DICT)
self.rhythm = Rhythm()
self.dynamics = Dynamics()
self.equalizerFactor = { }
self.equalizerFactor[-0.1] = 1.0
self.equalizerFactor[220] = 1.0
self.equalizerFactor[440] = 0.7
self.equalizerFactor[880] = 0.35
self.equalizerFactor[1760] = 0.15
self.equalizerFactor[3520] = 0.15
self.equalizerFactor[7040] = 0.15
self.equalizerFactor[14080] = 0.15
self.equalizerFactor[28160] = 0.15
self.equalizerFactor[56320] = 0.15
self.equalizerBreakPoints = [-0.1, 220, 440, 880, 1760, 3520, 7040, 14080, 28160, 56320]
# self.tempo = 60
# self.currentBeatValue = 60.0/self.tempo
# self.octaveNumber = 3
def equalize(self, freq):
a, b = interval(freq, self.equalizerBreakPoints)
f = mapInterval(freq, a,b, self.equalizerFactor[a], self.equalizerFactor[b])
# print freq, a, b, f
return f
# return tuple as string given frequency,
# duration, decay, and amplitude
def _tuple(self, freq, duration):
output = `freq`
output += " "+`duration`
a = self.amplitude
a = a*self.equalize(freq)
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]
#.........这里部分代码省略.........