Skip to content
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

Engine #50

Merged
merged 16 commits into from
Aug 12, 2024
Merged

Engine #50

merged 16 commits into from
Aug 12, 2024

Conversation

sepandhaghighi
Copy link
Member

@sepandhaghighi sepandhaghighi commented Aug 10, 2024

Reference Issues/PRs

What does this implement/fix? Explain your changes.

  • engine parameter added to play function
  • README.md modified
  • __play_win function renamed to __play_winsound
  • __play_mac function renamed to __play_afplay
  • __play_linux function renamed to __play_alsa

Any other comments?

Local tests on OSs

  • macOS
    • Sonoma
  • Windows
    • Windows 11
  • Linux
    • Ubuntu 22.04

@sepandhaghighi sepandhaghighi self-assigned this Aug 10, 2024
@sepandhaghighi sepandhaghighi added enhancement New feature or request major labels Aug 10, 2024
@sepandhaghighi sepandhaghighi added this to the nava v0.7 milestone Aug 10, 2024
Copy link

codecov bot commented Aug 10, 2024

Codecov Report

Attention: Patch coverage is 97.22222% with 1 line in your changes missing coverage. Please review.

Project coverage is 95.16%. Comparing base (b8f1fef) to head (4d3178c).

Files Patch % Lines
nava/functions.py 96.56% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev      #50      +/-   ##
==========================================
- Coverage   95.24%   95.16%   -0.08%     
==========================================
  Files           4        4              
  Lines         147      165      +18     
  Branches       19       24       +5     
==========================================
+ Hits          140      157      +17     
  Misses          2        2              
- Partials        5        6       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@sepandhaghighi sepandhaghighi marked this pull request as ready for review August 10, 2024 16:28
Copy link
Member

@sadrasabouri sadrasabouri left a comment

Choose a reason for hiding this comment

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

I tested it in MacOS and it's working fine. Minor changes requested.

Comment on lines +31 to +37
>>> sys_platform = sys.platform
>>> if sys_platform == "win32":
... sound_id = nava.play(os.path.join("others", "test.wav"), async_mode=True, engine=nava.Engine.WINSOUND)
... elif sys_platform == "darwin":
... sound_id = nava.play(os.path.join("others", "test.wav"), async_mode=True, engine=nava.Engine.AFPLAY)
... else:
... sound_id = nava.play(os.path.join("others", "test.wav"), async_mode=True, engine=nava.Engine.ALSA)
Copy link
Member

Choose a reason for hiding this comment

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

Why didn't you test __play_auto directly here?

Copy link
Member Author

Choose a reason for hiding this comment

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

This section of tests is not about the __play_auto function. Here, I tried to test each engine manually.

README.md Outdated

```python
from nava import play, Engine
sound_id = play("alarm.wav", async_mode=True, engine=Engine.AFPLAY)
Copy link
Member

Choose a reason for hiding this comment

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

I guess it's better to remove async_mode for this example, to prevent confusion.

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed in 4d3178c

Comment on lines +12 to +24
class Engine(Enum):
"""
Nava engine class.

>>> import nava
>>> engine = nava.Engine.ALSA
"""

AUTO = "auto"
WINSOUND = "winsound"
ALSA = "alsa"
AFPLAY = "afplay"

Copy link
Member

Choose a reason for hiding this comment

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

Now when user requests for an unavailable engine (an engine which is available in the Engine enum but not in the user's system) we raise the following error:

nava.errors.NavaBaseError: Sound can not play due to some issues.

It's better to handle this exception differently somewhere. We may want to handle this in another PR, but I am raising it here just for the record.

Copy link
Member Author

Choose a reason for hiding this comment

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

We should talk about it later. At the moment, all of the engines only work on one OS. In the future, it's possible that we'll have an engine that works on more than one OS. So, I believe that it's not a bad idea to give this option to the user to choose any engine anywhere.

@sadrasabouri sadrasabouri merged commit 0d81ddf into dev Aug 12, 2024
73 of 74 checks passed
@sadrasabouri sadrasabouri deleted the engine branch August 12, 2024 01:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request major
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants