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

No such device error when initializing mixer module #3134

Open
theelgass opened this issue Sep 29, 2024 · 9 comments
Open

No such device error when initializing mixer module #3134

theelgass opened this issue Sep 29, 2024 · 9 comments
Labels
Experimental Experimental code mixer pygame.mixer

Comments

@theelgass
Copy link

When I'm trying to play some audio via choosed input device (virtual audio cable) I'm getting an error: 'pygame.error: No such device.' despite the fact that the device is in the list. The same thing happens when I pass the name of the first device (index 0). When I'm trying to do same thing when I'm passing False value everything works fine. Few days ago selecting an input device worked without throwing any error.

Source:

from pygame._sdl2.audio import get_audio_device_names
from pygame import mixer
import pygame

pygame.init()
devices = get_audio_device_names(True)
print(devices)
file_path = "sounds/some-short-file.mp3"
mixer.quit()
mixer.init(devicename = devices[1])
mixer.music.load(file_path)
mixer.music.play()

Output:

pygame-ce 2.5.1 (SDL 2.30.6, Python 3.12.1)
['Microphone (Realtek(R) Audio)', 'CABLE Output (VB-Audio Virtual Cable)']
Traceback (most recent call last):
  File "D:\t.py", line 10, in <module>
    mixer.init(devicename = devices[1])
pygame.error: No such device.

Process finished with exit code 1
@ankith26
Copy link
Member

ankith26 commented Oct 2, 2024

Why are you doing get_audio_device_names(True) instead of get_audio_device_names(False)? If you goal is audio playback you should use a playback device and not a capture device.

@theelgass
Copy link
Author

@ankith26 I'm trying to play some audio via choosed input device I want to use it in other applications, just like a microphone (that's why I'm using virtual cable also). I want to achieve something like the built-in functionality of Voicemod app and earlier it was working fine.

@ankith26
Copy link
Member

ankith26 commented Oct 3, 2024

Can you post the output of get_audio_device_names(False) here? Also, it would be helpful for debugging if you could pinpoint exactly what change caused it to stop working if you say it was working fine earlier. Was it a pygame-ce version bump, or something else that changed in your side?

@bilhox bilhox added Experimental Experimental code mixer pygame.mixer labels Oct 3, 2024
@theelgass
Copy link
Author

@ankith26 Everything is in my first post, in output section. Reboot caused change of behaviour.

@ankith26
Copy link
Member

ankith26 commented Oct 4, 2024

Your first post has the output of get_audio_device_names(True), I'm asking the output of get_audio_device_names(False)

@theelgass
Copy link
Author

theelgass commented Oct 4, 2024

@ankith26
Output:

['Speakers (Realtek(R) Audio)']

In this case program runs fine.

@bilhox
Copy link
Contributor

bilhox commented Oct 5, 2024

I don't understand what you're doing, devicename in mixer.init is for output, it shouldn't be a input device.

@theelgass
Copy link
Author

@bilhox

I'm trying to play some audio via choosed input device I want to use it in other applications, just like a microphone (that's why I'm using virtual cable also). I want to achieve something like the built-in functionality of Voicemod app and earlier it was working fine.

For example - earlier, when I was recording audio (the recorder was set to CABLE Output - same device that was choosed in script to play audio through) while running the script - I could hear the sound from the file in the saved recording.

I want to use it in other applications, just like a microphone for playing audio files.

@Starbuck5
Copy link
Member

If pygame-ce doesn't see it as an output device it's not going to let you play audio to it.

Few days ago selecting an input device worked without throwing any error.

I would suggest you re-set up your virtual audio cable. Seems like that broke.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Experimental Experimental code mixer pygame.mixer
Projects
None yet
Development

No branches or pull requests

4 participants