Creates a sample stream from a DSD file.
HSTREAM BASS_DSD_StreamCreateFile( BOOL mem, void *file, QWORD offset, QWORD length, DWORD flags, DWORD freq );
mem | TRUE = stream the file from memory. | ||||||||||||||||||||||
file | Filename (mem = FALSE) or a memory location (mem = TRUE). | ||||||||||||||||||||||
offset | File offset to begin streaming from (only used if mem = FALSE). | ||||||||||||||||||||||
length | Data length... 0 = use all data up to the end of the file (if mem = FALSE). | ||||||||||||||||||||||
flags | A combination of these flags.
| ||||||||||||||||||||||
freq | Sample rate to convert the DSD data to PCM at... 0 = use the BASS_CONFIG_DSD_FREQ config setting. The rate will be rounded up (or down if there are none higher) to the nearest valid rate; the valid rates are 1/8, 1/16, 1/32, etc of the DSD rate down to a minimum of 44100 Hz. This parameter is ignored when the BASS_DSD_DOP or BASS_DSD_DOP_AA or BASS_DSD_RAW flag is specified. |
BASS_ERROR_INIT | BASS_Init has not been successfully called. |
BASS_ERROR_NOTAVAIL | The BASS_STREAM_AUTOFREE flag cannot be combined with the BASS_STREAM_DECODE flag. |
BASS_ERROR_ILLPARAM | The length must be specified when streaming from memory. |
BASS_ERROR_FILEOPEN | The file could not be opened. |
BASS_ERROR_FILEFORM | The file's format is not recognised/supported. |
BASS_ERROR_FORMAT | The sample format is not supported. |
BASS_ERROR_SPEAKER | The specified SPEAKER flags are invalid. |
BASS_ERROR_MEM | There is insufficient memory. |
BASS_ERROR_NO3D | Could not initialize 3D support. |
BASS_ERROR_UNKNOWN | Some other mystery problem! |
There are a few types of tag that may be available via BASS_ChannelGetTags. DSDIFF files may include artist and title information, which is available via the BASS_TAG_DSD_ARTIST and BASS_TAG_DSD_TITLE tags, which are ASCII strings. DSDIFF files can also include comments, which are available via the BASS_TAG_DSD_COMMENT+<index> tag (index=0 is the first comment), which gives a pointer to a TAG_DSD_COMMENT structure. DSF files may include ID3v2 tags, which are available via the BASS_TAG_ID3V2 tag. WavPack files may have ID3 and APEv2 tags, which are available via BASS_TAG_ID3 and BASS_TAG_APE.
DSD is 6dB quieter than PCM, so a 6dB gain will be applied by default when converting to PCM. That can be changed via the BASS_CONFIG_DSD_GAIN config option and the BASS_ATTRIB_DSD_GAIN attribute.
The DSD-over-PCM (BASS_DSD_DOP or BASS_DSD_DOP_AA) and raw DSD data (BASS_DSD_RAW) options allow supporting devices to play the DSD data directly, without converting to PCM. In both cases, the data needs to reach the device unmodified, so there can be no effects/resampling/mixing or anything else that will modify the data. Raw DSD data is playable with ASIO drivers that support DSD, eg. via BASSASIO. DSD-over-PCM data can be sent to a supporting device in any way that does not modify the data. If DSD-over-PCM data is played on a device that doesn't support it, then it will produce a low level noise. It is possible to switch between the 2 DSD-over-PCM options via BASS_ChannelFlags.
To stream a file from the internet, use BASS_DSD_StreamCreateURL. To stream from other locations, see BASS_DSD_StreamCreateFileUser.
HSTREAM stream = BASS_DSD_StreamCreateFile(FALSE, "file.dff", 0, 0, 0, 88200);
Play a DSDIFF file via WASAPI in DSD-over-PCM form.
stream=BASS_DSD_StreamCreateFile(FALSE, "file.dff", 0, 0, BASS_DSD_DOP | BASS_SAMPLE_FLOAT | BASS_STREAM_DECODE, 0); // open the DSD file in DoP mode BASS_CHANNELINFO ci; BASS_ChannelGetInfo(stream, &ci); // get the sample format BASS_WASPAPI_Init(-1, ci.freq, ci.chans, BASS_WASAPI_EXCLUSIVE, 0.4, 0, WasapiProc, 0); // initialize the WASAPI output device ... DWORD CALLBACK WasapiProc(void *buffer, DWORD length, void *user) { DWORD r = BASS_ChannelGetData(stream, buffer, length); // get data from the DSD stream if (r == (DWORD)-1) r = 0; return r; }
BASS_ChannelGetInfo, BASS_ChannelGetLength, BASS_ChannelGetTags, BASS_ChannelPlay, BASS_ChannelSetAttribute, BASS_ChannelSetDSP, BASS_ChannelSetFX, BASS_StreamFree, BASS_StreamGetFilePosition