Skip to content

Commit

Permalink
refactor: added cleaning sourceNode
Browse files Browse the repository at this point in the history
  • Loading branch information
Maciej Makowski committed Sep 30, 2024
1 parent ac932b0 commit a8c597f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ - (void)process:(AVAudioFrameCount)frameCount bufferList:(AudioBufferList *)buff

for (int bufferNum = 0; bufferNum < bufferList->mNumberBuffers; bufferNum += 1) {
float *buffer = (float *)bufferList->mBuffers[bufferNum].mData;

buffer[frame] *= currentGain;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ - (void)cleanup
_frequencyParam = nil;
_detuneParam = nil;
_format = nil;
_sourceNode = nil;
}

- (OSStatus)renderCallbackWithIsSilence:(BOOL *)isSilence
Expand Down Expand Up @@ -104,8 +105,10 @@ - (OSStatus)renderCallbackWithIsSilence:(BOOL *)isSilence
_phase += FULL_CIRCLE_RADIANS;
}
}

[self process:frameCount bufferList:outputData];

if (self.isPlaying) {
[self process:frameCount bufferList:outputData];
}

return noErr;
}
Expand Down

0 comments on commit a8c597f

Please sign in to comment.