Mixxx

/home/maxime/Projets/Mixxx/1.10/mixxx/src/script/trackrecorder.cpp

Go to the documentation of this file.
00001 #include "trackrecorder.h"
00002 
00003 TrackRecorder::TrackRecorder(Track* track, int channel) : SignalRecorder() {
00004         m_times = QList<int>();
00005         m_paths = QList<QString>();
00006         m_base = 0;
00007 
00008         m_track = track;
00009         m_channel = channel;
00010 }
00011 
00012 void TrackRecorder::reset() {
00013         m_times = QList<int>();
00014         m_paths = QList<QString>();
00015         stopRecord();
00016 }
00017 
00018 void TrackRecorder::startRecord(SDateTime* base) {
00019         m_base = base;
00020 
00021         if (m_channel == 1) {   
00022                 connect(m_track, SIGNAL(newTrackPlayer1(TrackInfoObject*)),
00023                         this, SLOT(logTrack(TrackInfoObject*)));
00024         } else if (m_channel == 2) {
00025                 connect(m_track, SIGNAL(newTrackPlayer2(TrackInfoObject*)),
00026                         this, SLOT(logTrack(TrackInfoObject*)));
00027         } else {
00028                 qDebug("Unknown channel (%i) in recorder", m_channel);
00029         }
00030 }
00031 
00032 void TrackRecorder::stopRecord() {
00033         m_track->disconnect(this);
00034 }
00035 
00036 void TrackRecorder::logTrack(TrackInfoObject* track) {
00037         QDateTime now = QDateTime::currentDateTime();
00038 
00039         int delta = m_base->msecsTo(&now);
00040 
00041         m_times.append(delta);
00042         m_paths.append(track->getLocation());
00043 
00044 }
00045 
00046 void TrackRecorder::writeToScript(Recorder* rec) {
00047         if (m_times.empty()) {
00048                 return;
00049         }
00050 
00051         QList<int>::const_iterator tit;
00052         QList<QString>::const_iterator pit;
00053         pit = m_paths.begin();
00054         for (tit = m_times.begin(); tit != m_times.end(); tit++) {
00055                 rec->playChannel(m_channel , *tit, *pit);
00056                 pit++;
00057         }
00058 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines