Now let's develop a Python example of modifying volume of an audio file. We will write a utility that can take an input audio file and write the output file with increased or decreased level of the default volume. The utility will support writing audio files with MP3 format. If you need some other formats, you can extend this application. Refer to the Audio Converter project we did in the previous chapter.
Download the file
AudioEffects.py
from Packt website. It has the source code for this example as well as for the Fading effect.Write the constructor of the class
AudioEffects
.1 def __init__(self): 2 self.is_playing = False 3 # Flag used for printing purpose only. 4 self.error_msg = '' 5 self.fade_example = False 6 self.inFileLocation = "C:/AudioFiles/audio1.mp3" 7 self.outFileLocation = ( 8 "C:/AudioFiles/audio1_out.mp3" ) 9 10 self.constructPipeline() 11 self.connectSignals()
The flag
self.fade_example
should...