-
-
Notifications
You must be signed in to change notification settings - Fork 49
Added a "dispose" method to PhaseLockedVocoder to clear the au wavetable #40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
90a131b
003b954
b418616
a1c6c64
e1e25c6
74c8e3e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,7 +79,12 @@ public class PhaseLockedVocoder: Node { | |
self.amplitude = amplitude | ||
self.pitchRatio = pitchRatio | ||
} | ||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Trailing Whitespace Violation: Lines should not have trailing whitespace. (trailing_whitespace) |
||
/// 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]) | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Trailing Whitespace Violation: Lines should not have trailing whitespace. (trailing_whitespace) |
||
internal func loadFile(_ avAudioFile: AVAudioFile) { | ||
Exit: do { | ||
var err: OSStatus = noErr | ||
|
@@ -160,10 +165,11 @@ 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 | ||
theData?.deallocate() | ||
theData = nil | ||
} | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you change this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because the default value was not in the value range. It was not a practical problem, but is more correct this way. See this issue: #41
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay