Skip to content

Commit

Permalink
Renamed AEAggregatorModule to AEMixerModule
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeltyson committed Jun 8, 2016
1 parent a5f987d commit 952efe1
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 39 deletions.
10 changes: 5 additions & 5 deletions TAAESample/Classes/AEAudioController.m
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ - (instancetype)init {
self.hit = oneshot;
[players addObject:oneshot];

// Create an aggregator module to run the players
AEAggregatorModule * aggregator = [[AEAggregatorModule alloc] initWithRenderer:subrenderer];
aggregator.modules = players;
// Create a mixer module to run the players
AEMixerModule * mixer = [[AEMixerModule alloc] initWithRenderer:subrenderer];
mixer.modules = players;

// Setup mic input (we'll draw from the output's IO audio unit, on iOS; on the Mac, this has its own IO unit).
AEAudioUnitInputModule * input = self.output.inputModule;
Expand All @@ -130,8 +130,8 @@ - (instancetype)init {
// rules apply: No holding locks, no memory allocation, no Objective-C/Swift code.
AEVarispeedModule * varispeed = [[AEVarispeedModule alloc] initWithRenderer:renderer subrenderer:subrenderer];
subrenderer.block = ^(const AERenderContext * _Nonnull context) {
// Run all the players, though the aggregator
AEModuleProcess(aggregator, context);
// Run all the players, though the mixer
AEModuleProcess(mixer, context);

// Put the resulting buffer on the output
AERenderContextOutput(context, 1);
Expand Down
32 changes: 16 additions & 16 deletions TheAmazingAudioEngine.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
4C3182DC1CDC1EA90085634F /* AERenderContext.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C3182D81CDC1EA90085634F /* AERenderContext.m */; };
4C3182DD1CDC1EA90085634F /* AERenderContext.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C3182D81CDC1EA90085634F /* AERenderContext.m */; };
4C3182DE1CDC1EA90085634F /* AERenderContext.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C3182D81CDC1EA90085634F /* AERenderContext.m */; };
4C3183101CDDEFDE0085634F /* AEAggregatorModule.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C31830E1CDDEFDE0085634F /* AEAggregatorModule.h */; settings = {ATTRIBUTES = (Public, ); }; };
4C3183111CDDEFDE0085634F /* AEAggregatorModule.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C31830E1CDDEFDE0085634F /* AEAggregatorModule.h */; settings = {ATTRIBUTES = (Public, ); }; };
4C3183121CDDEFDE0085634F /* AEAggregatorModule.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C31830E1CDDEFDE0085634F /* AEAggregatorModule.h */; settings = {ATTRIBUTES = (Public, ); }; };
4C3183131CDDEFDE0085634F /* AEAggregatorModule.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C31830F1CDDEFDE0085634F /* AEAggregatorModule.m */; };
4C3183141CDDEFDE0085634F /* AEAggregatorModule.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C31830F1CDDEFDE0085634F /* AEAggregatorModule.m */; };
4C3183151CDDEFDE0085634F /* AEAggregatorModule.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C31830F1CDDEFDE0085634F /* AEAggregatorModule.m */; };
4C3183101CDDEFDE0085634F /* AEMixerModule.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C31830E1CDDEFDE0085634F /* AEMixerModule.h */; settings = {ATTRIBUTES = (Public, ); }; };
4C3183111CDDEFDE0085634F /* AEMixerModule.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C31830E1CDDEFDE0085634F /* AEMixerModule.h */; settings = {ATTRIBUTES = (Public, ); }; };
4C3183121CDDEFDE0085634F /* AEMixerModule.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C31830E1CDDEFDE0085634F /* AEMixerModule.h */; settings = {ATTRIBUTES = (Public, ); }; };
4C3183131CDDEFDE0085634F /* AEMixerModule.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C31830F1CDDEFDE0085634F /* AEMixerModule.m */; };
4C3183141CDDEFDE0085634F /* AEMixerModule.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C31830F1CDDEFDE0085634F /* AEMixerModule.m */; };
4C3183151CDDEFDE0085634F /* AEMixerModule.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C31830F1CDDEFDE0085634F /* AEMixerModule.m */; };
4C3183181CDEC6560085634F /* AEAudioFileOutput.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C3183161CDEC6560085634F /* AEAudioFileOutput.h */; settings = {ATTRIBUTES = (Public, ); }; };
4C3183191CDEC6560085634F /* AEAudioFileOutput.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C3183161CDEC6560085634F /* AEAudioFileOutput.h */; settings = {ATTRIBUTES = (Public, ); }; };
4C31831A1CDEC6560085634F /* AEAudioFileOutput.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C3183161CDEC6560085634F /* AEAudioFileOutput.h */; settings = {ATTRIBUTES = (Public, ); }; };
Expand Down Expand Up @@ -323,8 +323,8 @@
/* Begin PBXFileReference section */
4C3182D71CDC1EA90085634F /* AERenderContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AERenderContext.h; sourceTree = "<group>"; };
4C3182D81CDC1EA90085634F /* AERenderContext.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AERenderContext.m; sourceTree = "<group>"; };
4C31830E1CDDEFDE0085634F /* AEAggregatorModule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AEAggregatorModule.h; sourceTree = "<group>"; };
4C31830F1CDDEFDE0085634F /* AEAggregatorModule.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AEAggregatorModule.m; sourceTree = "<group>"; };
4C31830E1CDDEFDE0085634F /* AEMixerModule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AEMixerModule.h; sourceTree = "<group>"; };
4C31830F1CDDEFDE0085634F /* AEMixerModule.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AEMixerModule.m; sourceTree = "<group>"; };
4C3183161CDEC6560085634F /* AEAudioFileOutput.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AEAudioFileOutput.h; sourceTree = "<group>"; };
4C3183171CDEC6560085634F /* AEAudioFileOutput.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AEAudioFileOutput.m; sourceTree = "<group>"; };
4C3183461CE8307A0085634F /* AEDSPUtilitiesTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AEDSPUtilitiesTests.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -605,8 +605,8 @@
4CDCAD9F1CA90FD3008AAEF1 /* AEAudioFilePlayerModule.m */,
4CDCAD511CA3D223008AAEF1 /* AEOscillatorModule.h */,
4CDCAD521CA3D223008AAEF1 /* AEOscillatorModule.m */,
4C31830E1CDDEFDE0085634F /* AEAggregatorModule.h */,
4C31830F1CDDEFDE0085634F /* AEAggregatorModule.m */,
4C31830E1CDDEFDE0085634F /* AEMixerModule.h */,
4C31830F1CDDEFDE0085634F /* AEMixerModule.m */,
4CBCF29C1CFBC3D200CA2EA0 /* AESplitterModule.h */,
4CBCF29D1CFBC3D200CA2EA0 /* AESplitterModule.m */,
);
Expand Down Expand Up @@ -682,7 +682,7 @@
4C9F0F5B1CB265F90032903E /* AEDistortionModule.h in Headers */,
4C9F0F5C1CB265F90032903E /* AEAudioUnitInputModule.h in Headers */,
4C9F0F5D1CB265F90032903E /* AEAudioUnitModule.h in Headers */,
4C3183111CDDEFDE0085634F /* AEAggregatorModule.h in Headers */,
4C3183111CDDEFDE0085634F /* AEMixerModule.h in Headers */,
4C9F0F5E1CB265F90032903E /* AELowPassModule.h in Headers */,
4C9F0F5F1CB265F90032903E /* AEDynamicsProcessorModule.h in Headers */,
4C9F0F601CB265F90032903E /* AEBandpassModule.h in Headers */,
Expand Down Expand Up @@ -732,7 +732,7 @@
4C9F0FA41CB269C30032903E /* AEDistortionModule.h in Headers */,
4C9F0FA51CB269C30032903E /* AEAudioUnitInputModule.h in Headers */,
4C9F0FA61CB269C30032903E /* AEAudioUnitModule.h in Headers */,
4C3183121CDDEFDE0085634F /* AEAggregatorModule.h in Headers */,
4C3183121CDDEFDE0085634F /* AEMixerModule.h in Headers */,
4C9F0FA71CB269C30032903E /* AELowPassModule.h in Headers */,
4C9F0FA81CB269C30032903E /* AEDynamicsProcessorModule.h in Headers */,
4C9F0FA91CB269C30032903E /* AEBandpassModule.h in Headers */,
Expand Down Expand Up @@ -765,7 +765,7 @@
buildActionMask = 2147483647;
files = (
4CDCAD7A1CA5484D008AAEF1 /* AEDelayModule.h in Headers */,
4C3183101CDDEFDE0085634F /* AEAggregatorModule.h in Headers */,
4C3183101CDDEFDE0085634F /* AEMixerModule.h in Headers */,
4C7756A01CD2E5E3004415A2 /* AECircularBuffer.h in Headers */,
4CDCAD471CA3C31C008AAEF1 /* AEUtilities.h in Headers */,
4CDCAD881CA5484D008AAEF1 /* AENewTimePitchModule.h in Headers */,
Expand Down Expand Up @@ -950,7 +950,7 @@
4C9F0F361CB265F90032903E /* AEOscillatorModule.m in Sources */,
4CE5F4C81CD30A1900322F03 /* AEMainThreadEndpoint.m in Sources */,
4C9F0F371CB265F90032903E /* AEMessageQueue.m in Sources */,
4C3183141CDDEFDE0085634F /* AEAggregatorModule.m in Sources */,
4C3183141CDDEFDE0085634F /* AEMixerModule.m in Sources */,
4CBCF2A21CFBC3D200CA2EA0 /* AESplitterModule.m in Sources */,
4C9F0F381CB265F90032903E /* AELowShelfModule.m in Sources */,
4C9F0F391CB265F90032903E /* AEAudioUnitInputModule.m in Sources */,
Expand Down Expand Up @@ -999,7 +999,7 @@
4C9F0F801CB269C30032903E /* AEOscillatorModule.m in Sources */,
4CE5F4C91CD30A1900322F03 /* AEMainThreadEndpoint.m in Sources */,
4C9F0F811CB269C30032903E /* AEMessageQueue.m in Sources */,
4C3183151CDDEFDE0085634F /* AEAggregatorModule.m in Sources */,
4C3183151CDDEFDE0085634F /* AEMixerModule.m in Sources */,
4CBCF2A31CFBC3D200CA2EA0 /* AESplitterModule.m in Sources */,
4C9F0F821CB269C30032903E /* AELowShelfModule.m in Sources */,
4C9F0F831CB269C30032903E /* AEAudioUnitInputModule.m in Sources */,
Expand Down Expand Up @@ -1058,7 +1058,7 @@
4CDCAD7D1CA5484D008AAEF1 /* AEDistortionModule.m in Sources */,
4CDCADBB1CAC95A8008AAEF1 /* AEAudioUnitOutput.m in Sources */,
4CDCAD851CA5484D008AAEF1 /* AELowPassModule.m in Sources */,
4C3183131CDDEFDE0085634F /* AEAggregatorModule.m in Sources */,
4C3183131CDDEFDE0085634F /* AEMixerModule.m in Sources */,
4CDCAD811CA5484D008AAEF1 /* AEHighPassModule.m in Sources */,
4CDCAD911CA5484D008AAEF1 /* AEVarispeedModule.m in Sources */,
4CDCAD791CA5484D008AAEF1 /* AEBandpassModule.m in Sources */,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// AEAggregatorModule.h
// AEMixerModule.h
// TheAmazingAudioEngine
//
// Created by Michael Tyson on 7/05/2016.
Expand Down Expand Up @@ -31,15 +31,15 @@ extern "C" {
#import "AEModule.h"

/*!
* Aggregator module
* Mixer module
*
* This module provides a convenient way to aggregate multiple generator modules
* together, with facilities for applying volume and balance per-generator module.
*
* You should use this with generator modules only - that is, modules that push
* a buffer onto the stack when they are processed.
*/
@interface AEAggregatorModule : AEModule
@interface AEMixerModule : AEModule

/*!
* Initializer
Expand Down Expand Up @@ -96,6 +96,9 @@ extern "C" {

@end

//! Temporary alias from AEAggregatorModule to AEMixerModule
typedef AEMixerModule AEAggregatorModule __deprecated_msg("use AEMixerModule");

#ifdef __cplusplus
}
#endif
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// AEAggregatorModule.m
// AEMixerModule.m
// TheAmazingAudioEngine
//
// Created by Michael Tyson on 7/05/2016.
Expand All @@ -25,7 +25,7 @@
//


#import "AEAggregatorModule.h"
#import "AEMixerModule.h"
#import "AEArray.h"
#import "AEBufferStack.h"
#import "AEUtilities.h"
Expand All @@ -37,13 +37,13 @@
float targetVolume;
float currentBalance;
float targetBalance;
} AEAggregatorModuleSubModuleEntry;
} AEMixerModuleSubModuleEntry;

@interface AEAggregatorModule ()
@interface AEMixerModule ()
@property (nonatomic, strong) AEArray * array;
@end

@implementation AEAggregatorModule
@implementation AEMixerModule
@dynamic modules;

- (instancetype)initWithRenderer:(AERenderer *)renderer {
Expand All @@ -56,7 +56,7 @@ - (instancetype)initWithRenderer:(AERenderer *)renderer {

self.numberOfChannels = 2;

self.processFunction = AEAggregatorModuleProcess;
self.processFunction = AEMixerModuleProcess;

return self;
}
Expand Down Expand Up @@ -88,30 +88,30 @@ - (void)setModules:(NSArray *)modules {
}

- (void)setVolume:(float)volume balance:(float)balance forModule:(AEModule *)module {
AEAggregatorModuleSubModuleEntry * entry = [self.array pointerValueForObject:module];
AEMixerModuleSubModuleEntry * entry = [self.array pointerValueForObject:module];
if ( entry ) {
entry->targetVolume = volume;
entry->targetBalance = balance;
}
}

- (void)getVolume:(float *)volume balance:(float *)balance forModule:(AEModule *)module {
AEAggregatorModuleSubModuleEntry * entry = [self.array pointerValueForObject:module];
AEMixerModuleSubModuleEntry * entry = [self.array pointerValueForObject:module];
if ( entry ) {
*volume = entry->targetVolume;
*balance = entry->targetBalance;
}
}

static void AEAggregatorModuleProcess(__unsafe_unretained AEAggregatorModule * self, const AERenderContext * _Nonnull context) {
static void AEMixerModuleProcess(__unsafe_unretained AEMixerModule * self, const AERenderContext * _Nonnull context) {
const AudioBufferList * abl = AEBufferStackPushWithChannels(context->stack, 1, self->_numberOfChannels);
if ( !abl ) return;

// Silence buffer first
AEAudioBufferListSilence(abl, 0, context->frames);

// Run each module, applying volume/balance then mixing into our output buffer
AEArrayEnumeratePointers(self->_array, AEAggregatorModuleSubModuleEntry *, entry, {
AEArrayEnumeratePointers(self->_array, AEMixerModuleSubModuleEntry *, entry, {

if ( !AEModuleIsActive(entry->module) ) {
// Module is idle; skip (and skip the volume/balance ramp, too)
Expand All @@ -129,7 +129,7 @@ static void AEAggregatorModuleProcess(__unsafe_unretained AEAggregatorModule * s
#ifdef DEBUG
if ( AEBufferStackCount(context->stack) != priorStackDepth+1 ) {
if ( AERateLimit() ) {
printf("A module within AEAggregatorModule didn't push a buffer! Sure it's a generator?\n");
printf("A module within AEMixerModule didn't push a buffer! Sure it's a generator?\n");
}
continue;
}
Expand All @@ -142,8 +142,8 @@ static void AEAggregatorModuleProcess(__unsafe_unretained AEAggregatorModule * s
});
}

- (AEAggregatorModuleSubModuleEntry *)newEntryForModule:(AEModule *)module volume:(float)volume balance:(float)balance {
AEAggregatorModuleSubModuleEntry * entry = malloc(sizeof(AEAggregatorModuleSubModuleEntry));
- (AEMixerModuleSubModuleEntry *)newEntryForModule:(AEModule *)module volume:(float)volume balance:(float)balance {
AEMixerModuleSubModuleEntry * entry = malloc(sizeof(AEMixerModuleSubModuleEntry));
entry->module = module;
entry->currentVolume = volume;
entry->targetVolume = volume;
Expand Down
4 changes: 2 additions & 2 deletions TheAmazingAudioEngine/TheAmazingAudioEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ extern "C" {
#import <TheAmazingAudioEngine/AEAudioUnitInputModule.h>
#import <TheAmazingAudioEngine/AEAudioFilePlayerModule.h>
#import <TheAmazingAudioEngine/AEOscillatorModule.h>
#import <TheAmazingAudioEngine/AEAggregatorModule.h>
#import <TheAmazingAudioEngine/AEMixerModule.h>
#import <TheAmazingAudioEngine/AESplitterModule.h>
#import <TheAmazingAudioEngine/AEBandpassModule.h>
#import <TheAmazingAudioEngine/AEDelayModule.h>
Expand Down Expand Up @@ -121,7 +121,7 @@ extern "C" {
- AEAudioUnitInputModule: Get system input.
- AEAudioFileRecorderModule: Record files.
- AESubrendererModule: Drive a sub-renderer.
- AEAggregatorModule: Drive multiple generators.
- AEMixerModule: Drive multiple generators.
</td>
</tr>
<tr>
Expand Down

0 comments on commit 952efe1

Please sign in to comment.