avaudiopcmbuffer

AVAudioCompressedBuffer to UInt8 array and vice versa

≯℡__Kan透↙ 提交于 2021-02-19 20:57:05
问题 I would like to know how to get the bytes of an AVAudioCompressedBuffer and then reconstruct an AVAudioCompressedBuffer from the bytes. The code below takes an AVAudioPCMBuffer, compresses it with AVAudioConverter to AVAudioCompressedBuffer (iLBC) and gets the bytes, then converts the bytes back to AVAudioCompressedBuffer (iLBC) and uncompresses back to AVAudioPCMBuffer and plays the buffer. Something goes wrong with converting the AVAudioCompressedBuffer to bytes and back. If I skip this

AVAudioCompressedBuffer to UInt8 array and vice versa

Deadly 提交于 2021-02-19 20:56:15
问题 I would like to know how to get the bytes of an AVAudioCompressedBuffer and then reconstruct an AVAudioCompressedBuffer from the bytes. The code below takes an AVAudioPCMBuffer, compresses it with AVAudioConverter to AVAudioCompressedBuffer (iLBC) and gets the bytes, then converts the bytes back to AVAudioCompressedBuffer (iLBC) and uncompresses back to AVAudioPCMBuffer and plays the buffer. Something goes wrong with converting the AVAudioCompressedBuffer to bytes and back. If I skip this

Schedule buffer with AVAudioPCMBuffer int16 data

那年仲夏 提交于 2021-01-29 14:58:04
问题 I'm trying to play music from byte array which is coming from the network in pcmInt16 data format. // formats let format1 = AVAudioFormat(commonFormat: AVAudioCommonFormat.pcmFormatFloat32, sampleRate: 48000, channels: 1, interleaved: false)! let format2 = AVAudioFormat(commonFormat: AVAudioCommonFormat.pcmFormatInt16, sampleRate: 48000, channels: 1, interleaved: false)! // byte array buffer var byteArray: [Int16]! // one packet size is 512 ... // 1. create / attach / connect engine engine

AVAudioPCMBuffer able to get audio with static/white noise only

做~自己de王妃 提交于 2020-03-25 18:38:13
问题 Thank you for taking the time and reading my question. Target : I am getting some audio data from UDP server and I have to convert them into PCM format to play the actual audio realtime. Query: For some reason using below code did not work for the format of my AVAudioPCMBuffer and yielded no sound, or a memory error. However, I am able to get white noise/static to play from the speakers by converting the NSData to a AVAudioPCMBuffer. I have a feeling that I am getting close to the answer,

Decode AAC to PCM format using AVAudioConverter Swift

泪湿孤枕 提交于 2020-02-18 05:20:26
问题 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 with decoding. I tried decode, and something doesn't work. I don't know what:( Calls: //buffer - it's AVAudioPCMBuffer from AVAudioInputNode(AVAudioEngine) let aacBuffer = AudioBufferConverter.convertToAAC(from: buffer, error: nil) //has data let

how to play sound with AVAudioPCMBuffer

你。 提交于 2019-12-21 04:49:08
问题 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, and I'd really appreciate for your help. import UIKit import AVFoundation class ViewController: UIViewController { let audioEngine: AVAudioEngine = AVAudioEngine() let audioFilePlayer: AVAudioPlayerNode = AVAudioPlayerNode() override func

AVAudioPCMBuffer for music files

邮差的信 提交于 2019-12-12 09:17:15
问题 I've been trying to play music in my SpriteKit game and used the AVAudioPlayerNode class to do so via AVAudioPCMBuffer s. Every time I exported my OS X project, it would crash and give me an error regarding audio playback. After banging my head against the wall for the last 24 hours I decided to re-watch WWDC session 501 (see 54:17). My solution to this problem was what the presenter used, which is to break the frames of the buffer into smaller pieces to break up the audio file being read.

Converting AVAudioPCMBuffer to NSData

吃可爱长大的小学妹 提交于 2019-12-11 17:13:36
问题 I'm currently trying to convert the audio samples from AVAudioPCMBuffer to NSData - I had taken a look at the accepted answer on this SO Post and this code from GitHub but it appears some of the AVFAudio API's have changed...below is the extension I have for AVAudioPCMBuffer : private extension AVAudioPCMBuffer { func toNSData() -> NSData { let channels = UnsafeBufferPointer(start: int16ChannelData, count: 1) let ch0Data = NSData(bytes: channels[0], length:Int(frameCapacity * format

AVAudioPCMBuffer built programmatically, not playing back in stereo

眉间皱痕 提交于 2019-12-10 21:55:32
问题 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 metronome looping accurately. I'm trying to build an AVAudioPCMBuffer with the length of a measure/bar so that I can use the .Loops option of the AVAudioPlayerNode's scheduleBuffer method. I start by loading my file(2 ch, 44100 Hz, Float32, non

How to save the audio recorded with pitch changed?

情到浓时终转凉″ 提交于 2019-12-07 08:00:44
问题 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 audio is generated with out voice what may be the error? -(void)saveEffectedAudioToFolder { NSError *error; if (_audioEngine) { AVAudioUnitTimePitch *pitchEffect = [AVAudioUnitTimePitch new]; pitchEffect.pitch = pitch; AVAudioFormat * commonFormat =