Login / Register  0 items | $0.00 New

ASIO LSB and MSB sample types.

Siekmanski
KVRist
 
32 posts since 22 Sep, 2013

Postby Siekmanski; Tue Sep 05, 2017 12:57 am ASIO LSB and MSB sample types.

I'm writing software for ASIO support in assembly for Windows systems.
Because it is a little endian system, is it nessesarry to support also the Asio MSB sample_types under windows?
If not, I can safely remove the byte_swap code.
PurpleSunray
KVRian
 
678 posts since 13 Mar, 2012

Postby PurpleSunray; Tue Sep 05, 2017 3:22 am Re: ASIO LSB and MSB sample types.

Depends what you want to play.
Compressed format decoders output float usually, so app needs to convert anyhow if you only accept ints.
When it comes to PCM format containers: WAV RIFF is little-endian, AIFF can have little and big endian. uPNP/DNLA streaming content types are big endian, same as almost all other network stuff - it is network-byte-order (= big endian).
Siekmanski
KVRist
 
32 posts since 22 Sep, 2013

Postby Siekmanski; Tue Sep 05, 2017 5:27 am Re: ASIO LSB and MSB sample types.

It's not about the conversion of sample bit formats in software.

I'm only interested in the internal sample bit format of the ASIO sound card.
Calling "Asio_getChannelInfo" you also get the sample data_type used by the sound card itself.
If the sample type is in MSB format, than I need to swap the bytes from little endian to big endian format before sending them to the ASIO sound buffer.

I just asked myself ( and you guys ) are there any ASIO sound cards for windows PC's that use internally the MSB (big endian) sample types?

These are all the sample types:
Code: Select all
;// Sample Types are expressed as long
ASIOSTInt16MSB0            equ 0
ASIOSTInt24MSB            equ 1         ;// used for 20 bits as well
ASIOSTInt32MSB            equ 2
ASIOSTFloat32MSB         equ 3         ;// IEEE 754 32 bit float
ASIOSTFloat64MSB         equ 4         ;// IEEE 754 64 bit double float
 
;// these are used for 32 bit data buffer, with different alignment of the data inside
;// 32 bit PCI bus systems can be more easily used with these
ASIOSTInt32MSB16         equ 8         ;// 32 bit data with 16 bit alignment
ASIOSTInt32MSB18         equ 9         ;// 32 bit data with 18 bit alignment
ASIOSTInt32MSB20         equ 10         ;// 32 bit data with 20 bit alignment
ASIOSTInt32MSB24         equ 11         ;// 32 bit data with 24 bit alignment

ASIOSTInt16LSB            equ 16
ASIOSTInt24LSB            equ 17         ;// used for 20 bits as well
ASIOSTInt32LSB            equ 18
ASIOSTFloat32LSB         equ 19         ;// IEEE 754 32 bit float, as found on Intel x86 architecture
ASIOSTFloat64LSB         equ 20         ;// IEEE 754 64 bit double float, as found on Intel x86 architecture
 
;// these are used for 32 bit data buffer, with different alignment of the data inside
;// 32 bit PCI bus systems can more easily used with these
ASIOSTInt32LSB16         equ 24         ;// 32 bit data with 18 bit alignment
ASIOSTInt32LSB18         equ 25         ;// 32 bit data with 18 bit alignment
ASIOSTInt32LSB20         equ 26         ;// 32 bit data with 20 bit alignment
ASIOSTInt32LSB24         equ 27         ;// 32 bit data with 24 bit alignment

;//   ASIO DSD format.
ASIOSTDSDInt8LSB1         equ 32         ;// DSD 1 bit data, 8 samples per byte. First sample in Least significant bit.
ASIOSTDSDInt8MSB1         equ 33         ;// DSD 1 bit data, 8 samples per byte. First sample in Most significant bit.
ASIOSTDSDInt8NER8         equ 40         ;// DSD 8 bit data, 1 sample per byte. No Endianness required.
PurpleSunray
KVRian
 
678 posts since 13 Mar, 2012

Postby PurpleSunray; Tue Sep 05, 2017 6:25 am Re: ASIO LSB and MSB sample types.

Oh, so you are the other end (wirting to ASIO not implementing ASIO).

> I just asked myself ( and you guys ) are there any ASIO sound cards for windows PC's that use internally the MSB (big endian) sample types?

