Low-Latency-Android-iOS-Linux-Windows-tvOS-macOS-Interactive-Audio-Platform icon indicating copy to clipboard operation
Low-Latency-Android-iOS-Linux-Windows-tvOS-macOS-Interactive-Audio-Platform copied to clipboard

[iOS] Recorder saves files not correctly

Open AndrewRudyk opened this issue 3 years ago • 0 comments

I'm using Recorder for saving mic input in files. As it's said in documentation, I create file path for "voiceRecording" for method "recorder->prepare" and create file path for "voiceTemp" for recorder initialization "new Superpowered::Recorder("voiceTemp.wav", false);"

When "recorder->recordInterleaved(input, numberOfFrames);" launches, I see "voiceTemp.wav" file in Documents folder. I stop recording using "recorder->stop()" and wait to see "voiceRecording.wav" in Documents folder. It appears not always, but "voiceTemp.wav" file remains when "voiceRecording.wav" doesn't appear, and opposite. This failure appears unpredictably - it can be first App launch, it can be start-stop recording.

I launch App in simulator and iPhone.

const char *test2Url;

static bool audioProcessing(void *clientdata, float *input, float *output, unsigned int numberOfFrames, unsigned int samplerate, uint64_t hostTime) {
    __unsafe_unretained SuperpoweredBridge *self = (__bridge SuperpoweredBridge *)clientdata;
     
    if (self->_recording && !self->recorderIsPrepared) {
        self->recorderIsPrepared = self->recorder->prepare(self->test2Url, samplerate, false, 0);
    }
    if (self->_recording) {
        self->recorder->recordInterleaved(input, numberOfFrames);
    }
}

- (void)startRecording {
    const char *tempUrl = createFileUrl("voiceTemp.wav");
    recorder = new Superpowered::Recorder(tempUrl);
    test2Url = createFileUrl("voiceRecording");
    _recording = true;
}

- (void)stopRecorder {
    if (self->recorder) recorder->stop();
    while (!recorder->isFinished()) NSLog(@"!!! %u", recorder->isFinished());
    _recording = false;
    recorderIsPrepared = false;
}

And samplerate setup isn't convenient in "recorder->prepare(self->test2Url, samplerate, false, 0);"

AndrewRudyk avatar Sep 21 '22 14:09 AndrewRudyk