Pythonist 3 app for iPad
Sound Code for Pythonista
sound — Play simple sounds
The sound module contains functions for playing simple sound effects on iOS.
The following sound effects are bundled with Editorial, and can be used directly with play_effect() (without specifying a file extension). When viewing the documentation inside Editorial, you can tap on one of the names to play a preview:
sound.load_effect(name)
Preload the sound effect with the given name to reduce latency when using play_effect().
sound.play_effect(name[, volume, pitch])
Play the sound effect with the given name.
Playback is asynchronous, i.e. the function returns before the sound has finished playing. The return value is an opaque identifier that can be used with the stop_effect() function. The volume and pitch arguments are optional, by default, the effect is played with the global volume, as set by set_volume().
sound.stop_effect(effect_id)
Stops playback of a sound effect. The effect_id is the return value of play_effect().
sound.set_volume(vol)
Sets the default volume for all sound effects (between 0.0 and 1.0, the default is 0.5).
sound — Play simple sounds
The sound module contains functions for playing simple sound effects on iOS.
The following sound effects are bundled with Editorial, and can be used directly with play_effect() (without specifying a file extension). When viewing the documentation inside Editorial, you can tap on one of the names to play a preview:
- Beep
- Bleep
- Boing_1
- Clank
- Click_1
- Click_2
- Clock_1
- Coin_1
- Coin_2
- Crashing
- Ding_1
- Ding_2
- Ding_3
- Error
- Explosion_1
- Footstep
- Jump
- Shot
- Spaceship
- Woosh_1
- Woosh_2
sound.load_effect(name)
Preload the sound effect with the given name to reduce latency when using play_effect().
sound.play_effect(name[, volume, pitch])
Play the sound effect with the given name.
Playback is asynchronous, i.e. the function returns before the sound has finished playing. The return value is an opaque identifier that can be used with the stop_effect() function. The volume and pitch arguments are optional, by default, the effect is played with the global volume, as set by set_volume().
sound.stop_effect(effect_id)
Stops playback of a sound effect. The effect_id is the return value of play_effect().
sound.set_volume(vol)
Sets the default volume for all sound effects (between 0.0 and 1.0, the default is 0.5).