Hmm. Good question.
I think most (if not all) PC ASIO drivers will provide little endian formats, even if the chip cannot do it (then the driver will swap).
The AD1852 chip on my RME card can only do LE, so this would be save. For others ask google :D
Try searching for SNDRV_PCM_FMTBIT_S16_BE and/or SNDRV_PCM_FMTBIT_S16_LE
You find tons of linux driver code (this are the sample type on Linux SND / ALSA) that point you directly to the DAC chip.
i.e. https://github.com/bashrc/linux/blob/ma ... ci/rme96.c -> some RME drivers, chips can do SNDRV_PCM_FMTBIT_S16_LE and SNDRV_PCM_FMTBIT_S32_LE. http://elixir.free-electrons.com/linux/ ... c97.c#L237 - the MPC500 AC97 can only do SNDRV_PCM_FMTBIT_S32_BE (it's a SoC not relevant for you). ....

you will need to google the chips that are relevant for you to get absolutly sure - or simply keep the 2 lines of code to swap if card can only accept BE :clown:
Siekmanski
KVRist
 
32 posts since 22 Sep, 2013

Postby Siekmanski; Tue Sep 05, 2017 7:01 am Re: ASIO LSB and MSB sample types.

I couldn't find anything on the web, have to look harder I think.

you will need to google the chips that are relevant for you to get absolutly sure - or simply keep the 2 lines of code to swap if card can only accept BE :clown:


Yeah, maybe I'll have to include the byte swapping. :(
But without I can fit my sample copy loop within one cache line and improve speed and avoid bloating my executable with dead code. ( half less conversion routines for the sample types. ) 8)
PurpleSunray
KVRian
 
678 posts since 13 Mar, 2012

Postby PurpleSunray; Tue Sep 05, 2017 7:19 am Re: ASIO LSB and MSB sample types.

Siekmanski wrote:Yeah, maybe I'll have to include the byte swapping. :(
But without I can fit my sample copy loop within one cache line and improve speed and avoid bloating my executable with dead code. ( half less conversion routines for the sample types. ) 8)

You still can, just code your function to do so :D
Do not put it all into one function, but write optimzied functions for each format.

Yeah.. lot of work and you might end up with a construct similar to mine ( :lol: :lol: ), like

