Advertisement
Kitomas

_kit_kmixerPrivate.h as of 2023-8-24

Aug 25th, 2023
1,013
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 3.48 KB | None | 0 0
  1. #ifndef _KIT_KMIXERPRIVATE_H
  2. #define _KIT_KMIXERPRIVATE_H
  3.  
  4.  
  5.  
  6.  
  7. struct _kit_kmixerGlobals_t {
  8.   SDL_mutex* lock;
  9.   int threadPoolSize, cores, capabilities;
  10.   int init;
  11. };
  12. extern struct _kit_kmixerGlobals_t _kit_kmixerGlobals;
  13.  
  14.  
  15.  
  16.  
  17. typedef union {
  18.   void*   ptr;
  19.   Uint8*  u_8;
  20.   Sint16* i16;
  21.   Sint32* i32;
  22.   float*  f32;
  23. } _mono_samples;
  24.  
  25.  
  26.  
  27. //(stores left and right ear components of a stereo stream)
  28. typedef struct { Uint8  l,r; } _stereo_samples_u_8;
  29. typedef struct { Sint16 l,r; } _stereo_samples_i16;
  30. typedef struct { Sint32 l,r; } _stereo_samples_i32;
  31. typedef struct { float  l,r; } _stereo_samples_f32;
  32.  
  33.  
  34. typedef union {
  35.   void*                ptr;
  36.   _stereo_samples_u_8* u_8;
  37.   _stereo_samples_i16* i16;
  38.   _stereo_samples_i32* i32;
  39.   _stereo_samples_f32* f32;
  40. } _stereo_samples;
  41.  
  42.  
  43.  
  44. typedef union {
  45.   void*           v;
  46.   _mono_samples   m;
  47.   _stereo_samples s;
  48. } _kit_kmixerVoiceBuffer;
  49.  
  50.  
  51.  
  52. typedef union {
  53.   void*                v;
  54.   float*               m;
  55.   _stereo_samples_f32* s;
  56. } _kit_kmixerVoiceBufferF;
  57.  
  58.  
  59.  
  60. typedef struct {
  61.   _kit_kmixerVoiceBufferF   bufferInput; //input buffer (or the mixing stage's output)
  62.   _kit_kmixerVoiceBufferF    bufferType; //output of type conversion to f32 (always stereo size)
  63.   _kit_kmixerVoiceBufferF bufferChannel; //output of mono-stereo or stereo-mono conversion (always stereo size)
  64.   _kit_kmixerVoiceBuffer     bufferUser; //buffer to be filled in or modified by user
  65.   _kit_kmixerVoiceBufferF  bufferOutput; //final output buffer (or the mixing stage's input)
  66.  
  67.   SDL_mutex*                  lock; //to make sure a voice doesn't get deleted while it's processing
  68.   kit_kmixerVoiceCallback callback; //user-implemented callback for processing audio data
  69.   void*                   userdata; //user-defined pointer to be passed to the kit_kmixerVoiceCallback
  70.   kit_coreVector*           inputs; //indexes of input voices, if any (can be NULL)
  71.  
  72.   Uint32                _padding32; //for padding to a multiple of 8 bytes
  73.   Uint32                     index; //index of this specific voice in the device's voice list
  74.   Uint32                sampleRate; //samples per second, in Hz
  75.   Uint32           bufferUser_size; //size of inBuffer, in bytes
  76.  
  77.   //volume can actually be <0, but for volL it will override applyVolume to SDL_FALSE,
  78.    //and for volR, volR would then be set to volL
  79.   float                       volL; //left ear volume (or total volume if mono); 0.0 -> 1.0
  80.   float                       volR; //right ear volume (ignored if mono); 0.0 -> 1.0
  81.  
  82.   SDL_bool             applyVolume; //if SDL_TRUE, apply volume when mixing voice's output
  83.   SDL_bool             stereoInput; //input is mono if SDL_FALSE, stereo if SDL_TRUE
  84.   SDL_bool              stereoUser; //voice is mono if SDL_FALSE, stereo if SDL_TRUE
  85.   SDL_bool            stereoOutput; //output is mono if SDL_FALSE, stereo if SDL_TRUE
  86.  
  87.   Uint16              sampleFrames; //number of sample frames in the audio stream
  88.   SDL_AudioFormat      formatInput; //data type of input buffer
  89.   SDL_AudioFormat       formatUser; //data type of voice (user) buffer
  90.   SDL_AudioFormat     formatOutput; //data type of output buffer
  91.  
  92.   //Uint16                _padding16; //for padding to a multiple of 8 bytes
  93. } /*__attribute__((packed))*/ _kit_kmixerVoice;
  94.  
  95.  
  96.  
  97.  
  98. extern int _kit_kmixerVoiceProc(void* data);
  99.  
  100.  
  101. extern void _kit_kmixerVoiceMix(_kit_kmixerVoice* ovoice,
  102.                                 _kit_kmixerVoice* ivoices, Uint32 ivoices_len);
  103.  
  104.  
  105.  
  106. #endif
  107.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement