Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
160b981
init of two_circle
Aug 21, 2023
9de630b
Added new code for a two pixel circle display, to a new branch
Aug 22, 2023
11858d2
Added the run demo folder and file,
Aug 22, 2023
9b808ea
Decided to split movement into separate functions. made a new branch
Aug 25, 2023
ec9f096
made changes to left and right movement, now it will continue to go w…
Aug 25, 2023
31b2cc0
Adds the updated working movement, and the colision with the bullit, …
Aug 29, 2023
9e02ea0
Adding sound files
schielb Aug 31, 2023
2b21905
Update tetris/main.py
schielb Aug 31, 2023
b3fe683
Trying to fit formatting requirements better
schielb Aug 31, 2023
79f1b4a
Adding a ton of sound files
schielb Aug 31, 2023
fa40734
Adding pygame-mixer sound broadcaster
schielb Aug 31, 2023
8c0cfaf
Adding parser file for sounds library
schielb Aug 31, 2023
63b1667
Some sounds don't work, removing them
schielb Aug 31, 2023
cad62e7
Fixing my formatting you-
schielb Aug 31, 2023
bef197d
Fixing formatting
schielb Sep 1, 2023
741126b
Fixing slight sound delay
schielb Sep 1, 2023
b888cad
Hangman sounds
schielb Sep 1, 2023
1731ae8
Snake sounds
schielb Sep 1, 2023
3409faf
Adding a ton of new sounds
schielb Sep 1, 2023
2504f71
Adding welcome_y
schielb Sep 1, 2023
bd7a484
Merge pull request #47 from NET-BYU/dev
schielb Sep 1, 2023
1fc376c
Fixing and adding some things
schielb Sep 1, 2023
0ac4d90
Formatting welcome_y
schielb Sep 1, 2023
de9d614
Formatting welcome_y
schielb Sep 1, 2023
2d8f115
Finished the first iteration of the game
Sep 1, 2023
aa372a4
creating a place for bryson to work his magic
Virginia2244 Sep 1, 2023
324bdc7
Merge pull request #48 from NET-BYU/sully_groan
schielb Sep 1, 2023
074749f
Adding sully sound
schielb Sep 1, 2023
b2759c7
Fixed formating
Sep 1, 2023
2420a71
Merge pull request #49 from NET-BYU/run
emilyk19 Sep 1, 2023
e4cce9c
Tetris clear row sound
schielb Sep 1, 2023
a6f26e7
Merge branch 'sound' of github.com:NET-BYU/sss into sound
schielb Sep 1, 2023
6aaba62
added sounds to movement
Sep 1, 2023
758a501
Merge branch 'sound' of https://github.com/NET-BYU/sss into sound
Sep 1, 2023
b4cd450
Adding Nyan Cat sound
schielb Sep 1, 2023
4e31758
Formatting video sound
schielb Sep 1, 2023
f09ba44
Fixing sounds
schielb Sep 1, 2023
4d87514
Quic under_construction
schielb Sep 1, 2023
e67c73a
Merge branch 'dev' of github.com:NET-BYU/sss into sound
byu-netlab Sep 1, 2023
9428a68
Merge branch 'sound' of github.com:NET-BYU/sss into sound
byu-netlab Sep 1, 2023
9fef8cc
Adding a few sounds
schielb Apr 12, 2024
8430efe
Merge branch 'sound' of github.com:NET-BYU/sss into sound
schielb Apr 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions broadcasters/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,32 @@ def start_outputs(system_queue, demo_output_queue):
logger.warning("Unable to import modules necessary to run MQTT output.")
logger.warning("Program will continue to run without this output.")

try:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be done in a later branch, but we need to meticulously check and make sure the exceptions to this block will prevent the sss from crashing (i.e.. include all possible exceptions)

logger.info("Loading pygame.mixer output...")
from . import pygame_mixer_bc

pygame_mixer_q = Queue()

pygame_mixer_runner = None
if pygame_mixer_bc.check_if_available():
pygame_mixer_runner = pygame_mixer_bc.start_processing_output(
system_queue, pygame_mixer_q
)
logger.info("...done")
except (ImportError, ModuleNotFoundError) as e:
pygame_mixer_runner = None
logger.warning(e)
logger.warning("Unable to import modules necessary to run keyboard input.")
logger.warning("Program will continue to run without this input.")

while True:
for payload in utils.get_all_from_queue(demo_output_queue):
if mqtt_runner:
mqtt_q.put(payload)
next(mqtt_runner)

if pygame_mixer_runner:
pygame_mixer_q.put(payload)
next(pygame_mixer_runner)

yield
45 changes: 45 additions & 0 deletions broadcasters/pygame_mixer_bc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
from loguru import logger
from pygame import mixer

from . import utils


def check_if_available():
try:
mixer.init()
return True
except:
return False


def start_processing_output(system_queue, pygame_mixer_q):
"""Called by the broadcaster module to initialize a connection to a loudspeaker local to the system."""

def process():
# Go through and see what sounds we need to add
while True:
try:
for item in utils.get_all_from_queue(pygame_mixer_q):
logger.debug("pygame_mixer: {}", item)
if str(item).startswith("SOUND "):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sentinel value should be re-evaluated and a better protocol should be devised to ignore unwanted communication

