Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

112 lines
3.5 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef VOICE_H
  8. #define VOICE_H
  9. #pragma once
  10. /*! @defgroup Voice Voice
  11. Defines the engine's interface to the voice code.
  12. @{
  13. */
  14. #define VOICE_OUTPUT_SAMPLE_RATE 11025 // Sample rate that we feed to the mixer.
  15. //! Returned on error from certain voice functions.
  16. #define VOICE_CHANNEL_ERROR -1
  17. #define VOICE_CHANNEL_IN_TWEAK_MODE -2 // Returned by AssignChannel if currently in tweak mode (not an error).
  18. //! Initialize the voice code.
  19. bool Voice_Init();
  20. //! Force Initialization with default codec.
  21. void Voice_ForceInit();
  22. //! Shutdown the voice code.
  23. void Voice_Deinit();
  24. //! Returns true if the client has voice enabled
  25. bool Voice_Enabled( void );
  26. //! Returns true if the user can hear themself speak.
  27. bool Voice_GetLoopback();
  28. //! This is called periodically by the engine when the server acks the local player talking.
  29. //! This tells the client DLL that the local player is talking and fades after about 200ms.
  30. void Voice_LocalPlayerTalkingAck( CSplitScreenSlot iSsSlot );
  31. //! Call every frame to update the voice stuff.
  32. bool Voice_Idle(float frametime);
  33. //! Returns true if mic input is currently being recorded.
  34. bool Voice_IsRecording( CSplitScreenSlot nSplitScreenSlot );
  35. //! Begin recording input from the mic.
  36. bool Voice_RecordStart(
  37. CSplitScreenSlot nSplitScreenSlot,
  38. //! Filename to store incoming mic data, or NULL if none.
  39. const char *pUncompressedFile,
  40. //! Filename to store the output of compression and decompressiong with the codec, or NULL if none.
  41. const char *pDecompressedFile,
  42. //! If this is non-null, the voice manager will use this file for input instead of the mic.
  43. const char *pMicInputFile
  44. );
  45. //! Stop recording from the mic.
  46. bool Voice_RecordStop( CSplitScreenSlot nSplitScreenSlot );
  47. //! Get the most recent N bytes of compressed data. If nCount is less than the number of
  48. //! available bytes, it discards the first bytes and gives you the last ones.
  49. //! Set bFinal to true on the last call to this (it will flush out any stored voice data).
  50. int Voice_GetCompressedData( CSplitScreenSlot nSplitScreenSlot, char *pchData, int nCount, bool bFinal);
  51. //! Pass incoming data from the server into here.
  52. //! The data should have been compressed and gotten through a Voice_GetCompressedData call.
  53. int Voice_AddIncomingData(
  54. //! Channel index.
  55. int nChannel,
  56. //! Compressed data to add to the channel.
  57. const char *pchData,
  58. //! Number of bytes in pchData.
  59. int nCount,
  60. //! Sequence number. If a packet is missed, it adds padding so the time isn't squashed.
  61. int iSequenceNumber,
  62. //! Was this data compressed?
  63. bool isCompressed = true
  64. );
  65. #define VOICE_TIME_PADDING 0.2f // Time between receiving the first voice packet and actually starting
  66. // to play the sound. This accounts for frametime differences on the clients
  67. // and the server.
  68. //! Call this to reserve a voice channel for the specified entity to talk into.
  69. //! \return A channel index for use with Voice_AddIncomingData or VOICE_CHANNEL_ERROR on error.
  70. int Voice_AssignChannel(int nEntity, bool bProximity, float timePadding = VOICE_TIME_PADDING );
  71. //! Call this to get the channel index that the specified entity is talking into.
  72. //! \return A channel index for use with Voice_AddIncomingData or VOICE_CHANNEL_ERROR if the entity isn't talking.
  73. int Voice_GetChannel(int nEntity);
  74. /*! @} */
  75. #endif // VOICE_H