parameters.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #pragma once
  2. #include "foundation/types.h"
  3. #include "foundation/guid.h"
  4. namespace nsaudio
  5. {
  6. enum
  7. {
  8. /* when this is set, the const void * passed to AudioOutput_Output is assumed to be an array of channels,
  9. e.g. (format_type == nsaudio_type_float && (format_flags & FORMAT_FLAG_NONINTERLEAVED) && number_of_channels == 2)
  10. means that you pass a float *[2] to AudioOutput_Output
  11. */
  12. FORMAT_FLAG_INTERLEAVED=0x1,
  13. FORMAT_FLAG_NONINTERLEAVED=0x2,
  14. FORMAT_FLAG_NATIVE_ENDIAN=0x4,
  15. FORMAT_FLAG_LITTLE_ENDIAN=0x8, /* audio is SPECIFICALLY little endian (as opposed to native endian on little-endian machines) */
  16. FORMAT_FLAG_BIG_ENDIAN=0x10, /* audio is SPECIFICALLY big endian (as opposed to native endian on big-endian machines) */
  17. FORMAT_FLAG_SIGNED=0x20, /* e.g. 8 bit PCM is typically unsigned (0-255) */
  18. FORMAT_FLAG_UNSIGNED=0x40, /* e.g. 8 bit PCM is typically unsigned (0-255) */
  19. /* so that you can check if a flag was set that you don't understand */
  20. FORMAT_FLAG_VALID_INTERLEAVE = FORMAT_FLAG_INTERLEAVED|FORMAT_FLAG_NONINTERLEAVED,
  21. FORMAT_FLAG_VALID_ENDIAN = FORMAT_FLAG_NATIVE_ENDIAN|FORMAT_FLAG_LITTLE_ENDIAN|FORMAT_FLAG_BIG_ENDIAN,
  22. FORMAT_FLAG_VALID_SIGNED=FORMAT_FLAG_SIGNED|FORMAT_FLAG_UNSIGNED,
  23. FORMAT_FLAG_VALID_MASK=FORMAT_FLAG_VALID_INTERLEAVE|FORMAT_FLAG_VALID_ENDIAN|FORMAT_FLAG_VALID_SIGNED,
  24. };
  25. // {4B80932C-E55F-4969-91EA-772584ABEDC2}
  26. static const GUID format_type_pcm =
  27. { 0x4b80932c, 0xe55f, 0x4969, { 0x91, 0xea, 0x77, 0x25, 0x84, 0xab, 0xed, 0xc2 } };
  28. // {6D47717F-A383-4CF8-BB1E-72254BE3F9DC}
  29. static const GUID format_type_float =
  30. { 0x6d47717f, 0xa383, 0x4cf8, { 0xbb, 0x1e, 0x72, 0x25, 0x4b, 0xe3, 0xf9, 0xdc } };
  31. struct Parameters
  32. {
  33. double sample_rate;
  34. GUID format_type; // PCM, floating point, SPDIF pass-thru, etc.
  35. unsigned int format_flags; // endian, interleaved, signed
  36. unsigned int bytes_per_sample; // e.g. 4 for 20bit in a 32bit container
  37. unsigned int bits_per_sample; // number of valid bits within the sample
  38. unsigned int number_of_channels;
  39. unsigned int channel_layout;
  40. };
  41. };