Processing of mono AKAudioFiles causes crash #853

Closed
Audiograins opened this Issue Apr 18, 2017 · 6 comments

Comments

Projects
None yet
2 participants
@Audiograins

It seems that attempting to process a mono AKAudioFile will result in a crash. I tested this for both normalize() and reverse() and got the same result . I think normalized() is expecting self to be an array of floats so if the input to the function is mono it will result in a crash.

Log info below -

deleteFileWithFileName "131B033D-552D-4291-92C9-436C26C0376C.caf" deleted.
deleteFileWithFileName "3725B2AB-51C1-4E39-903F-234E9BA76679.caf" deleted.
deleteFileWithFileName "temp_recording.caf" deleted.
cleanTempDirectory() 3 files deleted
End of ViewDidLoad
This is run on the background queue
updatePCMBuffer() read 2383220 frames into buffer
-0.000132538
This is run on the main queue, after the previous code in outer block
2017-04-18 16:04:15.787097-0700 IASIAR[2021:298322] [central] 54:   ERROR:    [0x16dfdb000] >avae> AVAudioFile.mm:306: -[AVAudioFile writeFromBuffer:error:]: error -50
2017-04-18 16:04:15.787543-0700 IASIAR[2021:298322] *** Terminating app due to uncaught exception 'com.apple.coreaudio.avfaudio', reason: 'error -50'
*** First throw call stack:
(0x183b5efd8 0x1825c0538 0x183b5eeac 0x19dd131cc 0x19dd811dc 0x1003fd908 0x1003fd190 0x10035b36c 0x100078268 0x10007a830 0x1012d5a50 0x1012d5a10 0x1012e57dc 0x1012e539c 0x182c1f1d0 0x182c1ed7c)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 
@aure

This comment has been minimized.

Show comment
Hide comment
@aure

aure Apr 19, 2017

Member

Its quite possible that it expects the files to have the same number of channels as in the AudioKit settings.

Member

aure commented Apr 19, 2017

Its quite possible that it expects the files to have the same number of channels as in the AudioKit settings.

@Audiograins

This comment has been minimized.

Show comment
Hide comment
@Audiograins

Audiograins Apr 19, 2017

Thanks Aure, I just updated the code with AKSettings.numberOfChannels = 1 and load only mono files but I get the same error, so that doesn't seem to be the case

Thanks Aure, I just updated the code with AKSettings.numberOfChannels = 1 and load only mono files but I get the same error, so that doesn't seem to be the case

@aure

This comment has been minimized.

Show comment
Hide comment
@aure

aure Apr 22, 2017

Member

I'm thinking this might be easiest solved by converting the file to stereo, doing the processing, then creating a mono file again by dropping a channel.

Member

aure commented Apr 22, 2017

I'm thinking this might be easiest solved by converting the file to stereo, doing the processing, then creating a mono file again by dropping a channel.

@Audiograins

This comment has been minimized.

Show comment
Hide comment
@Audiograins

Audiograins Apr 25, 2017

That should be easy enough to do alright. Is there a function or approach in AudioKit to do this already?

That should be easy enough to do alright. Is there a function or approach in AudioKit to do this already?

@aure

This comment has been minimized.

Show comment
Hide comment
@aure

aure May 4, 2017

Member

So, there are two parts of AudioKit that convert a file from stereo to mono, and it is in Swift:

https://github.com/audiokit/AudioKit/blob/master/AudioKit/Common/Nodes/Effects/Reverb/Convolution/AKConvolution.swift#L62

Member

aure commented May 4, 2017

So, there are two parts of AudioKit that convert a file from stereo to mono, and it is in Swift:

https://github.com/audiokit/AudioKit/blob/master/AudioKit/Common/Nodes/Effects/Reverb/Convolution/AKConvolution.swift#L62

@aure

This comment has been minimized.

Show comment
Hide comment
@aure

aure Jun 1, 2017

Member

AKSamplePlayer is a new player that creates a stereo file from a mono signal. I think you just need to use that code to create the file, process it and then do the conversion back to mono. Sorry that it has to be so convoluted, but we're just very stereo-centric with AudioKit.

Member

aure commented Jun 1, 2017

AKSamplePlayer is a new player that creates a stereo file from a mono signal. I think you just need to use that code to create the file, process it and then do the conversion back to mono. Sorry that it has to be so convoluted, but we're just very stereo-centric with AudioKit.

@aure aure closed this Jun 1, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment