Create your own Sound Effects in Python

zapThe purpose of this challenge is to create your own collection of sound effects to be used a library of assets for your own retro arcade games.

We will use Python code online to create the sound file using EarSketch.

EarSketch?


A Digital Audio Workstation (DAW), is the main tool for producing music on a computer. A DAW is specialised computer software for recording, editing, and playing digital audio files. EarSketch is a DAW which let you place audio clips and effects into a DAW timeline using either Python code or JavaScript code.

Check the following sound effects that we have created using EarSketch. You can re-use and adapt the code for your own video game projects.

Cannon EffectRefill EffectAlternative Cannon Effect
#Cannon Effect by 101Computing.net
from earsketch import *

init()
setTempo(120)
clip = DUBSTEP_BASS_WOBBLE_018
clip = EIGHT_BIT_ATARI_SFX_001

# 0 starts playing a clip, - is a rest/silence, + extends the audio clip into the next sixteenth note sub-beat
beat = "-0+0+-0+0+-0+0+--000000+-000000+"

makeBeat(clip, 1, 1, beat)

finish()
Open sound effect using EarSketch
#Refill/Reload Effect by 101Computing.net
from earsketch import *
init()
setTempo(120)

clip = EIGHT_BIT_ATARI_LEAD_007
beat = "00000000000000000000000000000000"
makeBeat(clip, 1, 1, beat)
setEffect(1, PITCHSHIFT, PITCHSHIFT_SHIFT, 0, 1, 12, 3)

# Finish
finish()
Open sound effect using EarSketch
#Cannon Effect by 101Computing.net
from earsketch import *

init()
setTempo(120)
clip = DUBSTEP_BASS_WOBBLE_018

# 0 starts playing a clip, - is a rest/silence, + extends the audio clip into the next sixteenth note sub-beat
beat = "-00+-00+-00+-00+"
makeBeat(clip, 1, 1, beat)

finish()
Open sound effect using EarSketch

Using Sound Effects with PyGame


To add sound effects, download some wav or mp3 files into a folder called “Sounds” and add the following code when you want to play the sound effect:

effect = pygame.mixer.Sound('Sounds/cannon_effect.mp3')
effect.play()

Did you like this challenge?

Click on a star to rate it!

Average rating 5 / 5. Vote count: 7

No votes so far! Be the first to rate this post.

As you found this challenge interesting...

Follow us on social media!