- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我完全坚持这一点,非常感谢任何帮助...
我在 AVAudioEngine 图表中实现了一个 AUMatrixMixer,但我听不到任何声音。如果我将 AUMatrixMixer 换成 AUMultiChannelMixer,我就能听到声音。我在直接上游节点 (AUHighPassFilter) 上安装了一个分路器,我可以看到音频被 AUMatrixMixer 提取。如果我将水龙头移到 AUMatrixMixer 的输出端,我可以看到从下一个下游节点 - AVAudioEngine 主混音器节点 - 拉取数据,但它完全没有声音......
关于 AUMatrixMixers 的评论不多,所以它可能是一些我不知道的神奇设置。作为引用来源,我收到了一封来自 Apple 技术支持的电子邮件,其中包含以下关键观察结果:
“...要在您的 AVAudioEngine 设置中使用 Matrix-Mixer,您需要使用 +instantiateWithComponentDescription:options:completionHandler: API 创建一个 AVAudioUnit,在此处找到 AVAudioUnit:
由于 AVAudioUnit 是 AVAudioNode 的子类,因此您可以在 AVAudioEngine 设置中使用利用 Matrix-Mixer 的 AVAudioUnit。您将能够进行类似于以下的设置:
AVAudioPlayerNode -> AVAudioUnit(配置了一个矩阵混音器音频单元来分割你的 channel ) -> 主混音器(你会为多路由 channel 映射配置) -> 输出...”
所以它应该可以工作。我也分析了Apple提供的示例代码:
(MatrixMixerTest https://developer.apple.com/library/mac/samplecode/MatrixMixerTest/Introduction/Intro.html ) - 这不是我想要做的,但我看不出 API 等的使用有什么不同。
创建 AUMatrixMixer(一个输入总线,两个输出总线)的代码:
private func setupMatrixMixer() {
AVAudioUnit.instantiate(with: matrixMixerDescr, options: [.loadOutOfProcess], completionHandler: {(audioUnit, auError) in
if let au = audioUnit {
self.matrixMixer = au
var error:OSStatus = noErr
var numInputBuses:UInt32 = 1
var numOutputBuses:UInt32 = 2
// Input bus config
error = AudioUnitSetProperty(self.matrixMixer.audioUnit,
AudioUnitPropertyID(kAudioUnitProperty_ElementCount),
AudioUnitScope(kAudioUnitScope_Input),
0,
&numInputBuses,
UInt32(MemoryLayout<UInt32>.size))
if error != noErr {
assert(true, "ERROR: Setting matrix mixer number of input buses")
return
}
// Output bus config
error = AudioUnitSetProperty(self.matrixMixer.audioUnit,
AudioUnitPropertyID(kAudioUnitProperty_ElementCount),
AudioUnitScope(kAudioUnitScope_Output),
0,
&numOutputBuses,
UInt32(MemoryLayout<UInt32>.size))
if error != noErr {
assert(true, "ERROR: Setting matrix mixer number of output buses")
return
}
}
else { trace(level: .skim, items: "ERROR: failed to create matrix mixer. Error code: \(String(describing: auError))")}
} )
}
图形创建:
private func makeEngineConnections() {
// Get the engine's optional singleton main mixer node
let output = engine.mainMixerNode
// Connect nodes
engine.connect(player, to: timePitch, fromBus: 0, toBus: 0, format: audioFormat)
engine.connect(timePitch, to: lowPassFilter, fromBus: 0, toBus: 0, format: audioFormat)
engine.connect(lowPassFilter, to: highPassFilter, fromBus: 0, toBus: 0, format: audioFormat)
engine.connect(highPassFilter, to: matrixMixer, fromBus: 0, toBus: 0, format: audioFormat)
engine.connect(matrixMixer, to: output, fromBus: 0, toBus: 0, format: audioFormat)
engine.connect(matrixMixer, to: output, fromBus: 1, toBus: 1, format: audioFormat)
}
设置后引擎图的转储:
________ 图描述 ________AVAudioEngineGraph 0x1701c6450:初始化=1,运行=1,节点数=8
******** output chain ********
node 0x1700a9960 {'auou' 'rioc' 'appl'}, 'I'
inputs = 1
(bus0) <- (bus0) 0x1740ee180, {'aumx' 'mcmx' 'appl'}, [ 2 ch, 44100 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved]
node 0x1740ee180 {'aumx' 'mcmx' 'appl'}, 'I'
inputs = 2
(bus0) <- (bus0) 0x1700f0200, {'aumx' 'mxmx' 'appl'}, [ 2 ch, 44100 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved]
(bus1) <- (bus1) 0x1700f0200, {'aumx' 'mxmx' 'appl'}, [ 2 ch, 44100 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved]
outputs = 1
(bus0) -> (bus0) 0x1700a9960, {'auou' 'rioc' 'appl'}, [ 2 ch, 44100 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved]
node 0x1700f0200 {'aumx' 'mxmx' 'appl'}, 'I'
inputs = 1
(bus0) <- (bus0) 0x1740ee100, {'aufx' 'hpas' 'appl'}, [ 2 ch, 44100 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved]
outputs = 2
(bus0) -> (bus0) 0x1740ee180, {'aumx' 'mcmx' 'appl'}, [ 2 ch, 44100 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved]
(bus1) -> (bus1) 0x1740ee180, {'aumx' 'mcmx' 'appl'}, [ 2 ch, 44100 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved]
node 0x1740ee100 {'aufx' 'hpas' 'appl'}, 'I'
inputs = 1
(bus0) <- (bus0) 0x1740ee700, {'aufx' 'lpas' 'appl'}, [ 2 ch, 44100 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved]
outputs = 1
(bus0) -> (bus0) 0x1700f0200, {'aumx' 'mxmx' 'appl'}, [ 2 ch, 44100 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved]
node 0x1740ee700 {'aufx' 'lpas' 'appl'}, 'I'
inputs = 1
(bus0) <- (bus0) 0x1740ee480, {'aufc' 'nutp' 'appl'}, [ 2 ch, 44100 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved]
outputs = 1
(bus0) -> (bus0) 0x1740ee100, {'aufx' 'hpas' 'appl'}, [ 2 ch, 44100 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved]
node 0x1740ee480 {'aufc' 'nutp' 'appl'}, 'I'
inputs = 1
(bus0) <- (bus0) 0x174198fc0, {'augn' 'sspl' 'appl'}, [ 2 ch, 44100 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved]
outputs = 1
(bus0) -> (bus0) 0x1740ee700, {'aufx' 'lpas' 'appl'}, [ 2 ch, 44100 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved]
node 0x174198fc0 {'augn' 'sspl' 'appl'}, 'I'
outputs = 1
(bus0) -> (bus0) 0x1740ee480, {'aufc' 'nutp' 'appl'}, [ 2 ch, 44100 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved]
******** other nodes ********
node 0x1700ef000 {'aumx' 'mcmx' 'appl'}, 'U'
AUMatrixMixer 内部的设置有点乏味。总结:
这是执行上述操作后的内部状态转储:
Matrix dimensions: [2, 4]
Input element count: 1
Input channel 0 volume: 1.0
Input channel 1 volume: 1.0
Output element count: 2
Output channel 0 volume: 1.0
Output channel 1 volume: 1.0
Output channel 2 volume: 1.0
Output channel 3 volume: 1.0
Crosspoint volumes: [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
Input 0 enabled parameter: 1.0
Output 0 enabled parameter: 1.0
Output 1 enabled parameter: 1.0
如您所见,一切都已启用,所有音量都设置为最大但没有输出声音....
如上所述,通过点击不同节点的输出,我已经验证了良好的数据正在从高通滤波器移动到矩阵混音器,但在矩阵混音器和主混音器之间移动的是静音混合器节点。
有谁知道我还需要做些什么才能从中获得声音?
问候,空调
最佳答案
几个星期以来,我一直面临同样的情况。刚才,我正在写一段示例代码来询问 Apple Code-Level 支持。我在准备发送时测试了它,假设它不会像往常一样工作,但令人惊讶的是它确实有效!我认为,像 AUGraph 一样,必须有一些特定的顺序来设置流格式、连接节点等,这是它正常工作所必需的。 (而且,与 AUGraph 一样,文档并没有准确解释该顺序是什么。)所以我不太确定这次我做了什么不同的事情,但至少它现在对我有用。
所以这是一个成功使用带有 AVAudioEngine 的矩阵混音器的准系统示例:
NSURL *audioURL = /*an audio URL*/
AVAudioFile *file = [[AVAudioFile alloc] initForReading:audioURL error:nil];
AVAudioPlayerNode *audioPlayer = [[AVAudioPlayerNode alloc] init];
_engine = [[AVAudioEngine alloc] init];
[_engine attachNode:audioPlayer];
AudioComponentDescription mixerDesc;
mixerDesc.componentType = kAudioUnitType_Mixer;
mixerDesc.componentSubType = kAudioUnitSubType_MatrixMixer;
mixerDesc.componentManufacturer = kAudioUnitManufacturer_Apple;
mixerDesc.componentFlags = kAudioComponentFlag_SandboxSafe;
[AVAudioUnit instantiateWithComponentDescription:mixerDesc options:kAudioComponentInstantiation_LoadInProcess completionHandler:^(__kindof AVAudioUnit * _Nullable mixerUnit, NSError * _Nullable error) {
[_engine attachNode:mixerUnit];
/*Give the mixer one input bus and one output bus*/
UInt32 inBuses = 1;
UInt32 outBuses = 1;
AudioUnitSetProperty(mixerUnit.audioUnit, kAudioUnitProperty_ElementCount, kAudioUnitScope_Input, 0, &inBuses, sizeof(UInt32));
AudioUnitSetProperty(mixerUnit.audioUnit, kAudioUnitProperty_ElementCount, kAudioUnitScope_Output, 0, &outBuses, sizeof(UInt32));
/*Set the mixer's input format to have 2 channels*/
UInt32 inputChannels = 2;
AudioStreamBasicDescription mixerFormatIn;
UInt32 size;
AudioUnitGetProperty(mixerUnit.audioUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, 0, &mixerFormatIn, &size);
mixerFormatIn.mChannelsPerFrame = inputChannels;
AudioUnitSetProperty(mixerUnit.audioUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, 0, &mixerFormatIn, size);
/*Set the mixer's output format to have 2 channels*/
UInt32 outputChannels = 2;
AudioStreamBasicDescription mixerFormatOut;
AudioUnitGetProperty(mixerUnit.audioUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Output, 0, &mixerFormatOut, &size);
mixerFormatOut.mChannelsPerFrame = outputChannels;
AudioUnitSetProperty(mixerUnit.audioUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Output, 0, &mixerFormatOut, size);
/*Connect the nodes*/
[_engine connect:audioPlayer to:mixerUnit format:nil];
[_engine connect:mixerUnit to:_engine.outputNode format:nil];
/*Start the engine*/
[_engine startAndReturnError:nil];
/*Play the audio file*/
[audioPlayer scheduleFile:file atTime:nil completionHandler:nil];
[audioPlayer play];
/*Set all matrix volumes to 1*/
/*Set the master volume*/
AudioUnitSetParameter(mixerUnit.audioUnit, kMatrixMixerParam_Volume, kAudioUnitScope_Global, 0xFFFFFFFF, 1.0, 0);
for(UInt32 i = 0; i < inputChannels; i++) {
/*Set input volumes*/
AudioUnitSetParameter(mixerUnit.audioUnit, kMatrixMixerParam_Volume, kAudioUnitScope_Input, i, 1.0, 0);
for(UInt32 j = 0; j < outputChannels; j++) {
/*Set output volumes (only one outer iteration necessary)*/
if(i == 0) {
AudioUnitSetParameter(mixerUnit.audioUnit, kMatrixMixerParam_Volume, kAudioUnitScope_Output, j, 1.0, 0);
}
/*Set cross point volumes - 1.0 for corresponding
inputs/outputs, otherwise 0.0*/
UInt32 crossPoint = (i << 16) | (j & 0x0000FFFF);
AudioUnitSetParameter(mixerUnit.audioUnit, kMatrixMixerParam_Volume, kAudioUnitScope_Global, crossPoint, (i == j) ? 1.0 : 0.0, 0);
}
}
/*If you want to verify it's working, try something like this to silence only one channel of audio
AudioUnitSetParameter(mixerUnit.audioUnit, kMatrixMixerParam_Volume, kAudioUnitScope_Output, 0, 0.0, 0);
*/
}];
关于ios - 应该如何在 AVAudioEngine 图中配置 AUMatrixMixer?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48059405/
我想填充 3D 等高线图 (contour3(X,Y,Z)),就像 2D 等高线填充图 (contourf(X,Y,Z))。但我无法弄清楚如何实现这一目标。 contour3 和 surf 的组合不是
我有一个 c3.js 折线图,表示 2 个值的演变。我需要折线图的工具提示是饼图(工具提示 = 另一个 c3.js 图形)。 这是我成功的: http://jsfiddle.net/owhxgaqm/
我有具有结构的 Pandas 数据框: A B 0 1 1 1 2 1 2 3 4 3 3 7 4 6 8 如何生成 Seaborn Violin 图,每列作为其自己的单独
我正在使用 D3DXSPRITE 方法将我的 map 图 block 绘制到屏幕上,我刚刚添加了一个缩放功能,当您按住向上箭头时会放大,但注意到您现在可以看到图 block 之间的间隙,这是一些屏幕截
1、系统环境如下图: 2、为该系统添加一块新的虚拟硬盘,添加后需重启虚拟机,否则系统不识别;如下图,/dev/sdc 是新添加的硬盘; 3、fdisk /dev/sdc为新硬盘创建分区:
1、nagios简介 nagios是一款开源的电脑系统和网络监视工具,能有效监控windows、linux和unix的主机状态,交换机路由器等网络设置,打印机等。在系统或服务状态异常时发
越来越多人开始习惯用手机上网,浏览网页、查看邮件···移动化已经成为互联网发展必然趋势,包括facebook在内的很多互联网公司都将移动广告作为下一个淘金地
1.图片处理 1.圆角图片 复制代码 代码如下: /** * 转换成圆角 * &n
Microsoft SQL Server Management Studio是SQL SERVER的客户端工具,相信大家都知道。我不知道大伙使用导入数据的情况怎么样,反正我最近是遇到过。主要是因为没
debian6系统: 首先先安装mysql吧: 打开终端(root)用户登入 apt-get purge mysql-server-5.5 安装完成后: 默认情况下Mysql只允许本地登录
fedora16英文环境下支持中文输入法的方法 fedora16英文环境下支持FCITX的中文输入法: $ im-chooser 就会出现选择界面,选择第二个就行了。
Net预编译命令 C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -? 显示说明 我们需要选择的命令为&n
有的时候电脑出现一些故障有的时候通过将其修改bios设置的方法来解决故障,那么在bios上设置能不能将电脑恢复出厂设置呢?其实也是可以的。方法也很简单的,只要会进入电脑的bios懂的上面英文的意思就
笔者曾介绍过Deepin 将对龙芯进行全面支持,打造最优美龙芯电脑桌面。现在Deepin团队移植工作取得了突破性的成果,Deepin桌面已经在龙芯3A和龙芯3B电脑上成功运行起来了。 以下为龙芯3
在安装一些软件之后,我们的电脑总是会发生一点小变化,不是桌面上多了几个网址图标,就是IE浏览器的默认主页被篡改成乱七八糟的网址。最可气的是,在IE设置中将默认主页改回来后,下次启动Win7后又变了回
“注册表编辑器怎么打开”虽说不是很难的问题,但是对于对电脑常识不是很擅长的网民来说,当电脑出现问题或需要更改设置时,着实还是件头疼的问题。因为需要打开注册表进行操作解决。那么如何打开注册表编辑器呢?
这篇文章重点介绍10个重要的WordPress安全插件和技巧,用来保护WordPress网站或者博客。 1. WP Security 人工帮助你修复被黑客入侵的网站,只要按照他们网站上的联系电话
其实运用object和javascript调用外部文件,也能实现不同栏目调用不同友情链接,即相当于调用不同栏目友情链接文件, {dede:field.typeid/}来获取当前栏目的ID。
我有一个复值矩阵。 如果我发出命令: plot(myMatrix) 然后它在图形设备上显示一种散点图,X 轴标记为 Re(myMatrix),Y 轴标记为 Im(myMatrix)。这显示了我正在寻找
关闭。这个问题需要更多focused .它目前不接受答案。 想改善这个问题吗?更新问题,使其仅关注一个问题 editing this post . 4年前关闭。 Improve this questi
我是一名优秀的程序员,十分优秀!