Skip to content

Added AEMeteringModule#2

Closed
jcypher wants to merge 2 commits intoTheAmazingAudioEngine:masterfrom
jcypher:master
Closed

Added AEMeteringModule#2
jcypher wants to merge 2 commits intoTheAmazingAudioEngine:masterfrom
jcypher:master

Conversation

@jcypher
Copy link

@jcypher jcypher commented Apr 7, 2016

I cleaned up the files a bit as per your suggestions first, then merged just the AEMeteringModule.h/m files into master. I updated TheAmazingAudioEngine.h to import the new files.

@lijon
Copy link

lijon commented Apr 7, 2016

Buffers on the buffer stack might not always be stereo, or mono. They can have any number of channels. Instead of having individual variables for "left" and "right", I'd suggest having C arrays for peak and avg, dynamically allocated by the module initializer, like initWithChannelCount: or so. The process func would then loop from 0 to min(numBufferChannels, this->channelCount)..

@jcypher
Copy link
Author

jcypher commented Apr 7, 2016

Thanks lijon, that makes sense - I'll take a stab at changing it.

@jcypher jcypher closed this Apr 7, 2016
@jcypher
Copy link
Author

jcypher commented Apr 7, 2016

@lijon - I've updated the AEMeteringModule.h/AEMeteringModule.m files to allow for variable number of audio channels.

@lijon
Copy link

lijon commented Apr 8, 2016

Looks good!

Another thing that I didn't think of before: the levels you read from this module is only the levels for the last buffer. So it can't be used for any real metering purposes - there might have been a peak in between the calls that you never see! Instead, one should get the average and peak levels since last retrieval of the levels.

Take a look at the metering code in TAAE1, it uses a reset flag that is set when getting avg and peak (both are retreived by a single call with output float * params), then the process function would check this flag and if set it would reset peak and average, otherwise update them. In TAAE1 it uses an average accumulator that is divided by number of read buffers since last reset, but I think one could also use a simple smoothing filter instead, something like _average += alpha * (avg - _average) where alpha controls the smoothing rate.

@jcypher
Copy link
Author

jcypher commented Apr 9, 2016

Thanks for the great feedback! I'm going to work on this some more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants