1 /* GSequencer - Advanced GTK Sequencer
2 * Copyright (C) 2005-2019 Joël Krähemann
3 *
4 * This file is part of GSequencer.
5 *
6 * GSequencer is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * GSequencer is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with GSequencer. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #include <ags/object/ags_tactable.h>
21
22 #include <ags/object/ags_marshal.h>
23
24 void ags_tactable_class_init(AgsTactableInterface *ginterface);
25
26 /**
27 * SECTION:ags_tactable
28 * @short_description: Unique tempo set or attributes access
29 * @title: AgsTactable
30 * @section_id: AgsTactable
31 * @include: ags/object/ags_tactable.h
32 *
33 * The #AgsTactable interface gives you a unique access to modify tempo.
34 */
35
36 enum {
37 CHANGE_SEQUENCER_DURATION,
38 CHANGE_NOTATION_DURATION,
39 CHANGE_WAVE_DURATION,
40 CHANGE_MIDI_DURATION,
41 CHANGE_TACT,
42 CHANGE_BPM,
43 LAST_SIGNAL,
44 };
45
46 static guint tactable_signals[LAST_SIGNAL];
47
48 GType
ags_tactable_get_type()49 ags_tactable_get_type()
50 {
51 static volatile gsize g_define_type_id__volatile = 0;
52
53 if(g_once_init_enter (&g_define_type_id__volatile)){
54 GType ags_type_tactable = 0;
55
56 ags_type_tactable = g_type_register_static_simple(G_TYPE_INTERFACE,
57 "AgsTactable",
58 sizeof (AgsTactableInterface),
59 (GClassInitFunc) ags_tactable_class_init,
60 0, NULL, 0);
61
62 g_once_init_leave(&g_define_type_id__volatile, ags_type_tactable);
63 }
64
65 return g_define_type_id__volatile;
66 }
67
68 void
ags_tactable_class_init(AgsTactableInterface * ginterface)69 ags_tactable_class_init(AgsTactableInterface *ginterface)
70 {
71 /**
72 * AgsTactable::change-sequencer-duration:
73 * @tactable: the #AgsTactable object
74 * @sequencer_duration: new duration
75 *
76 * The ::change-sequencer-duration signal notifies about changed duration
77 * of sequencer.
78 *
79 * Since: 3.0.0
80 */
81 tactable_signals[CHANGE_SEQUENCER_DURATION] =
82 g_signal_new("change-sequencer-duration",
83 G_TYPE_FROM_INTERFACE(ginterface),
84 G_SIGNAL_RUN_LAST,
85 G_STRUCT_OFFSET(AgsTactableInterface, change_sequencer_duration),
86 NULL, NULL,
87 ags_cclosure_marshal_VOID__UINT64,
88 G_TYPE_NONE, 1,
89 G_TYPE_UINT64);
90
91 /**
92 * AgsTactable::change-notation-duration:
93 * @tactable: the #AgsTactable object
94 * @notation_duration: new duration
95 *
96 * The ::change-notation-duration signal notifies about changed duration
97 * of notation.
98 *
99 * Since: 3.0.0
100 */
101 tactable_signals[CHANGE_NOTATION_DURATION] =
102 g_signal_new("change-notation-duration",
103 G_TYPE_FROM_INTERFACE(ginterface),
104 G_SIGNAL_RUN_LAST,
105 G_STRUCT_OFFSET(AgsTactableInterface, change_notation_duration),
106 NULL, NULL,
107 ags_cclosure_marshal_VOID__UINT64,
108 G_TYPE_NONE, 1,
109 G_TYPE_UINT64);
110
111 /**
112 * AgsTactable::change-wave-duration:
113 * @tactable: the #AgsTactable object
114 * @wave_duration: new duration
115 *
116 * The ::change-wave-duration signal notifies about changed duration
117 * of wave.
118 *
119 * Since: 3.0.0
120 */
121 tactable_signals[CHANGE_WAVE_DURATION] =
122 g_signal_new("change-wave-duration",
123 G_TYPE_FROM_INTERFACE(ginterface),
124 G_SIGNAL_RUN_LAST,
125 G_STRUCT_OFFSET(AgsTactableInterface, change_wave_duration),
126 NULL, NULL,
127 ags_cclosure_marshal_VOID__UINT64,
128 G_TYPE_NONE, 1,
129 G_TYPE_UINT64);
130
131 /**
132 * AgsTactable::change-midi-duration:
133 * @tactable: the #AgsTactable object
134 * @midi_duration: new duration
135 *
136 * The ::change-midi-duration signal notifies about changed duration
137 * of midi.
138 *
139 * Since: 3.0.0
140 */
141 tactable_signals[CHANGE_MIDI_DURATION] =
142 g_signal_new("change-midi-duration",
143 G_TYPE_FROM_INTERFACE(ginterface),
144 G_SIGNAL_RUN_LAST,
145 G_STRUCT_OFFSET(AgsTactableInterface, change_midi_duration),
146 NULL, NULL,
147 ags_cclosure_marshal_VOID__UINT64,
148 G_TYPE_NONE, 1,
149 G_TYPE_UINT64);
150
151 /**
152 * AgsTactable::change-tact
153 * @tactable: the #AgsTactable object
154 * @new_tact: new tact
155 * @old_tact: old tact
156 *
157 * The ::change-tact signal notifies about changed tact.
158 *
159 * Since: 3.0.0
160 */
161 tactable_signals[CHANGE_TACT] =
162 g_signal_new("change-tact",
163 G_TYPE_FROM_INTERFACE(ginterface),
164 G_SIGNAL_RUN_LAST,
165 G_STRUCT_OFFSET(AgsTactableInterface, change_tact),
166 NULL, NULL,
167 ags_cclosure_marshal_VOID__DOUBLE_DOUBLE,
168 G_TYPE_NONE, 2,
169 G_TYPE_DOUBLE, G_TYPE_DOUBLE);
170
171 /**
172 * AgsTactable::change-bpm:
173 * @tactable: the #AgsTactable object
174 * @new_bpm: new BPM
175 * @old_bpm: old BPM
176 *
177 * The ::change-bpm signal notifies about changed bpm.
178 *
179 * Since: 3.0.0
180 */
181 tactable_signals[CHANGE_BPM] =
182 g_signal_new("change-bpm",
183 G_TYPE_FROM_INTERFACE(ginterface),
184 G_SIGNAL_RUN_LAST,
185 G_STRUCT_OFFSET(AgsTactableInterface, change_bpm),
186 NULL, NULL,
187 ags_cclosure_marshal_VOID__DOUBLE_DOUBLE,
188 G_TYPE_NONE, 2,
189 G_TYPE_DOUBLE, G_TYPE_DOUBLE);
190 }
191
192 /**
193 * ags_tactable_get_sequencer_duration:
194 * @tactable: the #AgsTactable
195 *
196 * Get sequencer duration.
197 *
198 * Returns: the sequencer duration
199 *
200 * Since: 3.0.0
201 */
202 guint64
ags_tactable_get_sequencer_duration(AgsTactable * tactable)203 ags_tactable_get_sequencer_duration(AgsTactable *tactable)
204 {
205 AgsTactableInterface *tactable_interface;
206
207 g_return_val_if_fail(AGS_IS_TACTABLE(tactable), 0);
208 tactable_interface = AGS_TACTABLE_GET_INTERFACE(tactable);
209 g_return_val_if_fail(tactable_interface->get_sequencer_duration, 0);
210
211 return(tactable_interface->get_sequencer_duration(tactable));
212 }
213
214 /**
215 * ags_tactable_get_notation_duration:
216 * @tactable: the #AgsTactable
217 *
218 * Get notation duration.
219 *
220 * Returns: the notation duration
221 *
222 * Since: 3.0.0
223 */
224 guint64
ags_tactable_get_notation_duration(AgsTactable * tactable)225 ags_tactable_get_notation_duration(AgsTactable *tactable)
226 {
227 AgsTactableInterface *tactable_interface;
228
229 g_return_val_if_fail(AGS_IS_TACTABLE(tactable), 0);
230 tactable_interface = AGS_TACTABLE_GET_INTERFACE(tactable);
231 g_return_val_if_fail(tactable_interface->get_notation_duration, 0);
232
233 return(tactable_interface->get_notation_duration(tactable));
234 }
235
236 /**
237 * ags_tactable_get_wave_duration:
238 * @tactable: the #AgsTactable
239 *
240 * Get wave duration.
241 *
242 * Returns: the wave duration
243 *
244 * Since: 3.0.0
245 */
246 guint64
ags_tactable_get_wave_duration(AgsTactable * tactable)247 ags_tactable_get_wave_duration(AgsTactable *tactable)
248 {
249 AgsTactableInterface *tactable_interface;
250
251 g_return_val_if_fail(AGS_IS_TACTABLE(tactable), 0);
252 tactable_interface = AGS_TACTABLE_GET_INTERFACE(tactable);
253 g_return_val_if_fail(tactable_interface->get_wave_duration, 0);
254
255 return(tactable_interface->get_wave_duration(tactable));
256 }
257
258 /**
259 * ags_tactable_get_midi_duration:
260 * @tactable: the #AgsTactable
261 *
262 * Get midi duration.
263 *
264 * Returns: the midi duration
265 *
266 * Since: 3.0.0
267 */
268 guint64
ags_tactable_get_midi_duration(AgsTactable * tactable)269 ags_tactable_get_midi_duration(AgsTactable *tactable)
270 {
271 AgsTactableInterface *tactable_interface;
272
273 g_return_val_if_fail(AGS_IS_TACTABLE(tactable), 0);
274 tactable_interface = AGS_TACTABLE_GET_INTERFACE(tactable);
275 g_return_val_if_fail(tactable_interface->get_midi_duration, 0);
276
277 return(tactable_interface->get_midi_duration(tactable));
278 }
279
280 /**
281 * ags_tactable_get_bpm:
282 * @tactable: the #AgsTactable
283 *
284 * Get bpm.
285 *
286 * Returns: the bpm
287 *
288 * Since: 3.0.0
289 */
290 gdouble
ags_tactable_get_bpm(AgsTactable * tactable)291 ags_tactable_get_bpm(AgsTactable *tactable)
292 {
293 AgsTactableInterface *tactable_interface;
294
295 g_return_val_if_fail(AGS_IS_TACTABLE(tactable), -1.0);
296 tactable_interface = AGS_TACTABLE_GET_INTERFACE(tactable);
297 g_return_val_if_fail(tactable_interface->get_bpm, -1.0);
298
299 return(tactable_interface->get_bpm(tactable));
300 }
301
302 /**
303 * ags_tactable_get_tact:
304 * @tactable: the #AgsTactable
305 *
306 * Get tact.
307 *
308 * Returns: the tact
309 *
310 * Since: 3.0.0
311 */
312 gdouble
ags_tactable_get_tact(AgsTactable * tactable)313 ags_tactable_get_tact(AgsTactable *tactable)
314 {
315 AgsTactableInterface *tactable_interface;
316
317 g_return_val_if_fail(AGS_IS_TACTABLE(tactable), -1.0);
318 tactable_interface = AGS_TACTABLE_GET_INTERFACE(tactable);
319 g_return_val_if_fail(tactable_interface->get_tact, -1.0);
320
321 return(tactable_interface->get_tact(tactable));
322 }
323
324 /**
325 * ags_tactable_change_sequencer_duration:
326 * @tactable: the #AgsTactable
327 * @sequencer_duration: the duration
328 *
329 * Change sequencer duration.
330 *
331 * Since: 3.0.0
332 */
333 void
ags_tactable_change_sequencer_duration(AgsTactable * tactable,guint64 sequencer_duration)334 ags_tactable_change_sequencer_duration(AgsTactable *tactable, guint64 sequencer_duration)
335 {
336 g_signal_emit(tactable,
337 tactable_signals[CHANGE_SEQUENCER_DURATION],
338 0,
339 sequencer_duration);
340 }
341
342 /**
343 * ags_tactable_change_notation_duration:
344 * @tactable: the #AgsTactable
345 * @notation_duration: the duration
346 *
347 * Change notation duration.
348 *
349 * Since: 3.0.0
350 */
351 void
ags_tactable_change_notation_duration(AgsTactable * tactable,guint64 notation_duration)352 ags_tactable_change_notation_duration(AgsTactable *tactable, guint64 notation_duration)
353 {
354 g_signal_emit(tactable,
355 tactable_signals[CHANGE_NOTATION_DURATION],
356 0,
357 notation_duration);
358 }
359
360 /**
361 * ags_tactable_change_wave_duration:
362 * @tactable: the #AgsTactable
363 * @wave_duration: the duration
364 *
365 * Change wave duration.
366 *
367 * Since: 3.0.0
368 */
369 void
ags_tactable_change_wave_duration(AgsTactable * tactable,guint64 wave_duration)370 ags_tactable_change_wave_duration(AgsTactable *tactable, guint64 wave_duration)
371 {
372 g_signal_emit(tactable,
373 tactable_signals[CHANGE_WAVE_DURATION],
374 0,
375 wave_duration);
376 }
377
378 /**
379 * ags_tactable_change_midi_duration:
380 * @tactable: the #AgsTactable
381 * @midi_duration: the duration
382 *
383 * Change midi duration.
384 *
385 * Since: 3.0.0
386 */
387 void
ags_tactable_change_midi_duration(AgsTactable * tactable,guint64 midi_duration)388 ags_tactable_change_midi_duration(AgsTactable *tactable, guint64 midi_duration)
389 {
390 g_signal_emit(tactable,
391 tactable_signals[CHANGE_MIDI_DURATION],
392 0,
393 midi_duration);
394 }
395
396 /**
397 * ags_tactable_change_tact:
398 * @tactable: the #AgsTactable
399 * @new_tact: the new tact
400 * @old_tact: the old tact
401 *
402 * Change tact.
403 *
404 * Since: 3.0.0
405 */
406 void
ags_tactable_change_tact(AgsTactable * tactable,gdouble new_tact,gdouble old_tact)407 ags_tactable_change_tact(AgsTactable *tactable, gdouble new_tact, gdouble old_tact)
408 {
409 g_signal_emit(tactable,
410 tactable_signals[CHANGE_TACT],
411 0,
412 new_tact,
413 old_tact);
414 }
415
416 /**
417 * ags_tactable_change_bpm:
418 * @tactable: the #AgsTactable
419 * @new_bpm: the new bpm
420 * @old_bpm: the old bpm
421 *
422 * Change bpm.
423 *
424 * Since: 3.0.0
425 */
426 void
ags_tactable_change_bpm(AgsTactable * tactable,gdouble new_bpm,gdouble old_bpm)427 ags_tactable_change_bpm(AgsTactable *tactable, gdouble new_bpm, gdouble old_bpm)
428 {
429 g_signal_emit(tactable,
430 tactable_signals[CHANGE_BPM],
431 0,
432 new_bpm,
433 old_bpm);
434 }
435