So here is my attempt at translating your example to Swift…
func getDSDToPCMData(theURL:String)->Data{
var trackData:Data? = nil
let stream = BASS_DSD_StreamCreateURL(theURL, 0, DWORD(BASS_SAMPLE_FLOAT | BASS_STREAM_DECODE), nil, nil, 0)
var length:QWORD = BASS_ChannelGetLength(stream, DWORD(BASS_POS_BYTE))
let bufferSize = length
let buffer = UnsafeMutablePointer<UInt32>.allocate(capacity: Int(bufferSize))
defer {
buffer.deallocate()
}
var done:QWORD = 0
while (done < length) {
let got = BASS_ChannelGetData(DWORD(stream), buffer + UnsafeMutableRawPointer.Stride(done), 0xFFFFFFF)
if (Int(got) == -1) { // error/end
length = done
break
}
done += UInt64(got)
}
trackData = Data(bytes: buffer, count: Int(length))
return trackData!
}
This appears to provide me with Audio data that I could perform DSP on. Before I attempt that, I tried to play the data through BASS by creating another URL Stream; but no stream could be created from this data.
Either I'm missing a further step, which would be needed to convert this to PCM/WAV data format, or I've made a mistake, or both.
The last two lines are there to convert the buffer pointers to Swift's "Data" format.
NOTE: I needed to use "BASS_SAMPLE_FLOAT" in order to retrieve data that was close to the same size as the original DSF data.
I'm using UnsafeMutablePointer<UInt32> because I believe I need Int pointers of that size.
Any further help will be appreciated, as always.