TheAmazingAudioEngine / TheAmazingAudioEngine2

The Amazing Audio Engine is a sophisticated framework for iOS audio applications, built so you don't have to.
http://theamazingaudioengine.com/doc2
Other
544 stars 87 forks source link

Add protocol for output modules? #30

Closed jackpal closed 8 years ago

jackpal commented 8 years ago

I've been using TAAE2 in a music player, and so far it's been working well.

For my automated tests I wrote an AudioDataOutput class, that is similar to AEAudioFileOutput, but instead of writing to an audio file it calls a callback method with the current batch of audio data. That way my automated tests can compare the generated audio to the expected audio.

This works, and it's convenient to have the tests run faster than real time.

I wonder if (a) this is something that TAAE2 could have built in, and (b) if there should be some sort of common protocol for output modules, so that it would be easier to write code that works with one of several output modules.

Currently my code that handles which output unit to create looks something like this:

... in my class's instance variable declaration block. // Poor-man's polymorphism. Only one of these two outputs will be initialized. AEAudioUnitOutput _output; MYAudioDataOutput _dataOutput;

if (testing) { _dataOutput = [[MYAudioDataOutput alloc] initWithRenderer:renderer ...]; [_dataOutput start:NULL]; } else { _output = [[AEAudioUnitOutput alloc] initWithRenderer:renderer]; [_output start:NULL]; }

If there was a common protocol for output modules, the code could look like:

AEOutput *_output;

if (testing) { _output = [[MYAudioDataOutput alloc] initWithRenderer:renderer ...]; } else { _output = [[AEAudioUnitOutput alloc] initWithRenderer:renderer]; } [_output start:NULL];

jackpal commented 8 years ago

FWIW I've refactored my code so that I don't need this feature any more.