41 #include "MatrixMixerVolumes.h"
42 #include "CAXException.h"
44 OSStatus NumberChannels (AudioUnit au,
45 AudioUnitScope inScope,
46 AudioUnitElement inEl,
50 OSStatus PrintBuses (FILE* file,
char* str, AudioUnit au, AudioUnitScope inScope)
54 UInt32 theSize =
sizeof(busCount);
56 ca_require_noerr (result = AudioUnitGetProperty (au, kAudioUnitProperty_ElementCount,
57 inScope, 0, &busCount, &theSize), home);
59 fprintf (file,
"\t%s Elements:\n\t\t", str);
60 for (UInt32 i = 0; i < busCount; ++i) {
62 ca_require_noerr (result = AudioUnitGetParameter (au, kMatrixMixerParam_Enable, inScope, i, &val), home);
64 ca_require_noerr (result = NumberChannels (au, inScope, i, numChans), home);
65 char frameCharStart = (val != 0 ?
'[' :
'{');
66 char frameCharEnd = (val != 0 ?
']' :
'}');
67 fprintf (file,
"%d:%c%d, %c%c ", (
int)i, frameCharStart, (
int)numChans, (val != 0 ?
'T' :
'F'), frameCharEnd);
74 void PrintMatrixMixerVolumes (FILE* file, AudioUnit au)
77 UInt32 theSize =
sizeof(UInt32) * 2;
78 Float32 *theVols = NULL;
82 ca_require_noerr (result = AudioUnitGetProperty (au, kAudioUnitProperty_MatrixDimensions,
83 kAudioUnitScope_Global, 0, dims, &theSize), home);
85 theSize = ((dims[0] + 1) * (dims[1] + 1)) *
sizeof(Float32);
87 theVols =
static_cast<Float32*
> (malloc (theSize));
89 ca_require_noerr (result = AudioUnitGetProperty (au, kAudioUnitProperty_MatrixLevels,
90 kAudioUnitScope_Global, 0, theVols, &theSize), home);
99 theSize /=
sizeof(Float32);
101 unsigned int inputs = dims[0];
102 unsigned int outputs = dims[1];
104 fprintf (file,
"\tInput Channels = %d, Output Channels = %d\n", (
int)dims[0], (
int)dims[1]);
105 PrintBuses (file,
"Input", au, kAudioUnitScope_Input);
106 PrintBuses (file,
"Output", au, kAudioUnitScope_Output);
107 fprintf (file,
"\tGlobal Volume: %.3f\n", theVols [theSize - 1]);
108 for (
unsigned int i = 0; i < (inputs + 1); ++i) {
110 fprintf (file,
"\t%.3f ", theVols[(i + 1) * (outputs + 1) - 1]);
112 for (
unsigned int j = 0; j < outputs; ++j)
113 fprintf (file,
"(%.3f) ", theVols[(i * (outputs + 1)) + j]);
115 fprintf (file,
"\t ");
116 for (
unsigned int j = 0; j < outputs; ++j)
117 fprintf (file,
" %.3f ", theVols[(i * (outputs + 1)) + j]);
119 fprintf (file,
"\n");
123 for (
unsigned int i = 0; i < theSize; ++i)
124 printf (
"%f, ", theVols[i]);
130 OSStatus NumberChannels (AudioUnit au,
131 AudioUnitScope inScope,
132 AudioUnitElement inEl,
135 AudioStreamBasicDescription desc;
136 UInt32 dataSize =
sizeof (AudioStreamBasicDescription);
137 OSStatus result = AudioUnitGetProperty (au, kAudioUnitProperty_StreamFormat,
141 outChans = desc.mChannelsPerFrame;