Mixxx

/home/maxime/Projets/Mixxx/1.10/mixxx/src/track/beatgrid.h

Go to the documentation of this file.
00001 #ifndef BEATGRID_H
00002 #define BEATGRID_H
00003 
00004 #include <QMutex>
00005 #include <QObject>
00006 
00007 #include "trackinfoobject.h"
00008 #include "track/beats.h"
00009 
00010 // BeatGrid is an implementation of the Beats interface that implements an
00011 // infinite grid of beats, aligned to a song simply by a starting offset of the
00012 // first beat and the song's average beats-per-minute.
00013 class BeatGrid : public QObject, public virtual Beats {
00014     Q_OBJECT
00015   public:
00016     BeatGrid(TrackPointer pTrack, const QByteArray* pByteArray=NULL);
00017     virtual ~BeatGrid();
00018 
00019     // Initializes the BeatGrid to have a BPM of dBpm and the first beat offset
00020     // of dFirstBeatSample. Does not generate an updated() signal, since it is
00021     // meant for initialization.
00022     void setGrid(double dBpm, double dFirstBeatSample);
00023 
00024     // The following are all methods from the Beats interface, see method
00025     // comments in beats.h
00026 
00027     virtual Beats::CapabilitiesFlags getCapabilities() const {
00028         return BEATSCAP_TRANSLATE | BEATSCAP_SCALE;
00029     }
00030 
00031     virtual QByteArray* toByteArray() const;
00032     virtual QString getVersion() const;
00033 
00035     // Beat calculations
00037 
00038     virtual double findNextBeat(double dSamples) const;
00039     virtual double findPrevBeat(double dSamples) const;
00040     virtual double findClosestBeat(double dSamples) const;
00041     virtual double findNthBeat(double dSamples, int n) const;
00042     virtual void findBeats(double startSample, double stopSample, BeatList* pBeatsList) const;
00043     virtual bool hasBeatInRange(double startSample, double stopSample) const;
00044     virtual double getBpm() const;
00045     virtual double getBpmRange(double startSample, double stopSample) const;
00046 
00048     // Beat mutations
00050 
00051     virtual void addBeat(double dBeatSample);
00052     virtual void removeBeat(double dBeatSample);
00053     virtual void moveBeat(double dBeatSample, double dNewBeatSample);
00054     virtual void translate(double dNumSamples);
00055     virtual void scale(double dScalePercentage);
00056 
00057   signals:
00058     void updated();
00059 
00060   private slots:
00061     void slotTrackBpmUpdated(double bpm);
00062 
00063   private:
00064     void readByteArray(const QByteArray* pByteArray);
00065     // For internal use only.
00066     bool isValid() const;
00067 
00068     mutable QMutex m_mutex;
00069     int m_iSampleRate;      
00070     double m_dBpm;          
00071     double m_dFirstBeat;    
00072     double m_dBeatLength;   
00073 };
00074 
00075 
00076 #endif /* BEATGRID_H */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines