Etterna 0.74.4
Loading...
Searching...
No Matches
RageSoundReader_SpeedChange.h
1/* RageSoundReader_SpeedChange - change the speed of an audio stream without
2 * changing its pitch. */
3
4#ifndef RAGE_SOUND_READER_SPEED_CHANGE_H
5#define RAGE_SOUND_READER_SPEED_CHANGE_H
6
7#include <string>
8#include <vector>
9
10#include "RageSoundReader_Filter.h"
11
13{
14 public:
15 RageSoundReader_SpeedChange(RageSoundReader* pSource, bool bStepMania);
16
17 virtual int SetPosition(int iFrame);
18 virtual int Read(float* pBuf, int iFrames);
19 virtual RageSoundReader_SpeedChange* Copy() const
20 {
21 return new RageSoundReader_SpeedChange(*this);
22 }
23 virtual bool SetProperty(const std::string& sProperty, float fValue);
24 virtual int GetNextSourceFrame() const;
25 virtual float GetStreamToSourceRatio() const;
26
27 void SetSpeedRatio(float fRatio);
28
29 /* Return true if the next Read() will start a new block, allowing
30 * GetRatio() to be updated to a new value. Used by
31 * RageSoundReader_PitchChange. */
32 bool NextReadWillStep() const { return GetCursorAvail() == 0; }
33
34 /* Get the ratio last set by SetSpeedRatio. */
35 float GetRatio() const { return m_fSpeedRatio; }
36
37 protected:
38 int FillData(int iMax);
39 void EraseData(int iToDelete);
40 int Step();
41 void Reset();
42
43 int GetCursorAvail() const;
44
45 int GetWindowSizeFrames() const;
46 int GetToleranceFrames() const { return GetWindowSizeFrames() / 4; }
47
48 int m_iDataBufferAvailFrames;
50 {
51 std::vector<float> m_DataBuffer;
52 int m_iCorrelatedPos;
53 int m_iLastCorrelatedPos;
54 };
55 std::vector<ChannelInfo> m_Channels;
56
57 int m_iUncorrelatedPos;
58 int m_iPos;
59
60 float m_fSpeedRatio;
61 float m_fTrailingSpeedRatio;
62 float m_fErrorFrames;
63
64 const int m_iWindowSize;
65 const bool m_bMidSideEncoding;
66};
67
68#endif
Definition RageSoundReader_Filter.h:10
Definition RageSoundReader_SpeedChange.h:13
Definition RageSoundReader.h:7
Definition RageSoundReader_SpeedChange.h:50