标签: audiounit

音频单元记录:增加缓冲区的容量

我正在为iPhone构建一个录音应用程序,我在其中使用远程音频设备.在对传入缓冲区执行某些音频分析后,我使用以下方法将缓冲区写入磁盘

ExtAudioFileWriteAsync

但是,我遇到的问题是记录的缓冲区比我想要的更安静.

我想通过在写入磁盘之前手动将它们乘以体积因子来增加缓冲区的容量.任何人都可以向我解释最好的方法吗?

(由于各种原因,最后阶段的手动调整比更改任何音频单元属性更有吸引力,否则这些属性对我的应用程序很有用.)

提前致谢!!

xcode core-audio audiounit ios

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

ExtAudioFileRead太慢了.如何让它更快?

我写了自己的音频库.(傻,我知道,但我喜欢它.)现在,我正在用它来播放iOS上iPod库的立体声文件.它运行良好,但有时调用ExtAudioFileRead()的时间超过23毫秒.由于我的AudioUnits输出设置正在以44.1KHz播放音频,并且它要求每回调1024帧.我的代码+ ExtAudioFileRead()的响应时间不得超过23毫秒.

我很惊讶ExtAudioFileRead()太慢了.我正在做的事似乎很正常.我在想,必须有一些我没有做过的无证配置魔法.这是我的相关配置代码:

ExtAudioFileRef _extAudioFileRef;
OSStatus        result;

result = ::ExtAudioFileOpenURL((__bridge CFURLRef)_url, &_extAudioFileRef);

AudioStreamBasicDescription     format;

format.mBitsPerChannel = 8 * sizeof(float);
format.mBytesPerFrame = sizeof(float);
format.mBytesPerPacket = sizeof(float);
format.mChannelsPerFrame = channelCount;
format.mFormatFlags = kAudioFormatFlagIsFloat|kAudioFormatFlagIsNonInterleaved;
format.mFormatID = kAudioFormatLinearPCM;
format.mFramesPerPacket = 1;
format.mSampleRate = framesPerSecond;
result = ::ExtAudioFileSetProperty(_extAudioFileRef,
                                    kExtAudioFileProperty_ClientDataFormat,
                                    sizeof(format),
                                    &format);
Run Code Online (Sandbox Code Playgroud)

我没有设置_extAudioFileRef的任何其他属性.

我已经跟踪了这个问题.我只是调用ExtAudioFileRead()来调整时间,所以我知道这不是我的代码减慢了这个过程.它必须是配置问题,对吧?

非常感谢任何帮助甚至猜测!

干杯,克里斯托弗

core-audio extaudiofile audiounit ios extaudiofileread

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

如何使用音频单元 osx 从设备音频输入获取音频

我花了很长时间试图弄清楚如何使用音频单元从用户麦克风获取声音,以便我可以在音频单元录音回调中使用它,但我仍然堆栈。

- (OSStatus) setupMicInput {
AudioObjectPropertyAddress addr;
UInt32 size = sizeof(AudioDeviceID);
AudioDeviceID deviceID = 0;

addr.mSelector = kAudioHardwarePropertyDefaultInputDevice;
addr.mScope = kAudioObjectPropertyScopeGlobal;
addr.mElement = kAudioObjectPropertyElementMaster;

OSStatus err = AudioObjectGetPropertyData(kAudioObjectSystemObject, &addr, 0, NULL, &size, &deviceID);
checkStatus(err);

if (err == noErr) {
    err = AudioUnitSetProperty(audioUnit, kAudioOutputUnitProperty_CurrentDevice, kAudioUnitScope_Global, 0, &deviceID, size);
}

checkStatus(err);

return err;
}
Run Code Online (Sandbox Code Playgroud)

我确实收到此错误

2018-05-08 10:07:29.454485+0300 OsxSocketSound[1414:20839] [AudioHAL_Client] AudioHardware.cpp:578:AudioObjectGetPropertyDataSize:  AudioObjectGetPropertyDataSize: no object with given ID 0
2018-05-08 10:07:29.454517+0300 OsxSocketSound[1414:20839] 

[AudioHAL_Client] AudioHardware.cpp:666:AudioObjectGetPropertyData:  AudioObjectGetPropertyData: no object with given ID 0
2018-05-08 10:07:29.454715+0300 OsxSocketSound[1414:20839] …
Run Code Online (Sandbox Code Playgroud)

macos audiounit

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

如何在 mac os 中录制系统声音,如 Wondershare Filmora Scrn?

Soundflower 通常被使用,但必须安装。Filmora srcn 无需安装驱动程序即可录制系统声音。它是如何捕捉声音的?MacOS,而不是 iOS

c++ macos core-audio kernel-extension audiounit

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

IOS AudioUnit播放裂纹问题(swift)

我正在尝试在 IOS 中播放来自 Android 设备的 UDP 字节。我正在使用 TPCircularBuffer 来播放字节。我的代码如下:

let success = initCircularBuffer(&circularBuffer, 1024)
        if success {
            print("Circular buffer init was successful")
        } else {
            print("Circular buffer init not successful")
        }



func udpReceive() {
        receivingQueue.async {
            repeat {
                do {
                    let datagram = try self.tcpClient?.receive()
                    let byteData = datagram?["data"] as? Data
                    let dataLength = datagram?["length"] as? Int
                    self.dataLength = dataLength!

                    let _ = TPCircularBufferProduceBytes(&self.circularBuffer, byteData!.bytes, UInt32(dataLength! * MemoryLayout<UInt8>.stride * 2))

                } catch {
                    fatalError(error.localizedDescription)
                }
            } while true
        }


    } …
Run Code Online (Sandbox Code Playgroud)

core-audio playback audiounit ios swift

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

在 Android 上使用 opus 剪辑从 IOS 发送的声音

我正在 IOS 中从 audioUnit 录制音频,用 opus 编码字节并通过 UDP 将其发送到 android 端。问题是播放的声音有点削波。我还通过将原始数据从 IOS 发送到 Android 来测试声音,效果非常完美。

我的 AudioSession 代码是

      try audioSession.setCategory(.playAndRecord, mode: .voiceChat, options: [.defaultToSpeaker])
        try audioSession.setPreferredIOBufferDuration(0.02)
        try audioSession.setActive(true)
Run Code Online (Sandbox Code Playgroud)

我的录音回调代码是:

func performRecording(
    _ ioActionFlags: UnsafeMutablePointer<AudioUnitRenderActionFlags>,
    inTimeStamp: UnsafePointer<AudioTimeStamp>,
    inBufNumber: UInt32,
    inNumberFrames: UInt32,
    ioData: UnsafeMutablePointer<AudioBufferList>) -> OSStatus
 {
var err: OSStatus = noErr

err = AudioUnitRender(audioUnit!, ioActionFlags, inTimeStamp, 1, inNumberFrames, ioData)

if let mData = ioData[0].mBuffers.mData {
    let ptrData = mData.bindMemory(to: Int16.self, capacity: Int(inNumberFrames))
    let bufferPtr = UnsafeBufferPointer(start: ptrData, count: Int(inNumberFrames)) …
Run Code Online (Sandbox Code Playgroud)

core-audio audiounit ios opus swift

0
推荐指数
1
解决办法
529
查看次数