标签: audiounit

iOS上的自定义EQ AudioUnit

iOS上AudioUnit的唯一影响是"iTunes EQ",它只允许您使用EQ预设.我想在我的音频图表中使用自定义的eq

我在这个问题上遇到了这个问题,看到了一个答案,建议在渲染回调中使用这个DSP代码.这看起来很有希望,人们似乎在各种平台上有效地使用它.然而,即使平坦的eq,我的实施也有很多噪音.

这是我的20行集成到Apple的"MixerHost"示例应用程序的"MixerHostAudio"类(一次性提交):

https://github.com/tassock/mixerhost/commit/4b8b87028bfffe352ed67609f747858059a3e89b

关于如何让这个工作的任何想法?整合情商的任何其他策略?

编辑:这是我遇到的失真的一个例子(使用eq flat):http: //www.youtube.com/watch?v = W_6JaNUvUjA

audio objective-c core-audio audiounit ios

6
推荐指数
1
解决办法
3517
查看次数

设备中的iPhone AudioUnitRender错误-50

我正在开发一个项目,其中我使用了AudioUnitRender,它在模拟器中运行良好,但在设备中出现-50错误.

如果有人遇到类似的问题,请给我一些解决方案.

RIOInterface* THIS = (RIOInterface *)inRefCon;
COMPLEX_SPLIT A = THIS->A;
void *dataBuffer = THIS->dataBuffer;
float *outputBuffer = THIS->outputBuffer;
FFTSetup fftSetup = THIS->fftSetup;

uint32_t log2n = THIS->log2n;
uint32_t n = THIS->n;
uint32_t nOver2 = THIS->nOver2;
uint32_t stride = 1;
int bufferCapacity = THIS->bufferCapacity;
SInt16 index = THIS->index;

AudioUnit rioUnit = THIS->ioUnit;
OSStatus renderErr;
UInt32 bus1 = 1;

renderErr = AudioUnitRender(rioUnit, ioActionFlags, 
    inTimeStamp, bus1, inNumberFrames, THIS->bufferList);
NSLog(@"%d",renderErr);
if (renderErr < 0) {
    return renderErr;
}
Run Code Online (Sandbox Code Playgroud)

有关样本大小和框架的数据......

bytesPerSample = sizeof(SInt16);
asbd.mFormatID = …
Run Code Online (Sandbox Code Playgroud)

iphone audio device audiounit ios

6
推荐指数
1
解决办法
2552
查看次数

实时midi输入和音频同步

我已经构建了一个项目的独立应用程序版本,到目前为止只是一个VST/audiounit.我通过rtaudio提供音频支持.

我想使用rtmidi添加MIDI支持,但我不清楚如何同步音频和MIDI部分.

在VST/audiounit land中,我习惯于具有时间戳的MIDI事件,该时间戳指示从音频块的开始处的样本中的偏移.

rtmidi提供了自上次事件以来以秒为单位的增量时间,但我不确定如何抓住这些事件以及如何计算与音频线程中当前样本相关的时间.

插件主机如何做到这一点?

我可以理解事件在回放时的样本是如何准确的,但是在使用实时输入时它们是如何准确地采样的还不清楚.

rtaudio给了我一个回调函数.我将以低块大小运行(32个样本).我想我会将指向rtmidi实例的指针作为回调的userdata部分传递,然后调用midiin-> getMessage(&message); 在音频回调中,但我不确定这是否是线程敏感的.

非常感谢您给我的任何提示

audio midi vst audiounit

6
推荐指数
1
解决办法
1095
查看次数

在IOS核心音频中,您如何找到文件播放器音频单元的真实当前播放头位置?

我有一个程序,它使用文件播放器音频单元来播放,暂停和停止音频文件.我实现这一点的方法是初始化文件播放器音频单元以在零位置播放文件,然后当用户按下暂停按钮时,我停止AUGraph,捕获当前位置,然后使用该位置作为起始位置当用户按下播放按钮时.一切都按照应有的方式工作,但每经过3到4次暂停然后再播放,这首歌就会在我暂停的那一刻开始播放半秒到一秒.

我无法弄清楚为什么会发生这种情况,你们有什么想法吗?这是我的代码的简化版本.

//initialize AUGraph and File player Audio unit
...
...
...

//Start AUGraph 
...
...
...

