1 /*
2 * Copyright (C) 2020 Alexandros Theodotou <alex at zrythm dot org>
3 *
4 * This file is part of Zrythm
5 *
6 * Zrythm is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Affero 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 * Zrythm 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 Affero General Public License for more details.
15 *
16 * You should have received a copy of the GNU Affero General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20 #include "guile/modules.h"
21
22 #ifndef SNARF_MODE
23 #include "audio/tracklist.h"
24 #include "project.h"
25 #include "zrythm_app.h"
26 #endif
27
28 SCM_DEFINE (
29 s_tracklist_insert_track,
30 "tracklist-insert-track", 3, 0, 0,
31 (SCM tracklist, SCM track, SCM idx),
32 "Inserts track @var{track} at index @var{idx} in "
33 "the tracklist.")
34 #define FUNC_NAME s_
35 {
36 Tracklist * tl =
37 (Tracklist *) scm_to_pointer (tracklist);
38
39 tracklist_insert_track (
40 tl, scm_to_pointer (track),
41 scm_to_int (idx), true, true);
42
43 return SCM_BOOL_T;
44 }
45 #undef FUNC_NAME
46
47 SCM_DEFINE (
48 s_tracklist_get_track_at_pos, "tracklist-get-track-at-pos",
49 2, 0, 0,
50 (SCM tracklist, SCM pos),
51 "Returns the track at @var{pos} in the tracklist.")
52 #define FUNC_NAME s_
53 {
54 Tracklist * tl =
55 (Tracklist *) scm_to_pointer (tracklist);
56
57 return
58 scm_from_pointer (
59 tl->tracks[scm_to_int (pos)], NULL);
60 }
61 #undef FUNC_NAME
62
63 SCM_DEFINE (
64 s_tracklist_get_num_tracks, "tracklist-get-num-tracks", 1, 0, 0,
65 (SCM tracklist),
66 "Returns the number of tracks in the tracklist.")
67 #define FUNC_NAME s_
68 {
69 Tracklist * tl =
70 (Tracklist *) scm_to_pointer (tracklist);
71
72 return
73 scm_from_int (tl->num_tracks);
74 }
75 #undef FUNC_NAME
76
77 static void
init_module(void * data)78 init_module (void * data)
79 {
80 #ifndef SNARF_MODE
81 #include "audio_tracklist.x"
82 #endif
83 scm_c_export (
84 "tracklist-insert-track",
85 "tracklist-get-track-at-pos",
86 "tracklist-get-num-tracks",
87 NULL);
88 }
89
90 void
guile_audio_tracklist_define_module(void)91 guile_audio_tracklist_define_module (void)
92 {
93 scm_c_define_module (
94 "audio tracklist", init_module, NULL);
95 }
96