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 Zrythm.  If not, see <https://www.gnu.org/licenses/>.
18  */
19 
20 /**
21  * \file
22  *
23  * MIDI functions.
24  *
25  * TODO move to a more appropriate directory.
26  */
27 
28 #ifndef __AUDIO_MIDI_FUNCTION_H__
29 #define __AUDIO_MIDI_FUNCTION_H__
30 
31 #include "utils/yaml.h"
32 
33 typedef struct ArrangerSelections ArrangerSelections;
34 
35 /**
36  * @addtogroup audio
37  *
38  * @{
39  */
40 
41 typedef enum MidiFunctionType
42 {
43   MIDI_FUNCTION_CRESCENDO,
44   MIDI_FUNCTION_FLAM,
45   MIDI_FUNCTION_FLIP_HORIZONTAL,
46   MIDI_FUNCTION_FLIP_VERTICAL,
47   MIDI_FUNCTION_LEGATO,
48   MIDI_FUNCTION_PORTATO,
49   MIDI_FUNCTION_STACCATO,
50   MIDI_FUNCTION_STRUM,
51 } MidiFunctionType;
52 
53 static const cyaml_strval_t
54   midi_function_type_strings[] =
55 {
56   { __("Crescendo"), MIDI_FUNCTION_CRESCENDO },
57   { __("Flam"), MIDI_FUNCTION_FLAM },
58   { __("Flip H"), MIDI_FUNCTION_FLIP_HORIZONTAL },
59   { __("Flip V"), MIDI_FUNCTION_FLIP_VERTICAL },
60   { __("Legato"), MIDI_FUNCTION_LEGATO },
61   { __("Portato"), MIDI_FUNCTION_PORTATO },
62   { __("Staccato"), MIDI_FUNCTION_STACCATO },
63   { __("Strum"), MIDI_FUNCTION_STRUM },
64 };
65 
66 static inline const char *
midi_function_type_to_string(MidiFunctionType type)67 midi_function_type_to_string (
68   MidiFunctionType type)
69 {
70   return midi_function_type_strings[type].str;
71 }
72 
73 /**
74  * Applies the given action to the given selections.
75  *
76  * @param sel Selections to edit.
77  * @param type Function type.
78  */
79 int
80 midi_function_apply (
81   ArrangerSelections * sel,
82   MidiFunctionType     type,
83   GError **            error);
84 
85 /**
86  * @}
87  */
88 
89 #endif
90