Code Monkey home page Code Monkey logo

Comments (36)

bastibe avatar bastibe commented on August 30, 2024

Can you show me a code example of what you are running when the error happens?

The RuntimeWarnings are likely a result of the error.

from soundcard.

Warniz avatar Warniz commented on August 30, 2024

I'm just running the demo code:

import soundcard as sc
import numpy`

speakers = sc.all_speakers()

default_speaker = sc.default_speaker()

mics = sc.all_microphones()

default_mic = sc.default_microphone()

data = default_mic.record(samplerate=48000, numframes=48000)

default_speaker.play(data/numpy.max(data), samplerate=48000)

The -10863 error seems to be connected to the data = default_mic.record(samplerate=48000, numframes=48000)
And the runtime error connected the default_speaker.play function

from soundcard.

bastibe avatar bastibe commented on August 30, 2024

What version of macOS are you running, and what kind of sound card is your default_microphone?

from soundcard.

Warniz avatar Warniz commented on August 30, 2024

I'm running 10.14.1 Mojave and i'm just using the built-in mic. So my macbooks built-in soundcard. Which is a macbook pro 2012.

from soundcard.

bastibe avatar bastibe commented on August 30, 2024

Sorry, one more question: What version of SoundCard are you running? I'm afraid I am not able to reproduce your issue on my Mac, and macOS is terribly flickle with its audio system for all kinds of cases. Are you running any audio plugins like SoundFlower?

from soundcard.

Warniz avatar Warniz commented on August 30, 2024

Running 0.2.2 and yeah I do have SoundFlower installed. But the default is set to not be a SoundFlower device.

from soundcard.

bastibe avatar bastibe commented on August 30, 2024

I have tried a different Mac, and am seeing your issue now. It appears that something broke in the update to Mojave. I am not sure, what, though.

However, it seems that the sample rate is what is causing the error message. On my computer, it runs fine if I use 44100 as the sample rate. For now, you can try using 44100 as a workaround.

I won't have access to a Mac in the next few weeks, so I won't be able to fix this in the near future. But I'll try to get this issue fixed in January.

from soundcard.

rostyboost avatar rostyboost commented on August 30, 2024

FYI I hit the same issue. Mac book air 2012, High Sierra. Universal Audio Apollo Twin 2.
Setting up the sample rate of the sound card to 44.1KHz and calling .record with samplerate=44100 worked. Any other sample rate fails (I tried 48KHz and 96KHz).
So I don't think the bug is coming from Mojave update.

from soundcard.

bastibe avatar bastibe commented on August 30, 2024

Well, it did work for all sample rates the last time I checked, but that was pre-Mojave, and possibly pre-High-Sierra. It seems to be related to the sample rate converter unit used for recording at non-default sample rates. (Oh, if only core audio would convert sample rates automatically, like any sane audio API, and indeed their playback units... but I digress).

I currently don't have a Mac available at home, and won't have access to my work Mac until the second week of January. So any fixes will have to wait until then. Of course, if any one of you would like to take a stab at it, I will try to help you as much as I can, and gladly merge a pull request!

from soundcard.

melvyn2 avatar melvyn2 commented on August 30, 2024

I've tried mic.record(samplerate=44100, numframes=44100), and it's failing with this message for me.

from soundcard.

bastibe avatar bastibe commented on August 30, 2024

@melvyn2 does it work for some other sampling rate? (Are you using a special sound card?)

from soundcard.

melvyn2 avatar melvyn2 commented on August 30, 2024

I've only tried 44.1, 48, and 96 kHz, and none work. I've been using stream() for what I need to do and it works.

from soundcard.

bastibe avatar bastibe commented on August 30, 2024

What do you mean by

I've been using stream()?

from soundcard.

melvyn2 avatar melvyn2 commented on August 30, 2024

Instead of using sc.mic.record() or whatever, I've been using sd.Stream() for what I needed to do.

from soundcard.

bastibe avatar bastibe commented on August 30, 2024

This issue is not about SoundDevice, but SoundCard, a different library.

from soundcard.

melvyn2 avatar melvyn2 commented on August 30, 2024

whoops, sorry. I consfused the two. my original issue still stands, though.

from soundcard.

daverz avatar daverz commented on August 30, 2024

Only settings of 44100 and 88200 in Audio MIDI Setup work for me.

OS X 10.13.4 on a MacBook Pro (Retina, 15-inch, Late 2013).

From the anaconda package listing:

anaconda 2018.12 py37_0
cffi 1.11.5 py37h6174b99_1
python 3.7.1 haf84260_7
soundcard 0.2.2 pypi_0 pypi

For the internal mic, I get the errror when sample rates of 48000 and 96000 are set in Audio MIDI Setup, but not when 44100 or 88200 are set.

Unfortunately my Umik-1 mic only offers a sample rate of 48000.

import soundcard
mic = soundcard.default_microphone()
print(mic)
data = mic.record(samplerate=48000, numframes=1024)

<Microphone Umik-1  Gain: 18dB   (2 channels)>
error during recording: -10863
error during recording: -10863
error during recording: -10863

from soundcard.

bastibe avatar bastibe commented on August 30, 2024

To be honest, I don't know what is causing this problem. It used to work fine. I'd be grateful for anyone to try to dig into the horrible, undocumented mess that is CoreAudio, to try to find the cause of this.

from soundcard.

stswong avatar stswong commented on August 30, 2024

Any progress on this problem?

I have V0.3 installed running with Python 3.7, Mojave 10.14.4, 15" 2018 MacBook Pro. No recording works, at any sample rate, even for builtin microphone. I got the same error -10863.

When I tried it on my Windows 10 VM with Parallel on the same computer, Recording worked just fine.

from soundcard.

bastibe avatar bastibe commented on August 30, 2024

No progress yet. I didn't have time to look into it, yet. Any help would be welcome!

from soundcard.

bastibe avatar bastibe commented on August 30, 2024

I just tried to reproduce the issue on a work MacBook, and it worked without issue. (Built-in Python 3.6.1 on macOS 10.14.4). I will now try again with a more recent version of Python.

from soundcard.

bastibe avatar bastibe commented on August 30, 2024

While I was unable to reproduce your error messages on my Mac, I did find a few errors in the macOS implementation. Could you check if the latest version fixed your issues on macOS?

from soundcard.

stswong avatar stswong commented on August 30, 2024

from soundcard.

bastibe avatar bastibe commented on August 30, 2024

OK, that's disappointing. Now we'll have to find the difference between our systems.

Could you try again with the SoundFlower virtual sound card, to try to make this as reproducible as possible?

When recording it timed out and returned with error -10863. I checked and the code means CannotDoInCurrentContext.

Yeah, that's what core audio always says if it doesn't like anything. I wish it told us why it can't do it in the current context on your machine, but apparently has no such qualms on my Mac. Context here typically means "during playback" or "in the stream callback". Probably, it means "can not call AudioUnitRender in the RenderCallback" (line 801 in coreaudio.py).

I'd be grateful for any information on this. Could you try adding some debugging code to the input_callback and print the values of its arguments? Whether it's the first call that fails or a later one?

Are you running this from a bare Python prompt, or as part of an IDE of some kind? Are you playing any other audio in the background? Are you using the built-in system Python or another version? If so, what version of Python are you using? Also, my computer told me it couldn't do block sizes larger than 512, but one example up above seemed to have used 1024 without issue.

I would really like to find and fix this bug.

from soundcard.

stswong avatar stswong commented on August 30, 2024

from soundcard.

stswong avatar stswong commented on August 30, 2024

from soundcard.

bastibe avatar bastibe commented on August 30, 2024

Thank you! I will compare these to the numbers I get on my computer when I get back to work tomorrow (that's where the computer is at).

Just to make sure, could you show me actionflags[0] and timestamp[0] (dereference the pointers)?

from soundcard.

stswong avatar stswong commented on August 30, 2024

from soundcard.

bastibe avatar bastibe commented on August 30, 2024

Thank you. This is frustrating, your example works on my machine:

>>> soundcard.get_microphone("Soundflower64").record(samplerate=48000, channels=8, numframes=16)
channels =  8
userdata =  <cdata 'void *' NULL>
actionflags[0] =  0
timestamp[0] =  <cdata 'AudioTimeStamp &' 0x10c2150a0>
busnumber =  1
numframes =  512
bufferlist.mNumberBuffers =  1
bufferlist.mBuffers[0].mNumberChannels =  8
bufferlist.mBuffers[0].mDataByteSize =  16384

(I used Soundflower, as this is my only 8-channel device. But it works on my computer for every other sound card as well.)

from soundcard.

bastibe avatar bastibe commented on August 30, 2024

Does it work if you return 0 instead of the status code from AudioUnitRender? Perhaps the error only happens once, and we just have to ignore that initial error, or something like that.

from soundcard.

stswong avatar stswong commented on August 30, 2024

from soundcard.

stswong avatar stswong commented on August 30, 2024

from soundcard.

bastibe avatar bastibe commented on August 30, 2024

The MacBook Pro Mic works for me. However, I connected a USB sound card, and finally, I get the error as well!

Thank you very much for helping me get to this point! Now that I can reproduce the error, I can get started looking for causes.

from soundcard.

bastibe avatar bastibe commented on August 30, 2024

I think I found the issue: Could you check the value of actionflags[0] after the call to AudioUnitRender?

On my machine, it is 16, which corresponds to _cac.kAudioUnitRenderAction_OutputIsSilence. So it's not actually an error, but simply a lack of input, which we could ignore and return zeros.

Would this make sense in your case?

from soundcard.

bastibe avatar bastibe commented on August 30, 2024

The latest commit fixes the OutputIsSilence issue. Can you confirm that this solves your problem?

from soundcard.

stswong avatar stswong commented on August 30, 2024

from soundcard.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.