gordonklaus / portaudio

Go bindings for the PortAudio audio I/O library
MIT License
704 stars 95 forks source link

unable to open on a device #43

Closed claudio-ortega closed 3 years ago

claudio-ortega commented 3 years ago

Hi everyone,

First of all, great job everyone involved in the construction of this piece of software.

I have been using portaudio very successfully for the past weeks for developing a low delay app for musicians https://bitbucket.org/claudio_ortega/jambridge/src/master/doc/jambridge-README.md

Here's the bad news, I've run today into an issue, which seems to be very likely system dependent.

I am using an AudioBox USB96 interface, which has been working and still works just fine. Please find at the bottom the test case with the minimum piece of code that shows the failure. The problem is in the call to OpenStream() which returns "PortAudio Internal Error"

The test passes in these two test beds:

The exact same test does not pass in my third test bed:

In all cases I am with go1.15.x, and I have no 'user' applications opened. Also in all cases I've verified that the name for the device picked up by the call to DefaultInputDevice is always the same: "AudioBox USB 96", which is the one that I expect and the one I want.

The audio parameters used in the test are: 44.1k/64samples/16bits/1channel. However, I've tried with different combinations of sampling freq and buffer length, all working fine on 1,2 above, but none of those have worked on (3).

I hope somebody has run into this issue, and hopefully might shed some light on it.

Thanks again for the great work put on this library.

Claudio

package audiotest

import (
    "testing"
    "time"
    "github.com/gordonklaus/portaudio"
)

func TestBigSurIssue(t *testing.T) {

    err := portaudio.Initialize()
    checkErr(t, err)

    inputDeviceInfo, err := portaudio.DefaultInputDevice()
    checkErr(t, err)

    streamParameters := portaudio.LowLatencyParameters(inputDeviceInfo, nil)
    streamParameters.SampleRate = 44100.0
    streamParameters.FramesPerBuffer = 64
    streamParameters.Input.Channels = 1
    streamParameters.Input.Latency = time.Millisecond

    _, err = portaudio.OpenStream(
        streamParameters,
        func(in []int16,
            outIgnore []int16,
            timeInfo portaudio.StreamCallbackTimeInfo,
            flags portaudio.StreamCallbackFlags,
        ) {
        })
    checkErr(t, err)

    err = portaudio.Terminate()
    checkErr(t, err)
}

func checkErr(t testing.TB, err error) {
    if err != nil {
        t.Fatal(err)
    }
}
claudio-ortega commented 3 years ago

Update on the issue. There is more evidence to show. I built two executables on the same (and last) commit of my app. One (a) is built on the iMac 2009, and (b) is built on the Mac Mini 2018 To recap: problem is that when I run (b) on the Mac Mini 2018 it fails. But, here the news: when I run (a) en the Mac Mini 2018, it works. So it has to do with an issue during the build, and not with any condition at runtime.

So here's something that I omitted to mention in the original post, and my apologies for that: When building on the Mac Mini the go build prints this to the console, and repeatedly:

app_darwin.m:11:32: warning: 'NSUserNotification' is deprecated: first deprecated in macOS 11.0 - All NSUserNotifications API should be replaced with UserNotifications.frameworks API [-Wdeprecated-declarations]
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSUserNotification.h:24:12: note: 'NSUserNotification' has been explicitly marked deprecated here
app_darwin.m:17:33: warning: 'NSUserNotificationCenter' is deprecated: first deprecated in macOS 11.0 - All NSUserNotifications API should be replaced with UserNotifications.frameworks API [-Wdeprecated-declarations]
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSUserNotification.h:118:12: note: 'NSUserNotificationCenter' has been explicitly marked deprecated here

...
(it repeats a few time over the same pair of warnings)

I hope this rings any bell to somebody

Thanks

gordonklaus commented 3 years ago

Hi, cool application!

I suspect this is another case (like #41) related to this issue with the PortAudio C library on Big Sur. The latest development indicate that the macOS SDK version built against affects whether it fails at runtime on Big Sur. I assume you are using SDK 11 on your Mac Mini 2018 and not on the iMac 2009.

I'l close this issue since it seems to be an issue with the underlying C library. Feel free to re-open or share your thoughts if there is something relevant to the Go bindings.

claudio-ortega commented 3 years ago

Hi Gordon,

Thanks for your reply, and thank you for the compliment as well.

My apologies, I should have checked the 'closed issues' as well, I did not. I agree that the issue should be closed.

Thank you once again for the library you wrote. You rock.

Claudio

On Wed, Jan 27, 2021 at 1:07 AM Gordon Klaus notifications@github.com wrote:

Hi, cool application!

I suspect this is another case (like #41 https://github.com/gordonklaus/portaudio/issues/41) related to this issue https://github.com/PortAudio/portaudio/issues/218 with the PortAudio C library on Big Sur. The latest development https://github.com/PortAudio/portaudio/issues/468 indicate that the macOS SDK version built against affects whether it fails at runtime on Big Sur. I assume you are using SDK 11 on your Mac Mini 2018 and not on the iMac 2009.

I'l close this issue since it seems to be an issue with the underlying C library. Feel free to re-open or share your thoughts if there is something relevant to the Go bindings.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/gordonklaus/portaudio/issues/43#issuecomment-768142530, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADF4SM4IP4AUHULTDIR5XH3S37JUNANCNFSM4WUJ3QBA .

claudio-ortega commented 3 years ago

Hey Gordon, I did my homework reading all the reports. I have no idea how to make this work in Big Sur. Any ideas for me?. How did you handle this yourself? Claudio

On Wed, Jan 27, 2021 at 9:23 AM Claudio Ortega < claudio.alberto.ortega@gmail.com> wrote:

Hi Gordon,

Thanks for your reply, and thank you for the compliment as well.

My apologies, I should have checked the 'closed issues' as well, I did not. I agree that the issue should be closed.

Thank you once again for the library you wrote. You rock.

Claudio

On Wed, Jan 27, 2021 at 1:07 AM Gordon Klaus notifications@github.com wrote:

Hi, cool application!

I suspect this is another case (like #41 https://github.com/gordonklaus/portaudio/issues/41) related to this issue https://github.com/PortAudio/portaudio/issues/218 with the PortAudio C library on Big Sur. The latest development https://github.com/PortAudio/portaudio/issues/468 indicate that the macOS SDK version built against affects whether it fails at runtime on Big Sur. I assume you are using SDK 11 on your Mac Mini 2018 and not on the iMac 2009.

I'l close this issue since it seems to be an issue with the underlying C library. Feel free to re-open or share your thoughts if there is something relevant to the Go bindings.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/gordonklaus/portaudio/issues/43#issuecomment-768142530, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADF4SM4IP4AUHULTDIR5XH3S37JUNANCNFSM4WUJ3QBA .

gordonklaus commented 3 years ago

I think we just have to wait for those issues to be fixed. I'm not on BIg Sur so I haven't had the problem and can't test.

claudio-ortega commented 3 years ago

Thank you, man C

On Wed, Jan 27, 2021 at 9:47 AM Gordon Klaus notifications@github.com wrote:

I think we just have to wait for those issues to be fixed. I'm not on BIg Sur so I haven't had the problem and can't test.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/gordonklaus/portaudio/issues/43#issuecomment-768458383, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADF4SM6UGG6DNSGH2GWAMYTS4BGRTANCNFSM4WUJ3QBA .