Questions tagged [avaudiopcmbuffer]

41 questions
17
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
  • 15,652
  • 16
  • 79
  • 129
14
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…
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
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,103
  • 4
  • 29
  • 47
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
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
  • 3,730
  • 2
  • 25
  • 61
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…
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

Swift: How to stop scheduleBuffer completion handler being called when interrupted?

I have a AVAudioPlayerNode that I'm scheduling a lot of buffers on using the following: node.scheduleBuffer(buffer, at: nil, options: .interrupts, completionHandler: completeFunc) But I'm having a bit of a problem. If I play another buffer…
MysteryPancake
  • 1,125
  • 1
  • 13
  • 36
3
votes
2 answers

AVAudioPCMBuffer built programmatically, not playing back in stereo

I'm trying to fill an AVAudioPCMBuffer programmatically in Swift to build a metronome. This is the first real app I'm trying to build, so it's also my first audio app. Right now I'm experimenting with different frameworks and methods of getting the…
3
votes
0 answers

how to create AVAudioPCMBuffer from NSData

I receive mp3 from stream and convert pcm data. I try to use AVAudioEngine but can not create AVAudioPCMBuffer without file. - (void)playAudio:(NSNotification *)notification { self.runAudioThread = YES; dispatch_queue_t…
3
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
  • 151
  • 1
  • 6
3
votes
0 answers

How to remove silence from an audioFile

I have recorded an audio file using AVAudioEngine: [mainMixer installTapOnBus:0 bufferSize:4096 format:[mainMixer outputFormatForBus:0] block:^(AVAudioPCMBuffer *buffer, AVAudioTime *when) { NSError *error; // as AVAudioPCMBuffer's are…
Thomas
  • 177
  • 2
  • 9
3
votes
1 answer

Audible glitches on buffer playback via AVAudioPlayerNode in iOS (Swift) *working in simulator, but not on device

When using an AVAudioPlayerNode to schedule a short buffer to play immediately on a touch event ("Touch Up Inside"), I've noticed audible glitches / artifacts on playback while testing. The audio does not glitch at all in iOS simulator, however…
1
2 3