Canorus  0.7
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
playback.h
Go to the documentation of this file.
1 
8 #ifndef PLAYBACK_H_
9 #define PLAYBACK_H_
10 
11 #include <QThread>
12 #include <QList>
13 
14 class CAMidiDevice;
15 class CASheet;
16 class CAMusElement;
17 class CAPlayable;
18 class CANote;
19 
20 class CAPlayback : public QThread {
21 #ifndef SWIG
22 Q_OBJECT
23 #endif
24 public:
26  CAPlayback( CAMidiDevice*, int port );
27  ~CAPlayback();
28 
29  void run();
30  void stop();
31 
32  void playImmediately( QList<CAMusElement*> elts, int port );
33 
34  inline const int getInitTimeStart() { return _initTimeStart; }
35  inline void setInitTimeStart(int t) { _initTimeStart = t; }
36  inline CAMidiDevice *midiDevice() { return _midiDevice; }
37  inline CASheet *sheet() { return _sheet; }
38  inline void setSheet( CASheet *s ) { _sheet = s; }
39  inline QList<CAPlayable*>& curPlaying() { return _curPlaying; }
40 
41 #ifndef SWIG
42 public slots:
43 #else
44 public:
45 #endif
46  void stopNow();
47 
48 #ifndef SWIG
49 signals:
50  void playbackFinished();
51 #endif
52 
53 private:
54  void initStreams( CASheet *sheet );
55  void loopUntilPlayable( int i, bool ignoreRepeats=false );
56  void playSelectionImpl();
57 
58  inline QList<CAMusElement*> streamAt(int idx) { return _stream[idx]; }
59  inline int streamCount() { return _stream.size(); }
60  inline int& streamIdx( int i ) { return _streamIdx[i]; }
61  inline int& curTime( int i ) { return _curTime[i]; }
62  inline int& lastRepeatOpenIdx( int i ) { return _lastRepeatOpenIdx[i]; }
63  inline bool& repeating( int i ) { return _repeating[i]; }
64 
65  inline bool stopLock() { return _stopLock; }
66  inline void setStopLock(bool lock) { _stopLock = lock; }
67 
69 
71  inline void setMidiDevice( CAMidiDevice *d ) { _midiDevice = d; }
72 
73  inline void setStop(bool stop) { _stop = stop; }
74  bool _stop;
75  bool _stopLock;
76 
78  QList<CAMusElement*> _selection;
79 
81 
82  QList< QList<CAMusElement*> > _stream;
83  QList<CAPlayable*> _curPlaying; // list of currently playing notes and rests
84  int *_streamIdx;
85  bool *_repeating;
87  int *_curTime; // multiple curTimes are needed for repeat bars, if staffs aren't synchronized
88 };
89 
90 #endif /* PLAYBACK_H_ */