LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Acquire Sound not working - macos 11.6

Solved!
Go to solution

Hi,

 

I'm running LabVIEW Community 21.0 64bit on macos 11.6 (intel) and am trying to get the Express VI "Acquire Sound" working. On Windows, I have had no issues building a test vi (with Aquire Sound wired into Play Waveform) but on Mac, no audio is being picked up.

The error codes I've gotten are 0x2A (42) and 0x12C3 (4803). Here is the configuration I used to get something, but typically running it just results in no output at all. I played around with the settings since the support page for 0x12C3 says something about the configuration not matching the hardware, but I can't say I really know what I'm doing.

Screen Shot 2021-12-06 at 9.04.22 PM.png

 Matching 24 bit in LabVIEW to the system defaults for the microphone resulted in sometimes giving a preview that had a large spike like the one shown in the screenshot. I also matched the sample rates. A friend of mine was able to duplicate the issue on his M1 mac as well, running the same version of LabVIEW.

 

I was thinking this had something to do with Community edition not coming with all the extra stuff, but the page for Aquire Sound Express VI only mentions drivers for Windows and Linux. Play Waveform does appear to work, which claims to depend on the same drivers. I briefly looked into somehow installing OSS in mac (since it is unix under the hood), but that doesn't seem to be the solution.

 

Any insight, tips, or solutions are appreciated!

 

-Nate

0 Kudos
Message 1 of 7
(2,756 Views)

Hi Nate,

 

If you use the acquire sound VIs directly (instead of the express VI), is it much better? You can find examples for sound acquisition in the example finder (see Finite Sound Input.vi). You might also try running the attached VI which queries the input device to see what its capabilities are to confirm you are configuring it correctly.

 

Unfortunately LabVIEW's sound library is rather old and hasn't been updated for many years, especially on Linux and macOS. I'm working on a replacement library called G-Audio (see my sig), and includes Core Audio support on macOS. It's only been tested on Intel hardware, but hopefully works on M1 hardware.

 

It currently doesn't support packed 24-bit audio data, but capturing 16-bit and 32-bit audio should work. The bundled example Audio Capture Example.vi demonstrates capturing audio and saving it to a wav file, and can be modified to playback audio.

0 Kudos
Message 2 of 7
(2,738 Views)

Hi and thanks for responding.

 

Using the sound vi's directly was still unsuccessful, but thanks for making me aware of the example finder. Finite Sound Input.vi hits the same issue as it uses those vi's (see screenshot). Query Input Sound Device was useful for determining that the blip I get at 24bit is probably an anomaly, since it only supports 8&16bit (see screenshot).

 

Thanks for the info about the state of labview. I successfully installed G-Audio on my PC (also 21.0), but the mac was unsuccessful (see screenshot). I'll take another stab at it tomorrow night either way. Have you had success installing it on 21.0 for mac? It looks like I can still download and install 20.0 if need be, but will have to deal with workarounds to avoid crashing.

0 Kudos
Message 3 of 7
(2,718 Views)

Thanks for reporting the VIPM issue. The package is configured to install on 20.0+ so should work with 21.0, but I've not tested installing it on 21.0. I'll try get that fixed.

 

In the mean time, you can download the source (either clone the github repo, or download and extract the zipped source code). From there you can open src/LabVIEW/G-Audio.lvproj and verify that the audio capture example VI works.

 

To use the library in your own project, copy the src/LabVIEW/G-Audio folder to your project's path on disk, and then add G-Audio.lvlib to your project.

0 Kudos
Message 4 of 7
(2,708 Views)
Solution
Accepted by topic author nate820

Ok, this was an adventure!

 

tldr: Use LabVIEW 2020 for sound input and output on macos until it is fixed for 2021. You will have to follow this solution if you are using macos 11.6 or newer. And I hate VIPM now.

 

First off: Trying to use sound in LabVIEW 2021 never worked, even using G-Audio. I was unable to use VI Project Manager to install G-Audio on macos 11.6 to either LabView 2020 or 2021: I consistently got Error Code 5000. Also, after clicking the button for adding G-Audio to my library without installing it, VIPM said it was successful even though it never showed up.

 

I wound up needing Dataflow_G's updated build: 3.1.1., not 3.0.1 that is linking in the post. 3.0.1 has issues with running in 64bit (I happened to read this on the github page), and LabVIEW only runs in 64bit on newer versions of macos, so G-Audio didn't work at all and threw a bunch of errors. After using the new version, I got a dependency error when opening G-Audio.lvproj by following Dataflow_G's instructions, but this was safely ignored. When opening Audio Capture Example.vi in the project's Examples folder, the vi initially would not run due to a broken dependency, "G-Audio.lvlib:Capture Audio.vim". But all I had to do was open the Capture Audio.vim subvi and this issue was resolved [shrug].

 

Nevertheless, finally running this vi in 2021 still did not pick up any audio, but trying it in LabVIEW 2020 prompted macos to ask for microphone permissions and work.

 

...

 

As I was writing this I downgraded the vi I was using in the original post to work in LabVIEW 2020 and checked to see if the sound works. It does. So thankfully I don't need to use G-Audio as long as I stick with 2020, though I'm trying to stay positive and convice myself that I learned something from all the time spent trying to import it and just get it working on macos.

0 Kudos
Message 5 of 7
(2,595 Views)

The problem seems to be that access to the microphone is since a few MacOS versions a rather protected privilege. After all there are spy applications out there who could use it to spy on you (I'm not sure the real ones haven't found a way to get around that protection anyways though).

 

And LabVIEW 2021 seems to do something that prevents the MacOS security alert about granting access to the microphone to appear. What about going explicitly into the System Security Settings? That may not work either though, as it seems that a user only has 30 minutes after that alert has been raised, to grant permission to a specific developer identification associated with the application in question. After that the entry in the System Security Settings seems to disappear and never be prompted again for the application in question. It does start to look to me like security being taken a little bit over the top.

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 6 of 7
(2,566 Views)

Rolf, because of your post I checked Security and Privacy settings within System Preferences, and to my surprise LabVIEW 2021 was already given acces under microphone! (see attached) Following this discovery, I retried opening and running the vi using the Acquire Sound and Play Waveform Express VIs (arranged in attached vi) in 2021, and it ran successfully. Somehow audio permissions seem to be tied between the two seperate installations, since LabVIEW 2020 does not appear to be allowed access, but was the version to finally ask for microphone permissions and work.

 

I was going to try going manually into Security and Privacy like you suggested, but don't need to or intend to uninstall and reinstall everything just to test that theory. I still think this has more to do with a bug regarding asking for microphone permissions in 2021 than overzealous security by macos, but it's definitely worth a try by anyone else facing my issue (a lot less time consuming than downloading multiple versions...).

Download All
0 Kudos
Message 7 of 7
(2,545 Views)