有关PyQt Phonon后端音频效果“速度"的文档 [英] Documentation on PyQt Phonon backend audio effect 'speed'

查看:81
本文介绍了有关PyQt Phonon后端音频效果“速度"的文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我看函数的输出时

Phonon.BackendCapabilities.availableAudioEffects()

我将其作为选项之一:

>>> speed_effect = Phonon.BackendCapabilities.availableAudioEffects()[3]
>>> speed_effect.name()
PyQt4.QtCore.QString(u'speed')
>>> speed_effect.__doc__
'Phonon.EffectDescription()\nPhonon.EffectDescription(int, dict-of-QByteArray-QVariant)\nPhonon.EffectDescription(Phonon.EffectDescription)'

我知道我需要将此效果插入连接到音频源文件的路径中,并且实现起来并不困难.我不了解的是如何访问选项或这种速度"效果的功能是什么.如何通过Python界面访问它?是否可以指定回放速率(例如2倍,4倍等,以便将速度提高一倍或四倍)?

I understand that I need to insert this effect into a path connecting to my audio source file, and that implementation won't be difficult. What I don't understand is how to access options or what the functionality of this 'speed' effect is. How do I access it through the Python interface? Can I specify a playback rate (like 2x, 4x, etc., for doubling or quadrupling the speed) as an option to this?

推荐答案

嗯,没有太多的人在看这个,所以我一直走下去,终于弄明白了.请注意,所有这些都是特定于我的特定于Phonon的后端媒体播放器gstreamer.如果您拥有不同的后端,则需要进行一些修补,以查看需要使用哪些效果.

Well, not too many people were looking at this so I kept going and finally figured it out. Note that all of this is specific to my particular backend media player, gstreamer, for Phonon. If you have a different backend, you'll need to do some tinkering to see what effects you need to play around with.

此方法的工作方式是,您可以通过调用函数查看Phonon.Effect()选项的名称和说明

The way this works is that you can see names and descriptions of your Phonon.Effect() options by calling the function

 from PyQt4 import QtGui, QtCore
 from PyQt4.phonon import Phonon
 list_of_backend_audio_effects = Phonon.BackendCapabilities.availableAudioEffects()

此后,我通过执行以下操作找出了gstreamer选项'speed'可用的效果:

After this, I figured out which of the available effects was the gstreamer option 'speed', by doing this:

 list_of_effect_names = [str(elem.name()) for elem in list_of_backend_audio_effects]
 for iter in range(len(list_of_effect_names)):
     if list_of_effect_names[iter] == 'speed':
         effect_index = iter
         break

最后,您需要实际编辑参数,这必须通过称为QVariant的数据类型来完成.为了使音频速度加倍,这就是我所说的:

Finally, you need to actually edit the parameters, which has to be done by going through a data type called a QVariant. To double the speed of the audio, here's what I called:

 speed_effect = Phonon.Effect(list_of_backend_audio_effects[effect_index])
 speed_effect.setParameterValue(speed_effect.parameters()[0],QtCore.QVariant(str(2)))

在第一行中,我创建一个新的Phonon.Effect(),它将效果描述作为输入(调用可用的AudioEffects()返回的内容).然后,我将此效果对象的参数(第一个参数)设置为QVariant值'2'(第二个参数).在我的系统上,默认速度为"1",最小值为"0.1",最大值为"40",代表的速度范围是常规音频文件编码速度的十分之一到40倍.

In the first line, I create a new Phonon.Effect() which takes the effect description as an input (the things returned by the call the availableAudioEffects()). Then I set the parameter of this effect object (the first argument) to take the QVariant value '2' (the second argument). On my system, the default speed is '1', the min is '0.1' and the max is '40', which represents ranges of speeds between one-tenth and 40 times as fast as the regular audio file encodes.

我希望这可以帮助一些使用gstreamer的Python人士改变音频速度.

I hope this helps some Python folks with gstreamer change speeds of audio.

这篇关于有关PyQt Phonon后端音频效果“速度"的文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