|
coastline 0.0.4
|
The buffers and the channels of the sound effects of the PC port. More...
#include <windows.h>#include <dsound.h>#include "common/assetnames.h"#include "common/soundbank.h"#include "common/soundsample.h"#include "common/soundsystem.h"#include "ear/wavechunks.h"

Go to the source code of this file.
Classes | |
| struct | SoundBufferNode |
| A sound buffer of a sample, in a list. More... | |
Enumerations | |
| enum | { SOUND_SET_FRONT_END , SOUND_SET_RACE } |
| The sets of sounds of LoadSoundSet(). More... | |
Functions | |
| HRESULT | CreateDirectSoundBufferFromSample (SoundBufferNode *pNode) |
| Create the buffer of DirectSound of a sample, static with control of the frequency, the pan, the volume, and the position, and copy the sample into it. | |
| HRESULT | ReleaseSoundBuffer (SoundBufferNode *pNode) |
| Release the buffer of DirectSound of a node. | |
| HRESULT | StopSoundBuffer (SoundBufferNode *pNode) |
| Stop the buffer of DirectSound of a node that plays. | |
| bool | IsSoundChannelPlaying (int nChannel) |
| Report whether the buffer of a channel plays, when sound is on. | |
| bool | SetAudioChannelLooping (int nChannel, int bLooping) |
| Set whether the buffer of a channel plays in a loop, when sound is on. | |
| void | SetSoundBankEntryIndex (int nVoice, int nIndex) |
| Record a sound for the even channel of a voice in the first row of the banks and in the rows of the variants and the looping sounds, as one more than its index. | |
| void | ResetSoundBankTables (void) |
| Clear the first entries of the three tables of the banks of sounds. | |
| int | AppendSoundBufferToList (SoundBufferNode *pHead, SoundBufferNode *pNode) |
| Add a node at the end of a list of sound buffers, not playing. | |
| HRESULT | ApplySoundBufferPan (SoundBufferNode *pNode) |
| Set the pan of the buffer of a node from nPan. | |
| HRESULT | ApplySoundBufferFrequency (SoundBufferNode *pNode) |
| Set the frequency of the buffer of a node from dwFrequency. | |
| HRESULT | ApplySoundBufferVolume (SoundBufferNode *pNode) |
| Set the volume of the buffer of a node from nVolume scaled by g_bSfxVolume, or silence it when the sound effects are off. | |
| HRESULT | RestartOrPlaySoundBuffer (SoundBufferNode *pNode) |
| Play the buffer of a node from its start: a buffer that plays goes back to its start, and one that does not starts, in a loop when bLooping is set, and is marked as playing. | |
| HRESULT | PlaySoundBuffer (SoundBufferNode *pNode, int bLooping) |
| Set whether the buffer of a node loops and play it from its start. | |
| bool | SetSoundBufferFrequency (SoundBufferNode *pNode, DWORD dwFrequency) |
| Set the frequency of the buffer of a node, when sound is on. | |
| bool | IsSoundBufferPlaying (SoundBufferNode *pNode) |
| Report whether the buffer of a node plays. | |
| bool | SetSoundChannelFrequency (int nSample, int nChannel, DWORD dwFrequency) |
| Set the frequency of a channel of a sample, when sound is on. | |
| bool | SetSoundVoiceFrequencyFloat (int nSample, int nVoice, float fFrequency) |
| Set the frequency of the even channel of a voice of a sample, dropping the fraction. | |
| bool | StopSoundVoice (int nSample, int nVoice) |
| Stop the buffer of the first channel of a voice of a sample, when sound is on. | |
| bool | SetSoundBufferStereoLevels (SoundBufferNode *pNode, DWORD dwLevels) |
| Set the volume and the pan of the buffer of a node from the levels of its two sides. | |
| bool | SetAudioChannelStereoLevels (int nChannel, DWORD dwLevels) |
| Set the levels of the two sides of the buffer of a channel and record them, when sound is on. | |
| bool | AssignAudioChannel (int nSample, int nChannel) |
| Stop the buffer of a channel and give the channel the buffer of a sample for it, when sound is on. | |
| bool | SetAudioChannelFrequency (int nChannel, long long llFrequency) |
| Set the frequency of the buffer of a channel, scaled by its sample, and record it, when sound is on. | |
| bool | StartSoundChannelPlayback (int nSample, int nChannel, int bLooping) |
| Play the buffer of a sample for a channel and give it to the channel, when sound is on. | |
| bool | InitSoundChannelWithVolume (short nChannel, int nSample, int nLength, int nLoopLength, DWORD dwLevels) |
| Request a sample and levels for a channel, give the channel the buffer of the sample, and play it. | |
| bool | SetStereoAndPlaySoundChannel (int nSample, int nChannel, DWORD dwLevels, int bLooping) |
| Set the levels of the two sides of a channel of a sample and play it, when sound is on. | |
| bool | PlaySoundChannelOneWithStereo (int nSample, DWORD dwLevels, int bLooping) |
| Set the levels of the two sides of channel 1 of a sample and play it. | |
| bool | SetSoundChannelStereo (int nSample, int nChannel, DWORD dwLevels) |
| Set the levels of the two sides of a channel of a sample, when sound is on. | |
| bool | SetSoundVoiceStereo (int nSample, int nVoice, DWORD dwLevels) |
| Set the levels of the two sides of the even channel of a voice of a sample. | |
| bool | PlaySoundChannelOneOnce (int nSample, DWORD dwLevels) |
| Set the levels of the two sides of channel 1 of a sample and play it once. | |
| bool | PlayLoopedSoundVoiceWithStereo (int nSample, int nVoice, DWORD dwLevels) |
| Set the levels of the two sides of the even channel of a voice of a sample and play it in a loop. | |
| SoundBufferNode * | LoadAudioFile (const char *pszPath, int sample=-1) |
| Load a wave file into a node of a buffer of DirectSound at the end of g_SoundBufferListHead, at its own frequency, the centre, and the volume of the sound effects. | |
| bool | LoadSfxWaveVariants (int nEffect) |
| Load the three files of a sound effect of a race, named by the prefixes the banks of sounds select for its channel: the wave (.wav), the variant (h.wav), and the looping sound (r.wav). | |
| bool | LoadSoundSet (int nSet) |
| Load the samples of a set of sounds into the channels the banks of sounds enable, from the second sample to the one before the last. | |
| HRESULT | StopAllSoundBuffersInList (SoundBufferNode *pHead) |
| Stop every sound buffer of a list. | |
| HRESULT | FreeSoundBufferList (SoundBufferNode *pHead) |
| Release and free every node of a list of sound buffers, with the sample and the format of each, and empty the list. | |
| bool | InitializeDirectSound (void) |
| Add a user of DirectSound when sound effects play. | |
| bool | ShutdownDirectSound (void) |
| Drop a user of DirectSound. | |
Variables | |
| IDirectSound * | g_pDirectSound |
| DirectSound. | |
| IDirectSoundBuffer * | g_pDirectSoundPrimaryBuffer |
| The primary buffer of DirectSound. | |
| WAVEFORMATEX * | g_pDirectSoundWaveFormat |
| The wave format of the primary buffer, in locked global memory. | |
| int | g_dwDirectSoundRefCount |
| The users of DirectSound. | |
| SoundBufferNode | g_SoundBufferListHead |
| The head of the list of the sound buffers. | |
| SoundBufferNode * | g_apSoundChannelBuffer [SOUND_CHANNEL_COUNT] |
| The sound buffers of the channels of the sound effects. | |
| int | g_dwLoadedSoundSampleCount |
| The number of entries of g_aSoundChannelBuffers that are loaded. | |
| SoundChannelState | g_aSoundChannelState [SOUND_CHANNEL_COUNT] |
| The settings last applied to the buffer of each channel. | |
| double | g_adChannelFrequencyScale [SOUND_CHANNEL_COUNT] |
| The scale of a frequency of each channel, from the sample assigned to it. | |
The buffers and the channels of the sound effects of the PC port.
The Windows libraries play each buffer through DirectSound, and the SDL game through a buffer of the mixer of EAR.
| anonymous enum |
The sets of sounds of LoadSoundSet().
| Enumerator | |
|---|---|
| SOUND_SET_FRONT_END | The sounds of the front end. |
| SOUND_SET_RACE | The sounds of a race. |
| HRESULT CreateDirectSoundBufferFromSample | ( | SoundBufferNode * | pNode | ) |
Create the buffer of DirectSound of a sample, static with control of the frequency, the pan, the volume, and the position, and copy the sample into it.
The volume is set full and the pan centred, and bHardware records where the buffer is. A step that fails releases the buffer.
| pNode | The node of the sample. |
| HRESULT ReleaseSoundBuffer | ( | SoundBufferNode * | pNode | ) |
Release the buffer of DirectSound of a node.
| pNode | The node. |
| HRESULT StopSoundBuffer | ( | SoundBufferNode * | pNode | ) |
Stop the buffer of DirectSound of a node that plays.
| pNode | The node. |
| bool IsSoundChannelPlaying | ( | int | nChannel | ) |
Report whether the buffer of a channel plays, when sound is on.
| nChannel | The channel. |
| bool SetAudioChannelLooping | ( | int | nChannel, |
| int | bLooping ) |
Set whether the buffer of a channel plays in a loop, when sound is on.
| nChannel | The channel. |
| bLooping | Whether it loops. |
| void SetSoundBankEntryIndex | ( | int | nVoice, |
| int | nIndex ) |
Record a sound for the even channel of a voice in the first row of the banks and in the rows of the variants and the looping sounds, as one more than its index.
| nVoice | The voice, half the channel. |
| nIndex | The index of the sound. |
| void ResetSoundBankTables | ( | void | ) |
Clear the first entries of the three tables of the banks of sounds.
| int AppendSoundBufferToList | ( | SoundBufferNode * | pHead, |
| SoundBufferNode * | pNode ) |
Add a node at the end of a list of sound buffers, not playing.
| pHead | The head of the list. |
| pNode | The node. |
| HRESULT ApplySoundBufferPan | ( | SoundBufferNode * | pNode | ) |
Set the pan of the buffer of a node from nPan.
| pNode | The node. |
| HRESULT ApplySoundBufferFrequency | ( | SoundBufferNode * | pNode | ) |
Set the frequency of the buffer of a node from dwFrequency.
| pNode | The node. |
| HRESULT ApplySoundBufferVolume | ( | SoundBufferNode * | pNode | ) |
Set the volume of the buffer of a node from nVolume scaled by g_bSfxVolume, or silence it when the sound effects are off.
| pNode | The node. |
| HRESULT RestartOrPlaySoundBuffer | ( | SoundBufferNode * | pNode | ) |
Play the buffer of a node from its start: a buffer that plays goes back to its start, and one that does not starts, in a loop when bLooping is set, and is marked as playing.
| pNode | The node. |
| HRESULT PlaySoundBuffer | ( | SoundBufferNode * | pNode, |
| int | bLooping ) |
Set whether the buffer of a node loops and play it from its start.
| pNode | The node. |
| bLooping | Whether the buffer plays in a loop. |
| bool SetSoundBufferFrequency | ( | SoundBufferNode * | pNode, |
| DWORD | dwFrequency ) |
Set the frequency of the buffer of a node, when sound is on.
| pNode | The node. |
| dwFrequency | The frequency, in samples a second. |
| bool IsSoundBufferPlaying | ( | SoundBufferNode * | pNode | ) |
Report whether the buffer of a node plays.
| pNode | The node. |
| bool SetSoundChannelFrequency | ( | int | nSample, |
| int | nChannel, | ||
| DWORD | dwFrequency ) |
Set the frequency of a channel of a sample, when sound is on.
| nSample | The sample. |
| nChannel | The channel. |
| dwFrequency | The frequency, in samples a second. |
| bool SetSoundVoiceFrequencyFloat | ( | int | nSample, |
| int | nVoice, | ||
| float | fFrequency ) |
Set the frequency of the even channel of a voice of a sample, dropping the fraction.
| nSample | The sample. |
| nVoice | The voice, half the channel. |
| fFrequency | The frequency, in samples a second. |
| bool StopSoundVoice | ( | int | nSample, |
| int | nVoice ) |
Stop the buffer of the first channel of a voice of a sample, when sound is on.
| nSample | The sample. |
| nVoice | The voice. Its first channel is twice the voice. |
| bool SetSoundBufferStereoLevels | ( | SoundBufferNode * | pNode, |
| DWORD | dwLevels ) |
Set the volume and the pan of the buffer of a node from the levels of its two sides.
| pNode | The node. |
| dwLevels | The level of the left side in the high word and of the right in the low word, each up to 32. |
| bool SetAudioChannelStereoLevels | ( | int | nChannel, |
| DWORD | dwLevels ) |
Set the levels of the two sides of the buffer of a channel and record them, when sound is on.
| nChannel | The channel. |
| dwLevels | The levels, as SetSoundBufferStereoLevels(). |
| bool AssignAudioChannel | ( | int | nSample, |
| int | nChannel ) |
Stop the buffer of a channel and give the channel the buffer of a sample for it, when sound is on.
| nSample | The sample. |
| nChannel | The channel. |
| bool SetAudioChannelFrequency | ( | int | nChannel, |
| long long | llFrequency ) |
Set the frequency of the buffer of a channel, scaled by its sample, and record it, when sound is on.
| nChannel | The channel. |
| llFrequency | The frequency in units of 2 to the power of -32. |
| bool StartSoundChannelPlayback | ( | int | nSample, |
| int | nChannel, | ||
| int | bLooping ) |
Play the buffer of a sample for a channel and give it to the channel, when sound is on.
The frequency of the buffer, without the scale of the channel, is requested and recorded.
| nSample | The sample. |
| nChannel | The channel. |
| bLooping | Whether the buffer plays in a loop. |
| bool InitSoundChannelWithVolume | ( | short | nChannel, |
| int | nSample, | ||
| int | nLength, | ||
| int | nLoopLength, | ||
| DWORD | dwLevels ) |
Request a sample and levels for a channel, give the channel the buffer of the sample, and play it.
| nChannel | The channel. |
| nSample | The sample. |
| nLength | The length of the sample, which is not read. |
| nLoopLength | The length of the loop of the sample, where any value but 0 plays it in a loop. |
| dwLevels | The levels, as SetSoundBufferStereoLevels(). |
| bool SetStereoAndPlaySoundChannel | ( | int | nSample, |
| int | nChannel, | ||
| DWORD | dwLevels, | ||
| int | bLooping ) |
Set the levels of the two sides of a channel of a sample and play it, when sound is on.
| nSample | The sample, an index into g_aSoundChannelBuffers. |
| nChannel | The channel. |
| dwLevels | The levels, as SetSoundBufferStereoLevels() takes them. |
| bLooping | Whether the buffer plays in a loop. |
| bool PlaySoundChannelOneWithStereo | ( | int | nSample, |
| DWORD | dwLevels, | ||
| int | bLooping ) |
Set the levels of the two sides of channel 1 of a sample and play it.
| nSample | The sample. |
| dwLevels | The levels, as SetSoundBufferStereoLevels() takes them. |
| bLooping | Whether the buffer plays in a loop. |
| bool SetSoundChannelStereo | ( | int | nSample, |
| int | nChannel, | ||
| DWORD | dwLevels ) |
Set the levels of the two sides of a channel of a sample, when sound is on.
| nSample | The sample. |
| nChannel | The channel. |
| dwLevels | The levels, as SetSoundBufferStereoLevels() takes them. |
| bool SetSoundVoiceStereo | ( | int | nSample, |
| int | nVoice, | ||
| DWORD | dwLevels ) |
Set the levels of the two sides of the even channel of a voice of a sample.
| nSample | The sample. |
| nVoice | The voice, half the channel. |
| dwLevels | The levels, as SetSoundBufferStereoLevels() takes them. |
| bool PlaySoundChannelOneOnce | ( | int | nSample, |
| DWORD | dwLevels ) |
Set the levels of the two sides of channel 1 of a sample and play it once.
| nSample | The sample. |
| dwLevels | The levels, as SetSoundBufferStereoLevels() takes them. |
| bool PlayLoopedSoundVoiceWithStereo | ( | int | nSample, |
| int | nVoice, | ||
| DWORD | dwLevels ) |
Set the levels of the two sides of the even channel of a voice of a sample and play it in a loop.
| nSample | The sample. |
| nVoice | The voice, half the channel. |
| dwLevels | The levels, as SetSoundBufferStereoLevels() takes them. |
| SoundBufferNode * LoadAudioFile | ( | const char * | pszPath, |
| int | sample = -1 ) |
Load a wave file into a node of a buffer of DirectSound at the end of g_SoundBufferListHead, at its own frequency, the centre, and the volume of the sound effects.
A step that fails frees what it created.
| pszPath | The path of the file. |
| sample | The SDL sample index, or -1 for no assigned sample. |
| bool LoadSfxWaveVariants | ( | int | nEffect | ) |
Load the three files of a sound effect of a race, named by the prefixes the banks of sounds select for its channel: the wave (.wav), the variant (h.wav), and the looping sound (r.wav).
Without sound, or when the first bank does not enable the channel, the three are cleared.
| nEffect | The effect, half the channel. |
| bool LoadSoundSet | ( | int | nSet | ) |
Load the samples of a set of sounds into the channels the banks of sounds enable, from the second sample to the one before the last.
The set of a race first loads the variants of its sound effects. Nothing loads without sound.
| nSet | The set, by the SOUND_SET_ values. |
| HRESULT StopAllSoundBuffersInList | ( | SoundBufferNode * | pHead | ) |
Stop every sound buffer of a list.
| pHead | The head of the list. |
| HRESULT FreeSoundBufferList | ( | SoundBufferNode * | pHead | ) |
Release and free every node of a list of sound buffers, with the sample and the format of each, and empty the list.
The head is not freed.
| pHead | The head of the list. |
| bool InitializeDirectSound | ( | void | ) |
Add a user of DirectSound when sound effects play.
The first user clears the channels and the banks, allocates the wave format of 22050 Hz, 16 bits, and two channels, and creates DirectSound with priority and its primary buffer, playing in a loop. A step that fails releases what it created.
| bool ShutdownDirectSound | ( | void | ) |
Drop a user of DirectSound.
The last user resets the audio, stops and releases the primary buffer and DirectSound, and frees the wave format and the list of sound buffers.
|
extern |
DirectSound.
|
extern |
The primary buffer of DirectSound.
|
extern |
The wave format of the primary buffer, in locked global memory.
|
extern |
The users of DirectSound.
The last ShutdownDirectSound() releases it.
|
extern |
The head of the list of the sound buffers.
Only its first member and its link are read here.
|
extern |
The sound buffers of the channels of the sound effects.
|
extern |
The number of entries of g_aSoundChannelBuffers that are loaded.
|
extern |
The settings last applied to the buffer of each channel.
|
extern |
The scale of a frequency of each channel, from the sample assigned to it.