Пример #1
0
void		CAAUMIDIMap::RestoreFromMapPList (const CFDictionaryRef inData, AUParameterMIDIMapping* outMappings, UInt32 inNumMappings)
{

	CACFDictionary dict (inData, false);
	
	if (dict.HasKey (kParamMIDIStr)) 
	{
		CFArrayRef cfArray;
		dict.GetArray (kParamMIDIStr, cfArray); 
		
		CACFArray array (cfArray, false);
		
		UInt32 count = array.GetNumberItems();
		if (count > inNumMappings)
			count = inNumMappings;
		
		for (unsigned int i = 0; i < count; ++i)
		{
			CFDictionaryRef paramsDictRef;
			if (!array.GetDictionary(i, paramsDictRef)) 
				return;
			
			CAAUMIDIMap parameterMap;
			parameterMap.Restore(paramsDictRef);
			outMappings[i] = parameterMap;
		}
	}
}
Пример #2
0
static void	HP_PreferredChannels_ConstructDictionaryFromLayout(const AudioChannelLayout& inLayout, CACFDictionary& outLayoutDictionary)
{
	//	stick in the tag
	outLayoutDictionary.AddUInt32(CFSTR("channel layout tag"), inLayout.mChannelLayoutTag);
	
	//	stick in the bitmap
	outLayoutDictionary.AddUInt32(CFSTR("channel bitmap"), inLayout.mChannelBitmap);
	
	//	stick in the number channels
	outLayoutDictionary.AddUInt32(CFSTR("number channels"), inLayout.mNumberChannelDescriptions);
	
	//	add the channel descriptions, if necessary
	if(inLayout.mChannelLayoutTag == kAudioChannelLayoutTag_UseChannelDescriptions)
	{
		//	create an array to hold the channel descriptions
		CACFArray theChannelDescriptions(true);
		if(theChannelDescriptions.IsValid())
		{
			//	iterate through the descriptions and stick them in the array
			for(UInt32 theChannelIndex = 0; theChannelIndex < inLayout.mNumberChannelDescriptions; ++theChannelIndex)
			{
				//	create a dictionary to hold the description
				CACFDictionary theDescription(true);
				if(theDescription.IsValid())
				{
					//	stick in the easy values
					theDescription.AddUInt32(CFSTR("channel label"), inLayout.mChannelDescriptions[theChannelIndex].mChannelLabel);
					theDescription.AddUInt32(CFSTR("channel flags"), inLayout.mChannelDescriptions[theChannelIndex].mChannelFlags);
				
					//	create an array to hold the coordinates
					CACFArray theCoordinates(true);
					if(theCoordinates.IsValid())
					{
						//	add the coordinates to the array
						for(UInt32 theCoordinateIndex = 0; theCoordinateIndex < 3; ++theCoordinateIndex)
						{
							theCoordinates.AppendFloat32(inLayout.mChannelDescriptions[theChannelIndex].mCoordinates[theCoordinateIndex]);
						}
						
						//	add the array of coordinates to the description
						theDescription.AddArray(CFSTR("coordinates"), theCoordinates.GetCFArray());
					}
					
					//	add the description to the array of descriptions
					theChannelDescriptions.AppendDictionary(theDescription.GetCFDictionary());
				}
			}
			
			//	add the array of descriptions to the layout dictionary
			outLayoutDictionary.AddArray(CFSTR("channel descriptions"), theChannelDescriptions.GetCFArray());
		}
	}
}
Пример #3
0
static void	HP_PreferredChannels_ConstructLayoutFromDictionary(const CACFDictionary& inLayoutDictionary, AudioChannelLayout& outLayout)
{
	//	get the tag, bitmap
	inLayoutDictionary.GetUInt32(CFSTR("channel layout tag"), outLayout.mChannelLayoutTag);
	inLayoutDictionary.GetUInt32(CFSTR("channel bitmap"), outLayout.mChannelBitmap);
	
	//	get the number of channels specified in the dictionary
	UInt32 theNumberChannelsInDictionary = 0;
	inLayoutDictionary.GetUInt32(CFSTR("number channels"), theNumberChannelsInDictionary);
	
	//	get the descriptions if they are present and required
	CFArrayRef __theDescriptions;
	if((outLayout.mChannelLayoutTag == kAudioChannelLayoutTag_UseChannelDescriptions) && inLayoutDictionary.GetArray(CFSTR("channel descriptions"), __theDescriptions))
	{
		//	don't release this array because it came straight out of the dictionary
		CACFArray theDescriptions(__theDescriptions, false);
		
		//	get the number of items in the array
		UInt32 theNumberItems = theDescriptions.GetNumberItems();
		
		//	iterate through the array and fill out the struct
		for(UInt32 theItemIndex = 0; (theItemIndex < theNumberItems) && (theItemIndex < outLayout.mNumberChannelDescriptions); ++theItemIndex)
		{
			//	get the description
			CFDictionaryRef __theDescription;
			if(theDescriptions.GetDictionary(theItemIndex, __theDescription))
			{
				//	don't release this dictionary because it came straight out of the array
				CACFDictionary theDescription(__theDescription, false);
				
				//	get the channel label and flags
				theDescription.GetUInt32(CFSTR("channel label"), outLayout.mChannelDescriptions[theItemIndex].mChannelLabel);
				theDescription.GetUInt32(CFSTR("channel flags"), outLayout.mChannelDescriptions[theItemIndex].mChannelFlags);
				
				//	get the coordinates
				CFArrayRef __theCoordinates;
				if(theDescription.GetArray(CFSTR("coordinates"), __theCoordinates))
				{
					//	don't release this array because it came straight out of the dictionary
					CACFArray theCoordinates(__theCoordinates, false);
					
					//	iterate through the array and get the coordinates
					UInt32 theNumberCoordinates = theCoordinates.GetNumberItems();
					for(UInt32 theCoordinateIndex = 0; (theCoordinateIndex < 3) && (theCoordinateIndex < theNumberCoordinates); ++theCoordinateIndex)
					{
						theCoordinates.GetFloat32(theCoordinateIndex, outLayout.mChannelDescriptions[theItemIndex].mCoordinates[theCoordinateIndex]);
					}
				}
			}
		}
	}
}
Пример #4
0
UInt32		CAAUMIDIMap::NumberOfMaps (const CFDictionaryRef inData)
{
	CACFDictionary dict (inData, false);
	
	if (dict.HasKey (kParamMIDIStr)) 
	{
		CFArrayRef cfArray;
		dict.GetArray (kParamMIDIStr, cfArray); 
		
		CACFArray array (cfArray, false);
		
		return array.GetNumberItems();
	}
	return 0;
}
Пример #5
0
OSStatus	CAAudioChannelLayout::Restore (CFPropertyListRef &inData) 
{
	if (CFGetTypeID (inData) != CFDictionaryGetTypeID()) return paramErr;
	CACFDictionary dict(static_cast<CFDictionaryRef>(inData), false);

	RefCountedLayout *temp = NULL;
	AudioChannelLayout* layout;
	
	CFArrayRef descs = NULL;
	UInt32 numDescs = 0;

	if (dict.GetArray (kACLDescsKey, descs)) {
		numDescs = CFArrayGetCount (descs);
	}
	
	temp = RefCountedLayout::CreateWithNumberChannelDescriptions(numDescs);
	layout = temp->GetLayout();
		
	if (!dict.GetUInt32 (kACLTagKey, layout->mChannelLayoutTag))
		goto badget;
	if (dict.HasKey (kACLBitmapKey)) {
		if (!dict.GetUInt32 (kACLBitmapKey, layout->mChannelBitmap))
			goto badget;
	} else
		layout->mChannelBitmap = 0;
		
	layout->mNumberChannelDescriptions = numDescs;
	
	if (numDescs)
	{
		AudioChannelDescription *desc = layout->mChannelDescriptions;
		for (unsigned int i = 0; i < numDescs; ++i, ++desc)
		{
			CFDictionaryRef descDict = (CFDictionaryRef)CFArrayGetValueAtIndex (descs, i);			
			CACFDictionary theDesc (descDict, false);
			
			if (!theDesc.GetUInt32 (kACLLabelKey, desc->mChannelLabel))
				goto badget;
			if (!theDesc.GetUInt32 (kACLFlagsKey, desc->mChannelFlags))
				goto badget;
			if (!theDesc.GetFloat32 (kACLCoords0Key, desc->mCoordinates[0]))
				goto badget;
			if (!theDesc.GetFloat32 (kACLCoords1Key, desc->mCoordinates[1]))
				goto badget;
			if (!theDesc.GetFloat32 (kACLCoords2Key, desc->mCoordinates[2]))
				goto badget;
		}
	}
	if (mLayout)
		mLayout->release();

	mLayout = temp;
	
	return noErr;

badget:
	delete temp;
	return paramErr;
}
Пример #6
0
OSStatus	CAAudioChannelLayout::Restore (CFPropertyListRef &inData) 
{
	if (CFGetTypeID (inData) != CFDictionaryGetTypeID()) return -1;
	CACFDictionary dict(static_cast<CFDictionaryRef>(inData), false);

	ACLRefCounter *temp = NULL;
	UInt32 size = 0;
	AudioChannelLayout* layout;
	
	UInt32 numDescs;
	if (!dict.GetUInt32 (kACLDescKey, numDescs))
		goto badget;
	
	size = numDescs * sizeof (AudioChannelDescription) + offsetof(AudioChannelLayout, mChannelDescriptions[0]);
	temp = new ACLRefCounter (size);
	layout = temp->GetLayout();
		
	if (!dict.GetUInt32 (kACLTagKey, layout->mChannelLayoutTag))
		goto badget;
	if (!dict.GetUInt32 (kACLBitmapKey, layout->mChannelBitmap))
		goto badget;
	layout->mNumberChannelDescriptions = numDescs;
	
	if (numDescs)
	{
		static char string[32];
		AudioChannelDescription *desc = layout->mChannelDescriptions;
		for (unsigned int i = 0; i < numDescs; ++i, ++desc)
		{
			sprintf (string, "%d", i);
			CFDictionaryRef descDict;
			if (!dict.GetCFTypeWithCStringKey (string, static_cast<const void*>(descDict)))
				goto badget;
			CACFDictionary theDesc (descDict, false);
			
			if (!theDesc.GetUInt32 (kACLLabelKey, desc->mChannelLabel))
				goto badget;
			if (!theDesc.GetUInt32 (kACLFlagsKey, desc->mChannelFlags))
				goto badget;
			if (!theDesc.GetFloat32 (kACLCoords0Key, desc->mCoordinates[0]))
				goto badget;
			if (!theDesc.GetFloat32 (kACLCoords1Key, desc->mCoordinates[1]))
				goto badget;
			if (!theDesc.GetFloat32 (kACLCoords2Key, desc->mCoordinates[2]))
				goto badget;
		}
	}
	if (mLayoutHolder)
		mLayoutHolder->release();

	mLayoutHolder = temp;
	
	return noErr;

badget:
	delete temp;
	return -1;
}
Пример #7
0
void CAAUMIDIMap::Restore(CFDictionaryRef inData)
{	
	CACFDictionary paramDict (inData, false);

	if (!paramDict.GetUInt32 (kLocalScopeStr, mScope)) return; 
	if (!paramDict.GetUInt32 (kLocalElementIDStr, mElement)) return; 
	if (!paramDict.GetUInt32 (kLocalParameterIDStr, mParameterID)) return; 
	if (!paramDict.GetUInt32 (kMIDIFlagsStr, mFlags)) return;
	if (!paramDict.GetFloat32 (kMIDISubMinStr, mSubRangeMin)) return; 
	if (!paramDict.GetFloat32 (kMIDISubMaxStr, mSubRangeMax)) return; 
	UInt32 data;		
	if (!paramDict.GetUInt32 (kMIDIStatusStr, data)) return;
	mStatus = data;
	if (!paramDict.GetUInt32 (kMIDIDataByteStr, data)) return; 
	mData1 = data;
}
Пример #8
0
void		CAAUMIDIMap::SaveAsMapPList (AudioUnit inUnit, const AUParameterMIDIMapping* inMappings, UInt32 inNumMappings, CFPropertyListRef &outData, CFStringRef inName)
{

	CACFDictionary mappingDict (false);	
	CACFArray maps (true);
	
	for (UInt32 i = 0; i< inNumMappings; ++i) 
	{
		CFPropertyListRef data;
		CAAUMIDIMap paramMap(inMappings[i]);
		paramMap.Save (data);
		if (data) 
		{
			maps.AppendCFType (data); 
			CFRelease(data); 
		}				
	}

	if (maps.GetNumberItems()) {
		mappingDict.AddCFType (kParamMIDIStr, maps.GetCFArray());
		
		// Add the AU info here - where this map came from
		CAAudioUnit au (inUnit);
		CFPropertyListRef data;
		au.Comp().Save (&data);
		
		mappingDict.AddCFType (kAUStr, data);
		CFRelease(data);
		
		if (!inName) inName = CFSTR("Untitled");
		mappingDict.AddString (CFSTR("name"), inName);
		
		mappingDict.AddUInt32 (CFSTR("version"), 1);
		
		outData = mappingDict.AsPropertyList();
	} else {
		mappingDict.ShouldRelease(true);
		outData = NULL;
	}
}
Пример #9
0
OSStatus	CAAudioChannelLayout::Save (CFPropertyListRef *outData) const 
{
	const AudioChannelLayout& layout = Layout();

	CACFDictionary dict (false);
	if (!dict.AddUInt32 (kACLTagKey, layout.mChannelLayoutTag))
		goto badadd;
	if (!dict.AddUInt32 (kACLBitmapKey, layout.mChannelBitmap))
		goto badadd;
	if (!dict.AddUInt32 (kACLDescKey, layout.mNumberChannelDescriptions))
		goto badadd;
	
	if (layout.mNumberChannelDescriptions)
	{	
		static char string[32];
		
		const AudioChannelDescription *desc = layout.mChannelDescriptions;
		for (unsigned int i = 0; i < layout.mNumberChannelDescriptions; ++i, ++desc) 
		{
			CACFDictionary descDict (true);
			sprintf (string, "%d", i);
			if (!descDict.AddUInt32 (kACLLabelKey, desc->mChannelLabel))
				goto badadd;
			if (!descDict.AddUInt32 (kACLFlagsKey, desc->mChannelFlags))
				goto badadd;
			if (!descDict.AddFloat32 (kACLCoords0Key, desc->mCoordinates[0]))
				goto badadd;
			if (!descDict.AddFloat32 (kACLCoords1Key, desc->mCoordinates[1]))
				goto badadd;
			if (!descDict.AddFloat32 (kACLCoords2Key, desc->mCoordinates[2]))
				goto badadd;
			if (!dict.AddCFTypeWithCStringKey (string, descDict.GetDict()))
				goto badadd;
		}
	}
	
	*outData = dict.GetDict();	
	
	return noErr;
	
badadd:
	dict.ShouldRelease(true);
	return -1;
}
Пример #10
0
OSStatus	CAAudioChannelLayout::Save (CFPropertyListRef *outData) const 
{
	const AudioChannelLayout& layout = Layout();

	CACFDictionary dict (false);
	if (!dict.AddUInt32 (kACLTagKey, layout.mChannelLayoutTag))
		goto badadd;
	if (layout.mChannelBitmap && !dict.AddUInt32 (kACLBitmapKey, layout.mChannelBitmap))
		goto badadd;
	
	if (layout.mNumberChannelDescriptions)
	{	
		CFMutableArrayRef descs = CFArrayCreateMutable (NULL, layout.mNumberChannelDescriptions, &kCFTypeArrayCallBacks);
		
		const AudioChannelDescription *desc = layout.mChannelDescriptions;
		for (unsigned int i = 0; i < layout.mNumberChannelDescriptions; ++i, ++desc) 
		{
			CACFDictionary descDict (true);
			if (!descDict.AddUInt32 (kACLLabelKey, desc->mChannelLabel))
				{ CFRelease (descs); goto badadd; }
			if (!descDict.AddUInt32 (kACLFlagsKey, desc->mChannelFlags))
				{ CFRelease (descs); goto badadd; }
			if (!descDict.AddFloat32 (kACLCoords0Key, desc->mCoordinates[0]))
				{ CFRelease (descs); goto badadd; }
			if (!descDict.AddFloat32 (kACLCoords1Key, desc->mCoordinates[1]))
				{ CFRelease (descs); goto badadd; }
			if (!descDict.AddFloat32 (kACLCoords2Key, desc->mCoordinates[2]))
				{ CFRelease (descs); goto badadd; }
			
			CFArrayAppendValue (descs, descDict.AsPropertyList());
		}
		dict.AddArray (kACLDescsKey, descs);
		
		CFRelease (descs);
	}
	
	*outData = dict.GetDict();	
	
	return noErr;
	
badadd:
	dict.ShouldRelease(true);
	return paramErr;
}