Author Topic: BASSAsio and BASSDSD on Mac  (Read 439 times)

soundgals

  • Posts: 24
BASSAsio and BASSDSD on Mac
« on: 6 Nov '23 - 12:50 »
I've been gradually adding BASS features to a Mac app I'm developing, which I plan to commercialise.

After testing over the weekend with some DSD capable DACs, I have a few questions related to BASSAsio and BASSDsd.

First of all from the description of BASSAsio here it states: "BASSASIO is a library for use in Windows software…" So I haven't even tried installing it in my xCode project.

My first question though is whether it could in fact work on Mac, and if this statement is only there because ASIO Drivers for Audio devices are rare on Mac. So perhaps it's assumed that it would only be of interest to Windows users?

I ask this, because I have an old exasound E28 dac which has an ASIO driver written by exasound for Mac. A "dashboard panel" can be downloaded together with this driver, which allows the user to choose between "ASIO" and "CoreAudio" for audio output. When ASIO is selected, presumably "Core Audio" is bypassed and the custom ASIO driver used.

The selection may be made by the user, or automatically by whichever software is used to playback the audio.

Interestingly BASS_GetDeviceInfo, when called within a loop cannot find this device, although all other devices are found within the count of devices determined by a built in Apple method.

So to use this device with my app running BASS, the user has to select it as the default device for Audio Output.

Then, interestingly, even if the user previously chose "Core Audio" in exasound's dashboard, it will indicate that BASS is talking to the ASIO driver. How reliable this indication is though, I don't know.

The next questions follows on from this.

I installed the BASSDsd add-on, and this is allowing me to play DSF/DFF files with conversion to PCM. With a DSD capable DAC though, I would like the user to be able to choose to play these as DSD if desired.

So I'm considering the two options:

1/ Native DSD
2/ DSD over DoP.

The documentation for BASSDsd states "DSD data is not playable by BASS, so the BASS_STREAM_DECODE flag is required" (On the page http://www.un4seen.com/doc/#bassdsd/BASS_DSD_StreamCreateURL.html)

I can't help wondering though, if this would still be the case when BASS is talking to an ASIO driver, perhaps with BASSAsio installed?

Finally, I attempted to play DSD over Dop, which I believe should work. The only example I found in the documentation was referring to playback on Windows vai WASAPI. So my final question is; can DSD over Dop be made to work on Mac?

I first attempted this with the exasound DAC. When it didn't work, I assumed it might be because BASS is talking to the ASIO driver and Dop would, presumably use Core Audio.

Following that I tried another DAC which supports DSD; but on Mac only via core audio. It didn't work. Perhaps I made a mistake in my code…

stream = BASS_DSD_StreamCreateFile(true, theURL, 0, 0, DWORD(BASS_DSD_DOP | BASS_SAMPLE_FLOAT), 0)
            var ci = BASS_CHANNELINFO()
            let format = BASS_ChannelGetInfo(stream, &ci)
            initialiseBassDevice(device: device, freq:UInt32(format))

I realise these are uncommon questions, and related to Mac only. Any thoughts/ideas on this will be much appreciated.

Thanks in advance,

Geoff


Ian @ un4seen

  • Administrator
  • Posts: 25612
Re: BASSAsio and BASSDSD on Mac
« Reply #1 on: 6 Nov '23 - 14:52 »
BASSASIO isn't currently available for macOS, only Windows. But you may still be able to use DoP output (eg. BASS_DSD_DOP) with CoreAudio. You would need to make sure there is no DSP applied then (including volume adjustment - all should be at 100%) so that the data reaches the DAC unmodified. You can use the BASS_DEVICE_FREQ flag with BASS_Init to request the output device is running at the required rate for the DoP data, to avoid resampling. You can confirm whether that request was successful with BASS_GetInfo. BASS_Init also has an undocumented BASS_DEVICE_HOG flag on macOS (basically equivalent to exclusive-mode WASAPI) that you could try, but it doesn't apply to the "Default" device, ie. you need to specify an actual device.

You can also use macOS's "Audio MIDI Setup" utility to check and set the device's sample format.

soundgals

  • Posts: 24
Re: BASSAsio and BASSDSD on Mac
« Reply #2 on: 6 Nov '23 - 16:52 »
Thanks Ian. I will try those methods as soon as I get a chance to do more testing with a DSD DAC.

BTW, I use "Audio MIDI Setup" a lot; but it doesn't report DSD rates for DSD capable DACs; only PCM rates.

When you say; "BASS_DEVICE_FREQ flag with BASS_Init to request the output device is running at the required rate for the DoP data" do you mean the PCM equivalent of the DSD Freq or the DSD Freq itself?

If the PCM equivalent, I'm not sure what that should be for each DSD rate. Of course I want the DSD rate reported by the DAC, to prove that it is processing the signal as DSD.
« Last Edit: 6 Nov '23 - 17:06 by soundgals »

Ian @ un4seen

  • Administrator
  • Posts: 25612
Re: BASSAsio and BASSDSD on Mac
« Reply #3 on: 6 Nov '23 - 17:41 »
The BASS_Init "freq" parameter would need to be set to the sample rate of the DoP data. You can get that by calling BASS_ChannelGetInfo on the DSD stream. Whenever you need to change the device's rate, you can use the BASS_DEVICE_REINIT flag to do so without losing streams. For example, like this:

Code: [Select]
BASS_CHANNELINFO chaninfo;
BASS_ChannelGetInfo(dsdstream, &chaninfo); // get the stream's info
BASS_INFO devinfo;
BASS_GetInfo(&devinfo); // get the device's info
if (devinfo.freq != chaninfo.freq) // the rates don't match
BASS_Init(device, chaninfo.freq, BASS_DEVICE_FREQ | BASS_DEVICE_REINIT, 0, 0); // try to change the device's rate

Note the device's output format also needs to be set to (at least) 24-bit for DoP data, which you can do with the "Audio MIDI Setup" utility.
« Last Edit: 7 Nov '23 - 16:08 by Ian @ un4seen »

soundgals

  • Posts: 24
Re: BASSAsio and BASSDSD on Mac
« Reply #4 on: 6 Nov '23 - 19:55 »
Thanks so much again Ian, for the clear explanation and example code. Will give that a try.

soundgals

  • Posts: 24
Re: BASSAsio and BASSDSD on Mac
« Reply #5 on: 7 Nov '23 - 14:50 »
Success! This works fine using DoP with DSD capable DACs on Mac.

You mentioned the BASS_DEVICE_REINIT flag; but didn't show it in your example. So I tried without; but it didn't work. It seems it is required, in my project after the stream has been created. With it the device sample rate is changed to match the stream's channelInfo frequency.

For me it makes sense to always make this check, regardless of the kind of stream I'm creating. So I init the device on my app's launch and only change it when the two frequencies don't match for a stream.

I should also mention that the exasound DACs mentioned in my OP are also correctly found by BASS. I was making a mistake in my code where I mixed Apple built in methods with BASS's and not taking account of the fact that for BASS the first device (0) is "No Sound".

Thanks again Ian.

Ian @ un4seen

  • Administrator
  • Posts: 25612
Re: BASSAsio and BASSDSD on Mac
« Reply #6 on: 7 Nov '23 - 16:10 »
Oops, I forgot to include the BASS_DEVICE_REINIT flag in the code snippet above. I've added it now. Anyway, great to hear that it's working!