diff options
| author | Jørgen P. Tjernø <[email protected]> | 2013-12-02 19:31:46 -0800 |
|---|---|---|
| committer | Jørgen P. Tjernø <[email protected]> | 2013-12-02 19:46:31 -0800 |
| commit | f56bb35301836e56582a575a75864392a0177875 (patch) | |
| tree | de61ddd39de3e7df52759711950b4c288592f0dc /mp/src/public/soundsystem | |
| parent | Mark some more files as text. (diff) | |
| download | source-sdk-2013-f56bb35301836e56582a575a75864392a0177875.tar.xz source-sdk-2013-f56bb35301836e56582a575a75864392a0177875.zip | |
Fix line endings. WHAMMY.
Diffstat (limited to 'mp/src/public/soundsystem')
| -rw-r--r-- | mp/src/public/soundsystem/isoundsystem.h | 140 | ||||
| -rw-r--r-- | mp/src/public/soundsystem/snd_audio_source.h | 202 | ||||
| -rw-r--r-- | mp/src/public/soundsystem/snd_device.h | 220 |
3 files changed, 281 insertions, 281 deletions
diff --git a/mp/src/public/soundsystem/isoundsystem.h b/mp/src/public/soundsystem/isoundsystem.h index f4d1ce94..8a370908 100644 --- a/mp/src/public/soundsystem/isoundsystem.h +++ b/mp/src/public/soundsystem/isoundsystem.h @@ -1,70 +1,70 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-//===========================================================================//
-
-#ifndef ISOUNDSYSTEM_H
-#define ISOUNDSYSTEM_H
-#ifdef _WIN32
-#pragma once
-#endif
-
-#include "appframework/iappsystem.h"
-
-
-//-----------------------------------------------------------------------------
-// Forward declarations
-//-----------------------------------------------------------------------------
-class IAudioDevice;
-class CAudioSource;
-class CAudioMixer;
-
-
-//-----------------------------------------------------------------------------
-// Sound handle
-//-----------------------------------------------------------------------------
-typedef unsigned short AudioSourceHandle_t;
-enum
-{
- AUDIOSOURCEHANDLE_INVALID = (AudioSourceHandle_t)~0
-};
-
-
-//-----------------------------------------------------------------------------
-// Flags for FindAudioSource
-//-----------------------------------------------------------------------------
-enum FindAudioSourceFlags_t
-{
- FINDAUDIOSOURCE_NODELAY = 0x1,
- FINDAUDIOSOURCE_PREFETCH = 0x2,
- FINDAUDIOSOURCE_PLAYONCE = 0x4,
-};
-
-
-//-----------------------------------------------------------------------------
-// Purpose: DLL interface for low-level sound utilities
-//-----------------------------------------------------------------------------
-#define SOUNDSYSTEM_INTERFACE_VERSION "SoundSystem001"
-
-abstract_class ISoundSystem : public IAppSystem
-{
-public:
- virtual void Update( float time ) = 0;
- virtual void Flush( void ) = 0;
-
- virtual CAudioSource *FindOrAddSound( const char *filename ) = 0;
- virtual CAudioSource *LoadSound( const char *wavfile ) = 0;
-
- virtual void PlaySound( CAudioSource *source, float volume, CAudioMixer **ppMixer ) = 0;
-
- virtual bool IsSoundPlaying( CAudioMixer *pMixer ) = 0;
- virtual CAudioMixer *FindMixer( CAudioSource *source ) = 0;
-
- virtual void StopAll( void ) = 0;
- virtual void StopSound( CAudioMixer *mixer ) = 0;
-};
-
-
-
-#endif // ISOUNDSYSTEM_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +//===========================================================================// + +#ifndef ISOUNDSYSTEM_H +#define ISOUNDSYSTEM_H +#ifdef _WIN32 +#pragma once +#endif + +#include "appframework/iappsystem.h" + + +//----------------------------------------------------------------------------- +// Forward declarations +//----------------------------------------------------------------------------- +class IAudioDevice; +class CAudioSource; +class CAudioMixer; + + +//----------------------------------------------------------------------------- +// Sound handle +//----------------------------------------------------------------------------- +typedef unsigned short AudioSourceHandle_t; +enum +{ + AUDIOSOURCEHANDLE_INVALID = (AudioSourceHandle_t)~0 +}; + + +//----------------------------------------------------------------------------- +// Flags for FindAudioSource +//----------------------------------------------------------------------------- +enum FindAudioSourceFlags_t +{ + FINDAUDIOSOURCE_NODELAY = 0x1, + FINDAUDIOSOURCE_PREFETCH = 0x2, + FINDAUDIOSOURCE_PLAYONCE = 0x4, +}; + + +//----------------------------------------------------------------------------- +// Purpose: DLL interface for low-level sound utilities +//----------------------------------------------------------------------------- +#define SOUNDSYSTEM_INTERFACE_VERSION "SoundSystem001" + +abstract_class ISoundSystem : public IAppSystem +{ +public: + virtual void Update( float time ) = 0; + virtual void Flush( void ) = 0; + + virtual CAudioSource *FindOrAddSound( const char *filename ) = 0; + virtual CAudioSource *LoadSound( const char *wavfile ) = 0; + + virtual void PlaySound( CAudioSource *source, float volume, CAudioMixer **ppMixer ) = 0; + + virtual bool IsSoundPlaying( CAudioMixer *pMixer ) = 0; + virtual CAudioMixer *FindMixer( CAudioSource *source ) = 0; + + virtual void StopAll( void ) = 0; + virtual void StopSound( CAudioMixer *mixer ) = 0; +}; + + + +#endif // ISOUNDSYSTEM_H diff --git a/mp/src/public/soundsystem/snd_audio_source.h b/mp/src/public/soundsystem/snd_audio_source.h index e43f22d5..11e4621c 100644 --- a/mp/src/public/soundsystem/snd_audio_source.h +++ b/mp/src/public/soundsystem/snd_audio_source.h @@ -1,101 +1,101 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-// $Workfile: $
-// $Date: $
-// $NoKeywords: $
-//===========================================================================//
-
-#ifndef SND_AUDIO_SOURCE_H
-#define SND_AUDIO_SOURCE_H
-
-#ifdef _WIN32
-#pragma once
-#endif
-
-#include "tier0/platform.h"
-
-
-//-----------------------------------------------------------------------------
-// Forward declarations
-//-----------------------------------------------------------------------------
-class CAudioSource;
-class IAudioDevice;
-struct channel_t;
-
-
-//-----------------------------------------------------------------------------
-// Purpose: This is an instance of an audio source.
-// Mixers are attached to channels and reference an audio source.
-// Mixers are specific to the sample format and source format.
-// Mixers are never re-used, so they can track instance data like
-// sample position, fractional sample, stream cache, faders, etc.
-//-----------------------------------------------------------------------------
-abstract_class CAudioMixer
-{
-public:
- virtual ~CAudioMixer( void ) {}
-
- // UNDONE: time compress
- virtual bool MixDataToDevice( IAudioDevice *pDevice, channel_t *pChannel, int startSample, int sampleCount, int outputRate, bool forward = true ) = 0;
- virtual void IncrementSamples( channel_t *pChannel, int startSample, int sampleCount,int outputRate, bool forward = true ) = 0;
- virtual bool SkipSamples( IAudioDevice *pDevice, channel_t *pChannel, int startSample, int sampleCount, int outputRate, bool forward = true ) = 0;
-
- virtual CAudioSource *GetSource( void ) = 0;
-
- virtual int GetSamplePosition( void ) = 0;
- virtual int GetScubPosition( void ) = 0;
-
- virtual bool SetSamplePosition( int position, bool scrubbing = false ) = 0;
- virtual void SetLoopPosition( int position ) = 0;
- virtual int GetStartPosition( void ) = 0;
-
- virtual bool GetActive( void ) = 0;
- virtual void SetActive( bool active ) = 0;
-
- virtual void SetModelIndex( int index ) = 0;
- virtual int GetModelIndex( void ) const = 0;
-
- virtual void SetDirection( bool forward ) = 0;
- virtual bool GetDirection( void ) const = 0;
-
- virtual void SetAutoDelete( bool autodelete ) = 0;
- virtual bool GetAutoDelete( void ) const = 0;
-
- virtual void SetVolume( float volume ) = 0;
- virtual channel_t *GetChannel() = 0;
-};
-
-//-----------------------------------------------------------------------------
-// Purpose: A source is an abstraction for a stream, cached file, or procedural
-// source of audio.
-//-----------------------------------------------------------------------------
-class CSentence;
-
-abstract_class CAudioSource
-{
-public:
- CAudioSource( void );
- virtual ~CAudioSource( void );
-
- // Create an instance (mixer) of this audio source
- virtual CAudioMixer *CreateMixer( void ) = 0;
- virtual int GetOutputData( void **pData, int samplePosition, int sampleCount, bool forward = true ) = 0;
- virtual int SampleRate( void ) = 0;
- virtual int SampleSize( void ) = 0;
- virtual int SampleCount( void ) = 0;
- virtual float TrueSampleSize( void ) = 0;
- virtual bool IsLooped( void ) = 0;
- virtual bool IsStreaming( void ) = 0;
- virtual float GetRunningLength( void ) = 0;
- virtual int GetNumChannels() = 0;
-
- virtual CSentence *GetSentence( void ) { return NULL; };
-
-};
-
-
-extern CAudioSource *AudioSource_Create( const char *pName );
-
-#endif // SND_AUDIO_SOURCE_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $Workfile: $ +// $Date: $ +// $NoKeywords: $ +//===========================================================================// + +#ifndef SND_AUDIO_SOURCE_H +#define SND_AUDIO_SOURCE_H + +#ifdef _WIN32 +#pragma once +#endif + +#include "tier0/platform.h" + + +//----------------------------------------------------------------------------- +// Forward declarations +//----------------------------------------------------------------------------- +class CAudioSource; +class IAudioDevice; +struct channel_t; + + +//----------------------------------------------------------------------------- +// Purpose: This is an instance of an audio source. +// Mixers are attached to channels and reference an audio source. +// Mixers are specific to the sample format and source format. +// Mixers are never re-used, so they can track instance data like +// sample position, fractional sample, stream cache, faders, etc. +//----------------------------------------------------------------------------- +abstract_class CAudioMixer +{ +public: + virtual ~CAudioMixer( void ) {} + + // UNDONE: time compress + virtual bool MixDataToDevice( IAudioDevice *pDevice, channel_t *pChannel, int startSample, int sampleCount, int outputRate, bool forward = true ) = 0; + virtual void IncrementSamples( channel_t *pChannel, int startSample, int sampleCount,int outputRate, bool forward = true ) = 0; + virtual bool SkipSamples( IAudioDevice *pDevice, channel_t *pChannel, int startSample, int sampleCount, int outputRate, bool forward = true ) = 0; + + virtual CAudioSource *GetSource( void ) = 0; + + virtual int GetSamplePosition( void ) = 0; + virtual int GetScubPosition( void ) = 0; + + virtual bool SetSamplePosition( int position, bool scrubbing = false ) = 0; + virtual void SetLoopPosition( int position ) = 0; + virtual int GetStartPosition( void ) = 0; + + virtual bool GetActive( void ) = 0; + virtual void SetActive( bool active ) = 0; + + virtual void SetModelIndex( int index ) = 0; + virtual int GetModelIndex( void ) const = 0; + + virtual void SetDirection( bool forward ) = 0; + virtual bool GetDirection( void ) const = 0; + + virtual void SetAutoDelete( bool autodelete ) = 0; + virtual bool GetAutoDelete( void ) const = 0; + + virtual void SetVolume( float volume ) = 0; + virtual channel_t *GetChannel() = 0; +}; + +//----------------------------------------------------------------------------- +// Purpose: A source is an abstraction for a stream, cached file, or procedural +// source of audio. +//----------------------------------------------------------------------------- +class CSentence; + +abstract_class CAudioSource +{ +public: + CAudioSource( void ); + virtual ~CAudioSource( void ); + + // Create an instance (mixer) of this audio source + virtual CAudioMixer *CreateMixer( void ) = 0; + virtual int GetOutputData( void **pData, int samplePosition, int sampleCount, bool forward = true ) = 0; + virtual int SampleRate( void ) = 0; + virtual int SampleSize( void ) = 0; + virtual int SampleCount( void ) = 0; + virtual float TrueSampleSize( void ) = 0; + virtual bool IsLooped( void ) = 0; + virtual bool IsStreaming( void ) = 0; + virtual float GetRunningLength( void ) = 0; + virtual int GetNumChannels() = 0; + + virtual CSentence *GetSentence( void ) { return NULL; }; + +}; + + +extern CAudioSource *AudioSource_Create( const char *pName ); + +#endif // SND_AUDIO_SOURCE_H diff --git a/mp/src/public/soundsystem/snd_device.h b/mp/src/public/soundsystem/snd_device.h index 7c5da313..fa855897 100644 --- a/mp/src/public/soundsystem/snd_device.h +++ b/mp/src/public/soundsystem/snd_device.h @@ -1,110 +1,110 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-// $Workfile: $
-// $Date: $
-// $NoKeywords: $
-//===========================================================================//
-
-#ifndef SND_DEVICE_H
-#define SND_DEVICE_H
-
-#ifdef _WIN32
-#pragma once
-#endif
-
-#include "tier0/platform.h"
-
-//-----------------------------------------------------------------------------
-// 4.28 fixed point stuff for real-time resampling
-//-----------------------------------------------------------------------------
-#define FIX_BITS 28
-#define FIX_SCALE (1 << FIX_BITS)
-#define FIX_MASK ((1 << FIX_BITS)-1)
-#define FIX_FLOAT(a) ((int)((a) * FIX_SCALE))
-#define FIX(a) (((int)(a)) << FIX_BITS)
-#define FIX_INTPART(a) (((int)(a)) >> FIX_BITS)
-#define FIX_FRACTION(a,b) (FIX(a)/(b))
-#define FIX_FRACPART(a) ((a) & FIX_MASK)
-
-typedef unsigned int fixedint;
-
-
-//-----------------------------------------------------------------------------
-// sound rate defines
-//-----------------------------------------------------------------------------
-#define SOUND_DMA_SPEED 44100 // hardware playback rate
-#define SOUND_11k 11025 // 11khz sample rate
-#define SOUND_22k 22050 // 22khz sample rate
-#define SOUND_44k 44100 // 44khz sample rate
-#define SOUND_ALL_RATES 1 // mix all sample rates
-
-
-//-----------------------------------------------------------------------------
-// Information about the channel
-//-----------------------------------------------------------------------------
-struct channel_t
-{
- int leftvol;
- int rightvol;
- float pitch;
-};
-
-
-//-----------------------------------------------------------------------------
-// The audio device is responsible for mixing
-//-----------------------------------------------------------------------------
-abstract_class IAudioDevice
-{
-public:
- // Add a virtual destructor to silence the clang warning.
- // This is harmless but not important since the only derived class
- // doesn't have a destructor.
- virtual ~IAudioDevice() {}
-
- // This initializes the sound hardware. true on success, false on failure
- virtual bool Init( void ) = 0;
-
- // This releases all sound hardware
- virtual void Shutdown( void ) = 0;
-
- // device parameters
- virtual const char *DeviceName( void ) const = 0;
- virtual int DeviceChannels( void ) const = 0; // 1 = mono, 2 = stereo
- virtual int DeviceSampleBits( void ) const = 0; // bits per sample (8 or 16)
- virtual int DeviceSampleBytes( void ) const = 0; // above / 8
- virtual int DeviceSampleRate( void ) const = 0; // Actual DMA speed
- virtual int DeviceSampleCount( void ) const = 0; // Total samples in buffer
-
- // Called each time a new paint buffer is mixed (may be multiple times per frame)
- virtual void MixBegin( void ) = 0;
-
- // Main mixing routines
- virtual void Mix8Mono( channel_t *pChannel, char *pData, int outputOffset, int inputOffset, fixedint rateScaleFix, int outCount, int timecompress, bool forward = true ) = 0;
- virtual void Mix8Stereo( channel_t *pChannel, char *pData, int outputOffset, int inputOffset, fixedint rateScaleFix, int outCount, int timecompress, bool forward = true ) = 0;
- virtual void Mix16Mono( channel_t *pChannel, short *pData, int outputOffset, int inputOffset, fixedint rateScaleFix, int outCount, int timecompress, bool forward = true ) = 0;
- virtual void Mix16Stereo( channel_t *pChannel, short *pData, int outputOffset, int inputOffset, fixedint rateScaleFix, int outCount, int timecompress, bool forward = true ) = 0;
-
- // Size of the paint buffer in samples
- virtual int PaintBufferSampleCount( void ) const = 0;
-
- // Adds a mixer to be mixed
- virtual void AddSource( CAudioMixer *pSource ) = 0;
-
- // Stops all sounds
- virtual void StopSounds( void ) = 0;
-
- // Updates sound mixing
- virtual void Update( float time ) = 0;
-
- // Resets the device
- virtual void Flush( void ) = 0;
-
- virtual int FindSourceIndex( CAudioMixer *pSource ) = 0;
- virtual CAudioMixer *GetMixerForSource( CAudioSource *source ) = 0;
- virtual void FreeChannel( int channelIndex ) = 0;
-};
-
-
-#endif // SND_DEVICE_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $Workfile: $ +// $Date: $ +// $NoKeywords: $ +//===========================================================================// + +#ifndef SND_DEVICE_H +#define SND_DEVICE_H + +#ifdef _WIN32 +#pragma once +#endif + +#include "tier0/platform.h" + +//----------------------------------------------------------------------------- +// 4.28 fixed point stuff for real-time resampling +//----------------------------------------------------------------------------- +#define FIX_BITS 28 +#define FIX_SCALE (1 << FIX_BITS) +#define FIX_MASK ((1 << FIX_BITS)-1) +#define FIX_FLOAT(a) ((int)((a) * FIX_SCALE)) +#define FIX(a) (((int)(a)) << FIX_BITS) +#define FIX_INTPART(a) (((int)(a)) >> FIX_BITS) +#define FIX_FRACTION(a,b) (FIX(a)/(b)) +#define FIX_FRACPART(a) ((a) & FIX_MASK) + +typedef unsigned int fixedint; + + +//----------------------------------------------------------------------------- +// sound rate defines +//----------------------------------------------------------------------------- +#define SOUND_DMA_SPEED 44100 // hardware playback rate +#define SOUND_11k 11025 // 11khz sample rate +#define SOUND_22k 22050 // 22khz sample rate +#define SOUND_44k 44100 // 44khz sample rate +#define SOUND_ALL_RATES 1 // mix all sample rates + + +//----------------------------------------------------------------------------- +// Information about the channel +//----------------------------------------------------------------------------- +struct channel_t +{ + int leftvol; + int rightvol; + float pitch; +}; + + +//----------------------------------------------------------------------------- +// The audio device is responsible for mixing +//----------------------------------------------------------------------------- +abstract_class IAudioDevice +{ +public: + // Add a virtual destructor to silence the clang warning. + // This is harmless but not important since the only derived class + // doesn't have a destructor. + virtual ~IAudioDevice() {} + + // This initializes the sound hardware. true on success, false on failure + virtual bool Init( void ) = 0; + + // This releases all sound hardware + virtual void Shutdown( void ) = 0; + + // device parameters + virtual const char *DeviceName( void ) const = 0; + virtual int DeviceChannels( void ) const = 0; // 1 = mono, 2 = stereo + virtual int DeviceSampleBits( void ) const = 0; // bits per sample (8 or 16) + virtual int DeviceSampleBytes( void ) const = 0; // above / 8 + virtual int DeviceSampleRate( void ) const = 0; // Actual DMA speed + virtual int DeviceSampleCount( void ) const = 0; // Total samples in buffer + + // Called each time a new paint buffer is mixed (may be multiple times per frame) + virtual void MixBegin( void ) = 0; + + // Main mixing routines + virtual void Mix8Mono( channel_t *pChannel, char *pData, int outputOffset, int inputOffset, fixedint rateScaleFix, int outCount, int timecompress, bool forward = true ) = 0; + virtual void Mix8Stereo( channel_t *pChannel, char *pData, int outputOffset, int inputOffset, fixedint rateScaleFix, int outCount, int timecompress, bool forward = true ) = 0; + virtual void Mix16Mono( channel_t *pChannel, short *pData, int outputOffset, int inputOffset, fixedint rateScaleFix, int outCount, int timecompress, bool forward = true ) = 0; + virtual void Mix16Stereo( channel_t *pChannel, short *pData, int outputOffset, int inputOffset, fixedint rateScaleFix, int outCount, int timecompress, bool forward = true ) = 0; + + // Size of the paint buffer in samples + virtual int PaintBufferSampleCount( void ) const = 0; + + // Adds a mixer to be mixed + virtual void AddSource( CAudioMixer *pSource ) = 0; + + // Stops all sounds + virtual void StopSounds( void ) = 0; + + // Updates sound mixing + virtual void Update( float time ) = 0; + + // Resets the device + virtual void Flush( void ) = 0; + + virtual int FindSourceIndex( CAudioMixer *pSource ) = 0; + virtual CAudioMixer *GetMixerForSource( CAudioSource *source ) = 0; + virtual void FreeChannel( int channelIndex ) = 0; +}; + + +#endif // SND_DEVICE_H |