-
-
Notifications
You must be signed in to change notification settings - Fork 481
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added sounds #1032
Added sounds #1032
Conversation
This reverts commit 52aa25c.
X and Y offset values can be set at 2 decimal precision
Basic sound notifications for connecting/disconnecting, job-end, non-fatal and fatal errors. TODO: Setting page for custom user sounds / volumes
Added the ability to change various event sounds. Updated Hungarian translation TODO: Volume slider
Added option to mute sounds Updated hungarian translation
It "sound" awesome :-) |
- use of enum instead of event id numbers - cleanup PlaySound function and protect against missing file or unreadable file issues - solve some problems due multiple call location of PlaySound(disconnect)
I had to make some changes to your code: First of all an aesthetic modification with the use of an enum instead of int to identify eventId and the cleanup of the PlaySound function. Second there was an issue because PlaySound(disconnect) was called from too much point that cause for example a double call of PlaySound(disconnect) or a call to PlaySound(disconnect) when closing LaserGRBL even if already disconnected. Also connect was called not in the right place. I think that the right place where to call PlaySound(connect/disconnect) is inside SetStatus function that is able to discriminate and discretize state changes. However I have some doubt on SoundPlayer class usage: I should do some test to be sure that there are no memory leak and no issue with this class. |
Thanks for the cleanup! Next time I'll try to do that the first time. |
The memory leak problem I'm talking about is not easily measurable because it is a cumulative effect of a few KB. The SoundPlayer object allocates unmanaged system resources (resources not included in the automatic memory management/cleanup done by the .net framework) which therefore are not released unless you call the "Dispose()" method of the SoundPlayer object itself. Since you create a new SoundPlayer object in your code whenever you want to play a sound, and you don't release it with the Dispose(), it is conceivable that there is this cumulative effect. I'm not sure how to solve this problem, however, because I doubt that calling dispose immediately after "Play" leads to the interruption of the sound, and calling it later - when the sound is finished - is not possible because it is not known when the sound ends (play() is asynchronous). It is not possible to call PlaySync() because this would block the thread from which the call comes (the thread that takes care of streaming the gcode, for example) for the time necessary to reproduce the sound. Finally I have the doubt that if the gcode code is received as full of errors from grbl (for example a third party file that contains gcode not implemented by grbl) the "PlaySound (warning)" is executed in a burst a lot of times sending in crisis the system (each Play() call is executed in its own thread, so thousand of thread could be created in this situation). |
Especially for this last detail you should do some specific tests and check how it behaves, possibly inserting "anti stress" methods that skip the execution of multiple calls too tight at the playsound. |
$$
response was not visible onNighty
theme.This PR should be up-to-date with the latest changes (as of 2020.06.03).
If there are any issues, let me know.