我正在开发iphone 3GS上的低音吉他音高检测应用程序.我发现使用RemoteIO无法获得低于150Hz的声音数据.然而,低音吉他可能会产生低于50hz的音调.根据报告"iPhone 4耳机输入频率响应",http://blog.faberacoustical.com/2010/iphone/iphone-4-audio-and-frequency-response-limitations/ 150以下急剧下降赫兹.
这里显示了我如何设置AudioUnit.
// set audio unit
{
// create AudioUnit
{
AudioComponentDescription desc;
desc.componentType = kAudioUnitType_Output;
desc.componentSubType = kAudioUnitSubType_RemoteIO;
desc.componentManufacturer = kAudioUnitManufacturer_Apple;
desc.componentFlags = 0;
desc.componentFlagsMask = 0;
AudioComponent comp = AudioComponentFindNext(NULL, &desc);
OSAssert(AudioComponentInstanceNew(comp, &m_AudioUnit));
}
//enable input on the remote I/O unit (output is default enabled, but input is not)
{
UInt32 one = 1;
OSAssert(AudioUnitSetProperty(m_AudioUnit, kAudioOutputUnitProperty_EnableIO,
kAudioUnitScope_Input, 1, &one, sizeof(one)));
}
//set render callback function
{
AURenderCallbackStruct callbackInfo;
callbackInfo.inputProc=staticPerformThru;
callbackInfo.inputProcRefCon=this;
OSAssert(AudioUnitSetProperty(m_AudioUnit,
kAudioUnitProperty_SetRenderCallback,
kAudioUnitScope_Input,
0, …
Run Code Online (Sandbox Code Playgroud) 我使用AVAssetExportSession导出ipod库中的mp3/m4a文件.此方法适用于iOS 5.0及更早版本.但是在将iOS升级到5.1之后,此方法不再适用于mp3,但仍适用于m4a.
这是源代码.
AVURLAsset *songAsset = [AVURLAsset URLAssetWithURL: [mediaItem assetUrl] options:nil];
NSLog (@"compatible presets for songAsset: %@",[AVAssetExportSession exportPresetsCompatibleWithAsset:songAsset]);
AVAssetExportSession *exporter = [[AVAssetExportSession alloc]
initWithAsset: songAsset
presetName: AVAssetExportPresetPassthrough];
NSLog (@"created exporter. supportedFileTypes: %@", exporter.supportedFileTypes);
NSLog(@"output file type=%@",[mediaItem fileType]);
NSLog(@"export file path=%@",exportPath);
exporter.outputFileType =[mediaItem fileType];
NSError *error1;
error1=0;
if([[NSFileManager defaultManager] fileExistsAtPath:exportPath])
{
[[NSFileManager defaultManager] removeItemAtPath:exportPath error:&error1];
if(error1)
NSLog(@"%@",error1);
}
NSURL* exportURL = [NSURL fileURLWithPath:exportPath];
exporter.outputURL = exportURL;
// do the export
[exporter exportAsynchronouslyWithCompletionHandler:^{
int exportStatus = exporter.status;
switch (exportStatus) {
case AVAssetExportSessionStatusFailed: …
Run Code Online (Sandbox Code Playgroud)