diff options
Diffstat (limited to 'core/voice.h')
-rw-r--r-- | core/voice.h | 65 |
1 files changed, 31 insertions, 34 deletions
diff --git a/core/voice.h b/core/voice.h index a599eda8..f212ebe5 100644 --- a/core/voice.h +++ b/core/voice.h @@ -32,7 +32,7 @@ enum class DistanceModel : unsigned char; using uint = unsigned int; -#define MAX_SENDS 6 +inline constexpr size_t MaxSendCount{6}; enum class SpatializeMode : unsigned char { @@ -48,7 +48,7 @@ enum class DirectMode : unsigned char { }; -constexpr uint MaxPitch{10}; +inline constexpr uint MaxPitch{10}; enum { @@ -66,14 +66,14 @@ struct DirectParams { NfcFilter NFCtrlFilter; struct { - HrtfFilter Old; - HrtfFilter Target; - alignas(16) std::array<float,HrtfHistoryLength> History; + HrtfFilter Old{}; + HrtfFilter Target{}; + alignas(16) std::array<float,HrtfHistoryLength> History{}; } Hrtf; struct { - std::array<float,MAX_OUTPUT_CHANNELS> Current; - std::array<float,MAX_OUTPUT_CHANNELS> Target; + std::array<float,MaxOutputChannels> Current{}; + std::array<float,MaxOutputChannels> Target{}; } Gains; }; @@ -82,8 +82,8 @@ struct SendParams { BiquadFilter HighPass; struct { - std::array<float,MaxAmbiChannels> Current; - std::array<float,MaxAmbiChannels> Target; + std::array<float,MaxAmbiChannels> Current{}; + std::array<float,MaxAmbiChannels> Target{}; } Gains; }; @@ -154,13 +154,12 @@ struct VoiceProps { float HFReference; float GainLF; float LFReference; - } Send[MAX_SENDS]; + }; + std::array<SendData,MaxSendCount> Send; }; struct VoicePropsItem : public VoiceProps { std::atomic<VoicePropsItem*> next{nullptr}; - - DEF_NEWDEL(VoicePropsItem) }; enum : uint { @@ -185,7 +184,7 @@ struct Voice { std::atomic<VoicePropsItem*> mUpdate{nullptr}; - VoiceProps mProps; + VoiceProps mProps{}; std::atomic<uint> mSourceID{0u}; std::atomic<State> mPlayState{Stopped}; @@ -195,30 +194,30 @@ struct Voice { * Source offset in samples, relative to the currently playing buffer, NOT * the whole queue. */ - std::atomic<int> mPosition; + std::atomic<int> mPosition{}; /** Fractional (fixed-point) offset to the next sample. */ - std::atomic<uint> mPositionFrac; + std::atomic<uint> mPositionFrac{}; /* Current buffer queue item being played. */ - std::atomic<VoiceBufferItem*> mCurrentBuffer; + std::atomic<VoiceBufferItem*> mCurrentBuffer{}; /* Buffer queue item to loop to at end of queue (will be NULL for non- * looping voices). */ - std::atomic<VoiceBufferItem*> mLoopBuffer; + std::atomic<VoiceBufferItem*> mLoopBuffer{}; std::chrono::nanoseconds mStartTime{}; /* Properties for the attached buffer(s). */ - FmtChannels mFmtChannels; - FmtType mFmtType; - uint mFrequency; - uint mFrameStep; /**< In steps of the sample type size. */ - uint mBytesPerBlock; /**< Or for PCM formats, BytesPerFrame. */ - uint mSamplesPerBlock; /**< Always 1 for PCM formats. */ - AmbiLayout mAmbiLayout; - AmbiScaling mAmbiScaling; - uint mAmbiOrder; + FmtChannels mFmtChannels{}; + FmtType mFmtType{}; + uint mFrequency{}; + uint mFrameStep{}; /**< In steps of the sample type size. */ + uint mBytesPerBlock{}; /**< Or for PCM formats, BytesPerFrame. */ + uint mSamplesPerBlock{}; /**< Always 1 for PCM formats. */ + AmbiLayout mAmbiLayout{}; + AmbiScaling mAmbiScaling{}; + uint mAmbiOrder{}; std::unique_ptr<DecoderBase> mDecoder; uint mDecoderPadding{}; @@ -226,20 +225,20 @@ struct Voice { /** Current target parameters used for mixing. */ uint mStep{0}; - ResamplerFunc mResampler; + ResamplerFunc mResampler{}; - InterpState mResampleState; + InterpState mResampleState{}; std::bitset<VoiceFlagCount> mFlags{}; uint mNumCallbackBlocks{0}; uint mCallbackBlockBase{0}; struct TargetData { - int FilterType; + int FilterType{}; al::span<FloatBufferLine> Buffer; }; TargetData mDirect; - std::array<TargetData,MAX_SENDS> mSend; + std::array<TargetData,MaxSendCount> mSend; /* The first MaxResamplerPadding/2 elements are the sample history from the * previous mix, with an additional MaxResamplerPadding/2 elements that are @@ -250,11 +249,11 @@ struct Voice { al::vector<HistoryLine,16> mPrevSamples{2}; struct ChannelData { - float mAmbiHFScale, mAmbiLFScale; + float mAmbiHFScale{}, mAmbiLFScale{}; BandSplitter mAmbiSplitter; DirectParams mDryParams; - std::array<SendParams,MAX_SENDS> mWetParams; + std::array<SendParams,MaxSendCount> mWetParams; }; al::vector<ChannelData> mChans{2}; @@ -270,8 +269,6 @@ struct Voice { void prepare(DeviceBase *device); static void InitMixer(std::optional<std::string> resampler); - - DEF_NEWDEL(Voice) }; extern Resampler ResamplerDefault; |