Mixxx

/home/maxime/Projets/Mixxx/1.10/mixxx/src/vinylcontrol/vinylcontrolproxy.cpp

Go to the documentation of this file.
00001 
00002 
00003 #include <QtDebug>
00004 #include "vinylcontrolproxy.h"
00005 #include "vinylcontrolxwax.h"
00006 #include "controlobjectthreadmain.h"
00007 
00008 
00009 //IVinylControl *VinylControlProxy::m_pVinylControl = 0;
00010 
00011 VinylControlProxy::VinylControlProxy(ConfigObject<ConfigValue> * pConfig, QString group) : VinylControl(pConfig, group)
00012 {
00013     QList<QString> xwax_timecodes;
00014     QList<QString> scratchlib_timecodes;
00015 
00016     xwax_timecodes.push_back(MIXXX_VINYL_SERATOCV02VINYLSIDEA);
00017     xwax_timecodes.push_back(MIXXX_VINYL_SERATOCV02VINYLSIDEB);
00018     xwax_timecodes.push_back(MIXXX_VINYL_SERATOCD);
00019     xwax_timecodes.push_back(MIXXX_VINYL_TRAKTORSCRATCHSIDEA);
00020     xwax_timecodes.push_back(MIXXX_VINYL_TRAKTORSCRATCHSIDEB);
00021 
00022     //Figure out which type of timecoded vinyl we're using.
00023     strVinylType = m_pConfig->getValueString(ConfigKey(m_group,"vinylcontrol_vinyl_type"));
00024 
00025     //Create the VinylControl object that matches the type of vinyl selected in the prefs...
00026     if (xwax_timecodes.contains(strVinylType))
00027     {
00028         m_pVinylControl = new VinylControlXwax(pConfig, m_group);
00029     }
00030     else
00031     {
00032         qDebug() << "VinylControlProxy: Unknown vinyl type " << strVinylType;
00033         qDebug() << "Defaulting to Serato...";
00034         strVinylType = MIXXX_VINYL_SERATOCV02VINYLSIDEA;
00035         pConfig->set(ConfigKey(m_group,"vinylcontrol_vinyl_type"), ConfigValue(MIXXX_VINYL_SERATOCV02VINYLSIDEA));
00036         m_pVinylControl = new VinylControlXwax(pConfig, m_group);
00037     }
00038 }
00039 
00040 
00041 VinylControlProxy::~VinylControlProxy()
00042 {
00043     if (m_pVinylControl)
00044     {
00045         delete m_pVinylControl;
00046         m_pVinylControl = NULL;
00047     }
00048 }
00049 
00050 bool VinylControlProxy::isEnabled()
00051 {
00052     return m_pVinylControl ? m_pVinylControl->isEnabled() : false;
00053 }
00054 
00055 void VinylControlProxy::ToggleVinylControl(bool enable)
00056 {
00057     if (m_pVinylControl)
00058         m_pVinylControl->ToggleVinylControl(enable);
00059     enabled->slotSet(enable);
00060 }
00061 
00062 /*
00063    void VinylControlProxy::syncPitch(double pitch)
00064    {
00065 
00066    }
00067 
00068    void VinylControlProxy::syncPosition()
00069    {
00070 
00071    } */
00072 
00073 void VinylControlProxy::AnalyseSamples(const short * samples, size_t size)
00074 {
00075     if (m_pVinylControl && samples)
00076         m_pVinylControl->AnalyseSamples(samples, size);
00077 }
00078 
00079 void VinylControlProxy::run()
00080 {
00081     unsigned static id = 0; //the id of this thread, for debugging purposes //XXX copypasta (should factor this out somehow), -kousu 2/2009
00082     QThread::currentThread()->setObjectName(QString("VinylControlProxy %1").arg(++id));
00083 }
00084 
00085 float VinylControlProxy::getSpeed()
00086 {
00087     if (m_pVinylControl)
00088         return m_pVinylControl->getSpeed();
00089     else
00090         return 0.0f;
00091 }
00092 
00095 float VinylControlProxy::getTimecodeQuality()
00096 {
00097     if (m_pVinylControl)
00098         return m_pVinylControl->getTimecodeQuality();
00099     else
00100         return 0.0f;
00101 }
00102 
00103 unsigned char* VinylControlProxy::getScopeBytemap()
00104 {
00105     if (m_pVinylControl)
00106         return m_pVinylControl->getScopeBytemap();
00107     else
00108         return NULL;
00109 }
00110 
00111 float VinylControlProxy::getAngle()
00112 {
00113     if (m_pVinylControl)
00114         return m_pVinylControl->getAngle();
00115     else
00116         return -1.0;
00117 }
00118 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines