core-audio

iOS Code to Convert m4a to WAV

夙愿已清 提交于 2019-11-27 15:24:55
问题 Does anyone have any code snippets that show how to convert an M4a file to WAV? I know there are libraries that convert the other way around. Thanks. 回答1: Just to update for Swift 3: func convertAudio(_ url: URL, outputURL: URL) { var error : OSStatus = noErr var destinationFile: ExtAudioFileRef? = nil var sourceFile : ExtAudioFileRef? = nil var srcFormat : AudioStreamBasicDescription = AudioStreamBasicDescription() var dstFormat : AudioStreamBasicDescription = AudioStreamBasicDescription()

AVAudioEngine multiple AVAudioInputNodes do not play in perfect sync

时间秒杀一切 提交于 2019-11-27 15:07:19
问题 I've been trying to use AVAudioEngine to schedule multiple audio files to play in perfect sync, but when listening to the output there seems to be a very slight delay between input nodes. The audio engine is implemented using the following graph: // //AVAudioPlayerNode1 --> //AVAudioPlayerNode2 --> //AVAudioPlayerNode3 --> AVAudioMixerNode --> AVAudioUnitVarispeed ---> AvAudioOutputNode //AVAudioPlayerNode4 --> | //AVAudioPlayerNode5 --> AudioTap // | //AVAudioPCMBuffers // And I am using the

Forcing iPhone Microphone as Audio Input

亡梦爱人 提交于 2019-11-27 14:26:36
I am developing an iOS application (targetted specifically for iPhone, at the moment) that requires the application to record audio only from iPhone internal microphone (even when headphone/headset is plugged in), and playback at headphone (let's assumed headphone is plugged in for now). I am wondering if this is currently possible with the available APIs? If so, can anyone please shed some light on how do I go about doing this? Thanks! I believe the answer to this question to be 'no'. I used an iPhone 4 and the new-to-iOS 4 AVFoundation to experiment, focussing on the AVCaptureDevice class. I

How to manually convert 8.24-bit deinterleaved lpcm to 16-bit lpcm?

本秂侑毒 提交于 2019-11-27 14:10:25
问题 I have a chunk of data (void*) which is 2 ch, 44100 Hz, 'lpcm' 8.24-bit little-endian signed integer, deinterleaved. I need to record that chunk to a file as 2 ch, 44100 Hz, 'lpcm' 16-bit little-endian signed integer. How do I convert data? I can imagine I need to do something like this: uint dataByteSize = sizeof(UInt32) * samplesCount; UInt32* source = ...; UInt32* dest = (UInt32*)malloc(dataByteSize); for (int i = 0; i < samplesCount; ++i) { UInt32 sourceSample = source[i]; UInt32

iPhone SDK: AVAudioRecorder metering — how to change peakPowerForChannel from decibel into percentage?

北慕城南 提交于 2019-11-27 13:16:59
问题 The AVAudioRecorder in the iPhone SDK can be used to get the peak and average power for a channel, in decibels. The range is between 0db to 160db. What is the calculation used to convert this into a scale between 0 - 10 or something similar that can be used for an audio level meter? 回答1: The range is from -160 dB to 0 dB. You probably want to display it in a meter that goes from -90 dB to 0 dB. Displaying it as decibels is actually more useful than as a linear audio level, because the

How to get array of float audio data from AudioQueueRef in iOS?

安稳与你 提交于 2019-11-27 12:27:53
问题 I'm working on getting audio into the iPhone in a form where I can pass it to a (C++) analysis algorithm. There are, of course, many options: the AudioQueue tutorial at trailsinthesand gets things started. The audio callback, though, gives an AudioQueueRef , and I'm finding Apple's documentation thin on this side of things. Built-in methods to write to a file, but nothing where you actually peer inside the packets to see the data. I need data. I don't want to write anything to a file, which

Playing back audio using AVAudioPlayer iOS 7

旧街凉风 提交于 2019-11-27 09:52:56
I'm struggling to follow Apple's documentation regarding playing back a small .wav file using the AVAudioPlayer class. I'm also not sure what toolboxes I need for basic audio playback. So far I have imported: AVFoundation.framework CoreAudio.framework AudioToolbox.framework Here is my code .h and .m : #import <UIKit/UIKit.h> #import <AVFoundation/AVFoundation.h> @interface ViewController : UIViewController <AVAudioPlayerDelegate> - (IBAction)playAudio:(id)sender; @end #import "ViewController.h" @interface ViewController () @end @implementation ViewController - (void)viewDidLoad { [super

Trim audio with iOS

一曲冷凌霜 提交于 2019-11-27 07:55:11
I want to implement a feature that lets the user trim an audio file (.caf) which he perviously recorded. The recording part already works, but how can i add a trimming feature similar to the one in the Voicememos app. Is there an api for the audio trimmer apple uses? Any help would be great... How about using the AVFoundation? Import the audio file into an AVAsset (composition etc), then you can export it - setting preferred time + duration - to a file. I wrote a stock function awhile ago that exports an asset to a file, you can also specify an audiomix. As below it exports all of the file,

AudioObjectGetPropertyData to get a list of input devices

元气小坏坏 提交于 2019-11-27 07:41:33
How do I utilize AudioObjectGetPropertyData in OS X to retrieve a list of the system's input devices? I currently have the following dummy code for retrieving a global list of devices: AudioDeviceID devices[12]; UInt32 arraySize = sizeof(devices); AudioObjectPropertyAddress thePropertyAddress = { kAudioHardwarePropertyDevices, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster }; AudioObjectGetPropertyData(kAudioObjectSystemObject, &thePropertyAddress, 0, NULL, &arraySize, &devices); To determine if a device is an input device you need to check and see if it has any input

Get Hz frequency from audio stream on iPhone

99封情书 提交于 2019-11-27 06:42:22
What would be the best way to get Hz frequency value from audio stream(music) on iOS? What are the best and easiest frameworks provided by Apple to do that. Thanks in advance. Bjorn Roche Questions like this are asked a lot here on SO. (I've answered a similar one here ) so I wrote a little tutorial with code that you can use even in commercial and closed source apps. This is not necessarily the BEST way, but it's a way that many people understand. You will have to modify it based on what you mean by "Hz average value of every short music segment". Do you mean the fundamental pitch or the