Code: Select all
static struct funcmap g_tab[] = {

#if defined(ARM_NEON) || defined(ARM64_NEON)
   { SAMPLETYPE_S16LE,       CPU_CAP_NEON, interleave_s16le_neon },
   { SAMPLETYPE_S32LE,       CPU_CAP_NEON, interleave_s32le_neon },
#endif
#if defined(IX86) || defined(IX64)
   { SAMPLETYPE_U8,          CPU_CAP_SSE4, interleave_u8_sse4 },
   { SAMPLETYPE_S8,          CPU_CAP_SSE4, interleave_s8_sse4 },
   { SAMPLETYPE_S16LE,       CPU_CAP_SSE4, interleave_s16le_sse4 },
   { SAMPLETYPE_S16BE,       CPU_CAP_SSE4, interleave_s16be_sse4 },
   { SAMPLETYPE_U8,          CPU_CAP_SSSE3, interleave_u8_ssse3 },
   { SAMPLETYPE_S8,          CPU_CAP_SSSE3, interleave_s8_ssse3 },
   { SAMPLETYPE_S16LE,       CPU_CAP_SSSE3, interleave_s16le_ssse3 },
   { SAMPLETYPE_S16BE,       CPU_CAP_SSSE3, interleave_s16be_ssse3 },
   { SAMPLETYPE_S24LE,       CPU_CAP_SSSE3, interleave_s24le_ssse3 },
   { SAMPLETYPE_S24BE,       CPU_CAP_SSSE3, interleave_s24be_ssse3 },
   { SAMPLETYPE_S32LE,       CPU_CAP_SSSE3, interleave_s32le_ssse3 },
   { SAMPLETYPE_S32BE,       CPU_CAP_SSSE3, interleave_s32be_ssse3 },
   { SAMPLETYPE_F32LE,       CPU_CAP_SSSE3, interleave_f32le_ssse3 },
   { SAMPLETYPE_F32BE,       CPU_CAP_SSSE3, interleave_f32be_ssse3 },
   { SAMPLETYPE_F64LE,       CPU_CAP_SSSE3, interleave_f64le_ssse3 },
   { SAMPLETYPE_F64BE,       CPU_CAP_SSSE3, interleave_f64be_ssse3 },
   { SAMPLETYPE_U8,          CPU_CAP_SSE2, interleave_u8_sse2 },
   { SAMPLETYPE_S8,          CPU_CAP_SSE2, interleave_s8_sse2 },
   { SAMPLETYPE_S16LE,       CPU_CAP_SSE2, interleave_s16le_sse2 },
   { SAMPLETYPE_S16BE,       CPU_CAP_SSE2, interleave_s16be_sse2 },
   { SAMPLETYPE_S24LE,       CPU_CAP_SSE2, interleave_s24le_sse2 },
   { SAMPLETYPE_S24BE,       CPU_CAP_SSE2, interleave_s24be_sse2 },
   { SAMPLETYPE_S32LE,       CPU_CAP_SSE2, interleave_s32le_sse2 },
   { SAMPLETYPE_S32BE,       CPU_CAP_SSE2, interleave_s32be_sse2 },
   { SAMPLETYPE_F32LE,       CPU_CAP_SSE2, interleave_f32le_sse2 },
   { SAMPLETYPE_F32BE,       CPU_CAP_SSE2, interleave_f32be_sse2 },
   { SAMPLETYPE_F64LE,       CPU_CAP_SSE2, interleave_f64le_sse2 },
   { SAMPLETYPE_F64BE,       CPU_CAP_SSE2, interleave_f64be_sse2 },
#endif
#ifdef IX86
   { SAMPLETYPE_U8,          0, interleave_u8_x86 },
   { SAMPLETYPE_S8,          0, interleave_s8_x86 },
   { SAMPLETYPE_S16LE,       0, interleave_s16le_x86 },
   { SAMPLETYPE_S16BE,       0, interleave_s16be_x86 },
   { SAMPLETYPE_S24LE,       0, interleave_s24le_x86 },
   { SAMPLETYPE_S24BE,       0, interleave_s24be_x86 },
   { SAMPLETYPE_S32LE,       0, interleave_s32le_x86 },
   { SAMPLETYPE_S32BE,       0, interleave_s32be_x86 },
   { SAMPLETYPE_F32LE,       0, interleave_f32le_x86 },
   { SAMPLETYPE_F32BE,       0, interleave_f32be_x86 },
   { SAMPLETYPE_F64LE,       0, interleave_f64le_x86 },
   { SAMPLETYPE_F64BE,       0, interleave_f64be_x86 },
#endif
   { SAMPLETYPE_U8,          0, interleave_u8_c },
   { SAMPLETYPE_S8,          0, interleave_s8_c },
   { SAMPLETYPE_S16LE,       0, interleave_s16le_c },
   { SAMPLETYPE_S16BE,       0, interleave_s16be_c },
   { SAMPLETYPE_S24LE,       0, interleave_s24le_c },

And then have tons of dedicated interleave_<format>_<cpu_feature> functions on the .asm to convert multichannel float into an PCM frames with interlaved samples for each channel, of the specifcied format. For the way back from int to float there is the same again, but with deinterleave_<format>_<cpu_feature>
Siekmanski
KVRist
 
32 posts since 22 Sep, 2013

Postby Siekmanski; Tue Sep 05, 2017 8:35 am Re: ASIO LSB and MSB sample types.

Do you really need all SIMD versions?
I need only SSE2 or AVX for all types of sample conversions.
Just shifting 4 or 8 samples at once to the wanted bit alignment.
PurpleSunray
KVRian
 
678 posts since 13 Mar, 2012

Postby PurpleSunray; Tue Sep 05, 2017 8:45 am Re: ASIO LSB and MSB sample types.

Nah. Actually I don't think the C or plain X86 code does run on any real system. SSE will be supported if it is no 20 year old CPU.
It has grown over time. First C, than X86 asm to make it faster, SSE2 to make it even faster, then SSSE3 to use that special feature an be even more faster, than ARM support was needed so you want NEON than ....
I just did not delete anything, as my code should still be able to run on 386 - see no reason drop it and make any SSE version a requirement
Siekmanski
KVRist
 
32 posts since 22 Sep, 2013

Postby Siekmanski; Tue Sep 05, 2017 10:03 am Re: ASIO LSB and MSB sample types.

:tu:
JCJR
KVRAF
 
2153 posts since 17 Apr, 2005, from S.E. TN

Postby JCJR; Sun Sep 10, 2017 7:04 am Re: ASIO LSB and MSB sample types.

I maintained asio support for some programs for many years. Most converters were x86 asm with x86 fpu code sprinkled in where needed. 32 bit only, 32 bit asm and fpu purt much worked on any cpu that could run windows. In fact, with very minor formatting changes the same converter asm code compiled and ran fine on intel mac. Basically all my 32bit asm audio code that wasn't OS-dependent compiled and ran the same on intel mac. Can't recall any exceptions.

Can't give any advice on 64 bit or sse.

ASIO on winders, there were a few oddball audio interfaces which used big-endian format on winders. I don't recall the names of them but we first found out from user complaints about interface not working because I had not at first written format converters for every single one of the zillions of possible formats. I had initially ignored the formats which seemed very unlikely on winders not wanting to write code for cases which "would never happen".

So then I wrote converters for all of them. It was slightly iffy, because for the uncommon formats one couldn't completely rule out lurking bugs, coding mistakes in the rarely used converters, unless a customer would come along with an oddball interface using that format and complain that it doesn't work (in the case of a lurking code mistake in that converter). :)
Siekmanski
KVRist
 
