I'm trying to understand AudioComponents before instanciate them and understand/use AudioUnits...
我试着在实例化它们之前先理解它们并且理解/使用AudioUnits…
I create an AudioComponentDescription by using wildcards:
我使用通配符创建了一个AudioComponentDescription:
var inDesc = AudioComponentDescription(componentType: OSType(),
componentSubType: OSType(),
componentManufacturer: OSType(),
componentFlags: UInt32(0),
componentFlagsMask: UInt32(0))
I look how many AudioComponent there is:
我看看有多少音频元件:
AudioComponentCount(&inDesc) // returns 98 in a playground (ok)
I focus the first AudioComponent by using "nil" as first parameter in AudioComponentFindNext:
我将第一个AudioComponent用“nil”作为AudioComponentFindNext中的第一个参数:
var currentComp = AudioComponentFindNext(nil, &inDesc)
Looking at its name:
看着它的名字:
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)
At this point, the following tries will not be "ok".
此时,下面的尝试将不是“ok”。
I want to know much more about this "Apple PAC3 Transcoder" and its description:
我想了解更多关于这个“Apple PAC3转码器”及其描述:
// Creating an empty AudioComponentDescription
var currentComponentDescription = AudioComponentDescription()
// Gettings currentComp's description (type)
AudioComponentGetDescription(currentComp, ¤tComponentDescription)
var compDescType:OSType = currentComponentDescription.componentType // returns 1633903715
At the last line of code, how could I get the letter code described in AUComponent.h:
在最后一行代码中,我如何获得在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'
};
for further compatibility I prefer to not have to reproduce this "enum" in my code.
为了进一步的兼容性,我宁愿不需要在代码中复制这个“enum”。
1 个解决方案
#1
0
componentType is an OSType
which is 4 ASCII character codes packed into 32 bits.
componentType是一种OSType,它是由4个ASCII字符编码组成的32位。
1633903715
in hexadecimal is 0x61636463
十六进制中的1633903715是0x61636463
0x61636463
in ascii is 'acdc'
(0x61 = 'a', 0x63 = 'c', etc...)
ascii中的0x61636463是“acdc”(0x61 =“a”,0x63 =“c”等)
#1
0
componentType is an OSType
which is 4 ASCII character codes packed into 32 bits.
componentType是一种OSType,它是由4个ASCII字符编码组成的32位。
1633903715
in hexadecimal is 0x61636463
十六进制中的1633903715是0x61636463
0x61636463
in ascii is 'acdc'
(0x61 = 'a', 0x63 = 'c', etc...)
ascii中的0x61636463是“acdc”(0x61 =“a”,0x63 =“c”等)