coastline 0.0.4
Loading...
Searching...
No Matches
EarSdlVoice Class Reference

A buffer of samples the mixer plays, as a secondary buffer of DirectSound plays in the original. More...

#include <sdlmixer.h>

Public Member Functions

void Release ()
 Remove the buffer from the mix and delete it.
void Write (std::uint32_t offset, const void *data, std::uint32_t bytes)
 Copy samples into the buffer, continuing at its start past its end.
void Play (bool looping)
 Start the buffer from its play cursor.
void Stop ()
 Stop the buffer, leaving its play cursor where it is.
bool IsPlaying () const
std::uint32_t GetPlayCursor () const
bool SetPlayCursor (std::uint32_t offset)
 Move the play cursor.
void SetFrequency (std::uint32_t frequency)
 Change playback frequency when the requested rate is within the device-compatible range.
void SetVolume (LONG volume)
 Change volume when the requested attenuation is within the device-compatible range.
void SetPan (LONG pan)
 Change stereo pan within the device-compatible range; out-of-range requests are ignored.
void MixInto (float *mix, int frames)
 Add the frames the buffer plays next to a mix.

Static Public Member Functions

static EarSdlVoice * Create (const EarWaveFormat &format, std::uint32_t bytes)
 Create a silent, stopped buffer and add it to the mix.

Detailed Description

A buffer of samples the mixer plays, as a secondary buffer of DirectSound plays in the original.

The volume and the pan take the units of DirectSound, hundredths of a decibel, and a value outside the range of DirectSound is rejected as DirectSound rejects it.

Member Function Documentation

◆ Create()

EarSdlVoice * EarSdlVoice::Create ( const EarWaveFormat & format,
std::uint32_t bytes )
static

Create a silent, stopped buffer and add it to the mix.

Parameters
formatThe format of the samples, 8-bit or 16-bit PCM of one or two channels.
bytesThe bytes of the buffer.
Returns
The buffer, or a null pointer for a format DirectSound does not play.

◆ Release()

void EarSdlVoice::Release ( )

Remove the buffer from the mix and delete it.

◆ Write()

void EarSdlVoice::Write ( std::uint32_t offset,
const void * data,
std::uint32_t bytes )

Copy samples into the buffer, continuing at its start past its end.

Parameters
offsetThe offset in the buffer, in bytes.
dataThe samples.
bytesThe bytes of the samples.

◆ Play()

void EarSdlVoice::Play ( bool looping)

Start the buffer from its play cursor.

Parameters
loopingWhether the buffer starts again at its end.

◆ Stop()

void EarSdlVoice::Stop ( )

Stop the buffer, leaving its play cursor where it is.

◆ IsPlaying()

bool EarSdlVoice::IsPlaying ( ) const
Returns
Whether the buffer is playing.

◆ GetPlayCursor()

std::uint32_t EarSdlVoice::GetPlayCursor ( ) const
Returns
The offset of the frame that plays next, in bytes.

◆ SetPlayCursor()

bool EarSdlVoice::SetPlayCursor ( std::uint32_t offset)

Move the play cursor.

Parameters
offsetThe offset, in bytes.
Returns
Whether the offset is in the buffer.

◆ SetFrequency()

void EarSdlVoice::SetFrequency ( std::uint32_t frequency)

Change playback frequency when the requested rate is within the device-compatible range.

Out-of-range requests preserve the previous frequency.

Parameters
frequencyThe frames a second the buffer plays at, from 100 to 100000.

◆ SetVolume()

void EarSdlVoice::SetVolume ( LONG volume)

Change volume when the requested attenuation is within the device-compatible range.

Out-of-range requests preserve the previous volume.

Parameters
volumeThe attenuation, from -10000 to 0 hundredths of a decibel.

◆ SetPan()

void EarSdlVoice::SetPan ( LONG pan)

Change stereo pan within the device-compatible range; out-of-range requests are ignored.

Parameters
panThe attenuation of the right side when negative, or of the left side when positive, from -10000 to 10000 hundredths of a decibel.

◆ MixInto()

void EarSdlVoice::MixInto ( float * mix,
int frames )

Add the frames the buffer plays next to a mix.

Parameters
mixThe interleaved stereo mix.
framesThe frames of the mix.

The documentation for this class was generated from the following file: