Canorus  0.7
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
/home/iurt/rpm/BUILD/canorus-0.7.R1002/src/interface/playback.h
Go to the documentation of this file.
00001 
00008 #ifndef PLAYBACK_H_
00009 #define PLAYBACK_H_
00010 
00011 #include <QThread>
00012 #include <QList>
00013 
00014 class CAMidiDevice;
00015 class CASheet;
00016 class CAMusElement;
00017 class CAPlayable;
00018 class CANote;
00019 
00020 class CAPlayback : public QThread {
00021 #ifndef SWIG
00022 Q_OBJECT
00023 #endif
00024 public:
00025         CAPlayback( CASheet*, CAMidiDevice* );
00026         CAPlayback( CAMidiDevice*, int port );
00027         ~CAPlayback();
00028 
00029         void run();
00030         void stop();
00031 
00032         void playImmediately( QList<CAMusElement*> elts, int port );
00033 
00034         inline const int getInitTimeStart() { return _initTimeStart; }
00035         inline void setInitTimeStart(int t) { _initTimeStart = t; }
00036         inline CAMidiDevice *midiDevice() { return _midiDevice; }
00037         inline CASheet *sheet() { return _sheet; }
00038         inline void setSheet( CASheet *s ) { _sheet = s; }
00039         inline QList<CAPlayable*>& curPlaying() { return _curPlaying; }
00040 
00041 #ifndef SWIG
00042 public slots:
00043 #else
00044 public:
00045 #endif
00046         void stopNow();
00047 
00048 #ifndef SWIG
00049 signals:
00050         void playbackFinished();
00051 #endif
00052 
00053 private:
00054         void initStreams( CASheet *sheet );
00055         void loopUntilPlayable( int i, bool ignoreRepeats=false );
00056         void playSelectionImpl();
00057 
00058         inline QList<CAMusElement*> streamAt(int idx) { return _stream[idx]; }
00059         inline int streamCount() { return _stream.size(); }
00060         inline int& streamIdx( int i ) { return _streamIdx[i]; }
00061         inline int& curTime( int i ) { return _curTime[i]; }
00062         inline int& lastRepeatOpenIdx( int i ) { return _lastRepeatOpenIdx[i]; }
00063         inline bool& repeating( int i ) { return _repeating[i]; }
00064 
00065         inline bool stopLock() { return _stopLock; }
00066         inline void setStopLock(bool lock) { _stopLock = lock; }
00067 
00068         CASheet *_sheet;
00069 
00070         CAMidiDevice *_midiDevice;
00071         inline void setMidiDevice( CAMidiDevice *d ) { _midiDevice = d; }
00072 
00073         inline void setStop(bool stop) { _stop = stop; }
00074         bool _stop;
00075         bool _stopLock;
00076 
00077         bool _playSelectionOnly;
00078         QList<CAMusElement*> _selection;
00079 
00080         int _initTimeStart;
00081 
00082         QList< QList<CAMusElement*> > _stream;
00083         QList<CAPlayable*> _curPlaying; // list of currently playing notes and rests
00084         int *_streamIdx;
00085         bool *_repeating;
00086         int *_lastRepeatOpenIdx;
00087         int *_curTime; // multiple curTimes are needed for repeat bars, if staffs aren't synchronized
00088 };
00089 
00090 #endif /* PLAYBACK_H_ */