Finale PDK Framework  0.54
ff_timesig.h
1 /*
2  * File: ff_timesig.h
3  * Author: Jari Williamsson
4  *
5  * Created on den 9 april 2011, 14:28
6  */
7 
8 #ifndef FF_TIMESIG_H
9 #define FF_TIMESIG_H
10 
11 #include "ff_basecollection.h"
12 /* ff_other.h can NOT be included here! */
13 
14 
15 #ifdef PDK_FRAMEWORK_COMPOSITETIMESIGS
18 #endif
19 
26 {
27 #include "pragma_align_begin.h"
28  struct _TIMESIG_DATASTRUCT {
29  twobyte beats;
30  twobyte beatduration;
31  bool compositetop;
32  bool compositebottom;
33  bool abbreviate;
34  } _timesigdata;
35 #include "pragma_align_end.h"
36 protected:
37 #ifndef DOXYGEN_SHOULD_IGNORE_THIS
38 
43  virtual EXTAG Tag() { return 0; }
44  virtual int DataSizeLoad() { return sizeof(_timesigdata); }
45  virtual void* Allocate() { return (void*) &_timesigdata; }
46 
51  virtual void CloneMemoryFrom(__FCBaseData* pSource)
52  {
53  memcpy(&_timesigdata, ((FCTimeSignature*)pSource)->_GetTimeSigDataPtr(), sizeof(_timesigdata));
54  _datablock = &_timesigdata;
56  }
57 
58  virtual __FCBaseData* CreateObject() { return new FCTimeSignature(); }
59 #endif /* DOXYGEN_SHOULD_IGNORE_THIS */
60 
64  virtual bool LoadFirst() { return false; }
65 public:
66 
67 
68 #ifndef DOXYGEN_SHOULD_IGNORE_THIS
69 
70  _TIMESIG_DATASTRUCT* _GetTimeSigDataPtr()
71  {
72  return &_timesigdata;
73  }
74 #endif /* DOXYGEN_SHOULD_IGNORE_THIS */
75 
76 
79  {
80  _timesigdata.beats = 4;
81  _timesigdata.beatduration = 1024;
82  _timesigdata.compositetop = false;
83  _timesigdata.compositebottom = false;
84  _timesigdata.abbreviate = false;
85  }
86 
87  virtual const char* ClassName() { return "FCTimeSignature"; }
88  virtual const PDKFRAMEWORK_CLASSID GetClassID() { return FCID_TIMESIGNATURE; }
89 
95  void SetBeats(twobyte value)
96  {
97  _timesigdata.beats = value;
98  }
99 
105  void SetBeatDuration(twobyte value)
106  {
107  _timesigdata.beatduration = value;
108  }
109 
111  void SetCompositeTop(bool value) { _timesigdata.compositetop = value; }
112 
114  void SetCompositeBottom(bool value) { _timesigdata.compositebottom = value; }
115 
116 
124  void SetAbbreviate(bool state) { _timesigdata.abbreviate = state; }
125 
135  twobyte GetBeats() const
136  {
137  return _timesigdata.beats;
138  }
139 
140 #ifdef PDK_FRAMEWORK_COMPOSITETIMESIGS
141 
148  twobyte CalcBeats();
149 
157  twobyte CalcLargestBeats();
158 #endif
159 
166  twobyte GetBeatDuration() const
167  {
168  return _timesigdata.beatduration;
169  }
170 
171 #ifdef PDK_FRAMEWORK_COMPOSITETIMESIGS
172 
179  twobyte CalcSmallestBeatDuration();
180 
188  twobyte CalcLargestBeatDuration();
189 #endif
190 
196  bool GetCompositeTop() const { return _timesigdata.compositetop; }
197 
203  bool GetCompositeBottom() const { return _timesigdata.compositebottom; }
204 
212  bool GetAbbreviate() const { return _timesigdata.abbreviate; }
213 
214 #ifdef PDK_FRAMEWORK_COMPOSITETIMESIGS
215 
221  bool IsBeatPosition(TimeEdu32 eduposition);
222 
231  int CalcBeatPosition(TimeEdu32 eduposition);
232 
239  TimeEdu32 CalcPrevBeatPosition(TimeEdu32 eduposition);
240 
250  TimeEdu32 CalcNextBeatPosition(TimeEdu32 eduposition);
251 
262  bool IsIdentical(FCTimeSignature* pCompareSig);
263 
274  bool IsCompound();
275 
281  {
282  if (GetBeats() != 4) return false;
283  if (GetBeatDuration() != 1024) return false;
284  return true;
285  }
286 #endif
287 
295  static bool IsCompoundBeatDuration(TimeEdu32 duration);
296 
304  void MakeString(FCString* pString);
305 
306 #ifdef PDK_FRAMEWORK_COMPOSITETIMESIGS
307 
315 
325  bool SaveNewCompositeTop(FCCompositeTimeSigTop* pCompositeTop);
326 
335 
345  bool SaveNewCompositeBottom(FCCompositeTimeSigBottom* pCompositeBottom);
346 #endif
347 };
348 
349 
350 #endif /* FF_TIMESIG_H */
351 
twobyte CalcBeats()
To get the number of beats for both standard or composite time signatures.
Definition: finaleframework.cpp:30796
void SetAbbreviate(bool state)
Sets if the time signature should be abbreviated (to cut and common time).
Definition: ff_timesig.h:124
twobyte GetBeatDuration() const
Gets the beat duration. If the time signature has a composite bottom, this represent a composite reco...
Definition: ff_timesig.h:166
void MakeString(FCString *pString)
Creates a string representation of the time signature.
Definition: finaleframework.cpp:30901
void SetCompositeBottom(bool value)
Sets the composite "mark" of the bottom part of the time signature.
Definition: ff_timesig.h:114
void SetCompositeTop(bool value)
Sets the composite "mark" of the top part of the time signature.
Definition: ff_timesig.h:111
bool GetAbbreviate() const
Returns true if the time signature should be abbreviated (to cut and common time).
Definition: ff_timesig.h:212
A collection of __FCCompositeTimeSigTopElement records.
Definition: ff_other.h:495
void * _datablock
Pointer to the object's data block, the meaning is implementation-specific for each derived subclass...
Definition: ff_base.h:640
FCCompositeTimeSigBottom * CreateCompositeBottom()
Creates, loads and initializes a composite bottom object.
Definition: finaleframework.cpp:31015
virtual const PDKFRAMEWORK_CLASSID GetClassID()
Returns the internal class ID for the PDK Framework class. This is implemented mostly because Lua has...
Definition: ff_timesig.h:88
bool GetCompositeBottom() const
Returns true if the bottom part of the time signature is marked as composite.
Definition: ff_timesig.h:203
void SetBeats(twobyte value)
Sets the number of beats, or the composite top ID.
Definition: ff_timesig.h:95
TimeEdu32 CalcPrevBeatPosition(TimeEdu32 eduposition)
Definition: finaleframework.cpp:30702
int CalcBeatPosition(TimeEdu32 eduposition)
Definition: finaleframework.cpp:30657
bool GetCompositeTop() const
Returns true if the top part of the time signature is marked as composite.
Definition: ff_timesig.h:196
PDKFRAMEWORK_CLASSID
Constants for the GetClassID method.
Definition: ff_base.h:60
A collection of __FCCompositeTimeSigBottomElement records.
Definition: ff_other.h:830
virtual void CloneMemoryFrom(__FCBaseData *pSource)
Definition: finaleframework.cpp:753
bool IsBeatPosition(TimeEdu32 eduposition)
Returns true if the position is a "beat" in the time signature.
Definition: finaleframework.cpp:30617
bool IsIdentical(FCTimeSignature *pCompareSig)
Returns true if the time signature is identical to the compared time signature.
Definition: finaleframework.cpp:30811
bool IsCommonTime()
Returns true if the time signature is in 4/4.
Definition: ff_timesig.h:280
virtual const char * ClassName()
Returns the name of the class, for diagnostic purposes. This method MUST be overwritten in each child...
Definition: ff_timesig.h:87
virtual void * Allocate()=0
twobyte CalcSmallestBeatDuration()
Gets the smallest beat duration found in the time signature. This method works with time sigs with co...
Definition: finaleframework.cpp:30525
twobyte CalcLargestBeats()
Gets the largest number of beats in the time signature. This method works with time sigs with composi...
Definition: finaleframework.cpp:30500
twobyte CalcLargestBeatDuration()
Gets the largest beat duration found in the time signature. This method works with time sigs with com...
Definition: finaleframework.cpp:30550
Class for time signatures.
Definition: ff_timesig.h:25
virtual bool LoadFirst()
Finding first time sig recs currently not supported.
Definition: ff_timesig.h:64
FCCompositeTimeSigTop * CreateCompositeTop()
Creates, loads and initializes a composite top object.
Definition: finaleframework.cpp:30990
twobyte GetBeats() const
Gets the number of beats. If the time signature has a composite top, this represent a composite recor...
Definition: ff_timesig.h:135
TimeEdu32 CalcNextBeatPosition(TimeEdu32 eduposition)
Definition: finaleframework.cpp:30750
int _loadedsize
Loaded size of the data block for a loaded object, in bytes. Since the datablock is implementation-sp...
Definition: ff_base.h:653
FCTimeSignature()
The constructor. Sets the default time signature to 4/4.
Definition: ff_timesig.h:78
Base class for all data-related classes (that handles Finale data).
Definition: ff_base.h:628
static bool IsCompoundBeatDuration(TimeEdu32 duration)
Returns true if the time signature duration is a compound meter, such as 3/8, 6/8, etc.
Definition: finaleframework.cpp:30605
bool SaveNewCompositeBottom(FCCompositeTimeSigBottom *pCompositeBottom)
Saves a new composite bottom object and assigns the ID to the time sig.
Definition: finaleframework.cpp:31027
virtual __FCBaseData * CreateObject()=0
Creates a new instance of the object.
bool SaveNewCompositeTop(FCCompositeTimeSigTop *pCompositeTop)
Saves a new composite top object and assigns the ID to the time sig.
Definition: finaleframework.cpp:31001
Class that provides storage for text. This is to achieve platform-transparent text handling...
Definition: ff_base.h:1473
virtual EXTAG Tag()=0
The Enigma tag for the derived class.
void SetBeatDuration(twobyte value)
Sets the beat duration (in EDUs), or the composite bottom ID.
Definition: ff_timesig.h:105
virtual int DataSizeLoad()=0
Returns the data size for the data structure that should be loaded.
bool IsCompound()
Returns true if the time signature is a compound meter, such as 3/8, 6/8, etc.
Definition: finaleframework.cpp:30575