32 posts since 22 Sep, 2013

Postby Siekmanski; Tue Sep 12, 2017 12:35 pm Re: ASIO LSB and MSB sample types.

Hi JCJR,

ASIO on winders, there were a few oddball audio interfaces which used big-endian format on winders.


So, you say that some ASIO sound card manufacturers build sound cards for Windows ( little-endian ) that use internally a big-endian sample data format? ( all the MSB types )
For me this is the world upside down..... :dog:

Since my program will only run on Windows, I thougth I could skip all support for all the MSB sample data types.
JCJR
KVRAF
 
2153 posts since 17 Apr, 2005, from S.E. TN

Postby JCJR; Tue Sep 12, 2017 6:25 pm Re: ASIO LSB and MSB sample types.

Siekmanski wrote:Hi JCJR,

ASIO on winders, there were a few oddball audio interfaces which used big-endian format on winders.


So, you say that some ASIO sound card manufacturers build sound cards for Windows ( little-endian ) that use internally a big-endian sample data format? ( all the MSB types )
For me this is the world upside down..... :dog:

Since my program will only run on Windows, I thougth I could skip all support for all the MSB sample data types.

I agree it is wierd. Am fairly certain we encountered such beasts though vanishingly rare. I wish I could remember brand/model numbers but memory fails.

IMO such would be rare enough that maybe you wouldn't encounter a user with such interface, unless you plan to have a huge user-base and have neurotic compulsion to "make every customer happy". :)

Cost-benefit-wise, it may be cheaper to just blow off and return a customer's money if only one or two of them have an incompatible oddball interface. On the other hand, if such customer is a squeaky wheel maybe he would leave internet messages complaining your software didn't work with his interface and you couldn't be bothered fixing the bug. Or worse maybe claim you were too dumb to know how to fix it. Which possibly could damage reputation and cost enough sales to make sure that rare squeaky wheels are greased, hopefully motivating the customer to say good things about your software.and possibly benefit sales.

So far as I can guess an interface using big-endian on windows might be blamed on the interface's asio driver being brain dead rather than the hardware. Regardless the hardware raw format, all that a driver author would have had to do is add a few extra lines to byte-swap data on the way between app and hardware and vice-versa. Maybe many interfaces are big-endian at the hardware level for all I know, but equipped with a proper driver, windows applications would never know or care about the interface internal format.

The formats about which I was most curious were the various float and double formats in the format enum. I don't recall seeing any asio devices with native float or double data format and wondered if any had ever been sold. I guessed maybe steinberg listed the entire kitchen sink of formats in case some day a manufacturer would decide to make a big endian double float interface or whatever?

Maybe nowadays a float or double interface could be more likely than in the past, dunno. Has anyone on the forum seen one?
Siekmanski
KVRist
 
32 posts since 22 Sep, 2013

Postby Siekmanski; Wed Sep 13, 2017 3:29 am Re: ASIO LSB and MSB sample types.

I thought I could safely cut corners in my code, but to be sure I'll add all sample conversions in my program. :)
If the user/customer paid for a rare ASIO sound card interface, I feel obliged supporting them too.

What about ASIO DSD format?

From the ASIO SDK,
// DSD support
// The following extensions are required to allow switching
// and control of the DSD subsystem.
kAsioSetIoFormat equ 23111961h ;/* ASIOIoFormat * in params. */
kAsioGetIoFormat equ 23111983h ;/* ASIOIoFormat * in params. */
kAsioCanDoIoFormat equ 23112004h ;/* ASIOIoFormat * in params. */

As far as I understand, DSD capable ASIO sound cards are also capable of processing PCM formats.
To use DSD format you first need to make sure you instruct the sound card to switch to DSD format, am I right?

If I look at this page: http://www.channld.com/support-soundcards.html

They seem to be capable of processing both PCM and DSD formats.
PurpleSunray
KVRian
 
678 posts since 13 Mar, 2012

Postby PurpleSunray; Thu Sep 14, 2017 9:57 am Re: ASIO LSB and MSB sample types.

Yes, DSD is an extension.
Haven't seen any DSD-only DAC chip so far and also wouldn't make sense to produce one, given the fact that 99.999999% are on PCM.

Moderator: Moderators (Main)

Return to DSP and Plug-in Development