Questions tagged [avaudiofile]

65 questions
12
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
  • 743
  • 2
  • 8
  • 18
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
  • 388
  • 2
  • 10
5
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…
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,444
  • 13
  • 33
5
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…
rodskagg
  • 3,827
  • 4
  • 27
  • 46
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…
rodskagg
  • 3,827
  • 4
  • 27
  • 46
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
  • 2,139
  • 1
  • 19
  • 31
4
votes
0 answers

Write incoming audio raw data to AVAudioPCMBuffer of AVAudioFile and play AVAudioFile

I'm receiving packets of audio raw data within a callback function with the following properties: 640 samples per packet 32 kHz sampling rate Signed 16-Bit PCM encoding Single channel In other words, each packet of incoming audio data is an array…
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
  • 343,457
  • 22
  • 230
  • 366
4
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
  • 439
  • 3
  • 15
4
votes
1 answer

Read an AVAudioFile into a buffer starting at a certain time

Let's say I have an AVAudioFile with a duration of 10 seconds. I want to load that file into an AVAudioPCMBuffer but I only want to load the audio frames that come after a certain number of seconds/milliseconds or after a certain…
WongWray
  • 2,414
  • 1
  • 20
  • 25
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,660
  • 5
  • 39
  • 62
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
  • 624
  • 1
  • 5
  • 25
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…
1
2 3 4 5