gtreshchev / RuntimeAudioImporter

Runtime Audio Importer plugin for Unreal Engine. Importing audio of various formats at runtime.
MIT License
308 stars 67 forks source link

Capture in ios always fail #36

Closed original-curtain closed 10 months ago

original-curtain commented 1 year ago

Hello! When I try capture sound in iphone,the return value is always false. I'm use UE5.1 and iphone 13,phone system is 16.3.1 image

original-curtain commented 1 year ago

the record permission is granted

gtreshchev commented 1 year ago

Hello. Can you please provide any logs you have? I haven't been able to test the capturable sound waves on iOS because I don't have that device at the moment, but if you can provide me with any logs that would be great.

To clarify, have you added NSMicrophoneUsageDescription to the AdditionalPlistData field in Unreal Engine? The DefaultEngine.ini file should have the following line (RuntimeAudioImporter is written just for consistency): AdditionalPlistData=<key>NSMicrophoneUsageDescription</key><string>RuntimeAudioImporter</string>

original-curtain commented 1 year ago

Hello.NSMicrophoneUsageDescription has added. image

And I'm not sure if the fellowing log is what you want.The log is in Xcode. log.txt

By the way,I'm facing same issue when I use UE's Audio capture.As shown below: image

When I first recording phone no response.On the second attempt, the phone crashed.That crash is in [File:./Runtime/AudioCaptureImplementations/IOS/AudioCaptureAudioUnit/Private/AudioCaptureAudioUnit.cpp] [Line: 165] image

gtreshchev commented 1 year ago

I think the following code also needs to be executed before capturing for iOS, can you test that please?

[[AVAudioSession sharedInstance] requestRecordPermission:^(BOOL granted) {
    // It might make sense to check the result here
}];

For example you could add the following function declaration to CapturableSoundWave.h:

UFUNCTION(BlueprintCallable, Category = "Capturable Sound Wave|Permissions")
void RequestCapturePermissions();

And the following function definition to CaptureableSoundWave.cpp:

void UCapturableSoundWave::RequestCapturePermissions()
{
#if PLATFORM_IOS
    [[AVAudioSession sharedInstance] requestRecordPermission:^(BOOL granted) {
        // It might make sense to check the result here
    }];
#endif
}

And revoke this function beforehand.

original-curtain commented 1 year ago

The permission is granted. image

Only when in case AVAudioSessionRecordPermissionGranted,I'll start capture audio

1165048017 commented 1 year ago

@gtreshchev T_T I have the same problem on my iphone too And also on my M1, the first record can play sound, but the second-time record doesn't playback. I just notice that the second time I press key to record, there is no log about PCM data, but on my windows, the PCM data always appears when I press record button.

1165048017 commented 1 year ago

@original-curtain Hello, do you make it work in IOS finally? ^_^

original-curtain commented 1 year ago

Sorry,I'm not make it work

1165048017 commented 1 year ago

@original-curtain I found that "Cross-Platform Voice Chat Pro" plugin can work in IOS, you can find the blog in https://blog.csdn.net/qq_31042143/article/details/129479405?spm=1001.2014.3001.5501 BTW, Are you Chinese? Me too ^_^

original-curtain commented 1 year ago

对啊 不过老哥 你这插件收费,目前我是通过调ios原生方法来实现录音的,只不过最后播放录音还是有问题 orz

1165048017 commented 1 year ago

@original-curtain 我查到的方法也是说要写原生插件。前几天三折,我买了这个Pro插件,哈哈;看了一下源码,他在UE里面直接调用AVFoundation.h,然后写了语音功能,没有用XCode去封装库调用;俺先研究研究 orz

original-curtain commented 1 year ago

@1165048017 (抱拳

gtreshchev commented 10 months ago

@1165048017 @original-curtain this support should have been added since commit bc628baf25206b294f5bfa8e8d779eeda5bc85d3. Please reopen this ticket if the issue still persists.