bastibe / SoundCard

A Pure-Python Real-Time Audio Library
https://soundcard.readthedocs.io
BSD 3-Clause "New" or "Revised" License
680 stars 69 forks source link

No input on Mac at 48000 samplerate #110

Open juanBerger opened 4 years ago

juanBerger commented 4 years ago

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!

bastibe commented 4 years ago

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?

0x0L commented 3 years ago

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)

bastibe commented 3 years ago

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.

0x0L commented 3 years ago

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

alfonsocv12 commented 2 years ago

The problem is Microphone permission I just Solve this