UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
SampleBufferReader.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreMinimal.h"
6#include "DSP/Dsp.h"
7#include "SampleBuffer.h"
8
9namespace Audio
10{
11 namespace ESeekType
12 {
19 }
20
22 {
23 public:
26
28
29 // This must be a completely loaded buffer. This buffer reader doesn't OWN the buffer memory.
31
32 // Seeks the buffer the given time in seconds. Returns true if succeeded.
34
35 // Sets the pitch of the buffer reader. Can be negative. Will linearly interpolate over the given time value.
36 SIGNALPROCESSING_API void SetPitch(const float InPitch, const float InterpolationTimeSec = 0.0f);
37
38 // Puts the wave reader into scrub mode
40
41 // Sets the scrub width. The sound will loop between the scrub width region and the current frame
43
44 // Returns the number of channels of this buffer.
46
47 // Returns the number of frames of the buffer.
49
50 // Returns the current playback position in seconds
51 float GetPlaybackProgress() const { return PlaybackProgress; }
52
53 // Generates the next block of audio. Returns true if it's no longer playing (reached end of the buffer and not set to wrap)
54 SIGNALPROCESSING_API bool Generate(float* OutAudioBuffer, const int32 NumFrames, const int32 OutChannels, const bool bWrap = false);
55
56 // Whether or not the buffer reader has a buffer
57 bool HasBuffer() const { return BufferPtr != nullptr; }
58
59 // Clears current buffer and resets state
61
62 protected:
63
67 SIGNALPROCESSING_API float GetSampleValue(const int16* InBuffer, const int32 SampleIndex);
68
75 float FadeValue;
77
79
80 // The current frame alpha
81 float BasePitch;
84
87 double AlphaLerp;
88
90
92
96
100
102 bool bWrap;
105 };
106
107}
108
FPlatformTypes::int16 int16
A 16-bit signed integer.
Definition Platform.h:1123
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
void Init()
Definition LockFreeList.h:4
Definition Dsp.h:619
Definition SampleBufferReader.h:22
float FadeIncrement
Definition SampleBufferReader.h:76
SIGNALPROCESSING_API void UpdateSeekFrame()
Definition SampleBufferReader.cpp:104
double ScrubMinFrame
Definition SampleBufferReader.h:94
double AlphaLerp
Definition SampleBufferReader.h:87
float PitchScale
Definition SampleBufferReader.h:82
int32 FadeFrames
Definition SampleBufferReader.h:74
float FadeValue
Definition SampleBufferReader.h:75
float GetPlaybackProgress() const
Definition SampleBufferReader.h:51
double CurrentBufferFrameIndexInterpolated
Definition SampleBufferReader.h:89
int32 NextFrameIndex
Definition SampleBufferReader.h:86
SIGNALPROCESSING_API float GetSampleValue(const int16 *InBuffer, const int32 SampleIndex)
Definition SampleBufferReader.cpp:204
SIGNALPROCESSING_API void SetScrubMode(const bool bInIsScrubMode)
Definition SampleBufferReader.cpp:177
float CurrentSeekTime
Definition SampleBufferReader.h:98
int32 GetNumFrames() const
Definition SampleBufferReader.h:48
bool HasBuffer() const
Definition SampleBufferReader.h:57
float PlaybackProgress
Definition SampleBufferReader.h:91
const int16 * BufferPtr
Definition SampleBufferReader.h:69
double ScrubMaxFrame
Definition SampleBufferReader.h:95
double ScrubAnchorFrame
Definition SampleBufferReader.h:93
SIGNALPROCESSING_API ~FSampleBufferReader()
Definition SampleBufferReader.cpp:38
bool bIsScrubMode
Definition SampleBufferReader.h:103
int32 CurrentFrameIndex
Definition SampleBufferReader.h:85
bool bWrap
Definition SampleBufferReader.h:102
int32 BufferNumChannels
Definition SampleBufferReader.h:73
float BasePitch
Definition SampleBufferReader.h:81
int32 BufferSampleRate
Definition SampleBufferReader.h:72
bool bIsFinished
Definition SampleBufferReader.h:104
SIGNALPROCESSING_API void SetPitch(const float InPitch, const float InterpolationTimeSec=0.0f)
Definition SampleBufferReader.cpp:171
SIGNALPROCESSING_API float GetSampleValueForChannel(const int32 Channel)
Definition SampleBufferReader.cpp:367
SIGNALPROCESSING_API void ClearBuffer()
Definition SampleBufferReader.cpp:95
int32 GetNumChannels() const
Definition SampleBufferReader.h:45
float CurrentScrubWidthSec
Definition SampleBufferReader.h:99
double ScrubWidthFrames
Definition SampleBufferReader.h:97
SIGNALPROCESSING_API void SetBuffer(const int16 *InBufferPtr, const int32 InNumBufferSamples, const int32 InNumChannels, const int32 InBufferSampleRate)
Definition SampleBufferReader.cpp:73
SIGNALPROCESSING_API void SeekTime(const float InTimeSec, const ESeekType::Type InSeekType=ESeekType::FromBeginning, const bool bWrap=true)
Definition SampleBufferReader.cpp:147
Audio::FLinearEase Pitch
Definition SampleBufferReader.h:83
ESeekType::Type CurrentSeekType
Definition SampleBufferReader.h:101
int32 BufferNumFrames
Definition SampleBufferReader.h:71
SIGNALPROCESSING_API void SetScrubTimeWidth(const float InScrubTimeWidthSec)
Definition SampleBufferReader.cpp:164
SIGNALPROCESSING_API FSampleBufferReader()
Definition SampleBufferReader.cpp:8
int32 BufferNumSamples
Definition SampleBufferReader.h:70
SIGNALPROCESSING_API void UpdateScrubMinAndMax()
Definition SampleBufferReader.cpp:187
SIGNALPROCESSING_API bool Generate(float *OutAudioBuffer, const int32 NumFrames, const int32 OutChannels, const bool bWrap=false)
Definition SampleBufferReader.cpp:210
float DeviceSampleRate
Definition SampleBufferReader.h:78
Type
Definition SampleBufferReader.h:14
@ FromBeginning
Definition SampleBufferReader.h:15
@ FromEnd
Definition SampleBufferReader.h:17
@ FromCurrentPosition
Definition SampleBufferReader.h:16
NO_LOGGING.
Definition AudioMixerPlatformAndroid.cpp:53