// pause playback
- (void) pauseAUGraph {

//first stop the AuGrpah
        result = AUGraphStop (processingGraph);

// get current play head position        
        AudioTimeStamp ts;
        UInt32 size = sizeof(ts);

        result = AudioUnitGetProperty(filePlayerUnit, 
                                      kAudioUnitProperty_CurrentPlayTime, kAudioUnitScope_Global, 0, &ts, 
                                      &size);
        //save our play head position for use later
        //must add it to itself to take care of multiple presses of the pause button
        sampleFrameSavedPosition = sampleFrameSavedPosition + ts.mSampleTime; …
Run Code Online (Sandbox Code Playgroud)

iphone audio core-audio audiounit ios

6
推荐指数
1
解决办法
1821
查看次数

了解远程I/O AudioStreamBasicDescription(ASBD)

我需要帮助理解以下ASBD.这是分配给新实例的默认ASBD RemoteIO(我通过AudioUnitGetProperty(..., kAudioUnitProperty_StreamFormat, ...)RemoteIO音频单元上执行,在分配和初始化之后立即获得它).

Float64 mSampleRate        44100
UInt32  mFormatID          1819304813
UInt32  mFormatFlags       41
UInt32  mBytesPerPacket    4
UInt32  mFramesPerPacket   1
UInt32  mBytesPerFrame     4
UInt32  mChannelsPerFrame  2
UInt32  mBitsPerChannel    32
UInt32  mReserved          0
Run Code Online (Sandbox Code Playgroud)

问题是,不mBytesPerFrame应该8吗?如果每个通道有32位(4字节),每帧2个通道,那么每帧不应该是8个字节长(而不是4个)?

提前致谢.

signal-processing core-audio audio-recording audio-streaming audiounit

6
推荐指数
2
解决办法
980
查看次数

iOS AudioUnits通过

我正在尝试编写一个iOS应用程序,它将从麦克风接收的声音传递给扬声器而不做任何更改.我读过苹果文档和指南.我选择了本指南中的第一个模式.但没有任何事情发生 - 沉默.正如你所看到的,我已经尝试使用AUAudioGraph(注释) - 结果相同(我在这个简单的例子中是否需要它?).

我在互联网上看到了几个使用回调的例子,但我不想使用任何回调.可能吗?

有什么建议?谢谢你的关注.

实际的代码

#import "AudioController.h"
#import <AudioToolbox/AudioToolbox.h>
#import <AVFoundation/AVFoundation.h>
#import <AudioToolbox/AudioServices.h>
#define kInputBus 1
#define kOutputBus 0

@interface AudioController ()
{
    AudioComponentDescription desc;
    AudioComponent component;
    AudioUnit unit;
    AudioStreamBasicDescription audioFormat;
    double rate;
    //AUGraph graph;
}


@end

@implementation AudioController

- (void) setUp {
    AVAudioSession *sess = [AVAudioSession sharedInstance];
    NSError *error = nil;
    rate = 44100.0;
    [sess setPreferredSampleRate:rate error:&error];
    [sess setCategory:AVAudioSessionCategoryPlayAndRecord error:&error];
    [sess setActive:YES error:&error];
    rate = [sess sampleRate];
    if (error) {
        NSLog(@"%@", error);
    }

    NSLog(@"Init..."); …
Run Code Online (Sandbox Code Playgroud)

core-audio audiounit ios avaudiosession

6
推荐指数
1
解决办法
4226
查看次数

iOS输入麦克风输出蓝牙设备

我正在尝试从Mic获取输入并使用audioRouteOverride将其输出到我的蓝牙设备.但没有运气.iphone麦克风输出仍然是iphone内置扬声器.我期待kAudioSessionOutputRoute_BluetoothA2DP是这里的关键.但它没有按预期工作.

以下是我使用的代码:

- (id) init {
    self = [super init];

    OSStatus status;

    // Describe audio component
    AudioComponentDescription desc;
    desc.componentType = kAudioUnitType_Output;
    desc.componentSubType = kAudioUnitSubType_RemoteIO;
    desc.componentFlags = 0;
    desc.componentFlagsMask = 0;
    desc.componentManufacturer = kAudioUnitManufacturer_Apple;

    // Get component
    AudioComponent inputComponent = AudioComponentFindNext(NULL, &desc);

    // Get audio units
    status = AudioComponentInstanceNew(inputComponent, &audioUnit);
    checkStatus(status);

    // Enable IO for recording
    UInt32 flag = 1;
    status = AudioUnitSetProperty(audioUnit, 
                                  kAudioOutputUnitProperty_EnableIO, 
                                  kAudioUnitScope_Input, 
                                  kInputBus,
                                  &flag, 
                                  sizeof(flag));
    checkStatus(status);

    // Enable IO for playback
    status = AudioUnitSetProperty(audioUnit, 
                                  kAudioOutputUnitProperty_EnableIO, 
                                  kAudioUnitScope_Output, 
                                  kOutputBus,
                                  &flag, …
Run Code Online (Sandbox Code Playgroud)

core-audio iobluetooth audiounit ios avaudiosession

6
推荐指数
1
解决办法
2805
查看次数

CMSampleBufferSetDataBufferFromAudioBufferList 返回错误 12731

我正在尝试捕获应用程序声音并将其传递给 AVAssetWriter 作为输入。
我正在设置音频单元的回调以获取 AudioBufferList。
问题始于将 AudioBufferList 转换为 CMSampleBufferRef。
它总是返回错误 -12731,这表明缺少所需的参数,

谢谢
Karol

-(OSStatus) recordingCallbackWithRef:(void*)inRefCon
                            flags:(AudioUnitRenderActionFlags*)flags
                        timeStamp:(const AudioTimeStamp*)timeStamp
                        busNumber:(UInt32)busNumber
                     framesNumber:(UInt32)numberOfFrames
                             data:(AudioBufferList*)data
{

AudioBufferList bufferList;
bufferList.mNumberBuffers = 1;
bufferList.mBuffers[0].mData = NULL;

OSStatus status;

status = AudioUnitRender(audioUnit,
                         flags,
                         timeStamp,
                         busNumber,
                         numberOfFrames,
                         &bufferList);
[self checkOSStatus:status];

AudioStreamBasicDescription audioFormat;
// Describe format
audioFormat.mSampleRate         = 44100.00;
audioFormat.mFormatID           = kAudioFormatLinearPCM;
audioFormat.mFormatFlags        = kAudioFormatFlagIsSignedInteger | kAudioFormatFlagIsPacked;
audioFormat.mFramesPerPacket    = 1;
audioFormat.mChannelsPerFrame   = 1;
audioFormat.mBitsPerChannel     = 16;
audioFormat.mBytesPerPacket     = 2;
audioFormat.mBytesPerFrame      = 2;

CMSampleBufferRef buff = NULL;
CMFormatDescriptionRef format = …
Run Code Online (Sandbox Code Playgroud)

iphone core-audio avfoundation audiounit ios

6
推荐指数
1
解决办法
2013
查看次数

在iOS中使用EPSSampler时,请使用系统通道而不是振铃通道

我正在使用EPSSampler在我的小iOS应用程序中播放一些笔记.除了通过振铃设置而不是系统音量设置控制声音之外,它的效果很好.问题是,如果铃声关闭,我的应用程序没有声音.

我能找到的最接近的是这个问题,但我无法将该解决方案完全转化为我的解决方案,因为我无法将其与EPSSampler的代码相匹配.任何见解?

编辑为了澄清,唯一专门处理音频的代码包含在EPSSampler类中,我的app只是实例,加载AUSampler预设,并调用EPSSampler中的音符播放方法,因此解决方案需要在EPSSampler中更改某些内容而不是在我的应用程序 - 这就是为什么我没有发布任何源代码.

avaudioplayer audiounit ios

6
推荐指数
1
解决办法
71
查看次数

AUAudioUnit 和 AudioUnitGetProperty、AudioUnitSetProperty

随着 Audio Unit v3 的到来,我们子类的主要类是新的 AUAudioUnit 目标 C 类。

AUAudioUnit 具有 AUParameter 实现,并且可以通过 AUAudioUnit.parameterTree 属性轻松使用 AUParameter。

我无法使用音频单元属性,因为 AUAudioUnit 不公开其作为参数所需的 AudioUnit 属性

extern OSStatus
AudioUnitGetProperty(           AudioUnit               inUnit,
                                AudioUnitPropertyID     inID,
                                AudioUnitScope          inScope,
                                AudioUnitElement        inElement,
                                void *                  outData,
                                UInt32 *                ioDataSize) 
Run Code Online (Sandbox Code Playgroud)

目前,AUAudioUnit 上没有 AudioUnit 类属性或检查。我不确定如何在 AudioUnit v3 框架中使用 AudioUnit 属性。

有人知道如何在新 API v3 中使用 AudioUnit 属性吗?

谢谢。

core-audio avfoundation audiounit

6
推荐指数
1
解决办法
895
查看次数