ZG  "1.00
 All Classes Namespaces Files Functions Variables Enumerator Friends Macros Pages
MusicData.h
Go to the documentation of this file.
1 #ifndef MusicData_h
2 #define MusicData_h
3 
4 #include "message/Message.h"
5 #include "util/Hashtable.h"
6 #include "util/String.h"
7 
8 #include "zg/ZGPeerID.h"
9 #include "zg/IDatabaseObject.h"
10 #include "ChoirNameSpace.h"
11 
12 namespace choir {
13 
14 class ChoirSession;
15 
21 enum
22 {
23  CHOIR_NOTE_E6 = 0, // 1318.51 (third implied-line above the top-most line of the treble staff)
24  CHOIR_NOTE_D6, // 1174.659
25  CHOIR_NOTE_C6, // 1046.502
26  CHOIR_NOTE_B5, // 987.7666
27  CHOIR_NOTE_A5, // 880
28  CHOIR_NOTE_G5, // 783.9909
29  CHOIR_NOTE_F5, // 698.4565 (top-most explicit-line of the treble staff)
30  CHOIR_NOTE_E5, // 659.2551
31  CHOIR_NOTE_D5, // 587.3295
32  CHOIR_NOTE_C5, // 523.2511
33  CHOIR_NOTE_B4, // 493.8833
34  CHOIR_NOTE_A4, // 440
35  CHOIR_NOTE_G4, // 391.9954
36  CHOIR_NOTE_F4, // 349.2282
37  CHOIR_NOTE_E4, // 329.6276 (bottom-most explicit-line of the treble staff)
38  CHOIR_NOTE_D4, // 293.6648
39  CHOIR_NOTE_C4, // 261.6256 (middle C)
40  CHOIR_NOTE_B3, // 246.9417
41  CHOIR_NOTE_A3, // 220
42  CHOIR_NOTE_G3, // 195.9977
43  CHOIR_NOTE_F3, // 174.6141 (third implied-line below the bottom-most line of the treble staff)
45 };
46 
48 const char * GetNoteName(uint32 noteIdx);
49 
51 String GetPeerNickname(const ZGPeerID & pid, const ConstMessageRef & optPeerInfo);
52 
53 enum {
54  MUSIC_TYPE_MUSIC_SHEET = 1836413795, // 'musc'
57 };
58 
59 enum {
60  DEFAULT_MICROSECONDS_PER_CHORD = 250000 // 4 chords/second is a reasonable default, I suppose?
61 };
62 
64 enum {
65  ASSIGNMENT_STRATEGY_AUTOMATIC = 0, // ChoirSession will try to keep bells load-balanced at all times
66  ASSIGNMENT_STRATEGY_ASSISTED, // ChoirSession will assign unassigned bells, but otherwise leave things as they are
67  ASSIGNMENT_STRATEGY_MANUAL, // ChoirSession won't auto-assign anything; it's up the user to do it
69 };
70 
75 {
76 public:
78  MusicDatabaseObject() {/* empty */}
79 
80 protected:
83 
85  const ChoirSession * GetChoirSession() const;
86 
91  ConstMessageRef SendFullStateToGUI(bool allowReviewTrigger);
92 
97  void SendMessageToGUI(const ConstMessageRef & msg, bool allowReviewTrigger);
98 
102  void SetReviewResults(uint64 allNotesUsedChord);
103 };
104 DECLARE_REFTYPES(MusicDatabaseObject);
105 
106 // Utility function to upgrade our histogram and notes-bit-chord in response to the addition or removal of a notes-chord
107 void UpdateNoteHistogram(uint64 chordVal, bool isAdd, Hashtable<uint8, uint32> & histogram, uint64 & bitchord);
108 
109 }; // end namespace choir
110 
111 #endif
An interface for an object that represents the full contents of a ZG database.
void SetReviewResults(uint64 allNotesUsedChord)
Convenience method; calls SetReviewResults(allNotesUsedChord) on our ChoirSession object...
A slight specialization of the IDatabaseObject class, just so I can add some application-specific hel...
Definition: MusicData.h:74
void UpdateNoteHistogram(uint64 chordVal, bool isAdd, Hashtable< uint8, uint32 > &histogram, uint64 &bitchord)
MusicDatabaseObject()
Default constructor.
Definition: MusicData.h:78
ChoirSession * GetChoirSession()
Returns a pointer to the ChoirSession object that created this object.
void SendMessageToGUI(const ConstMessageRef &msg, bool allowReviewTrigger)
Sends the specified Message to the GUI thread.
const char * GetNoteName(uint32 noteIdx)
Given a CHOIR_NOTE_* value, returns a human-readable description of the note (e.g.
ConstMessageRef SendFullStateToGUI(bool allowReviewTrigger)
Saves the state of this object into a Message and sends that Message to the GUI thread.
The choir namespace contains the code specific to the ZGChoir demonstration application.
Definition: ChoirNameSpace.h:7
ChoirSession
Definition: ChoirSession.h:75
String GetPeerNickname(const ZGPeerID &pid, const ConstMessageRef &optPeerInfo)
Given a peer's ID and his optional info, returns a human-readable ID string for him.
This is the class that that the Choir demo uses to implement its data-replication functionality...
Definition: ChoirSession.h:14