64bit stopped my app from audio recording using AVfoundation

I was so happy that I managed to buy a new license to upgrade my app to 64 bit… until I tried to audio record with it.
I am using AVfoundationMBS and it was working great.
However… since upgrading the 64 bit, the recording stopped working. I can still manipulate audio files - i.e. slicing and playing and speed control…

But the recording is not working. Luckily I had a parallels with Mojave on it (I’m now in Catalina). The audio recording worked as good as it ever did.
64 bit - no luck.

Does anybody know about this? Any solutions?
Cheers,
Sean

How does your code look like? What should it do? What happens instead?

I have all the MBS plugins.

like this:

[code]
dim f as FolderItem = SpecialFolder.SharedApplicationData.Child(“Guitar SightReader Toolbox”).child(“recording bin”).child(“transcribe”).Child( “temp.caf”)

dim recordSetting as new Dictionary

dim n as integer = OSTypeFromStringMBS(TranAVFoundation.kAudioFormatLinearPCM)
recordSetting.Value(AVFoundationMBS.AVFormatIDKey) = n
recordSetting.Value(AVFoundationMBS.AVSampleRateKey) = 44100.0
recordSetting.Value(AVFoundationMBS.AVNumberOfChannelsKey) = 2
recordSetting.Value(AVFoundationMBS.AVLinearPCMBitDepthKey) = 16
recordSetting.Value(AVFoundationMBS.AVLinearPCMIsBigEndianKey) = false
recordSetting.Value(AVFoundationMBS.AVLinearPCMIsFloatKey) = false

dim error as NSErrorMBS
recorder = new AVAudioRecorderMBS(f, nil, error)

if error<>Nil then
MsgBox error.LocalizedDescription
Return
end if
if recorder.record then
// ok
TranAVFoundation.CurrentFile = f
else
MsgBox “Failed to start recording.”
end if[/code]

You are using plugins, you probably need MBS support. But are those plugins updated to the latest ones?

I downloaded the latest ones… They don’t work either - it works in 32bit but not 64 bit. This is a real bummer as I spent a load of money to get the latest Xojo version because of Catalina and now I’m hamstrung because AVFoundationMBS doesn’t record in 64 bit

You need to include a few info.plist entries, e.g. NSCameraUsageDescription.

And we have newer functions for authorization. see authorizationStatusForMediaType and requestAccessForMediaType in AVCaptureDeviceMBS class.

Is there any info on how to install those NSCameraUsageDescriptions… Is this going to fix the recording audio in 64 bit?

It may help.
You need an info.plist file like the one included with our examples.

Info.plist looks like this:

<?xml version="1.0" encoding="UTF-8"?> NSCameraUsageDescription Demo

save it as text file and drop into your project.

For macOS Catalina you need to do 3 things to make it work:

  • Ask the user for permission. With the MBS plugins you need to use requestAccessForMediaType. If you do not add this, no access is granted for your app.
  • Add the plist entry that Christian explained.
  • Codesign your app

I use Appwrapper for doing the second and third steps.

I know where the Plist is… inside the contents of the app…

  1. I need to know what text I need to add… i.e.

so I added:

<key>NSCameraUsageDescription</key> <string>Demo</string> <key>NSMicrophoneUsageDescription</key> <string>Demo</string>
to my Plist.info

Is there anything else I need to add?

  1. What is the syntax for adding requestAccessForMediaType to my project and where does it go?

  2. am I correct in assuming I have to pay Apple to have a code to code sign with? I have never dealt with this previously - 32 bit version works great as expected.

Do a Goggle “codesign on macos”. You never ever had any user complain that you app couldn’t be opened??? You never had to deal with Gatekeeper???

Nope - it’s always been fine
I tell my users to right click on the app to open it the first time

But right now I can’t even start selling it until I find a way to AVFoundation do what it’s supposed to do with recording

Man, you were really really really lucky. Again: do a goggle on “codesign on macos”. You need to buy a certificate. Then you need to imagine you have to do your taxes crossed with having a root canal. If everything works then it’s okay. If you get an error then everything falls apart because the errors are really terrible. See recent posts from Greg Grzech (spelling?).

You can let AppWrapper do everything. My app is too complicated for AppWrapper so I do the codesign myself and let AppWrapper do the notarization part. There are some examples around how to do both.

Thanks for your comments Beatrix - what I’m really looking for is a way to record audio. port audio examples also dont work. Christian - do you think you could cobble up a small app that records audio in 64bit and plays it back? That would be magic!

Did you read the thread thoroughly?
All info how to record audio and/or video is here.
The key is you now have to add code that asks the customer to grand permission to use micro/camera.
It does require some extra work to implement it correctly.
There are several MBS examples showing how to do this.

Okay - This is now solved.

First of all - Once you’ve built your app, right click on it to open the package contents. Then open contents.
Edit the file info.plist with text edit.

after a line that reads

Insert this:

NSMicrophoneUsageDescription
Guitar SightReader Toolbox

For this to work, you need something between the . I have put the name of my app. If you don’t put anything between these two, it will not ask to access your microphone or any other audio source (I am usually using my scarlet audio to record from as I play rock guitar and I like a clearer signal than the microphone).

Thanks to Christian Schmitz and monkeybread for the fix. Everything audio recording now works perfectly on my built 64-bit app!

Why don’t you do that with an IDE script or a plist that you drop into the navigator? You shouldn’t change a signed app anyways.

That’s because I don’t know how to do that :slight_smile: - it works just great like I’m doing it now (although I had to build it every time I was testing my audio export feature).