ZG  "1.00
 All Classes Namespaces Files Functions Variables Enumerator Friends Macros Pages
Quasimodo.h
Go to the documentation of this file.
1 #ifndef Quasimodo_h
2 #define Quasimodo_h
3 
4 #include <QObject>
5 #include <QAudioOutput>
6 #include <QIODevice>
7 
8 #include "ChoirNameSpace.h"
9 #include "MusicData.h"
10 
11 namespace choir {
12 
16 class Quasimodo : public QIODevice
17 {
18 Q_OBJECT
19 
20 public:
22  Quasimodo(QObject * parent = NULL);
23 
25  ~Quasimodo();
26 
27 signals:
32  void RangLocalBells(quint64 notesChord);
33 
34 public slots:
36  void SetupTheBells();
37 
39  void SetLocalNoteAssignments(quint64 notesChord) {_localNotesChord = notesChord;}
40 
45  void RingSomeBells(quint64 notesChord, bool localNotesOnly);
46 
48  void DestroyTheBells();
49 
50 protected:
56  virtual qint64 readData(char * data, qint64 maxSize);
57 
59  virtual qint64 writeData(const char * /*data*/, qint64 maxSize) {return maxSize;}
60 
61 private:
62  void MixSamples(int16 * mixTo, uint32 numSamplesToMix, uint32 inputSampleOffset, uint64 notesChord) const;
63 
64  QAudioOutput * _audioOutput;
65  uint64 _localNotesChord;
66  uint64 _sampleCounter;
67 
68  QByteArray _noteBufs[NUM_CHOIR_NOTES];
69  uint32 _maxNoteLengthSamples;
70 
71  Hashtable<uint64, uint64> _sampleIndexToNotesChord;
72 };
73 
74 }; // end namespace choir
75 
76 #endif
void SetLocalNoteAssignments(quint64 notesChord)
Tells Quasimodo which bells he should actually play.
Definition: Quasimodo.h:39
This object is in charge of actually ringing the local bells (using QAudioOutput and a mixer algorith...
Definition: Quasimodo.h:16
virtual qint64 writeData(const char *, qint64 maxSize)
This method is a no-op and should never be called.
Definition: Quasimodo.h:59
~Quasimodo()
Destructor.
virtual qint64 readData(char *data, qint64 maxSize)
Overridden to fill (data) with audio samples from our internal sound-mixing-engine.
void SetupTheBells()
Should be called once at startup, since setting them up in the constructor causes thread-warnings...
Quasimodo(QObject *parent=NULL)
Constructor.
void RingSomeBells(quint64 notesChord, bool localNotesOnly)
Causes a given bell-sound to be played.
The choir namespace contains the code specific to the ZGChoir demonstration application.
Definition: ChoirNameSpace.h:7
void DestroyTheBells()
Should be called once at shutdown, since destroying the bells in the destructor causes more thread-wa...
void RangLocalBells(quint64 notesChord)
Emitted when we've played some bell sounds.