本文整理汇总了Python中pydub.utils.ratio_to_db函数的典型用法代码示例。如果您正苦于以下问题:Python ratio_to_db函数的具体用法?Python ratio_to_db怎么用?Python ratio_to_db使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ratio_to_db函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_fades
def test_fades(self):
seg = self.seg1[:10000]
# 1 ms difference in the position of the end of the fade out
inf_end = seg.fade(start=0, end=float('inf'), to_gain=-120)
negative_end = seg.fade(start=0, end=-1, to_gain=-120)
self.assertWithinTolerance(inf_end.rms, negative_end.rms, percentage=0.001)
self.assertTrue(negative_end.rms < inf_end.rms)
self.assertTrue(inf_end.rms < seg.rms)
self.assertEqual(len(inf_end), len(seg))
self.assertTrue(-3 < ratio_to_db(inf_end.rms, seg.rms) < -2)
# use a slice out of the middle to make sure there is audio
seg = self.seg2[20000:30000]
fade_out = seg.fade_out(5000)
fade_in = seg.fade_in(5000)
self.assertTrue(0 < fade_out.rms < seg.rms)
self.assertTrue(0 < fade_in.rms < seg.rms)
self.assertEqual(len(fade_out), len(seg))
self.assertEqual(len(fade_in), len(seg))
db_at_beginning = ratio_to_db(fade_in[:1000].rms, seg[:1000].rms)
db_at_end = ratio_to_db(fade_in[-1000:].rms, seg[-1000:].rms)
self.assertTrue(db_at_beginning < db_at_end)
db_at_beginning = ratio_to_db(fade_out[:1000].rms, seg[:1000].rms)
db_at_end = ratio_to_db(fade_out[-1000:].rms, seg[-1000:].rms)
self.assertTrue(db_at_end < db_at_beginning)
开发者ID:handloomweaver,项目名称:pydub,代码行数:31,代码来源:test.py
示例2: test_db_float_conversions
def test_db_float_conversions(self):
self.assertEqual(db_to_float(10), 10)
self.assertEqual(db_to_float(0), 1)
self.assertEqual(ratio_to_db(1), 0)
self.assertEqual(ratio_to_db(10), 10)
self.assertEqual(3, db_to_float(ratio_to_db(3)))
self.assertEqual(12, ratio_to_db(db_to_float(12)))
开发者ID:handloomweaver,项目名称:pydub,代码行数:7,代码来源:test.py
示例3: test_volume_with_add_sub
def test_volume_with_add_sub(self):
quieter = self.seg1 - 6
self.assertAlmostEqual(ratio_to_db(quieter.rms, self.seg1.rms),
-6,
places=2)
louder = quieter + 2.5
self.assertAlmostEqual(ratio_to_db(louder.rms, quieter.rms),
2.5,
places=2)
开发者ID:jiaaro,项目名称:pydub,代码行数:10,代码来源:test.py
示例4: normalize
def normalize(self, headroom=0.1):
"""
headroom is how close to the maximum volume to boost the signal up to (specified in dB)
"""
peak_sample_val = self.max
target_peak = self.max_possible_amplitude * db_to_float(-headroom)
needed_boost = ratio_to_db(target_peak / peak_sample_val)
return self.apply_gain(needed_boost)
开发者ID:ptpittman,项目名称:pydub,代码行数:9,代码来源:audio_segment.py
示例5: normalize
def normalize(seg, headroom=0.1):
peak_sample_val = seg.max
if peak_sample_val == 0:
return seg
target_peak = seg.max_possible_amplitude * db_to_float(-headroom)
needed_boost = ratio_to_db(target_peak / peak_sample_val)
return seg.apply_gain(needed_boost)
开发者ID:qwertypoiuyt1209,项目名称:Semantici_Sirius_5,代码行数:10,代码来源:audio.py
示例6: test_db_float_conversions
def test_db_float_conversions(self):
self.assertEqual(db_to_float(20), 10)
self.assertEqual(db_to_float(10, using_amplitude=False), 10)
self.assertEqual(db_to_float(0), 1)
self.assertEqual(ratio_to_db(1), 0)
self.assertEqual(ratio_to_db(10), 20)
self.assertEqual(ratio_to_db(10, using_amplitude=False), 10)
self.assertEqual(3, db_to_float(ratio_to_db(3)))
self.assertEqual(12, ratio_to_db(db_to_float(12)))
self.assertEqual(3, db_to_float(ratio_to_db(3, using_amplitude=False), using_amplitude=False))
self.assertEqual(12, ratio_to_db(db_to_float(12, using_amplitude=False), using_amplitude=False))
开发者ID:jiaaro,项目名称:pydub,代码行数:11,代码来源:test.py
注:本文中的pydub.utils.ratio_to_db函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论