forked from decarbonization/PlayerKit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PKMatrixReverbEffect.cpp
58 lines (49 loc) · 1.58 KB
/
PKMatrixReverbEffect.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
* PKMatrixReverbEffect.cpp
* PlayerKit
*
* Created by Peter MacWhinnie on 1/12/11.
* Copyright 2011 __MyCompanyName__. All rights reserved.
*
*/
#include "PKMatrixReverbEffect.h"
#include "CAComponentDescription.h"
#include "CoreAudioErrors.h"
#include <iostream>
#pragma mark Creation
PK_EXTERN PKMatrixReverbEffectRef PKMatrixReverbEffectCreate(CFErrorRef *outError)
{
AudioComponentDescription matrixReverbDescription = {
kAudioUnitType_Effect,
kAudioUnitSubType_MatrixReverb,
kAudioUnitManufacturer_Apple,
};
return PKAudioEffectCreate(matrixReverbDescription, outError);
}
#pragma mark -
#pragma mark Properties
PK_EXTERN Boolean PKMatrixReverbEffectSetAmount(PKMatrixReverbEffectRef effect, AudioUnitParameterValue value, CFErrorRef *outError)
{
OSStatus error = PKAudioEffectSetParameter(effect,
value,
kReverbParam_DryWetMix,
kAudioUnitScope_Global,
0);
if(error != noErr)
{
if(outError) *outError = PKCopyError(PKEffectsErrorDomain,
error,
NULL,
CFSTR("Could not reverb amount, Error %@ (%d)."), CoreAudioGetErrorName(error), error);
return false;
}
return true;
}
PK_EXTERN AudioUnitParameterValue PKMatrixReverbEffectGetAmount(PKMatrixReverbEffectRef effect)
{
AudioUnitParameterValue value = 0.0;
OSStatus error = PKAudioEffectCopyParameter(effect, &value, kReverbParam_DryWetMix, kAudioUnitScope_Global);
if(error != noErr)
std::cerr << __PRETTY_FUNCTION__ << ": Could not get value of amount. Ignoring error " << error << "." << std::endl;
return value;
}