Mixxx

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

Go to the documentation of this file.
00001 #include "vinylcontrol.h"
00002 #include "controlobjectthread.h"
00003 
00004 VinylControl::VinylControl(ConfigObject<ConfigValue> * pConfig, QString group)
00005 {
00006     m_pConfig = pConfig;
00007     m_group = group;
00008     iRIAACorrection = 0;
00009 
00010     iSampleRate = m_pConfig->getValueString(ConfigKey("[Soundcard]","Samplerate")).toULong();
00011 
00012     // Get Control objects
00013     playPos             = new ControlObjectThread(ControlObject::getControl(ConfigKey(group, "playposition")));    //Range: -.14 to 1.14
00014     trackSamples        = new ControlObjectThread(ControlObject::getControl(ConfigKey(group, "track_samples")));
00015     trackSampleRate     = new ControlObjectThread(ControlObject::getControl(ConfigKey(group, "track_samplerate")));
00016     vinylSeek           = new ControlObjectThread(ControlObject::getControl(ConfigKey(group, "vinylcontrol_seek")));
00017     controlScratch      = new ControlObjectThread(ControlObject::getControl(ConfigKey(group, "scratch2")));
00018     rateSlider          = new ControlObjectThread(ControlObject::getControl(ConfigKey(group, "rate")));    //Range -1.0 to 1.0
00019     playButton          = new ControlObjectThread(ControlObject::getControl(ConfigKey(group, "play")));
00020     reverseButton       = new ControlObjectThread(ControlObject::getControl(ConfigKey(group, "reverse")));
00021     duration            = new ControlObjectThread(ControlObject::getControl(ConfigKey(group, "duration")));
00022     mode                = new ControlObjectThread(ControlObject::getControl(ConfigKey(group, "vinylcontrol_mode")));
00023     enabled             = new ControlObjectThread(ControlObject::getControl(ConfigKey(group, "vinylcontrol_enabled")));
00024     wantenabled         = new ControlObjectThread(ControlObject::getControl(ConfigKey(group, "vinylcontrol_wantenabled")));
00025     cueing              = new ControlObjectThread(ControlObject::getControl(ConfigKey(group, "vinylcontrol_cueing")));
00026     rateRange           = new ControlObjectThread(ControlObject::getControl(ConfigKey(group, "rateRange")));
00027     vinylStatus     = new ControlObjectThread(ControlObject::getControl(ConfigKey(group, "vinylcontrol_status")));
00028     rateDir         = new ControlObjectThread(ControlObject::getControl(ConfigKey(group, "rate_dir")));
00029     loopEnabled     = new ControlObjectThread(ControlObject::getControl(ConfigKey(group, "loop_enabled")));
00030     signalenabled     = new ControlObjectThread(ControlObject::getControl(ConfigKey(group, "vinylcontrol_signal_enabled")));
00031 
00032     dVinylPitch = 0.0f;
00033     dVinylPosition = 0.0f;
00034     dVinylScratch = 0.0f;
00035     dDriftControl   = 0.0f;
00036     fRateRange = 0.0f;
00037     m_fTimecodeQuality = 0.0f;
00038 
00039     //Get the vinyl type
00040     strVinylType = m_pConfig->getValueString(ConfigKey(group,"vinylcontrol_vinyl_type"));
00041 
00042     //Get the vinyl speed
00043     strVinylSpeed = m_pConfig->getValueString(ConfigKey(group,"vinylcontrol_speed_type"));
00044 
00045     //Get the lead-in time
00046     iLeadInTime = m_pConfig->getValueString(ConfigKey("[VinylControl]","lead_in_time")).toInt();
00047 
00048     //RIAA correction
00049     iRIAACorrection =  m_pConfig->getValueString(ConfigKey("[VinylControl]","InputRIAACorrection")).toInt();
00050 
00051     //Vinyl control mode
00052     iVCMode = m_pConfig->getValueString(ConfigKey("[VinylControl]","mode")).toInt();
00053 
00054     //Enabled or not -- load from saved value in case vinyl control is restarting 
00055     bIsEnabled = wantenabled->get();
00056 
00057     //Gain
00058     ControlObject::getControl(ConfigKey("[VinylControl]", "gain"))->set(
00059         m_pConfig->getValueString(ConfigKey("[VinylControl]","gain")).toInt());
00060 }
00061 
00062 void VinylControl::ToggleVinylControl(bool enable)
00063 {
00064     bIsEnabled = enable;
00065     if (m_pConfig)
00066     {
00067         m_pConfig->set(ConfigKey(m_group,"vinylcontrol_enabled"), ConfigValue((int)enable));
00068     }
00069 
00070     enabled->slotSet(enable);
00071 
00072     //Reset the scratch control to make sure we don't get stuck moving forwards or backwards.
00073     //actually that might be a good thing
00074     //if (!enable)
00075     //    controlScratch->slotSet(0.0f);
00076 }
00077 
00078 VinylControl::~VinylControl()
00079 {
00080     bool wasEnabled = bIsEnabled;
00081     enabled->slotSet(false);
00082     vinylStatus->slotSet(VINYL_STATUS_DISABLED);
00083     if (wasEnabled)
00084     {
00085         //if vinyl control is just restarting, indicate that it should
00086         //be enabled
00087         wantenabled->slotSet(true);
00088     }
00089 }
00090 
00091 float VinylControl::getSpeed()
00092 {
00093     return dVinylScratch;
00094 }
00095 
00098 float VinylControl::getTimecodeQuality()
00099 {
00100     return m_fTimecodeQuality;
00101 }
00102 
00103 unsigned char* VinylControl::getScopeBytemap()
00104 {
00105     return NULL;
00106 }
00107 
00108 float VinylControl::getAngle()
00109 {
00110     return -1.0;
00111 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines