Questions tagged [avaudiopcmbuffer]
54 questions
23
votes
2 answers
Convert AVAudioPCMBuffer to NSData and back
How to convert AVAudioPCMBuffer to NSData? If it should be done as
let data = NSData(bytes: buffer.floatChannelData, length: bufferLength)
then how to calculate bufferLength?
And how to convert NSData to AVAudioPCMBuffer?

Shmidt
- 16,436
- 18
- 88
- 136
16
votes
1 answer
Decode AAC to PCM format using AVAudioConverter Swift
How convert AAC to PCM using AVAudioConverter, AVAudioCompressedBuffer and AVAudioPCMBuffer on Swift?
On WWDC 2015, 507 Session was said, that AVAudioConverter can encode and decode PCM buffer, was showed encode example, but wasn't showed examples…

Vladimir Prigarin
- 436
- 5
- 20
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
8
votes
2 answers
On extracting the sound pressure level from AVAudioPCMBuffer
I have almost no knowledge in signal-processing and currently I'm trying to implement a function in Swift that triggers an event when there is an increase in the sound pressure level (e.g. when a human screams).
I am tapping into an input node of…

Archy Will He 何魏奇
- 9,589
- 4
- 34
- 50
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
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…

Jason Yee
- 41
- 3
4
votes
1 answer
Play segment of AVAudioPCMBuffer
I'm creating this simple audio recorder and editor interface for an iOS app:
The audio is recorded into a float array that is used to create the waveform. After recording I copy the float data into an AVAudioPCMBuffer for playing with…

torof
- 368
- 1
- 12
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
1 answer
AVAudioPlayerNode multichannel audio control
I have successfully used AVAudioPlayerNode to play stereo and mono files. I would like to use files with 3+ channels (surround files) and be able to route the audio in a non-linear way. For instance, I could assign file channel 0 to output channel…

GW.Rodriguez
- 1,181
- 8
- 18
4
votes
1 answer
Accessing Float samples of AVAudioPCMBuffer for processing
I am trying to do some computation on the raw PCM samples of a mp3 files I'm playing with an AVAudioEngine graph. I have a closure every 44100 samples that provides an AVAudioPCMBuffer. It has a property channelData of type…

Alex Bollbach
- 4,370
- 9
- 32
- 80
4
votes
0 answers
How to save the audio recorded with pitch changed?
I'm working on recording the voice then change the pitch of the audio and save.
I call this method after recording the voice and click on the button to change the pitch then the new file is also created but the not not able to listen the audio the…

Mitesh Varu
- 246
- 1
- 14
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
How to modify a AVAudioPCMBuffer in swift
does anybody know how to modify the buffer contents of
an AVAudioPCMBuffer object? I want to do the following:
load an audio file into an AVAudioPCMBuffer - this works.
modify the samples data of the AVAudioPCMBuffer. - here i stuck
write the…

nik
- 181
- 1
- 6
3
votes
1 answer
Converting NSData to AVAudioPCMBuffer
I've got a data stream, specifically coming from an MP3 stream.
In an attempt to convert it to an AVAudioPCBBuffer, I'm creating an AVAudioFormat to describe it as follows:
AVAudioFormat* format = [[AVAudioFormat alloc]…

gerbil
- 859
- 7
- 26
3
votes
1 answer
How can mp3 data in memory be loaded into an AVAudioPCMBuffer in Swift?
I have a class method to read an mp3 file into an AVAudioPCMBuffer as follows:
private(set) var fullAudio: AVAudioPCMBuffer?
func initAudio(audioFileURL: URL) -> Bool {
var status = true
do {
let audioFile = try…

gimbal
- 63
- 8