#include "engine/enginebuffer.h"
#include <QtDebug>
#include "engine/cachingreader.h"
#include "preferences/usersettings.h"
#include "control/controlindicator.h"
#include "control/controllinpotmeter.h"
#include "control/controlproxy.h"
#include "control/controlpotmeter.h"
#include "control/controlpushbutton.h"
#include "engine/bpmcontrol.h"
#include "engine/clockcontrol.h"
#include "engine/cuecontrol.h"
#include "engine/enginebufferscalelinear.h"
#include "engine/enginebufferscalerubberband.h"
#include "engine/enginebufferscalest.h"
#include "engine/enginechannel.h"
#include "engine/enginecontrol.h"
#include "engine/enginemaster.h"
#include "engine/engineworkerscheduler.h"
#include "engine/keycontrol.h"
#include "engine/loopingcontrol.h"
#include "engine/quantizecontrol.h"
#include "engine/ratecontrol.h"
#include "engine/readaheadmanager.h"
#include "engine/sync/enginesync.h"
#include "engine/sync/synccontrol.h"
#include "track/beatfactory.h"
#include "track/keyutils.h"
#include "track/track.h"
#include "util/assert.h"
#include "util/compatibility.h"
#include "util/defs.h"
#include "util/math.h"
#include "util/sample.h"
#include "util/timer.h"
#include "waveform/visualplayposition.h"
#ifdef __VINYLCONTROL__
#include "engine/vinylcontrolcontrol.h"
#endif
namespace {
const double kLinearScalerElipsis = 1.00058; // 2^(0.01/12): changes < 1 cent allows a linear scaler
const SINT kSamplesPerFrame = 2; // Engine buffer uses Stereo frames only
} // anonymous namespace
EngineBuffer::EngineBuffer(QString group, UserSettingsPointer pConfig,
EngineChannel* pChannel, EngineMaster* pMixingEngine)
: m_group(group),
m_pConfig(pConfig),
m_pLoopingControl(NULL),
m_pSyncControl(NULL),
m_pVinylControlControl(NULL),
m_pRateControl(NULL),
m_pBpmControl(NULL),
m_pKeyControl(NULL),
m_pReadAheadManager(NULL),
m_pReader(NULL),
m_filepos_play(0.),
m_speed_old(0),
m_tempo_ratio_old(1.),
m_scratching_old(false),
m_reverse_old(false),
m_pitch_old(0),
m_baserate_old(0),
m_rate_old(0.),
m_trackSamplesOld(-1),