Skip to content

Instantly share code, notes, and snippets.

@mludvig
Created March 13, 2019 02:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mludvig/b9f20fdee401b6399b17fdd3955693d4 to your computer and use it in GitHub Desktop.
Save mludvig/b9f20fdee401b6399b17fdd3955693d4 to your computer and use it in GitHub Desktop.
Simple pygame audio test
#!/usr/bin/env python3
# audio_test.py - simple pygame audio test
# Author Michael Ludvig
import pygame
# PyGame initialisation
pygame.init()
pygame.mixer.init()
# Audio file from Scratch
audio = '/usr/share/scratch/Media/Sounds/Human/Laugh-male1.wav'
# Play the audio and wait for completion
pygame.mixer.music.load(audio)
pygame.mixer.music.play()
while pygame.mixer.music.get_busy():
pygame.time.Clock().tick(10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment