Jamoma API  0.6.0.a19
TimeDataspace.h
Go to the documentation of this file.
1 /** @file
2  *
3  * @ingroup foundationDataspaceLib
4  *
5  * @brief The #TimeDataspace converts between different measurement untis describing time intervals and frequencies.
6  *
7  * @details The neutral unit of the time dataspace is _second (s)_.
8  *
9  * @authors Tim Place, Nils Peters, Trond Lossius, ...
10  *
11  * @copyright Copyright © 2007 by Tim Place @n
12  * This code is licensed under the terms of the "New BSD License" @n
13  * http://creativecommons.org/licenses/BSD/
14  */
15 
16 
17 #ifndef __TIME_DATASPACE_H__
18 #define __TIME_DATASPACE_H__
19 
20 #include "TTDataspace.h"
21 
22 
23 /** Base class for the time dataspace, provides dataspace support for converting values representing time or frequency between bark, bpm, cent, frequency, mel, midi, millisecond, sample, second and speed.
24  *
25  * @details: _Second (s)_ is the neutral data unit of this dataspace.
26  */
27 class TimeDataspace : public TTDataObjectBase, public TTDataspace {
29 
30  /** Unit test for the time dataspace.
31  @param returnedTestInfo The outcome from the performed unit test.
32  @return #TTErr error code if the method fails to execute, else #kTTErrNone.
33  */
34  virtual TTErr test(TTValue& returnedTestInfo);
35 };
36 
37 
38 
39 /** Converts time to and from Bark unit.
40  *
41  * @details This unit is denoted as "bark".
42  */
43 class BarkUnit : public TTDataObjectBase, public TTDataspaceUnit {
45 
46 public:
47 
48  /** Convert from Bark to neutral unit.
49  @param input Input time described using Bark .
50  @param output Returned time, converted to neutral unit.
51  */
52  void convertToNeutral(const TTValue& input, TTValue& output);
53 
54  /** Convert from neutral unit to Bark.
55  @param input Input time described using the neutral unit.
56  @param output Returned time, described using Bark.
57  */
58  void convertFromNeutral(const TTValue& input, TTValue& output);
59 };
60 
61 
62 /** Converts times to and from Bpm (beats per minute).
63  *
64  * @details This unit is denoted as "bpm".
65  */
66 class BpmUnit : public TTDataObjectBase, public TTDataspaceUnit {
68 
69 public:
70 
71  /** Convert from Bpm to neutral unit.
72  @param input Input time described using Bpm .
73  @param output Returned time, converted to neutral unit.
74  */
75  void convertToNeutral(const TTValue& input, TTValue& output);
76 
77  /** Convert from neutral unit to Bpm.
78  @param input Input time described using the neutral unit.
79  @param output Returned time, described using Bpm.
80  */
81  void convertFromNeutral(const TTValue& input, TTValue& output);
82 };
83 
84 
85 /** Converts times to and from MIDI Cents.
86  *
87  * @details This unit is denoted as "cents".
88  */
89 class CentUnit : public TTDataObjectBase, public TTDataspaceUnit {
91 
92 public:
93 
94  /** Convert from radians to neutral unit.
95  @param input Input time described using cents.
96  @param output Returned time, converted to neutral unit.
97  */
98  void convertToNeutral(const TTValue& input, TTValue& output);
99 
100  /** Convert from neutral unit to cents.
101  @param input Input time described using the neutral unit.
102  @param output Returned time, described using cents.
103  */
104  void convertFromNeutral(const TTValue& input, TTValue& output);
105 };
106 
107 
108 /** Converts times to and from frequency (Hz).
109  *
110  * @details This unit can be denoted as "fps", "Hz", "hz", or "Hertz".
111  */
114 
115 public:
116 
117  /** Convert from Hz to neutral unit.
118  @param input Input time described using Hz .
119  @param output Returned time, converted to neutral unit.
120  */
121  void convertToNeutral(const TTValue& input, TTValue& output);
122 
123  /** Convert from neutral unit to Hz.
124  @param input Input time described using the neutral unit.
125  @param output Returned time, described using Hz.
126  */
127  void convertFromNeutral(const TTValue& input, TTValue& output);
128 };
129 
130 
131 /** Converts times to and from Mel.
132  *
133  * @details This unit is denoted as "mel".
134  */
135 class MelUnit : public TTDataObjectBase, public TTDataspaceUnit {
137 
138 public:
139 
140  /** Convert from Mel to neutral unit.
141  @param input Input time described using Mel.
142  @param output Returned time, converted to neutral unit.
143  */
144  void convertToNeutral(const TTValue& input, TTValue& output);
145 
146  /** Convert from neutral unit to Mel.
147  @param input Input time described using the neutral unit.
148  @param output Returned time, described using Mel.
149  */
150  void convertFromNeutral(const TTValue& input, TTValue& output);
151 };
152 
153 
154 /** Converts times to and from MIDI pitch.
155  *
156  * @details This unit is denoted as "midi".
157  */
160 
161 public:
162 
163  /** Convert from MIDI pitch to neutral unit.
164  @param input Input time described using MIDI pitch.
165  @param output Returned time, converted to neutral unit.
166  */
167  void convertToNeutral(const TTValue& input, TTValue& output);
168 
169  /** Convert from neutral unit to MIDI pitch.
170  @param input Input time described using the neutral unit.
171  @param output Returned time, described using MIDI pitch.
172  */
173  void convertFromNeutral(const TTValue& input, TTValue& output);
174 };
175 
176 
177 /** Converts times to and from milliseconds.
178  *
179  * @details This unit can be denoted as "ms" or "millisecond".
180  */
183 public:
184 
185  /** Convert from milliseconds to neutral unit.
186  @param input Input time described using milliseconds.
187  @param output Returned time, converted to neutral unit.
188  */
189  void convertToNeutral(const TTValue& input, TTValue& output);
190 
191  /** Convert from neutral unit to milliseconds.
192  @param input Input time described using the neutral unit.
193  @param output Returned time, described using milliseconds.
194  */
195  void convertFromNeutral(const TTValue& input, TTValue& output);
196 };
197 
198 
199 /** Converts times to and from number of samples.
200  *
201  * @details This unit is denoted as "sample".
202  */
205 
206 public:
207 
208  /** Convert from samples to neutral unit.
209  @param input Input time described using number of samples .
210  @param output Returned time, converted to neutral unit.
211  */
212  void convertToNeutral(const TTValue& input, TTValue& output);
213 
214  /** Convert from neutral unit to number of samples.
215  @param input Input time described using the neutral unit.
216  @param output Returned time, described using number of samples.
217  */
218  void convertFromNeutral(const TTValue& input, TTValue& output);
219 };
220 
221 
222 /** Converts times to and from seconds.
223  *
224  * @details This unit can be denoted as "s" or "second".
225  */
228 
229 public:
230 
231  /** Convert from seconds to neutral unit.
232  @param input Input time described using seconds .
233  @param output Returned time, converted to neutral unit.
234  */
235  void convertToNeutral(const TTValue& input, TTValue& output);
236 
237  /** Convert from neutral unit to seconds.
238  @param input Input time described using the neutral unit.
239  @param output Returned time, described using seconds.
240  */
241  void convertFromNeutral(const TTValue& input, TTValue& output);
242 };
243 
244 
245 /** Converts times to and from transposition playback speed of buffers or sound files.
246  *
247  * @details This unit is denoted as "speed".
248  */
251 
252 public:
253 
254  /** Convert from speed to neutral unit.
255  @param input Input time described using speed .
256  @param output Returned time, converted to neutral unit.
257  */
258  void convertToNeutral(const TTValue& input, TTValue& output);
259 
260  /** Convert from neutral unit to speed.
261  @param input Input time described using the neutral unit.
262  @param output Returned time, described using speed.
263  */
264  void convertFromNeutral(const TTValue& input, TTValue& output);
265 };
266 
267 
268 #endif // __TIME_DATASPACE_H__
void convertToNeutral(const TTValue &input, TTValue &output)
Convert from radians to neutral unit.
Converts times to and from seconds.
void convertFromNeutral(const TTValue &input, TTValue &output)
Convert from neutral unit to seconds.
Converts times to and from MIDI pitch.
void convertToNeutral(const TTValue &input, TTValue &output)
Convert from milliseconds to neutral unit.
Converts times to and from frequency (Hz).
Base class for the time dataspace, provides dataspace support for converting values representing time...
Definition: TimeDataspace.h:27
void convertToNeutral(const TTValue &input, TTValue &output)
Convert from MIDI pitch to neutral unit.
void convertToNeutral(const TTValue &input, TTValue &output)
Convert from Hz to neutral unit.
Converts times to and from Bpm (beats per minute).
Definition: TimeDataspace.h:66
TTDataObjectBase is the base class for all data generating and processing objects.
void convertFromNeutral(const TTValue &input, TTValue &output)
Convert from neutral unit to MIDI pitch.
void convertToNeutral(const TTValue &input, TTValue &output)
Convert from samples to neutral unit.
#define TTCLASS_SETUP(className)
TODO Doxygen: need more comments here.
Definition: TTFoundation.h:54
void convertToNeutral(const TTValue &input, TTValue &output)
Convert from Bpm to neutral unit.
void convertFromNeutral(const TTValue &input, TTValue &output)
Convert from neutral unit to number of samples.
Specification for the base class of each DataspaceUnit.
void convertToNeutral(const TTValue &input, TTValue &output)
Convert from Mel to neutral unit.
void convertFromNeutral(const TTValue &input, TTValue &output)
Convert from neutral unit to Hz.
void convertFromNeutral(const TTValue &input, TTValue &output)
Convert from neutral unit to Mel.
void convertFromNeutral(const TTValue &input, TTValue &output)
Convert from neutral unit to milliseconds.
Converts times to and from number of samples.
Converts times to and from milliseconds.
Converts times to and from MIDI Cents.
Definition: TimeDataspace.h:89
Specification for TTDataspace, the base class of each dataspace.
TTErr
Jamoma Error Codes Enumeration of error codes that might be returned by any of the TTBlue functions a...
Definition: TTBase.h:342
Converts times to and from Mel.
void convertFromNeutral(const TTValue &input, TTValue &output)
Convert from neutral unit to cents.
void convertToNeutral(const TTValue &input, TTValue &output)
Convert from speed to neutral unit.
void convertFromNeutral(const TTValue &input, TTValue &output)
Convert from neutral unit to speed.
Base class for each dataspace.
Definition: TTDataspace.h:30
void convertToNeutral(const TTValue &input, TTValue &output)
Convert from seconds to neutral unit.
void convertFromNeutral(const TTValue &input, TTValue &output)
Convert from neutral unit to Bark.
Converts time to and from Bark unit.
Definition: TimeDataspace.h:43
void convertFromNeutral(const TTValue &input, TTValue &output)
Convert from neutral unit to Bpm.
void convertToNeutral(const TTValue &input, TTValue &output)
Convert from Bark to neutral unit.
[doxygenAppendixC_copyExample]
Definition: TTValue.h:34
Converts times to and from transposition playback speed of buffers or sound files.