Questions tagged [avaudiofile]

58 questions
9
votes
5 answers

how to play sound with AVAudioPCMBuffer

I Cannot play sound with AVAudioPCMBuffer (though I could play with AVAudioFile). I got this error. ERROR: AVAudioBuffer.mm:169: -[AVAudioPCMBuffer initWithPCMFormat:frameCapacity:]: required condition is false: isCommonFormat here is my code below,…
Bick
  • 713
  • 1
  • 8
  • 17
6
votes
2 answers

SWIFT - Is it possible to save audio from AVAudioEngine, or from AudioPlayerNode? If yes, how?

I've been looking around Swift documentation to save an audio output from AVAudioEngine but I couldn't find any useful tip. Any suggestion? Solution I found a way around thanks to matt's answer. Here a sample code of how to save an audio after…
mlk
  • 389
  • 2
  • 10
5
votes
3 answers

How to search the error code of 'com.apple.coreaudio.avfaudio'?

Where could I get the information of com.apple.coreaudio.avfaudio error codes, such as: Terminating app due to uncaught exception 'com.apple.coreaudio.avfaudio', reason: 'error -50' I always get an error while writing PCM buffer to AVAudioFile.…
Edward_Sun
  • 81
  • 1
  • 6
5
votes
0 answers

During cascading 2 audio files tracksWithMediaType always returns empty array

I have 2 audio files audioFile1.m4a and audioFile2.m4a. I want to create a cascaded audio combined.m4a which contains audioFile1.m4a and audioFile2.m4a, one after another. I used below code and my problem is tracksWithMediaType always returns empty…
Jaffer Sheriff
  • 1,274
  • 9
  • 29
5
votes
1 answer

AVAudioFile.length is 0 even if file exists

I'm creating an AVAudioFile for writing sound to a sound file. If the file already exists I want to move the framePosition to the end of the file, to continue writing at the end, instead of replacing the existing file. I did some tests, trying to…
andlin
  • 3,534
  • 3
  • 25
  • 43
5
votes
1 answer

AudioFileReadPackets deprecated in iOS8

I am getting strange behaviour with AudioFileReadPackets since it's been deprecated in iOS 8. How should it be replaced?
Cristian Pena
  • 1,989
  • 16
  • 30
4
votes
0 answers

Change encoder format version

I have, for the past week, been trying to take audio from the microphone (on iOS), down sample it and write that to a '.aac' file. I've finally gotten to point where it's almost working let inputNode = audioEngine.inputNode let inputFormat =…
MadProgrammer
  • 323,026
  • 21
  • 204
  • 329
4
votes
1 answer

How can I play a sound from the asset catalog using AVAudioPlayerNode?

I'm trying to use an AVAudioPlayerNode to play sounds from the Assets.xcassets asset catalog, but I can't figure out how to do it. I've been using AVAudioPlayer, which can be initialized with an NSDataAsset like this: let sound = NSDataAsset(name:…
Robert
  • 6,182
  • 5
  • 33
  • 58
4
votes
0 answers

IOS copying a part of AVAudioPCMBuffer to another

I have AVAudioPCMBuffer which I want to copy a portion of to other buffer (cutting some part of the voice from the end of it ) let samples = Array(UnsafeBufferPointer(start: buffer.floatChannelData![0], count:Int(buffer.frameLength))) let…
user3703910
  • 604
  • 1
  • 5
  • 22
4
votes
2 answers

iOS Swift malloc error

I want to record audio on iOS in real time, analyze the raw audio data and save parts of the recorded data. I'm recording the data with this code: https://gist.github.com/hotpaw2/ba815fc23b5d642705f2b1dedfaf0107 Now, my data is saved in a Float…
4
votes
1 answer

AVAudioFile doesn't play in AVAudioEngine

I'm attempting to play an AVAudioFile using the AVAudioEngine. The code is largely taken and adapted from the Apple Developer on-line videos, but there is no playback. Have spent some time going through the forums, but nothing seems to throw any…
aseago
  • 43
  • 4
4
votes
0 answers

Writing mono AVAudioPCMBuffer to stereo AVAudioFile

I'm using AVAudioEngine to record audio, and saving it as a sound file. The user can choose to import an audio file, and they can then continue to record at the end of this file if they wish to. I'm getting the audio data from the imported file by…
andlin
  • 3,534
  • 3
  • 25
  • 43
3
votes
1 answer

Crash on Read AVAudioFile Buffer Create Waves Swift

I have been working in AVAudioPlayer and draw a wave. I am using AudioArmada Github pods to draw waves With the help of AudioArmada Pods. But Some Cases AVAudioFile Crash on reading buffer time. Code Below: public func openFile(_ file: URL) { …
Sham Dhiman
  • 544
  • 6
  • 26
3
votes
2 answers

Error when installing a tap on audio engine input node

whenever the code reaches inputNode.installTap(onBus: 0, bufferSize: 1024, format: recordingFormat) {[weak self] (buffer:AVAudioPCMBuffer, when:AVAudioTime), app is crashing with following error Terminating app due to uncaught exception…
mahdi
  • 360
  • 2
  • 15
3
votes
1 answer

Writing AVAudioPCMBuffer into an AVAudioFile compressed

We're working on an application which records and persists microphone input. The use of AVAudioRecorder was not an option, because real-time audio processing is needed. AVAudioEngine is used because it provides low-level access to the input…
1
2 3 4