From 90a131ba9a6377f7bd8a9277dd67b5f28722e622 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Weibezahn?= Date: Thu, 8 May 2025 16:24:58 +0200 Subject: [PATCH 1/6] Fixing a memory leak from not deallocating audio data pointer --- Sources/SoundpipeAudioKit/Generators/PhaseLockedVocoder.swift | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Sources/SoundpipeAudioKit/Generators/PhaseLockedVocoder.swift b/Sources/SoundpipeAudioKit/Generators/PhaseLockedVocoder.swift index 81b4d64..5d48e1d 100644 --- a/Sources/SoundpipeAudioKit/Generators/PhaseLockedVocoder.swift +++ b/Sources/SoundpipeAudioKit/Generators/PhaseLockedVocoder.swift @@ -158,6 +158,9 @@ public class PhaseLockedVocoder: Node { bufferList.mBuffers.mData?.assumingMemoryBound(to: Float.self) ) au.setWavetable(data: data, size: Int(ioNumberFrames)) + // Fixing a previous memory leak + theData?.deallocate() + theData = nil } else { // failure theData?.deallocate() From 003b95454db43dbaeaee8084dc9fbcb53ef957cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Weibezahn?= Date: Thu, 8 May 2025 16:42:06 +0200 Subject: [PATCH 2/6] Moved the deallocation of theData to the end --- .../SoundpipeAudioKit/Generators/PhaseLockedVocoder.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Sources/SoundpipeAudioKit/Generators/PhaseLockedVocoder.swift b/Sources/SoundpipeAudioKit/Generators/PhaseLockedVocoder.swift index 5d48e1d..1fb86b0 100644 --- a/Sources/SoundpipeAudioKit/Generators/PhaseLockedVocoder.swift +++ b/Sources/SoundpipeAudioKit/Generators/PhaseLockedVocoder.swift @@ -158,15 +158,15 @@ public class PhaseLockedVocoder: Node { bufferList.mBuffers.mData?.assumingMemoryBound(to: Float.self) ) au.setWavetable(data: data, size: Int(ioNumberFrames)) - // Fixing a previous memory leak - theData?.deallocate() - theData = nil } else { // failure theData?.deallocate() theData = nil // make sure to return NULL Log("Error = \(err)"); break Exit } + // Fixing a previous memory leak + theData?.deallocate() + theData = nil } } } From b418616ba1d1fff54b2a2821c8197b0778a96149 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Weibezahn?= Date: Fri, 9 May 2025 08:55:27 +0200 Subject: [PATCH 3/6] cleaned up unneeded deallocation in 164 --- Sources/SoundpipeAudioKit/Generators/PhaseLockedVocoder.swift | 2 -- 1 file changed, 2 deletions(-) diff --git a/Sources/SoundpipeAudioKit/Generators/PhaseLockedVocoder.swift b/Sources/SoundpipeAudioKit/Generators/PhaseLockedVocoder.swift index 1fb86b0..33c7eb8 100644 --- a/Sources/SoundpipeAudioKit/Generators/PhaseLockedVocoder.swift +++ b/Sources/SoundpipeAudioKit/Generators/PhaseLockedVocoder.swift @@ -160,8 +160,6 @@ public class PhaseLockedVocoder: Node { au.setWavetable(data: data, size: Int(ioNumberFrames)) } else { // failure - theData?.deallocate() - theData = nil // make sure to return NULL Log("Error = \(err)"); break Exit } // Fixing a previous memory leak From a1c6c64eb600b0afbbfba618ea131411ffa2a141 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Weibezahn?= Date: Wed, 14 May 2025 13:33:27 +0200 Subject: [PATCH 4/6] Added a "dispose" method to clear the au wavetable --- .../SoundpipeAudioKit/Generators/PhaseLockedVocoder.swift | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Sources/SoundpipeAudioKit/Generators/PhaseLockedVocoder.swift b/Sources/SoundpipeAudioKit/Generators/PhaseLockedVocoder.swift index 33c7eb8..97813b1 100644 --- a/Sources/SoundpipeAudioKit/Generators/PhaseLockedVocoder.swift +++ b/Sources/SoundpipeAudioKit/Generators/PhaseLockedVocoder.swift @@ -79,7 +79,13 @@ public class PhaseLockedVocoder: Node { self.amplitude = amplitude self.pitchRatio = pitchRatio } - + + + /// Call this function after you are done with the node, to reset the au wavetable to prevent memory leaks + public func dispose() { + au.setWaveTable([0.0]) + } + internal func loadFile(_ avAudioFile: AVAudioFile) { Exit: do { var err: OSStatus = noErr From e1e25c68a1bd586e3460db4239b5ce86138fc23f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Weibezahn?= Date: Wed, 14 May 2025 13:36:11 +0200 Subject: [PATCH 5/6] removed white space --- Sources/SoundpipeAudioKit/Generators/PhaseLockedVocoder.swift | 1 - 1 file changed, 1 deletion(-) diff --git a/Sources/SoundpipeAudioKit/Generators/PhaseLockedVocoder.swift b/Sources/SoundpipeAudioKit/Generators/PhaseLockedVocoder.swift index 97813b1..2ce556f 100644 --- a/Sources/SoundpipeAudioKit/Generators/PhaseLockedVocoder.swift +++ b/Sources/SoundpipeAudioKit/Generators/PhaseLockedVocoder.swift @@ -80,7 +80,6 @@ public class PhaseLockedVocoder: Node { self.pitchRatio = pitchRatio } - /// Call this function after you are done with the node, to reset the au wavetable to prevent memory leaks public func dispose() { au.setWaveTable([0.0]) From 74c8e3e175864a28f5ae3a89bdb93360b9f4d3f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Weibezahn?= Date: Sat, 17 May 2025 11:46:01 +0200 Subject: [PATCH 6/6] Corrected a default param value in ZitaReverb The value range is 160.0...1000.0, but the default value was 1500.0 Nothing bad happened because of this, but now it is more correct, with a default value of 1000.0. --- Sources/SoundpipeAudioKit/Effects/ZitaReverb.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/SoundpipeAudioKit/Effects/ZitaReverb.swift b/Sources/SoundpipeAudioKit/Effects/ZitaReverb.swift index 735dded..9a99b57 100644 --- a/Sources/SoundpipeAudioKit/Effects/ZitaReverb.swift +++ b/Sources/SoundpipeAudioKit/Effects/ZitaReverb.swift @@ -114,7 +114,7 @@ public class ZitaReverb: Node { identifier: "EQ Frequency 2", name: "EQ Frequency 2", address: akGetParameterAddress("ZitaReverbParameterEqualizerFrequency2"), - defaultValue: 1500.0, + defaultValue: 1000.0, range: 160.0 ... 1000.0, unit: .hertz )