new_sound = str(item)[6:]

short_Sound = mixer.Sound(new_sound)
short_Sound.play()

# if new_sound != current_sound:
# current_sound = new_sound
# mixer.Sound.load(new_sound)
# mixer.Sound.play()
elif str(item).startswith("BACKGROUND SOUND "):
new_sound = str(item)[17:]
mixer.music.load(new_sound)
mixer.music.play(-1)
elif str(item).startswith("STOP SOUND"):
mixer.music.stop()
except:
logger.warning("Unable to play sound file: {}".format(new_sound))

yield

return process()
12 changes: 12 additions & 0 deletions demos/breakout/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from random import getrandbits

from demos.utils import get_all_from_queue
from sss_sounds import sss_sounds

ARENA_START = 14
ARENA_END = ARENA_START - 15
Expand Down Expand Up @@ -73,6 +74,7 @@ def run(self):
while True:
try:
if self.input_queue.get(block=False) == "START_P":
self.output_queue.put("SOUND " + sss_sounds.BEEP_06_GOOD)
break
except queue.Empty:
pass
Expand Down Expand Up @@ -143,6 +145,8 @@ def run(self):
score += SCORE_INC
self.output_queue.put("SCORE " + str(score))

self.output_queue.put("SOUND " + sss_sounds.TICK)

self.bricks[row].remove(self.ball[0])
screen.draw_pixel(self.ball[0], row, PIXEL_OFF)
if not self.ball[0] % 2:
Expand All @@ -161,6 +165,8 @@ def run(self):
self.output_queue.put("LIVES " + str(lives))
self.init_screen(screen)

self.output_queue.put("SOUND " + sss_sounds.LEVEL_UP)

screen.draw_pixel(self.ball[0], self.ball[1], PIXEL_OFF)

# Bounds check for ball
Expand All @@ -178,6 +184,8 @@ def run(self):
self.frame_rate = 20 + (spin // (1 + spin // 2))
is_down = False

self.output_queue.put("SOUND " + sss_sounds.BEEP_15)

# Checks to see if ball falls out of screen
if self.ball[1] >= screen.y_height - 1:
is_down = True
Expand All @@ -191,9 +199,13 @@ def run(self):
)
if lives == 0:
self.gameover = True

self.output_queue.put("SOUND " + sss_sounds.END_FAIL_7)
break
self.ball = [screen.x_width // 2, screen.y_height // 2]

self.output_queue.put("SOUND " + sss_sounds.END_FAIL_6)

# Calculates ball path
is_left, is_down = self.ball_travel(is_left, is_down, spin, screen)

Expand Down
18 changes: 18 additions & 0 deletions demos/hangman/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from demos.hangman.guess import Guess
from demos.hangman.trace import Trace
from demos.utils import get_all_from_queue
from sss_sounds import sss_sounds


class Hangman:
Expand Down Expand Up @@ -53,6 +54,8 @@ def run(self):

# Create generator here
while True:
self.output_queue.put("SOUND " + sss_sounds.BEEP_01)

trace.draw_init()
trace.draw_choice(guess.letter_select(choice), True)
word = guess.pick_word(seed_num)
Expand Down Expand Up @@ -87,12 +90,16 @@ def run(self):
for i in range(len(word)):
trace.draw_letter(i, word[i], True)

self.output_queue.put("SOUND " + sss_sounds.END_FAIL_7)

# Check to see if the player has guessed all the letters in the word and the game is over
if num_correct == 5:
self.gameover = True
self.win = True
trace.draw_endgame(True)

self.output_queue.put("SOUND " + sss_sounds.BEEP_06_GOOD)

# If the player presses the LEFT key then the game will scroll through the alphabet backwards
if repeat_left:
trace.draw_choice(guess.letter_select(choice), False)
Expand All @@ -103,6 +110,8 @@ def run(self):
choice = choice - 1
trace.draw_choice(guess.letter_select(choice), True)

self.output_queue.put("SOUND " + sss_sounds.TICK)

# If the player pressed the RIGHT key then the game will scroll through the alphabet forwards
if repeat_right:
trace.draw_choice(guess.letter_select(choice), False)
Expand All @@ -113,6 +122,8 @@ def run(self):
choice = choice + 1
trace.draw_choice(guess.letter_select(choice), True)

self.output_queue.put("SOUND " + sss_sounds.TICK)

# If the player pressed the START key then the game will check to see if that letter is in the word
# If the letter is in the word then the num_correct will increment
# If the letter is not in the word then the num_errors will increment
Expand All @@ -129,6 +140,10 @@ def run(self):
correct = True
num_correct += 1
guess.add_guess_list(guess.letter_select(choice))

if num_correct < 5:
self.output_queue.put("SOUND " + sss_sounds.BEEP_10)

if correct == False and guessed == False:
num_errors = num_errors + 1
trace.draw_person(num_errors, True)
Expand All @@ -140,6 +155,9 @@ def run(self):
True,
True,
)

if num_errors < 7:
self.output_queue.put("SOUND " + sss_sounds.BEEP_08)
yield

# This will wait until the player has pressed the START button again before restarting a new game
Expand Down
Loading