我试图在实现它们之前理解AudioComponents并理解/使用AudioUnits ...
我使用通配符创建了一个AudioComponentDescription:
var inDesc = AudioComponentDescription(componentType: OSType(),
componentSubType: OSType(),
componentManufacturer: OSType(),
componentFlags: UInt32(0),
componentFlagsMask: UInt32(0))
我看看有多少AudioComponent:
AudioComponentCount(&inDesc) // returns 98 in a playground (ok)
我通过使用" nil"来聚焦第一个AudioComponent。作为AudioComponentFindNext中的第一个参数:
var currentComp = AudioComponentFindNext(nil, &inDesc)
看它的名字:
func getAudioComponentName (componentInit:AudioComponent) -> CFString {
var componentProp:AudioComponent = componentInit
var componentNameProp:CFString = "" as CFString
var unmanagedCurrentCompName:Unmanaged<CFString>?
AudioComponentCopyName(componentProp, &unmanagedCurrentCompName)
componentNameProp = unmanagedCurrentCompName!.takeRetainedValue()
return componentNameProp
}
var currentComponentName:CFString = "" as CFString
currentComponentName = getAudioComponentName(currentComp) // returns "Apple PAC3 Transcoder" (ok)
此时,以下尝试将不会是&#34;确定&#34;。
我想更多地了解这个&#34; Apple PAC3 Transcoder&#34;及其描述:
// Creating an empty AudioComponentDescription
var currentComponentDescription = AudioComponentDescription()
// Gettings currentComp's description (type)
AudioComponentGetDescription(currentComp, ¤tComponentDescription)
var compDescType:OSType = currentComponentDescription.componentType // returns 1633903715
在最后一行代码中,我如何获得 AUComponent.h 中描述的字母代码:
enum
{
kAudioUnitType_Output = 'auou',
kAudioUnitType_MusicDevice = 'aumu',
kAudioUnitType_MusicEffect = 'aumf',
kAudioUnitType_FormatConverter = 'aufc',
kAudioUnitType_Effect = 'aufx',
kAudioUnitType_Mixer = 'aumx',
kAudioUnitType_Panner = 'aupn',
kAudioUnitType_Generator = 'augn',
kAudioUnitType_OfflineEffect = 'auol',
kAudioUnitType_MIDIProcessor = 'aumi'
};
为了进一步兼容,我宁愿不必重现这个&#34; enum&#34;在我的代码中。
答案 0 :(得分:0)
componentType是OSType
,它是4个ASCII字符代码,打包成32位。
1633903715
为0x61636463
0x61636463
为'acdc'
(0x61 =&#39; a&#39;,0x63 =&#39; c&#39;等等...)