Skip to content

Commit

Permalink
fix API issue with macOS for #85
Browse files Browse the repository at this point in the history
  • Loading branch information
dmrschmidt committed Nov 3, 2023
1 parent a5416a7 commit 8930049
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Sources/DSWaveformImage/WaveformImageDrawer+macOS.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public extension WaveformImageDrawer {
/// Renders a DSImage of the provided waveform samples.
///
/// Samples need to be normalized within interval `(0...1)`.
func waveformImage(from samples: [Float], with configuration: Waveform.Configuration, renderer: WaveformRenderer) -> DSImage? {
func waveformImage(from samples: [Float], with configuration: Waveform.Configuration, renderer: WaveformRenderer, position: Waveform.Position = .middle) -> DSImage? {
guard samples.count > 0, samples.count == Int(configuration.size.width * configuration.scale) else {
print("ERROR: samples: \(samples.count) != \(configuration.size.width) * \(configuration.scale)")
return nil
Expand All @@ -19,7 +19,7 @@ public extension WaveformImageDrawer {
guard let context = NSGraphicsContext.current?.cgContext else {
fatalError("Missing context")
}
self.draw(on: context, from: dampedSamples, with: configuration, renderer: renderer)
self.draw(on: context, from: dampedSamples, with: configuration, renderer: renderer, position: position)
return true
}
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/DSWaveformImage/WaveformImageDrawer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ extension WaveformImageDrawer {
///
/// Samples need to be normalized within interval `(0...1)`.
/// Ensure context size & scale match with the configuration's size & scale.
public func draw(waveform samples: [Float], on context: CGContext, with configuration: Waveform.Configuration, renderer: WaveformRenderer) {
public func draw(waveform samples: [Float], on context: CGContext, with configuration: Waveform.Configuration, renderer: WaveformRenderer, position: Waveform.Position = .middle) {
guard samples.count > 0 || shouldDrawSilencePadding else {
return
}
Expand Down Expand Up @@ -95,7 +95,7 @@ extension WaveformImageDrawer {
let dampedSamples = configuration.shouldDamp ? damp(clippedSamples, with: configuration) : clippedSamples
let paddedSamples = shouldDrawSilencePadding ? Array(repeating: 1, count: samplesNeeded - clippedSamples.count) + dampedSamples : dampedSamples

draw(on: context, from: paddedSamples, with: configuration, renderer: renderer)
draw(on: context, from: paddedSamples, with: configuration, renderer: renderer, position: position)
}

func draw(on context: CGContext, from samples: [Float], with configuration: Waveform.Configuration, renderer: WaveformRenderer, position: Waveform.Position = .middle) {
Expand Down

0 comments on commit 8930049

Please sign in to comment.