Nightlies and iOS sound input

I am trying to mobe to nightlies as suggested by the forum post, I want to use sound input for iOS, but there is an issue I dont understand.

When the bool ofxiOSSoundStream::setup(const ofSoundStreamSettings & settings)
function runs it has an error:

Thread 1: EXC_BAD_ACCESS (code=1, address=0x464630b96110)

On this line:

        [(__bridge SoundInputStream *)soundInputStream start];

Does anyone have any clues as to how to solve this?

Ahh I wonder if its a permissions issue with the plist - you might need to add the microphone capability as described here:

Seemingly the plist does nto trigger a request for access, I had to add some code do do that, I tried in a few ways but something like this worked:

bool ofxiOSSoundStream::setup(const ofSoundStreamSettings & settings) {
    close();
    
    microphonePermissionGranted = false;
    AVAudioSessionRecordPermission permissionStatus = [[AVAudioSession sharedInstance] recordPermission];
    if (permissionStatus == AVAudioSessionRecordPermissionGranted) {
        microphonePermissionGranted = true;
        ofLogVerbose("ofxiOSSoundStream") << "Has mic permission";
    } else if (permissionStatus == AVAudioSessionRecordPermissionDenied) {
        microphonePermissionGranted = false;
        ofLogVerbose("ofxiOSSoundStream") << "No mic permission";
    } else {
        AVAudioSession *audioSession = [AVAudioSession sharedInstance];
        [audioSession requestRecordPermission:^(BOOL granted) {
            microphonePermissionGranted = granted;
            ofLogVerbose("ofxiOSSoundStream") << "Asked for and got mic permission";
        }];
    }
    
    if(microphonePermissionGranted) {
        this->settings = settings;
        
        
        if(settings.numInputChannels > 0) {
            soundInputStream = (__bridge void *)[[SoundInputStream alloc] initWithNumOfChannels:settings.numInputChannels
                                                                                 withSampleRate:settings.sampleRate
                                                                                 withBufferSize:settings.bufferSize];
            ofxiOSSoundStreamDelegate * delegate = [[ofxiOSSoundStreamDelegate alloc] initWithSoundInputFn:settings.inCallback];
            
            
            ((__bridge SoundInputStream *)soundInputStream).delegate = delegate;
            [(__bridge SoundInputStream *)soundInputStream start];
        }
        
        if(settings.numOutputChannels > 0) {
            soundOutputStream = (__bridge void *)[[SoundOutputStream alloc] initWithNumOfChannels:settings.numOutputChannels
                                                                                   withSampleRate:settings.sampleRate
                                                                                   withBufferSize:settings.bufferSize];
            ofxiOSSoundStreamDelegate * delegate = [[ofxiOSSoundStreamDelegate alloc] initWithSoundOutputFn:settings.outCallback];
            ((__bridge SoundInputStream *)soundOutputStream).delegate = delegate;
            [(__bridge SoundInputStream *)soundOutputStream start];
        }
        
        bool bOk = (soundInputStream != NULL) || (soundOutputStream != NULL);
        return bOk;
    }
    else{
        return false;
    }
}

The app then asked for permission on run (before the soundstream was initialised) but crashed as described above.

With some help I managed to get this going. I’m not sure if this a perfect solution but it helped me.

hey @fresla can you please test it again with the current master or tomorrow nightly? thanks

Hi, yes the recent fixes work for me, soundstream input and output work as do the sound players. I do see the same issue as you meontioned on github, the playback level of the file is low when the soundstream input is active. Otherwise it is all working well.