summaryrefslogtreecommitdiff
path: root/libs/appleutility/CoreAudio/AudioUnits/AUPublic/OtherBases/AUPannerBase.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libs/appleutility/CoreAudio/AudioUnits/AUPublic/OtherBases/AUPannerBase.cpp')
-rw-r--r--libs/appleutility/CoreAudio/AudioUnits/AUPublic/OtherBases/AUPannerBase.cpp164
1 files changed, 82 insertions, 82 deletions
diff --git a/libs/appleutility/CoreAudio/AudioUnits/AUPublic/OtherBases/AUPannerBase.cpp b/libs/appleutility/CoreAudio/AudioUnits/AUPublic/OtherBases/AUPannerBase.cpp
index f1e2f248ab..91e7d9cc7e 100644
--- a/libs/appleutility/CoreAudio/AudioUnits/AUPublic/OtherBases/AUPannerBase.cpp
+++ b/libs/appleutility/CoreAudio/AudioUnits/AUPublic/OtherBases/AUPannerBase.cpp
@@ -2,14 +2,14 @@
File: AUPannerBase.cpp
Abstract: AUPannerBase.h
Version: 1.1
-
+
Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple
Inc. ("Apple") in consideration of your agreement to the following
terms, and your use, installation, modification or redistribution of
this Apple software constitutes acceptance of these terms. If you do
not agree with these terms, please do not use, install, modify or
redistribute this Apple software.
-
+
In consideration of your agreement to abide by the following terms, and
subject to these terms, Apple grants you a personal, non-exclusive
license, under Apple's copyrights in this original Apple software (the
@@ -25,13 +25,13 @@
implied, are granted by Apple herein, including but not limited to any
patent rights that may be infringed by your derivative works or by other
works in which the Apple Software may be incorporated.
-
+
The Apple Software is provided by Apple on an "AS IS" basis. APPLE
MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
-
+
IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
@@ -40,9 +40,9 @@
AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-
+
Copyright (C) 2014 Apple Inc. All Rights Reserved.
-
+
*/
#include "AUPannerBase.h"
#include "CABundleLocker.h"
@@ -51,13 +51,13 @@
static bool sLocalized = false;
-static CFStringRef kPanner_Azimuth_Name = CFSTR("azimuth");
-static CFStringRef kPanner_Elevation_Name = CFSTR("elevation");
+static CFStringRef kPanner_Azimuth_Name = CFSTR("azimuth");
+static CFStringRef kPanner_Elevation_Name = CFSTR("elevation");
static CFStringRef kPanner_Distance_Name = CFSTR("distance");
-static CFStringRef kPanner_CoordScale_Name = CFSTR("coordinate scale");
-static CFStringRef kPanner_RefDistance_Name = CFSTR("reference distance");
-static CFStringRef kPanner_Gain_Name = CFSTR("gain");
+static CFStringRef kPanner_CoordScale_Name = CFSTR("coordinate scale");
+static CFStringRef kPanner_RefDistance_Name = CFSTR("reference distance");
+static CFStringRef kPanner_Gain_Name = CFSTR("gain");
static Float32 kPannerParamDefault_Azimuth = 0.;
static Float32 kPannerParamDefault_Elevation = 0.;
@@ -75,30 +75,30 @@ AUPannerBase::AUPannerBase(AudioComponentInstance inAudioUnit)
{
CABundleLocker lock;
if (!sLocalized)
- {
+ {
CFBundleRef bundle = CFBundleGetBundleWithIdentifier( CFSTR("com.apple.audio.units.Components") );
if (bundle != NULL)
{
kPanner_Azimuth_Name = CFCopyLocalizedStringFromTableInBundle(kPanner_Azimuth_Name, CFSTR("AudioUnits"), bundle, CFSTR(""));
kPanner_Elevation_Name = CFCopyLocalizedStringFromTableInBundle(kPanner_Elevation_Name, CFSTR("AudioUnits"), bundle, CFSTR(""));
kPanner_Distance_Name = CFCopyLocalizedStringFromTableInBundle(kPanner_Distance_Name, CFSTR("AudioUnits"), bundle, CFSTR(""));
-
+
kPanner_CoordScale_Name = CFCopyLocalizedStringFromTableInBundle(kPanner_CoordScale_Name, CFSTR("AudioUnits"), bundle, CFSTR(""));
kPanner_RefDistance_Name = CFCopyLocalizedStringFromTableInBundle(kPanner_RefDistance_Name, CFSTR("AudioUnits"), bundle, CFSTR(""));
kPanner_Gain_Name = CFCopyLocalizedStringFromTableInBundle(kPanner_Gain_Name, CFSTR("AudioUnits"), bundle, CFSTR(""));
}
-
+
sLocalized = true;
}
}
-
+
CreateElements();
-
+
SetParameter(kPannerParam_Azimuth, kPannerParamDefault_Azimuth);
SetParameter(kPannerParam_Elevation, kPannerParamDefault_Elevation);
SetParameter(kPannerParam_Distance, kPannerParamDefault_Distance);
-
+
SetParameter(kPannerParam_CoordScale, kPannerParamDefault_CoordScale);
SetParameter(kPannerParam_RefDistance, kPannerParamDefault_RefDistance);
SetParameter(kPannerParam_Gain, kPannerParamDefault_Gain);
@@ -135,13 +135,13 @@ void AUPannerBase::AllocBypassMatrix()
static AudioChannelLayoutTag DefaultTagForNumberOfChannels(UInt32 inNumberChannels)
{
switch (inNumberChannels) {
- case 1: return kAudioChannelLayoutTag_Mono;
- case 2: return kAudioChannelLayoutTag_Stereo;
- case 4: return kAudioChannelLayoutTag_Quadraphonic;
- case 5: return kAudioChannelLayoutTag_AudioUnit_5_0;
- case 6: return kAudioChannelLayoutTag_AudioUnit_6_0;
- case 7: return kAudioChannelLayoutTag_AudioUnit_7_0;
- case 8: return kAudioChannelLayoutTag_AudioUnit_8;
+ case 1: return kAudioChannelLayoutTag_Mono;
+ case 2: return kAudioChannelLayoutTag_Stereo;
+ case 4: return kAudioChannelLayoutTag_Quadraphonic;
+ case 5: return kAudioChannelLayoutTag_AudioUnit_5_0;
+ case 6: return kAudioChannelLayoutTag_AudioUnit_6_0;
+ case 7: return kAudioChannelLayoutTag_AudioUnit_7_0;
+ case 8: return kAudioChannelLayoutTag_AudioUnit_8;
default: return 0xFFFF0000 | inNumberChannels;
}
@@ -153,7 +153,7 @@ static AudioChannelLayoutTag DefaultTagForNumberOfChannels(UInt32 inNumberChanne
OSStatus AUPannerBase::SetDefaultChannelLayoutsIfNone()
{
OSStatus err = noErr;
-
+
// if layout has not been set, then guess layout from number of channels
UInt32 inChannels = GetNumberOfInputChannels();
AudioChannelLayout inputLayoutSubstitute;
@@ -168,7 +168,7 @@ OSStatus AUPannerBase::SetDefaultChannelLayoutsIfNone()
err = SetAudioChannelLayout(kAudioUnitScope_Input, 0, &GetInputLayout());
if (err) return err;
}
-
+
// if layout has not been set, then guess layout from number of channels
UInt32 outChannels = GetNumberOfOutputChannels();
AudioChannelLayout outputLayoutSubstitute;
@@ -183,29 +183,29 @@ OSStatus AUPannerBase::SetDefaultChannelLayoutsIfNone()
err = SetAudioChannelLayout(kAudioUnitScope_Output, 0, &GetOutputLayout());
if (err) return err;
}
-
+
return err;
}
-
+
OSStatus AUPannerBase::UpdateBypassMatrix()
{
OSStatus err = SetDefaultChannelLayoutsIfNone();
if (err) return err;
-
+
UInt32 inChannels = GetNumberOfInputChannels();
- UInt32 outChannels = GetNumberOfOutputChannels();
-
+ UInt32 outChannels = GetNumberOfOutputChannels();
+
const AudioChannelLayout* inoutACL[2];
-
+
inoutACL[0] = &GetInputLayout();
inoutACL[1] = &GetOutputLayout();
mBypassMatrix.alloc(inChannels * outChannels, true);
-
+
UInt32 propSize = inChannels * outChannels * sizeof(Float32);
-
+
err = AudioFormatGetProperty(kAudioFormatProperty_MatrixMixMap, sizeof(inoutACL), inoutACL, &propSize, mBypassMatrix());
if (err) {
// if there is an error, use a diagonal matrix.
@@ -225,7 +225,7 @@ OSStatus AUPannerBase::UpdateBypassMatrix()
/*! @method Cleanup */
void AUPannerBase::Cleanup()
{
-
+
}
@@ -249,9 +249,9 @@ OSStatus AUPannerBase::GetParameterInfo( AudioUnitScope inScope,
outParameterInfo.flags = kAudioUnitParameterFlag_IsWritable
+ kAudioUnitParameterFlag_IsReadable;
-
+
if (inScope == kAudioUnitScope_Global) {
-
+
switch(inParameterID)
{
case kPannerParam_Azimuth:
@@ -279,7 +279,7 @@ OSStatus AUPannerBase::GetParameterInfo( AudioUnitScope inScope,
outParameterInfo.flags += kAudioUnitParameterFlag_IsHighResolution;
//outParameterInfo.flags += kAudioUnitParameterFlag_DisplayLogarithmic;
break;
-
+
case kPannerParam_CoordScale:
AUBase::FillInParameterName (outParameterInfo, kPanner_CoordScale_Name, false);
outParameterInfo.unit = kAudioUnitParameterUnit_Meters;
@@ -313,9 +313,9 @@ OSStatus AUPannerBase::GetParameterInfo( AudioUnitScope inScope,
} else {
result = kAudioUnitErr_InvalidParameter;
}
-
+
return result;
-}
+}
//_____________________________________________________________________________
//
@@ -324,15 +324,15 @@ OSStatus AUPannerBase::GetParameter( AudioUnitParameterID inParamID,
AudioUnitElement inElement,
Float32 & outValue)
{
- if (inScope != kAudioUnitScope_Global)
+ if (inScope != kAudioUnitScope_Global)
return kAudioUnitErr_InvalidScope;
-
+
outValue = Globals()->GetParameter(inParamID);
return noErr;
}
-
+
//_____________________________________________________________________________
//
OSStatus AUPannerBase::SetParameter( AudioUnitParameterID inParamID,
@@ -341,11 +341,11 @@ OSStatus AUPannerBase::SetParameter( AudioUnitParameterID inParamID,
Float32 inValue,
UInt32 inBufferOffsetInFrames)
{
- if (inScope != kAudioUnitScope_Global)
+ if (inScope != kAudioUnitScope_Global)
return kAudioUnitErr_InvalidScope;
Globals()->SetParameter(inParamID, inValue);
-
+
return noErr;
}
@@ -365,7 +365,7 @@ OSStatus AUPannerBase::GetPropertyInfo (AudioUnitPropertyID inID,
case kAudioUnitProperty_BypassEffect:
if (inScope != kAudioUnitScope_Global)
return kAudioUnitErr_InvalidScope;
-
+
outWritable = true;
outDataSize = sizeof (UInt32);
break;
@@ -384,7 +384,7 @@ OSStatus AUPannerBase::GetProperty (AudioUnitPropertyID inID,
void * outData)
{
OSStatus err = noErr;
- switch (inID)
+ switch (inID)
{
case kAudioUnitProperty_BypassEffect:
if (inScope != kAudioUnitScope_Global)
@@ -407,14 +407,14 @@ OSStatus AUPannerBase::SetProperty(AudioUnitPropertyID inID,
const void * inData,
UInt32 inDataSize)
{
- switch (inID)
+ switch (inID)
{
case kAudioUnitProperty_BypassEffect:
if (inDataSize < sizeof(UInt32))
return kAudioUnitErr_InvalidPropertyValue;
bool tempNewSetting = *((UInt32*)inData) != 0;
// we're changing the state of bypass
- if (tempNewSetting != IsBypassEffect())
+ if (tempNewSetting != IsBypassEffect())
{
if (!tempNewSetting && IsBypassEffect() && IsInitialized()) // turning bypass off and we're initialized
Reset(0, 0);
@@ -444,15 +444,15 @@ OSStatus AUPannerBase::ChangeStreamFormat (
const CAStreamBasicDescription & inPrevFormat,
const CAStreamBasicDescription & inNewFormat)
{
- if (inScope == kAudioUnitScope_Input && !InputChannelConfigIsSupported(inNewFormat.NumberChannels()))
+ if (inScope == kAudioUnitScope_Input && !InputChannelConfigIsSupported(inNewFormat.NumberChannels()))
return kAudioUnitErr_FormatNotSupported;
-
- if (inScope == kAudioUnitScope_Output && !OutputChannelConfigIsSupported(inNewFormat.NumberChannels()))
+
+ if (inScope == kAudioUnitScope_Output && !OutputChannelConfigIsSupported(inNewFormat.NumberChannels()))
return kAudioUnitErr_FormatNotSupported;
-
+
if (inNewFormat.NumberChannels() != inPrevFormat.NumberChannels())
RemoveAudioChannelLayout(inScope, inElement);
-
+
return AUBase::ChangeStreamFormat(inScope, inElement, inPrevFormat, inNewFormat);
}
@@ -463,9 +463,9 @@ OSStatus AUPannerBase::Render(AudioUnitRenderActionFlags & ioActionFlags,
const AudioTimeStamp & inTimeStamp,
UInt32 inNumberFrames)
{
- if (IsBypassEffect())
+ if (IsBypassEffect())
return BypassRender(ioActionFlags, inTimeStamp, inNumberFrames);
- else
+ else
return PannerRender(ioActionFlags, inTimeStamp, inNumberFrames);
}
@@ -483,16 +483,16 @@ OSStatus AUPannerBase::BypassRender(AudioUnitRenderActionFlags & ioActionFlags
AudioBufferList& outputBufferList = GetOutput(0)->GetBufferList();
AUBufferList::ZeroBuffer(outputBufferList);
-
- if (!isSilent)
+
+ if (!isSilent)
{
UInt32 inChannels = GetNumberOfInputChannels();
UInt32 outChannels = GetNumberOfOutputChannels();
Float32* bypass = mBypassMatrix();
for (UInt32 outChan = 0; outChan < outChannels; ++outChan)
{
- float* outData = GetOutput(0)->GetChannelData(outChan);
-
+ float* outData = GetOutput(0)->GetChannelData(outChan);
+
for (UInt32 inChan = 0; inChan < inChannels; ++inChan)
{
float* inData = GetInput(0)->GetChannelData(inChan);
@@ -510,13 +510,13 @@ UInt32 AUPannerBase::GetAudioChannelLayout( AudioUnitScope inScope,
AudioUnitElement inElement,
AudioChannelLayout * outLayoutPtr,
Boolean & outWritable)
-{
+{
SetDefaultChannelLayoutsIfNone();
-
+
outWritable = true;
-
+
CAAudioChannelLayout* caacl = NULL;
- switch (inScope)
+ switch (inScope)
{
case kAudioUnitScope_Input:
caacl = &mInputLayout;
@@ -527,14 +527,14 @@ UInt32 AUPannerBase::GetAudioChannelLayout( AudioUnitScope inScope,
default:
COMPONENT_THROW(kAudioUnitErr_InvalidScope);
}
-
+
if (inElement != 0)
COMPONENT_THROW(kAudioUnitErr_InvalidElement);
-
+
UInt32 size = caacl->IsValid() ? caacl->Size() : 0;
if (size > 0 && outLayoutPtr)
memcpy(outLayoutPtr, &caacl->Layout(), size);
-
+
return size;
}
@@ -544,7 +544,7 @@ OSStatus AUPannerBase::RemoveAudioChannelLayout( AudioUnitScope inScope,
AudioUnitElement inElement)
{
CAAudioChannelLayout* caacl = NULL;
- switch (inScope)
+ switch (inScope)
{
case kAudioUnitScope_Input:
caacl = &mInputLayout;
@@ -555,17 +555,17 @@ OSStatus AUPannerBase::RemoveAudioChannelLayout( AudioUnitScope inScope,
default:
return kAudioUnitErr_InvalidScope;
}
-
+
if (inElement != 0)
return kAudioUnitErr_InvalidElement;
-
+
*caacl = NULL;
return noErr;
}
//_____________________________________________________________________________
//
-OSStatus AUPannerBase::SetAudioChannelLayout( AudioUnitScope inScope,
+OSStatus AUPannerBase::SetAudioChannelLayout( AudioUnitScope inScope,
AudioUnitElement inElement,
const AudioChannelLayout * inLayout)
{
@@ -574,10 +574,10 @@ OSStatus AUPannerBase::SetAudioChannelLayout( AudioUnitScope inScope,
if (!ChannelLayoutTagIsSupported(inScope, inElement, inLayout->mChannelLayoutTag))
return kAudioUnitErr_FormatNotSupported;
-
+
CAAudioChannelLayout* caacl = NULL;
UInt32 currentChannels;
- switch (inScope)
+ switch (inScope)
{
case kAudioUnitScope_Input:
caacl = &mInputLayout;
@@ -590,28 +590,28 @@ OSStatus AUPannerBase::SetAudioChannelLayout( AudioUnitScope inScope,
default:
return kAudioUnitErr_InvalidScope;
}
-
+
if (inElement != 0)
return kAudioUnitErr_InvalidElement;
UInt32 numChannelsInLayout = CAAudioChannelLayout::NumberChannels(*inLayout);
if (currentChannels != numChannelsInLayout)
return kAudioUnitErr_InvalidPropertyValue;
-
+
*caacl = inLayout;
if (IsInitialized())
UpdateBypassMatrix();
-
+
return noErr;
}
//_____________________________________________________________________________
//
UInt32 AUPannerBase::GetChannelLayoutTags( AudioUnitScope inScope,
- AudioUnitElement inElement,
+ AudioUnitElement inElement,
AudioChannelLayoutTag* outTags)
{
- switch (inScope)
+ switch (inScope)
{
case kAudioUnitScope_Input:
if (outTags) {
@@ -687,20 +687,20 @@ bool AUPannerBase::OutputChannelConfigIsSupported(UInt32 inNumberChannels)
//_____________________________________________________________________________
//
-bool AUPannerBase::ChannelLayoutTagIsSupported( AudioUnitScope inScope,
- AudioUnitElement inElement,
+bool AUPannerBase::ChannelLayoutTagIsSupported( AudioUnitScope inScope,
+ AudioUnitElement inElement,
AudioChannelLayoutTag inTag)
{
UInt32 numTags = GetChannelLayoutTags(inScope, inElement, NULL);
CAAutoFree<AudioChannelLayoutTag> tags(numTags);
GetChannelLayoutTags(inScope, inElement, tags());
-
+
for (UInt32 i = 0; i < numTags; ++i)
{
if (tags[i] == inTag)
return true;
}
-
+
return false;
}