‘Dance a merry dance, my dear boy!’ the judge said, whilst pouring me a generous brandy. ‘And if the gods should laugh, be sure to press record on your tape recorder.’
He was drunk.
‘I can make a movie of the gods,’ I retorted, ‘with my movie studio.’
‘Prey,’ he replied, his boozy red cheeks filling my eyes, ‘Prey, tell me more.’
Here’s the killer robot being tracked with a cross hair:
But what good is a cross hair without the sound of bullets? Let’s add some audio to the movie!
PyMovieStudio uses Pygame to play audio:
from pygame import mixer
Once the mixer is imported, we can initialize it:
And playing a sound is simple. I use a couple of parameters to specify the path and name of the wav file I want to play:
Now that’s all fine and dandy, but how do we determine when in the movie the bullet sounds should play?
I import a Python random package:
from random import randint
And whenever the random number matches zero I play the bullet sound:
if randint(0, self.config_provider.audio_sound_delay) == 0:
If I set the audio_sound_delay configuration setting to 10 then the bullet sound will have a 1 in 10 chance of playing. If I want the bullet sound to play less often in my movie I simply change the setting to a higher number!
All that’s left to do is to save to a log the points in our movie that the bullet sound played, so that we can replay the exact same audio again and again:
19,gunshot.wav 25,gunshot.wav 37,gunshot.wav 44,gunshot.wav 60,gunshot.wav 93,gunshot.wav 97,gunshot.wav 100,gunshot.wav 111,gunshot.wav 125,gunshot.wav 128,gunshot.wav 147,gunshot.wav 151,gunshot.wav 166,gunshot.wav 181,gunshot.wav
As you can see, on frame number 19 of the movie the gunshot.wav sound file will be played. It is played again on frame 25 of the movie. And so on.
Indeed, we can manually edit this audio log file, to add different sound files on different frames, such as dialog between actors.
Here’s my PyMovieStudio video, with audio added:
I got the bullet sound from Bird Man on Freesound. Thanks Bird Man, may your plumage stay the perfect oily sheen.
So that’s that, why not check out the PyMovieStudio Wiki and start making your very own movies.
But for me, I must bundle this steaming judge into a taxi. Take him to Cumbernauld Shopping Centre I shout to the cabbie over the churning of the engine. Let him see how the cider men live, in amongst the rust and pipes.