Advertisement
Kitomas

kit_kmixer.h as of 2023-10-12

Oct 12th, 2023
1,076
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 21.56 KB | None | 0 0
  1. /**
  2.  * \file kit_kmixer.h
  3.  * \brief Header file for KIT SDL2's KMixer module
  4.  */
  5. #ifndef _KIT_KMIXER_H
  6. #define _KIT_KMIXER_H
  7. #ifndef _KIT_SDL2_KMIXER_H
  8. #define _KIT_SDL2_KMIXER_H
  9. //todo: make kmixerAsync
  10.  
  11.  
  12. #include "./kit_core.h" //includes SDL2/SDL.h
  13. #include "./_kit_acodecPCM.h" //contains PCM data stuff
  14.  
  15. #ifdef __cplusplus
  16. extern "C" {
  17. #endif
  18.  
  19.  
  20.  
  21.  
  22. /* +kit_kmixerDevice struct/union typedefs+ */
  23. typedef struct kit_kmixerDevice kit_kmixerDevice;
  24. /* -kit_kmixerDevice struct/union typedefs- */
  25.  
  26. /* +kit_kmixerVoice struct/union typedefs+ */
  27. typedef struct kit_kmixerVoiceSpec kit_kmixerVoiceSpec;
  28. /* -kit_kmixerVoice struct/union typedefs- */
  29.  
  30.  
  31.  
  32.  
  33. /* ++++++++++++ */
  34. /* +kit_kmixer+ */
  35. /* ++++++++++++ */
  36.  
  37. extern const SDL_bool kit_kmixerIsDebug;
  38.  
  39.  
  40.  
  41. /**
  42.  * Initialize kmixer
  43.  * \param[in] numDeviceThreads The maximum number of active threads a device can have. \n
  44.                                Negative values will use fractions of total core count (-2 for half, -3 for a third, etc.)
  45.  * \return 0 on success, >0 on warning, or <0 on error (call SDL_GetError() for more info)
  46.  *
  47.  * \remark Setting numDeviceThreads to 0 is treated the same as setting it to -1 (as many threads as there are CPU cores).
  48.  * \sa kit_kmixerQuit
  49.  */
  50. extern int kit_kmixerInit(int numDeviceThreads);
  51.  
  52. /**
  53.  * Shut down kmixer
  54.  * \return 0 on success, >0 on warning, <0 on error (call SDL_GetError() for more info)
  55.  *
  56.  * \sa kit_kmixerInit
  57.  */
  58. extern int kit_kmixerQuit();
  59.  
  60. /* ------------ */
  61. /* -kit_kmixer- */
  62. /* ------------ */
  63.  
  64.  
  65.  
  66.  
  67. /* ++++++++++++++++++ */
  68. /* +kit_kmixerDevice+ */
  69. /* ++++++++++++++++++ */
  70.  
  71. /**
  72.  * \brief This struct contains all info needed for a kmixer device and its voice chains
  73.  * \remark Every member of this struct has the "_" prefix,
  74.  *         which means they should be treated as read-only
  75.  */
  76. struct kit_kmixerDevice { //112B
  77.   union {
  78.     char             str[8]; ///< \brief String portion of struct ID ("kmxrDev\x00")
  79.     Uint64              num; ///< \brief Integer portion of struct ID (0x0076654472786D6B)
  80.   } /* ------------ */ _magic; ///< \brief Struct ID number; union of Uint64 and char[8]
  81.   SDL_AudioSpec         _spec; ///< \brief Audio specification of the device
  82.   SDL_mutex*            _lock; ///< \brief Mutex for device access (lock unnecessary for accessing some members)
  83.   kit_coreVector*    _threads; ///< \brief The device's thread list for voice processing
  84.   kit_coreVector* _threadData; ///< \brief List of data to be fed into the device threads
  85.   kit_coreVector*        _raw; ///< \brief 1D array of all registered voice structs
  86.   kit_coreVector*        _ord; ///< \brief 2D array of voice references (of raw), ordered by input chain stage
  87.   float            _fadeDelta; ///< \brief the number to apply to _fadeVolume when applying fade ins/outs
  88.   float           _fadeVolume; ///< \brief Volume used for fade ins/outs
  89.   Uint32         _fadeInDelay; ///< \brief How many samples to write 0 to before fading in
  90.   Uint32           _lockCount; ///< \brief The number of threads currently locking the device
  91.   SDL_AudioDeviceID    _devID; ///< \brief The device ID number that SDL uses
  92.   SDL_bool           _playing; ///< \brief A boolean of whether the device is currently active
  93.   SDL_bool           _closing; ///< \brief Should only be set inside a call to kit_kmixerDeviceClose
  94.   SDL_bool           _fadeOut; ///< \brief Used internally for fade ins/outs
  95. };
  96.  
  97.  
  98.  
  99. /**
  100.  * Lock or unlock the mutex of a kit_kmixerAudioDevice
  101.  * \param[in] device The device to lock
  102.  * \param[in] lockState A boolean of whether to lock the device or unlock it
  103.  * \return 0 on success, 1 if device already unlocked, or <0 on error (call SDL_GetError() for more info).
  104.  *
  105.  * \remark Only lock a device as long as necessary, as locking the device's mutex
  106.  *         prevents kmixer from interacting with the device at all. \n
  107.  *         Also, locks are counted by reference, so every lock needs to be
  108.  *         paired with an unlock until the device can be fully unlocked.
  109.  */
  110. extern int kit_kmixerDeviceLock(kit_kmixerDevice* device, SDL_bool lockState);
  111.  
  112.  
  113. /**
  114.  * Play or pause a kit_kmixerAudioDevice
  115.  * \param[in] device The device to play or pause
  116.  * \param[in] playState A boolean of whether to play or pause the device
  117.  * \return 0 on success, or <0 on error (call SDL_GetError() for more info)
  118.  *
  119.  * \remark When unpausing a paused device, there is 490ms of silence, followed by 10ms of fade-in. \n
  120.  * \remark Conversely, when pausing a currently unpaused device, there's 10ms of fade-out.
  121.  * \sa kit_kmixerDeviceUnpauseAndWait
  122.  * \sa kit_kmixerDevicePauseAndWait
  123.  */
  124. extern int kit_kmixerDevicePlay(kit_kmixerDevice* device, SDL_bool playState);
  125.  
  126.  
  127. /**
  128.  * Close a kit_kmixerAudioDevice
  129.  * \param[in] device_p A pointer to the device to close
  130.  * \return 0 on success, or <0 on error (call SDL_GetError() for more info)
  131.  *
  132.  * \remark Do note that this will call the kit_kmixerVoiceRemoveCallback
  133.  *         of any voices destroyed during this operation.
  134.  * \sa kit_kmixerDeviceOpen
  135.  */
  136. extern int kit_kmixerDeviceClose(kit_kmixerDevice** device_p);
  137.  
  138. /**
  139.  * Open a kit_kmixerAudioDevice
  140.  * \param[in] deviceName A string given by SDL_GetAudioDeviceName
  141.  *            (NULL for most reasonable default device)
  142.  * \param[in] allowedChanges Any combination of
  143.  *            SDL_AUDIO_ALLOW_<FREQUENCY,FORMAT,CHANNELS,SAMPLES,ANY>_CHANGE, OR'd together
  144.  * \param[in] voiceSpecDesired The requested specification of the device and initial voice
  145.  * \param[out] voiceSpecObtained The real specification of the device/initial voice,
  146.  *             altered depending on allowedChange's flags
  147.  *
  148.  * \remark If the ".format" member of voiceSpecDesired is set to 0,
  149.  *         voice 1 will not be created (useful in some scenarios). \n
  150.  * \remark (Devices will start in a paused state!)
  151.  * \sa kit_kmixerDeviceClose
  152.  * \sa kit_kmixerDevicePlay
  153.  */
  154. extern kit_kmixerDevice* kit_kmixerDeviceOpen(const char* deviceName, int allowedChanges,
  155.                                               const kit_kmixerVoiceSpec* voiceSpecDesired,
  156.                                               kit_kmixerVoiceSpec* voiceSpecObtained);
  157.  
  158.  
  159. /**
  160.  * Unpause a device, halting the calling thread until device fade-in completes
  161.  * \param[in] device The device to unpause
  162.  * \return 0 on success, or <0 on error (call SDL_GetError() for more info)
  163.  *
  164.  * \sa kit_kmixerDevicePlay
  165.  * \sa kit_kmixerDevicePauseAndWait
  166.  */
  167. extern int kit_kmixerDeviceUnpauseAndWait(kit_kmixerDevice* device);
  168.  
  169. /**
  170.  * Pause a device, halting the calling thread until device fade-out completes
  171.  * \param[in] device The device to unpause
  172.  * \return 0 on success, or <0 on error (call SDL_GetError() for more info)
  173.  *
  174.  * \sa kit_kmixerDevicePlay
  175.  * \sa kit_kmixerDeviceUnpauseAndWait
  176.  */
  177. extern int kit_kmixerDevicePauseAndWait(kit_kmixerDevice* device);
  178.  
  179.  
  180. extern int kit_kmixerDevice_Test(); // debug
  181.  
  182. /* ------------------ */
  183. /* -kit_kmixerDevice- */
  184. /* ------------------ */
  185.  
  186.  
  187.  
  188.  
  189. /* +++++++++++++++++ */
  190. /* +kit_kmixerVoice+ */
  191. /* +++++++++++++++++ */
  192.  
  193. /**
  194.  * \name Print a kit_kmixerVoiceSpec (These should probably become inlines at some point)
  195.  */
  196. /** @{ */
  197. #define PRINT_VOICE_SPEC(_pref, _vspec) {                              \
  198.   kit_coreLog(_pref".remove   = %p",(_vspec).remove);                  \
  199.   kit_coreLog(_pref".callback = %p",(_vspec).callback);                \
  200.   kit_coreLog(_pref".userdata = %p",(_vspec).userdata);                \
  201.   kit_coreLog(_pref".freq     = %i",(_vspec).freq);                    \
  202.   kit_coreLog(_pref"._size    = %u",(_vspec)._size);                   \
  203.   kit_coreLog(_pref".stereo   = %s",boolstr[(_vspec).stereo]); \
  204.   kit_coreLog(_pref".samples  = %u",(_vspec).samples);                 \
  205.   kit_coreLog(_pref".format   = 0x%04X",(_vspec).format);              }
  206.  
  207. #define PRINT_VOICE_SPEC_P(_pref, _vspec_pointer) {                              \
  208.   kit_coreLog(_pref"->remove   = %p",(_vspec_pointer)->remove);                  \
  209.   kit_coreLog(_pref"->callback = %p",(_vspec_pointer)->callback);                \
  210.   kit_coreLog(_pref"->userdata = %p",(_vspec_pointer)->userdata);                \
  211.   kit_coreLog(_pref"->freq     = %i",(_vspec_pointer)->freq);                    \
  212.   kit_coreLog(_pref"->_size    = %u",(_vspec_pointer)->_size);                   \
  213.   kit_coreLog(_pref"->stereo   = %s",boolstr[(_vspec_pointer)->stereo]); \
  214.   kit_coreLog(_pref"->samples  = %u",(_vspec_pointer)->samples);                 \
  215.   kit_coreLog(_pref"->format   = 0x%04X",(_vspec_pointer)->format);              }
  216. /** @} */
  217.  
  218.  
  219.  
  220. /**
  221.  * PCM Audio Voice Callback
  222.  * This type of function is called when added as a voice to a KMixer audio device
  223.  * While each voice's callback is given its own threadpool task (and should be thread-safe),
  224.  * the overall speed is determined by device's slowest voice chain (processing-wise)
  225.  * The given audio buffer must be completely filled before returning
  226.  * \param[in] userdata A user-defined pointer passed to the voice callback
  227.  * \param[in] _stream  A pointer to the audio data buffer
  228.  * \param[in] size     The size of that buffer, in bytes
  229.  * \param[in] hasInput A boolean of whether _stream already contains input PCM data (useful for applying DSP effects)
  230.  *
  231.  * \remark The audio data buffer is not guaranteed to be zeroed out, even if hasInput is SDL_FALSE
  232.  */
  233. typedef void (*kit_kmixerVoiceCallback) (void* userdata, void* _stream, int size, SDL_bool hasInput);
  234.  
  235.  
  236. /**
  237.  * Voice Destructor Callback
  238.  * This type of function is called when removing a voice, so userdata can be properly handled by the user.
  239.  * \param[in] userdata The user defined pointer to operate on.
  240.  *
  241.  * \remark Warning: unless kit_kmixerVoiceSpec.remove was set to NULL,
  242.  *         this will still be called, whether or not userdata is also NULL.
  243.  */
  244. typedef void (*kit_kmixerVoiceRemoveCallback) (void* userdata);
  245.  
  246.  
  247.  
  248. /**
  249.  * \brief The struct used when opening a kmixerDevice, as well as adding a voice to that device.
  250.  * \details When adding a voice, ".freq", and ".samples" are ignored, as that is tied to the device itself.
  251.  */
  252. struct kit_kmixerVoiceSpec { //40B
  253.   kit_kmixerVoiceRemoveCallback remove; ///< \brief A callback that should handle userdata in the event of voice removal (can be NULL)
  254.   kit_kmixerVoiceCallback callback; ///< \brief A callback that should either fill or modify its input stream
  255.   void*                   userdata; ///< \brief A user-defined pointer, passed to the callback (can be NULL)
  256.   Sint32                      freq; ///< \brief The PCM audio's sample rate, in Hz
  257.   Uint32                     _size; ///< \brief (internal; automatically calculated) The size of the audio buffer, in bytes
  258.   SDL_bool                  stereo; ///< \brief Stereo if SDL_TRUE, mono if SDL_FALSE
  259.   Uint16                   samples; ///< \brief The Audio buffer's length in sample FRAMES (total samples divided by channel count)
  260.   SDL_AudioFormat           format; ///< \brief Format can be one of AUDIO_<U8,S16,S32,F32>
  261. };
  262.  
  263.  
  264.  
  265. /**
  266.  * Remove a kmixer device's voice, as well as any input voices, recursively
  267.  * \param[in] device The device to remove a voice from
  268.  * \param[in] voiceID The ID number of the voice to remove
  269.  * \return 0 on success, -1 on error (call SDL_GetError() for more info)
  270.  *
  271.  * \remark The selected voice's kit_kmixerVoiceRemoveCallback will trigger
  272.  *         after the voice itself is mostly done being removed (if it isn't NULL) \n
  273.  * \remark Also, bit 31 of voiceID is reserved for detecting recursion, so don't set it.
  274.  * \sa kit_kmixerVoiceRemoveCallback
  275.  * \sa kit_kmixerVoiceAdd
  276.  * \sa kit_kmixerVoiceRedirect
  277.  */
  278. extern int kit_kmixerVoiceRemove(kit_kmixerDevice* device, Uint32 voiceID);
  279.  
  280. /**
  281.  * Add a voice to output to either a kmixer device or one of the device's voices
  282.  * \param[in] device The device to add a voice to
  283.  * \param[in] spec The specification for the voice
  284.  * \param[in] outputVoiceID The ID number of the output voice (0 for the device itself)
  285.  * \return The ID number of the newly-created voice, or 0 on error (call SDL_GetError() for more info)
  286.  *
  287.  * \sa kit_kmixerVoiceRemove
  288.  * \sa kit_kmixerVoiceRedirect
  289.  */
  290. extern Uint32 kit_kmixerVoiceAdd(kit_kmixerDevice* device, kit_kmixerVoiceSpec* spec,
  291.                                  Uint32 outputVoiceID);
  292.  
  293. /**
  294.  * Redirect the output of a voice
  295.  * \param[in] device The device to alter the voices of
  296.  * \param[in] inputVoiceID The voice to be redirected
  297.  * \param[in] outputVoiceID The new voice to output to (0 for the device itself)
  298.  * \return 0 on success, -1 on error (call SDL_GetError() for more info)
  299.  *
  300.  * \sa kit_kmixerVoiceRemove
  301.  * \sa kit_kmixerVoiceAdd
  302.  */
  303. extern int kit_kmixerVoiceRedirect(kit_kmixerDevice* device,
  304.                                    Uint32 inputVoiceID, Uint32 outputVoiceID);
  305.  
  306.  
  307. /**
  308.  * Get the number of inputs of a given voice
  309.  * \param[in] device The device access the voices of
  310.  * \param[in] voiceID The specific voice to query (0 for the device itself)
  311.  * \return The total number of inputs, or -1 on error (call SDL_GetError() for more info)
  312.  *
  313.  * \sa kit_kmixerVoiceGetInputs
  314.  * \sa kit_kmixerVoiceGetOutput
  315.  */
  316. extern Uint32 kit_kmixerVoiceGetNumInputs(kit_kmixerDevice* device, Uint32 voiceID);
  317.  
  318. /**
  319.  * Create a deep copy of a voice's input list
  320.  * \param[in] device The device access the voices of
  321.  * \param[in] voiceID The specific voice to query (0 for the device itself)
  322.  * \return A deep copy of voice's input list, or NULL on error (call SDL_GetError() for more info)
  323.  *
  324.  * \remark (Make sure to call kit_coreVectorDestroy after the returned vector is no longer used!)
  325.  * \sa kit_kmixerVoiceGetNumInputs
  326.  * \sa kit_kmixerVoiceGetOutput
  327.  */
  328. extern kit_coreVector* kit_kmixerVoiceGetInputs(kit_kmixerDevice* device, Uint32 voiceID);
  329.  
  330. /**
  331.  * Get the output voice ID of a given input voice
  332.  * \param[in] device The device access the voices of
  333.  * \param[in] voiceID The specific voice to query
  334.  * \return The output voice ID, or -1 on error (call SDL_GetError() for more info)
  335.  *
  336.  * \sa kit_kmixerVoiceGetNumInputs
  337.  * \sa kit_kmixerVoiceGetInputs
  338.  */
  339. extern Uint32 kit_kmixerVoiceGetOutput(kit_kmixerDevice* device, Uint32 voiceID);
  340.  
  341.  
  342. /**
  343.  * Get the time stamp of a voice at its point of creation
  344.  * \param[in] device The device access the voices of
  345.  * \param[in] voiceID The specific voice to query (0 for the device itself)
  346.  * \return The time stamp, in milliseconds, or -1 on error (call SDL_GetError() for more info)
  347.  *
  348.  * \remark Specifically, the value SDL_GetTicks() returned when the voice was created.
  349.  */
  350. extern Uint32 kit_kmixerVoiceGetTimeStamp(kit_kmixerDevice* device, Uint32 voiceID);
  351.  
  352. /**
  353.  * Get the voice processing stage of a given voice
  354.  * \param[in] device The device access the voices of
  355.  * \param[in] voiceID The specific voice to query (0 for the device itself)
  356.  * \return The voice's chain stage, or -1 on error (call SDL_GetError() for more info)
  357.  *
  358.  * \remark Voices are processed by order of highest stage to lowest. \n
  359.  *         For example, voice 0 is always on stage 0, whereas a voice that outputs to it will be on stage 1.
  360.  */
  361. extern Uint32 kit_kmixerVoiceGetChainStage(kit_kmixerDevice* device, Uint32 voiceID);
  362.  
  363.  
  364. /**
  365.  * Get the specification of a given voice
  366.  * \param[in] device The device access the voices of
  367.  * \param[in] voiceID The specific voice to query (0 for the device itself)
  368.  * \return The voice's specification struct. ".format" will be 0 on error (call SDL_GetError() for more info)
  369.  *
  370.  * \sa kit_kmixerVoiceSetSpecRemove
  371.  * \sa kit_kmixerVoiceSetSpecCallback
  372.  * \sa kit_kmixerVoiceSetSpecUserdata
  373.  */
  374. extern kit_kmixerVoiceSpec kit_kmixerVoiceGetSpec(kit_kmixerDevice* device, Uint32 voiceID);
  375.  
  376. /**
  377.  * Set the kit_kmixerVoiceRemoveCallback of a given voice
  378.  * \param[in] device The device access the voices of
  379.  * \param[in] voiceID The specific voice to query
  380.  * \param[in] remove The new kit_kmixerVoiceRemoveCallback the voice should use (can be NULL)
  381.  * \return 0 on success, or <0 on error (call SDL_GetError() for more info)
  382.  *
  383.  * \sa kit_kmixerVoiceGetSpec
  384.  * \sa kit_kmixerVoiceSetSpecCallback
  385.  * \sa kit_kmixerVoiceSetSpecUserdata
  386.  */
  387. extern int kit_kmixerVoiceSetSpecRemove(kit_kmixerDevice* device, Uint32 voiceID,
  388.                                         kit_kmixerVoiceRemoveCallback remove);
  389.  
  390. /**
  391.  * Set the kit_kmixerVoiceCallback of a given voice
  392.  * \param[in] device The device access the voices of
  393.  * \param[in] voiceID The specific voice to query
  394.  * \param[in] callback The new kit_kmixerVoiceCallback the voice should use
  395.  * \return 0 on success, or <0 on error (call SDL_GetError() for more info)
  396.  *
  397.  * \sa kit_kmixerVoiceGetSpec
  398.  * \sa kit_kmixerVoiceSetSpecRemove
  399.  * \sa kit_kmixerVoiceSetSpecUserdata
  400.  */
  401. extern int kit_kmixerVoiceSetSpecCallback(kit_kmixerDevice* device, Uint32 voiceID,
  402.                                           kit_kmixerVoiceCallback callback);
  403.  
  404. /**
  405.  * Set the userdata pointer of a given voice
  406.  * \param[in] device The device access the voices of
  407.  * \param[in] voiceID The specific voice to query
  408.  * \param[in] userdata The new userdata pointer the voice should use (can be NULL)
  409.  * \return 0 on success, or <0 on error (call SDL_GetError() for more info)
  410.  *
  411.  * \sa kit_kmixerVoiceGetSpec
  412.  * \sa kit_kmixerVoiceSetSpecRemove
  413.  * \sa kit_kmixerVoiceSetSpecCallback
  414.  */
  415. extern int kit_kmixerVoiceSetSpecUserdata(kit_kmixerDevice* device, Uint32 voiceID, void* userdata);
  416.  
  417.  
  418. /**
  419.  * Get the left channel volume of a given voice (or total volume if voice is mono)
  420.  * \param[in] device The device access the voices of
  421.  * \param[in] voiceID The specific voice to query (0 for the device itself)
  422.  * \return The voice's volume, or NAN on error (call SDL_GetError() for more info)
  423.  *
  424.  * \sa kit_kmixerVoiceGetVolR
  425.  * \sa kit_kmixerVoiceSetVolL
  426.  * \sa kit_kmixerVoiceSetVolR
  427.  * \sa kit_kmixerVoiceSetVolume
  428.  */
  429. extern float kit_kmixerVoiceGetVolL(kit_kmixerDevice* device, Uint32 voiceID);
  430.  
  431. /**
  432.  * Get the right channel volume of a given voice (or total volume if voice is mono)
  433.  * \param[in] device The device access the voices of
  434.  * \param[in] voiceID The specific voice to query (0 for the device itself)
  435.  * \return The voice's volume, or NAN on error (call SDL_GetError() for more info)
  436.  *
  437.  * \sa kit_kmixerVoiceGetVolL
  438.  * \sa kit_kmixerVoiceSetVolL
  439.  * \sa kit_kmixerVoiceSetVolR
  440.  * \sa kit_kmixerVoiceSetVolume
  441.  */
  442. extern float kit_kmixerVoiceGetVolR(kit_kmixerDevice* device, Uint32 voiceID);
  443.  
  444. /**
  445.  * Set the left channel volume of a given voice (or total volume if voice is mono)
  446.  * \param[in] device The device access the voices of
  447.  * \param[in] voiceID The specific voice to query (0 for the device itself)
  448.  * \param[in] volL The new volume to set the voice to
  449.  * \return 0 on success, or <0 on error (call SDL_GetError() for more info)
  450.  *
  451.  * \remark If volL <0, volL will be MAX()'d to 0
  452.  * \sa kit_kmixerVoiceGetVolL
  453.  * \sa kit_kmixerVoiceGetVolR
  454.  * \sa kit_kmixerVoiceSetVolR
  455.  * \sa kit_kmixerVoiceSetVolume
  456.  */
  457. extern int kit_kmixerVoiceSetVolL(kit_kmixerDevice* device, Uint32 voiceID, float volL);
  458.  
  459. /**
  460.  * Set the right channel volume of a given voice (ignored if voice is mono)
  461.  * \param[in] device The device access the voices of
  462.  * \param[in] voiceID The specific voice to query (0 for the device itself)
  463.  * \param[in] volR The new volume to set the voice to
  464.  * \return 0 on success, or <0 on error (call SDL_GetError() for more info)
  465.  *
  466.  * \remark If the voice is stereo, but volR <0, volR will be set to volL
  467.  * \sa kit_kmixerVoiceGetVolL
  468.  * \sa kit_kmixerVoiceGetVolR
  469.  * \sa kit_kmixerVoiceSetVolL
  470.  * \sa kit_kmixerVoiceSetVolume
  471.  */
  472. extern int kit_kmixerVoiceSetVolR(kit_kmixerDevice* device, Uint32 voiceID, float volR);
  473.  
  474. /**
  475.  * Set both the left and right channel volumes of a given voice
  476.  * \param[in] device The device access the voices of
  477.  * \param[in] voiceID The specific voice to query (0 for the device itself)
  478.  * \param[in] volL The new volume for the left channel
  479.  * \param[in] volR The new volume for the right channel
  480.  * \return 0 on success, or <0 on error (call SDL_GetError() for more info)
  481.  *
  482.  * \remark The same rules that apply to kit_kmixerVoiceSetVolL and kit_kmixerVoiceSetVolR apply here too.
  483.  * \sa kit_kmixerVoiceGetVolL
  484.  * \sa kit_kmixerVoiceGetVolR
  485.  * \sa kit_kmixerVoiceSetVolL
  486.  * \sa kit_kmixerVoiceSetVolR
  487.  */
  488. extern int kit_kmixerVoiceSetVolume(kit_kmixerDevice* device, Uint32 voiceID, float volL, float volR);
  489.  
  490.  
  491. extern int kit_kmixerVoice_Test(); //debug
  492.  
  493. extern void kit_kmixerVoicePrintRawOrd(kit_kmixerDevice* device); //debug
  494.  
  495. /* ----------------- */
  496. /* -kit_kmixerVoice- */
  497. /* ----------------- */
  498.  
  499.  
  500.  
  501.  
  502. /* +++++++++++++++++ */
  503. /* +kit_kmixerAsync+ */
  504. /* +++++++++++++++++ */
  505.  
  506. /**
  507.  * Add an asyncronous mixer voice (useful for playing sound effects)
  508.  * \param[in] device The device to add the voice to
  509.  * \param[in] vspec The specification for the new voice
  510.  * \param[in] outputVoiceID The voice to output to (0 for the device itself)
  511.  * \param[in] numTracks The maximum number of tracks that can play at once
  512.  * \return The index of the newly-created voice, or 0 on error (call SDL_GetError() for more info)
  513.  *
  514.  * \remark There is no AsyncRemove function, as VoiceRemove handles everything automatically. \n
  515.  * \remark Also, only the stereo and format members of vspec are important. Everything else should be ignored
  516.  */
  517. extern Uint32 kit_kmixerAsyncAdd(kit_kmixerDevice* device, kit_kmixerVoiceSpec* vspec,
  518.                                  Uint32 outputVoiceID, Uint32 numTracks);
  519.  
  520. /* +++++++++++++++++ */
  521. /* +kit_kmixerAsync+ */
  522. /* +++++++++++++++++ */
  523.  
  524.  
  525.  
  526.  
  527. #ifdef __cplusplus
  528. }
  529. #endif
  530.  
  531. #endif /* _KIT_SDL2_KMIXER_H */
  532. #endif /* _KIT_KMIXER_H */
  533.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement