本文整理汇总了Python中Math.power_to_magnitude方法的典型用法代码示例。如果您正苦于以下问题:Python Math.power_to_magnitude方法的具体用法?Python Math.power_to_magnitude怎么用?Python Math.power_to_magnitude使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Math
的用法示例。
在下文中一共展示了Math.power_to_magnitude方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: analyze_semitone
# 需要导入模块: import Math [as 别名]
# 或者: from Math import power_to_magnitude [as 别名]
def analyze_semitone(self, control, semitone):
if not self.project:
return
if not control.has_data:
return
text = ""
for overtone, frequency, power, peak_center, difference_in_semitones in control.analyze_overtones(semitone, 10):
s = Math.frequency_to_semitone(frequency)
position = control.start + control.duration / 2.0
lower = Math.semitone_to_frequency(s - 0.5)
upper = Math.semitone_to_frequency(s + 0.5)
onset_min, onset_max = self.project.appsinkpipeline.find_onset(lower, upper, position, limit=5)
text += "%d. overtone: %f Hz (semitone %f; near %s)\n" % (overtone, frequency, s, Math.note_name(s))
text += "\tPower: %f (%f dB)\n" % (power, Math.power_to_magnitude(power))
text += "\tPosition: %f Hz (off by %f semitones)\n" % (peak_center, difference_in_semitones)
text += "\tOnset: between %fs and %fs\n" % (onset_min, onset_max)
text += "\n"
w = gtk.Window()
w.set_size_request(500, 400)
w.set_title("Info on %s (%f)" % (Math.note_name(semitone), semitone))
sw = gtk.ScrolledWindow()
w.add(sw)
tv = gtk.TextView()
tv.get_buffer().set_text(text)
tv.set_editable(False)
sw.add(tv)
w.show_all()
示例2: do_simple_paint
# 需要导入模块: import Math [as 别名]
# 或者: from Math import power_to_magnitude [as 别名]
def do_simple_paint(self, cr, bounds):
cr.translate(self.x, self.y)
cr.rectangle(0.0, 0.0, self.width, self.height)
if not self.control.has_data:
cr.set_source_rgb(1.,1.,1.)
elif self.method=="cumulate":
fpower, power, center, standard_deviation, upper_dependence, lower_dependence = self.control.analyze_semitone(self.semitone)
magnitude = Math.power_to_magnitude(power / 1.5 / 1000)
const,slope = self.control.get_brightness_coefficients_for_magnitude()
brightness = slope*magnitude + const
print self.semitone,"mag",magnitude,"tpow",power,"b",brightness,"pow",fpower
cr.set_source_rgb(brightness,brightness,brightness)
elif self.method=="test":
fpower, power, center, standard_deviation, upper_dependence, lower_dependence = self.control.analyze_semitone(self.semitone)
upper_dependence = min(1.,upper_dependence)
lower_dependence = min(1.,lower_dependence)
total_dependence = min(1., upper_dependence+lower_dependence)
power *= 1. - total_dependence
magnitude = Math.power_to_magnitude(power / 1.5 / 1000)
const,slope = self.control.get_brightness_coefficients_for_magnitude()
brightness = slope*magnitude + const
cr.set_source_rgb(brightness,brightness,brightness)
elif self.method=="inharmonicity":
fpower, power, center, standard_deviation, upper_dependence, lower_dependence = self.control.analyze_semitone(self.semitone)
brightness = standard_deviation / 0.5
cr.set_source_rgb(brightness,brightness,brightness)
elif self.method=="lower_dependence":
fpower, power, center, standard_deviation, upper_dependence, lower_dependence = self.control.analyze_semitone(self.semitone)
brightness = lower_dependence
cr.set_source_rgb(brightness,brightness,brightness)
elif self.method=="upper_dependence":
fpower, power, center, standard_deviation, upper_dependence, lower_dependence = self.control.analyze_semitone(self.semitone)
brightness = upper_dependence
cr.set_source_rgb(brightness,brightness,brightness)
elif self.method=="gradient":
assert not self.matrix==None
gradient = self.control.get_gradient()
gradient.set_matrix(self.matrix)
cr.set_source(gradient)
else:
raise ValueError, "Invalid method"
cr.fill_preserve()
cr.set_source_rgb(0.,0.,0.)
cr.stroke()
示例3: get_magnitude
# 需要导入模块: import Math [as 别名]
# 或者: from Math import power_to_magnitude [as 别名]
def get_magnitude(self):
if self.magnitude==None: self.magnitude = Math.power_to_magnitude(self.power)
return self.magnitude