SoundCard icon indicating copy to clipboard operation
SoundCard copied to clipboard

No input on Mac at 48000 samplerate

Open juanBerger opened this issue 5 years ago • 5 comments

Hi many thanks for the library,

As the title says, the baseline:

import soundcard as sc

SAMPLERATE = 48000
m = sc.default_microphone()

with m.recorder(samplerate=SAMPLERATE) as mic:
    while True:
        data = mic.record()
        print(data)

only shows '-0' when the system sample rate is 48000 (works fine with 44100). Mac OS is 10.14.6 Mojave. Any ideas? Thanks!

juanBerger avatar Sep 29 '20 21:09 juanBerger

Could you give me a bit more detail about this? Where does it "show '-0'"? Is there an error or a backtrace? Which function seems to cause the error? What kind of sound card are you using?

bastibe avatar Sep 30 '20 07:09 bastibe

On my system with Big Sur, I can't get anything from the built-in mic (whether in 44.1 or 48kHz). But it works okay with my Apogee One!

When tracing, I see that the condition below is always hit https://github.com/bastibe/SoundCard/blob/745771575e56ab4c5ebf7118816e457c8e6b1b3d/soundcard/coreaudio.py#L815

~~Since it works fine with my external soundcard I'm suspecting some security/privacy issues but that's just a wild guess~~ (after reading https://developer.apple.com/documentation/audiotoolbox/1537630-audio_graph_errors/kaugrapherr_cannotdoincurrentcontext?language=objc)

0x0L avatar Dec 06 '20 12:12 0x0L

I have seen a number of errors such as this during the development of soundcard. The CoreAudio API documentation and error messages are regrettable, to say the least. If you happen to find a workaround, I would be extremely grateful.

bastibe avatar Dec 08 '20 04:12 bastibe

Yeah... the doc is awful :) I'm glad you did all the work and that I found your package I'll give another try to narrow it down

0x0L avatar Dec 08 '20 14:12 0x0L

The problem is Microphone permission I just Solve this

alfonsocv12 avatar May 20 '22 23:05 alfonsocv12