Skip to content

Conversation

@philipbl
Copy link
Member

This is my first attempt to add sound. Maybe I don't understand the whole problem, but I came up with this, and I would love some feedback.

I created a broadcaster for sounds and a demo to showcase how to use it. As part of the broadcaster, I created a BroadcastMessage data type. If you like that idea, I will convert the MQTT broadcaster to the same data type. Another design decision I made is that all messages sent through the broadcast queue are copied to all broadcasters. This allows the broadcaster to decide if it wants to deal with the message or not. For example, I expected the sound broadcaster to only care about SOUND broadcasts. However, the MQTT broadcaster might care about SOUNDS and TEXT broadcasts.

We also might want to create a ControllerMessage data type, but that is for another pull request.

@christopolise christopolise self-requested a review October 25, 2024 17:21
@apal6981 apal6981 self-requested a review October 25, 2024 17:59
@christopolise
Copy link
Contributor

So I got it to work on my machine, my issue is that it seems to be susceptible to delay if there are lots of sounds coming down the pipeline. I don't know if that is an issue with our queuing system or an inherent weakness of playsound. I haven't tested it with the actual hardware yet but I reckon we'd need a more pygame native sound broadcaster when in simulator mode...

@christopolise
Copy link
Contributor

Another issue I am seeing with certain Python versions is the Path library doesn't always play nice (i.e. on Python 3.10.14 I have to cast the path as a string before putting it into the playsound function).

@christopolise
Copy link
Contributor

Another idea we have is to find a way and play all the sounds at once per tick somehow? We thought we'd achieve something akin to that by disabling the block=False flag in the playsound function, but it still buffers a little...

@christopolise
Copy link
Contributor

The new broadcast arch looks promising. Feel free to convert the MQTT broadcaster accordingly so we can get a better idea of how it works as a whole

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants