syedhali / EZAudio

An iOS and macOS audio visualization framework built upon Core Audio useful for anyone doing real-time, low-latency audio processing and visualizations.
Other
4.94k stars 822 forks source link

EZAudioFile fails on loading file on iOS 9 iPhone6s/6s+ or maybe i'm just don't get something #274

Open IgorMuzyka opened 8 years ago

IgorMuzyka commented 8 years ago

Okay so my problem is that i have some really old code which writes audio from mic and which i kind of not willing or cannot just go and change cause it's a bit spaghetti. The code failed on iPhone6s/6s+ so i made a bad spike with check and passed it another AVAudioFormat which helped. And here is the code:


_node = self.audioController.audioEngine.inputNode;

AVAudioMixerNode *amp = [AVAudioMixerNode new];

[self.audioController.audioEngine attachNode:amp];

AVAudioFormat *format;
GBDeviceInfo *deviceInfo = [GBDeviceInfo deviceInfo];

if (deviceInfo.model == GBDeviceModeliPhone6S || deviceInfo.model == GBDeviceModeliPhone6SPlus) {
    format = [_node outputFormatForBus:0];
} else {
    format = [amp inputFormatForBus:0];
}

[self.audioController.audioEngine connect:_node to:amp format:format];
amp.outputVolume = 0.;
[self.audioController.audioEngine connect:amp to:self.audioController.audioEngine.mainMixerNode format:[self.audioController.audioEngine.mainMixerNode outputFormatForBus:0]];

And then i kinda chop the files in parts with AVAudioSession and use those files. And then i'm doing thing like:

        self.audioFile = [EZAudioFile audioFileWithURL:url];
        [self.audioFile getWaveformDataWithNumberOfPoints:length
                                               completion:^(float **channelsData, int length){
                                                   ...
        }];

And eventually it all worked but started to fail with: Error: Failed to read audio data from file waveform (-50) while trying to:

    [EZAudioUtilities checkResult:ExtAudioFileSetProperty(self.info->extAudioFileRef,
                                                          kExtAudioFileProperty_ClientDataFormat,
                                                          sizeof(clientFormat),
                                                          &clientFormat)
                        operation:"Couldn't set client data format on file"];

May anyone help me?

szarif commented 8 years ago

looking for help on this too!

963431755 commented 8 years ago

me too!

Nikilicious09 commented 7 years ago

The problem can be because of the device (whether it support lpcm or not) try changing the method to - (void)setClientFormat:(AudioStreamBasicDescription)clientFormat { if(![FGAudioUtilities checkResult:ExtAudioFileSetProperty(self.info->extAudioFileRef, kExtAudioFileProperty_ClientDataFormat, sizeof(clientFormat), &clientFormat) operation:"Failed to set client format on recorded audio file"]) { clientFormat.mFormatID = kAudioFileM4AType; } self.info->clientFormat = clientFormat;

}