1#ifndef COASTLINE_EAR_EARPLAYBACK_H
2#define COASTLINE_EAR_EARPLAYBACK_H
74 virtual void InitializeDirectSoundPlaybackState();
76 virtual void FinalizeDirectSoundPlaybackState();
109 virtual void UpdateDirectSoundPlaybackGainAndPan();
121 virtual void ResetEarPlaybackSmoothingPass();
164 virtual void UpdateDirectSoundPlaybackFrequency();
178 virtual int PlayDirectSoundEventBuffer();
190 virtual int StopDirectSoundEventBuffer();
211 virtual void ReleaseDirectSoundEventBuffer();
213 virtual void RefillEarPlaybackStream();
215 virtual void CopyEarPlaybackSamplesToOutput();
226 virtual int CheckEarPlaybackLoopCompletion();
288 virtual void OnBackendPlaybackParameterChanged();
392#if TGR_PLATFORM == TGR_PLATFORM_WIN
474 int GetBackendPlaybackOverrideEnabled();
476 int GetEarPlaybackLooping();
479 DWORD GetDirectSoundPlaybackCursor();
Device buffer reference and cached byte cursors for Windows DirectSound or the SDL mixer.
Definition directsoundstate.h:21
IDirectSoundBuffer Buffer
Windows device buffer type.
Definition directsoundstate.h:25
std::uint32_t streamHalfIndex
Next streaming half to refill, initially one.
Definition earplayback.h:499
EarDirectSoundPlaybackState directSound
Device buffer reference and cached byte cursors; resource release is explicit.
Definition earplayback.h:553
virtual std::uint32_t GetEarPlaybackMediaLength()
std::uint32_t frequency
Target sample frequency in hertz before device range clamping.
Definition earplayback.h:529
std::uint16_t smoothingPass
Smoothing pass index; zero selects the target directly.
Definition earplayback.h:535
std::uint32_t playbackHandle
Playback registry key, or zero when unregistered.
Definition earplayback.h:483
void DisablePlaybackLooping()
Clear the looping marker without changing device playback flags.
Definition earplayback.h:456
std::uint32_t loopDrainCount
Number of post-data streaming refills used while draining non-looping playback.
Definition earplayback.h:551
std::uint16_t notificationEvent
Event identifier included in window notifications.
Definition earplayback.h:489
virtual int ResumeEarPlayback()
Attempt a restart when paused and active, then clear paused status.
void SetEarPlaybackFlags(std::uint16_t flags)
Store source flags without validation or reinitialisation.
std::uint32_t bufferBytes
Decoded device sample-buffer capacity in bytes.
Definition earplayback.h:537
double cachedBackendParameter
Cached implementation-specific parameter, initially -1.
Definition earplayback.h:549
int looping
Nonzero while looping is requested.
Definition earplayback.h:493
virtual void SetEarPlaybackBaseFrequencyScale(double scale)
Store the initial frequency multiplier without validation or device updates.
virtual int IsBufferedEarPlaybackComplete()
Check requested completion or active device state and refill a stream half when necessary.
virtual int PauseEarPlayback()
Mark playback paused and attempt to stop the device buffer without clearing active state.
virtual void SetCachedBackendPlaybackParameter(double value)
Store an ordered changed backend parameter and invoke the parameter-change hook.
std::uint8_t unknown6c[2]
Unrecovered bytes retained at the original object offset.
Definition earplayback.h:533
std::uint32_t GetPlaybackHandle() const
Definition earplayback.h:388
void SetPlaybackBufferBytes(std::uint32_t bytes)
Store buffer capacity without reallocating storage.
Definition earplayback.h:334
void ResetPlaybackBufferFrequency()
Reset current frequency to the initialised base frequency without updating the device.
Definition earplayback.h:410
virtual void SetEarPlaybackMute(int muted)
Store mute state and refresh cached directional gain without stopping playback or timers.
std::uint16_t flags
Source flags interpreted by derived media implementations; base construction omits them.
Definition earplayback.h:491
EarDirectionalMatrixEntry targetMatrixEntry
Target directional pan and gain resolved from the selected matrix.
Definition earplayback.h:527
virtual void SetEarPlaybackLooping(int enabled)
Store looping state without changing the currently playing buffer's device flags.
std::uint16_t GetPlaybackSourceFlags() const
Definition earplayback.h:444
int streaming
Nonzero while media requires half-buffer refills.
Definition earplayback.h:495
virtual int InitializeEarPlayback(const void *source, int streaming, int looping)
Initialise implementation-specific media; the base implementation does not change state.
std::uint32_t GetStreamHalfIndex() const
Definition earplayback.h:460
int status
Pause status, zero when unpaused.
Definition earplayback.h:505
std::uint16_t directionIndex
Selected directional row index, normally 0..127.
Definition earplayback.h:519
std::uint32_t notificationFlags
Notification bits for starts (1) and registered closures (2).
Definition earplayback.h:487
virtual void ReleaseEarPlaybackResources()
Release registered playback through the virtual closure hook.
virtual void SetEarPlaybackDirectionalMatrix(std::uint16_t direction, std::uint16_t matrix)
Store directional matrix identifiers without resolving an entry or updating output.
std::uint16_t suppressionMarker
Suppression role, with one suppressing base device starts.
Definition earplayback.h:513
std::uint32_t reservedEventControl
Implementation-specific event control, including in-memory MIDI source length in bytes.
Definition earplayback.h:485
double frequencyScale
Current dimensionless playback frequency multiplier.
Definition earplayback.h:543
std::uint32_t IncrementLoopDrainCount()
Definition earplayback.h:435
int IsEarPlaybackStreaming()
bool HasPlaybackHandle() const
Definition earplayback.h:452
virtual void CompleteEarPlayback()
Perform implementation-specific completion; the base implementation does not change state.
HRESULT CreateDirectSoundPlaybackBuffer(IDirectSound *device, _DSBUFFERDESC *description)
Create a Windows device buffer; an existing buffer must be released before replacement.
int completionRequested
Nonzero after completion is requested or detected.
Definition earplayback.h:497
bool IsPlaybackLooping() const
Definition earplayback.h:448
std::uint16_t matrixId
Selected directional matrix handle, initially 16.
Definition earplayback.h:517
void SetPlaybackBaseFrequency(std::uint32_t value)
Store base frequency without updating the current device frequency.
Definition earplayback.h:377
std::uint32_t previousFrequency
Sample frequency in hertz at the start of the smoothing transition.
Definition earplayback.h:531
virtual void SetEarPlaybackDirectionalGain(std::uint16_t direction, double gain, std::uint16_t matrix)
Update cached directional gain for registered playback and restart active smoothing.
EarDirectionalMatrixEntry previousMatrixEntry
Directional pan and gain at the start of the current smoothing transition.
Definition earplayback.h:525
std::uint32_t GetStreamHalfBytes() const
Definition earplayback.h:464
virtual void SetEarPlaybackStartMilliseconds(std::uint16_t milliseconds)
Store an absolute start offset for wave-stream preparation.
void ClearPlaybackStartPosition()
Clear the specified marker and reset the start position to zero.
Definition earplayback.h:426
EarDirectSoundPlaybackState::Buffer * GetDirectSoundBuffer() const
Definition earplayback.h:431
void SetPlaybackHandle(std::uint32_t handle)
Store a registration handle without modifying the playback registry.
Definition earplayback.h:384
double targetGain
Target linear gain before directional and master attenuation.
Definition earplayback.h:523
virtual void ApplyPreset(EarWaveSample *preset)
Apply implementation-specific preset data; the base implementation ignores the request.
std::uint16_t GetPlaybackStartMilliseconds() const
Definition earplayback.h:349
void SetStreamHalfBytes(std::uint32_t bytes)
Store the refill-half capacity without changing the buffer.
Definition earplayback.h:341
virtual void SetEarPlaybackStartPosition(double position)
Store an ordered nonzero start position and mark it specified; zero and NaN are ignored.
int backendOverrideEnabled
Nonzero when implementation-specific position or frequency overrides are enabled.
Definition earplayback.h:507
std::uint16_t startMilliseconds
Wave-stream initial offset in milliseconds, or zero when disabled.
Definition earplayback.h:515
virtual void SetReservedPlaybackEventControl(std::uint32_t control)
Store a backend-specific event control value without applying it immediately.
double GetPlaybackBaseFrequencyScale() const
Definition earplayback.h:370
void EndStreamingPlaybackLoop()
Clear both loop and stream markers without stopping the device immediately.
Definition earplayback.h:439
void MarkComplete()
Request completion for the next completion check without stopping the device immediately.
void FlipStreamHalfIndex()
Toggle the refill-half index between zero and one.
Definition earplayback.h:468
std::uint32_t GetPlaybackBufferBytes() const
Definition earplayback.h:414
int active
Nonzero after successful playback starts, including during a pause.
Definition earplayback.h:501
virtual void CloseRegisteredEarPlayback()
Stop and release a registered buffer, post an enabled closure notification, and unregister playback.
bool HasNonStreamingStartPosition() const
Definition earplayback.h:418
double GetPlaybackStartPosition() const
Definition earplayback.h:422
virtual void SetEarPlaybackNotification(std::uint32_t flags, std::uint16_t event)
Store notification controls for later playback transitions.
void ClearPlaybackCompletion()
Withdraw a request to complete the playback.
double previousGain
Linear gain at the start of the current smoothing transition.
Definition earplayback.h:521
std::uint32_t baseFrequency
Initial sample frequency in hertz; derived initialisation must assign it.
Definition earplayback.h:547
std::uint32_t suppressionEnabled
Nonzero when spatial suppression processing is enabled.
Definition earplayback.h:509
virtual int IsDirectSoundBufferStopped()
Query the device buffer; a non-null buffer is required.
double startPosition
Implementation-specific start position, usually a fraction of media length.
Definition earplayback.h:541
virtual int StartEarPlayback()
Post an enabled start notification, attempt device playback, and mark successful starts active.
virtual void ProcessEarPlaybackSmoothing()
Apply a frequency, gain, and pan smoothing pass to the current device buffer.
virtual void SetBackendPlaybackOverrideEnabled(int enabled)
Store the implementation-specific playback override marker.
virtual void SetEarPlaybackFrequencyScale(double scale)
Clamp an ordered changed scale to 0..6.5535 and recalculate frequency from the base rate.
int muted
Nonzero when muted; cached gain remains available for unmuting.
Definition earplayback.h:503
~EarPlayback()
Invoke the base finalisation hook without releasing playback resources or derived storage.
void SetPlaybackStreamingAndLooping(int isStreaming, int isLooping)
Store stream and loop markers without validation or device changes.
Definition earplayback.h:365
void SpecifyPlaybackStartPosition()
Mark the stored start position specified without changing its value.
Definition earplayback.h:357
int ResetPlaybackCompletion()
Withdraw a request to complete the playback.
virtual void SetPlaybackSuppressionParameters(std::uint32_t enabled, std::uint16_t marker)
Store suppression controls without starting or stopping playback.
std::uint32_t streamHalfBytes
Decoded byte count in each streaming half.
Definition earplayback.h:539
double baseFrequencyScale
Initial frequency multiplier applied while preparing media.
Definition earplayback.h:545
virtual void OnPlaybackWaveSampleAttached(EarWaveSample *sample)
Respond to sample attachment; the base implementation ignores the notification.
bool HasPlaybackStartPosition() const
Definition earplayback.h:353
int startPositionSpecified
Nonzero when startPosition is specified rather than merely stored.
Definition earplayback.h:511
void DisablePlaybackStreaming()
Clear the streaming marker without changing device looping flags.
Definition earplayback.h:345
EarPlayback()
Initialise inactive playback and smoothing defaults without allocating media or a buffer.
A wave file loaded whole into memory, which a preset registers and sample playbacks share.
Definition wavesample.h:15
The pan and the gain of one direction of a directional matrix.
Definition directionalmatrix.h:12
WAVEFORMATEX EarWaveFormat
Definition wavechunks.h:23