Playing multiple sounds at once

From ESE205 Wiki
Revision as of 14:18, 25 April 2019 by Jennifer.fleites (talk | contribs) (Pydub and Pygame)
Jump to: navigation, search


This tutorial will explain different methods attempted in getting multiple sounds to play concurrently, as well as the method that was most valuable.


  • Pick wav files desired to be played.
  • Load wav files in code and save it to a variable that can be called later.
  • Find a line of code that will play the sound.
  • Find a line of code that will allow the sound to be played while different notes are being played at the same time.

Libraries tested

  • pydub
  • multiprocessing
  • multithreading
  • swmixer
  • pygame

Pydub and Pygame

These two libraries were used in finding the best way to play a sound by itself.

Using pydub:

from pydub import AudioSegment
from pydub.playback import play
sound = AudioSegment.from_wav('/home/pi/laserharp-sounds/samples/harpSound1.wav')

Using pygame:

import pygame
firstSound = pygame.mixer.Sound('/home/pi/laserharp-sounds/samples/ambi_dark.wav')
secondSound = pygame.mixer.Sound('/home/pi/laserharp-sounds/samples/ambi_choir.wav')
import pygame
firstSound ='/home/pi/laserharp-sounds/samples/ambi_dark.wav')
secondSound ='/home/pi/laserharp-sounds/samples/ambi_choir.wav')

Multiprocessing and Multithreading

Multithreading with Swmixer

Pygame with Channels

Link to project

Laser Harp