Adopted Span and MutableSpan for buffers across the library to adapt to Swift 6.4.
This commit is contained in:
@@ -75,9 +75,9 @@ extension Sound {
|
||||
{ userdata, left, right, nsamples, rate, drate in
|
||||
guard let userdata, let left else { return 0 }
|
||||
let box = Unmanaged<GeneratorBox>.fromOpaque(userdata).takeUnretainedValue()
|
||||
let leftBuffer = UnsafeMutableBufferPointer(start: left, count: Int(nsamples))
|
||||
let rightBuffer = right.map { UnsafeMutableBufferPointer(start: $0, count: Int(nsamples)) }
|
||||
return Int32(box.generator.render(leftBuffer, rightBuffer, rate, drate))
|
||||
var leftSpan = UnsafeMutableBufferPointer(start: left, count: Int(nsamples)).mutableSpan
|
||||
var rightSpan = UnsafeMutableBufferPointer(start: right, count: right == nil ? 0 : Int(nsamples)).mutableSpan
|
||||
return Int32(box.generator.render(&leftSpan, &rightSpan, rate, drate))
|
||||
},
|
||||
{ userdata, note, velocity, length in
|
||||
guard let userdata else { return }
|
||||
|
||||
@@ -2,11 +2,11 @@ extension Sound.Synth {
|
||||
/// Custom generator callbacks. Samples are in signed Q8.24 format.
|
||||
public struct Generator {
|
||||
/// Renders up to 256 sample frames into `left` (and `right` for
|
||||
/// stereo generators). `rate` is the per-frame phase step in
|
||||
/// stereo generators; it is empty for mono ones). `rate` is the per-frame phase step in
|
||||
/// Q0.32 format and `drate` its per-frame change. Returns the
|
||||
/// number of frames rendered.
|
||||
public var render: (_ left: UnsafeMutableBufferPointer<Int32>,
|
||||
_ right: UnsafeMutableBufferPointer<Int32>?,
|
||||
public var render: (_ left: inout MutableSpan<Int32>,
|
||||
_ right: inout MutableSpan<Int32>,
|
||||
_ rate: UInt32, _ drate: Int32) -> Int
|
||||
/// Called when a note starts. `length` is -1 for indefinite notes.
|
||||
public var noteOn: ((_ note: Sound.MIDINote, _ velocity: Float, _ length: Float) -> Void)?
|
||||
@@ -17,8 +17,8 @@ extension Sound.Synth {
|
||||
/// valid.
|
||||
public var setParameter: ((_ parameter: Int, _ value: Float) -> Bool)?
|
||||
|
||||
public init(render: @escaping (_ left: UnsafeMutableBufferPointer<Int32>,
|
||||
_ right: UnsafeMutableBufferPointer<Int32>?,
|
||||
public init(render: @escaping (_ left: inout MutableSpan<Int32>,
|
||||
_ right: inout MutableSpan<Int32>,
|
||||
_ rate: UInt32, _ drate: Int32) -> Int,
|
||||
noteOn: ((_ note: Sound.MIDINote, _ velocity: Float, _ length: Float) -> Void)? = nil,
|
||||
release: ((_ stop: Bool) -> Void)? = nil,
|
||||
|
||||
Reference in New Issue
Block a user