Documentation On Pyqt Phonon Backend Audio Effect 'speed'
Solution 1:
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.
The way this works is that you can see names and descriptions of your Phonon.Effect() options by calling the function
fromPyQt4importQtGui, QtCorefromPyQt4.phononimportPhonon
list_of_backend_audio_effects = Phonon.BackendCapabilities.availableAudioEffects()
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]
foriterinrange(len(list_of_effect_names)):
if list_of_effect_names[iter] == 'speed':
effect_index = iterbreak
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)))
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.
I hope this helps some Python folks with gstreamer change speeds of audio.
Post a Comment for "Documentation On Pyqt Phonon Backend Audio Effect 'speed'"