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

Enhance Audio Device Management: Volume and Mute Control Features #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Lemon-2333
Copy link

Overview

This submission introduces a set of functionalities for more effective management of audio device volume and mute status. With these changes, users can set and retrieve volume levels and mute status on specified audio devices, enhancing the flexibility and usability of audio control.

Key Changes

  1. Volume Setting and Retrieval:
  • setVolumeForDevice function: Allows users to set the volume of a specified device, taking the device ID and volume percentage (0-100) as parameters.

  • getVolumeForDevice function: Enables users to retrieve the current volume of a specified device, returning it as a percentage.

  1. Mute Status Management:
  • setMuteForDevice function: Gives users the ability to set the mute status of a specified device, accepting the device ID and a boolean value (true/false) as parameters.

  • getMuteForDevice function: Allows users to check the mute status of a specified device, returning 1 for muted and 0 for unmuted.

  1. Python Interface Updates:
  • Added Python interface support for the new functionalities, allowing users to easily call these features from Python code.

  • Updated the getDevices method to include the device ID in the return values for easier subsequent operations.

Code Example

Here’s an example of how to use the new functionalities:

import CoreAudio

# Initialize the module
CoreAudio.init()

# Retrieve all devices
devices = CoreAudio.getDevices()

# Set the volume for a device
device_id = devices[0][2]  # Get the ID of the first device
CoreAudio.setVolumeForDevice(device_id, 50)  # Set volume to 50%

# Get the volume of the device
volume = CoreAudio.getVolumeForDevice(device_id)
print(f"Device volume: {volume}%")

# Set the device to mute
CoreAudio.setMuteForDevice(device_id, True)  # Mute the device
mute_status = CoreAudio.getMuteForDevice(device_id)
print(f"Device mute status: {'Muted' if mute_status == 1 else 'Unmuted'}")

Add some methods that take specific devices as parameters
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.

1 participant