Equalizer: Fix to function properly

This was completely broken, oops.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
This commit is contained in:
Christopher Snowhill 2025-02-13 13:39:16 -08:00
parent 8647f76a46
commit f3132e0061

View file

@ -385,8 +385,7 @@ static OSStatus eqRenderCallback(void *inRefCon, AudioUnitRenderActionFlags *ioA
return [self readChunk:4096]; return [self readChunk:4096];
} }
size_t totalFrameCount = 0; AudioChunk *chunk = [self readChunkAsFloat32:4096];
AudioChunk *chunk = [self readAndMergeChunksAsFloat32:4096];
if(!chunk || ![chunk frameCount]) { if(!chunk || ![chunk frameCount]) {
processEntered = NO; processEntered = NO;
return nil; return nil;
@ -409,7 +408,7 @@ static OSStatus eqRenderCallback(void *inRefCon, AudioUnitRenderActionFlags *ioA
ioData->mNumberBuffers = (UInt32)channels; ioData->mNumberBuffers = (UInt32)channels;
for(size_t i = 0; i < channels; ++i) { for(size_t i = 0; i < channels; ++i) {
ioData->mBuffers[i].mData = &eqBuffer[4096 * i]; ioData->mBuffers[i].mData = &eqBuffer[4096 * i];
ioData->mBuffers[i].mDataByteSize = (UInt32)(totalFrameCount * sizeof(float)); ioData->mBuffers[i].mDataByteSize = (UInt32)(frameCount * sizeof(float));
ioData->mBuffers[i].mNumberChannels = 1; ioData->mBuffers[i].mNumberChannels = 1;
} }
@ -428,7 +427,7 @@ static OSStatus eqRenderCallback(void *inRefCon, AudioUnitRenderActionFlags *ioA
AudioChunk *outputChunk = nil; AudioChunk *outputChunk = nil;
if(frameCount) { if(frameCount) {
scale_by_volume(&outBuffer[0], totalFrameCount * channels, equalizerPreamp); scale_by_volume(&outBuffer[0], frameCount * channels, equalizerPreamp);
outputChunk = [[AudioChunk alloc] init]; outputChunk = [[AudioChunk alloc] init];
[outputChunk setFormat:inputFormat]; [outputChunk setFormat:inputFormat];
@ -438,7 +437,7 @@ static OSStatus eqRenderCallback(void *inRefCon, AudioUnitRenderActionFlags *ioA
if([chunk isHDCD]) [outputChunk setHDCD]; if([chunk isHDCD]) [outputChunk setHDCD];
[outputChunk setStreamTimestamp:streamTimestamp]; [outputChunk setStreamTimestamp:streamTimestamp];
[outputChunk setStreamTimeRatio:[chunk streamTimeRatio]]; [outputChunk setStreamTimeRatio:[chunk streamTimeRatio]];
[outputChunk assignSamples:&outBuffer[0] frameCount:totalFrameCount]; [outputChunk assignSamples:&outBuffer[0] frameCount:frameCount];
} }
processEntered = NO; processEntered = NO;