Initial ping-pong loop implementation

This commit is contained in:
Vesa
2014-04-03 03:50:20 +03:00
parent 61569864b4
commit 0cfda7d1f4
4 changed files with 178 additions and 28 deletions

View File

@@ -46,6 +46,11 @@ class EXPORT SampleBuffer : public QObject, public sharedObject
{
Q_OBJECT
public:
enum LoopMode {
LoopOff = 0,
LoopOn,
LoopPingPong
};
class EXPORT handleState
{
public:
@@ -62,11 +67,21 @@ public:
m_frameIndex = _index;
}
inline bool isBackwards() const
{
return m_isBackwards;
}
inline void setBackwards( bool _backwards )
{
m_isBackwards = _backwards;
}
private:
f_cnt_t m_frameIndex;
const bool m_varyingPitch;
bool m_isBackwards;
SRC_STATE * m_resamplingData;
friend class SampleBuffer;
@@ -86,7 +101,7 @@ public:
bool play( sampleFrame * _ab, handleState * _state,
const fpp_t _frames,
const float _freq,
const bool _looped = false );
const LoopMode _loopmode = LoopOff );
void visualize( QPainter & _p, const QRect & _dr, const QRect & _clip, f_cnt_t _from_frame = 0, f_cnt_t _to_frame = 0 );
inline void visualize( QPainter & _p, const QRect & _dr, f_cnt_t _from_frame = 0, f_cnt_t _to_frame = 0 )
@@ -108,7 +123,7 @@ public:
{
return m_endFrame;
}
inline f_cnt_t loopStartFrame() const
{
return m_loopStartFrame;
@@ -273,9 +288,11 @@ private:
sample_rate_t m_sampleRate;
sampleFrame * getSampleFragment( f_cnt_t _start, f_cnt_t _frames,
bool _looped,
sampleFrame * * _tmp ) const;
LoopMode _loopmode,
sampleFrame * * _tmp,
bool * _backwards ) const;
f_cnt_t getLoopedIndex( f_cnt_t _index ) const;
f_cnt_t getPingPongIndex( f_cnt_t _index ) const;
signals: