1 /* 2 * Copyright (C) 2019-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 * Custom types. 24 */ 25 26 #ifndef __UTILS_TYPES_H__ 27 #define __UTILS_TYPES_H__ 28 29 #include <stdbool.h> 30 #include <stdint.h> 31 32 /** 33 * @addtogroup utils 34 * 35 * @{ 36 */ 37 38 /** MIDI byte. */ 39 typedef uint8_t midi_byte_t; 40 41 /** Frame count. */ 42 typedef uint32_t nframes_t; 43 44 /** Sample rate. */ 45 typedef uint32_t sample_rate_t; 46 47 /** MIDI time in global frames. */ 48 typedef uint32_t midi_time_t; 49 50 /** Number of channels. */ 51 typedef unsigned int channels_t; 52 53 /** The sample type. */ 54 typedef float sample_t; 55 56 /** The BPM type. */ 57 typedef float bpm_t; 58 59 typedef double curviness_t; 60 61 /** 62 * Getter prototype for float values. 63 */ 64 typedef float (*GenericFloatGetter) ( 65 void * object); 66 67 /** 68 * Setter prototype for float values. 69 */ 70 typedef void (*GenericFloatSetter) ( 71 void * object, 72 float val); 73 74 /** 75 * Getter prototype for strings. 76 */ 77 typedef const char * (*GenericStringGetter) ( 78 void * object); 79 80 /** 81 * Getter prototype for strings to be saved in the 82 * given buffer. 83 */ 84 typedef void (*GenericStringCopyGetter) ( 85 void * object, 86 char * buf); 87 88 /** 89 * Setter prototype for float values. 90 */ 91 typedef void (*GenericStringSetter) ( 92 void * object, 93 const char * val); 94 95 /** 96 * Generic callback. 97 */ 98 typedef void (*GenericCallback) ( 99 void * object); 100 101 /** 102 * Generic comparator. 103 */ 104 typedef int (*GenericCmpFunc) ( 105 const void * a, 106 const void * b); 107 108 /** 109 * Predicate function prototype. 110 * 111 * To be used to return whether the given pointer 112 * matches some condition. 113 */ 114 typedef bool (*GenericPredicateFunc) ( 115 const void * object, 116 const void * user_data); 117 118 /** 119 * Generic progress info. 120 */ 121 typedef struct GenericProgressInfo 122 { 123 /** Progress done (0.0 to 1.0). */ 124 double progress; 125 126 /** Action cancelled. */ 127 bool cancelled; 128 129 /** Error occured. */ 130 bool has_error; 131 132 /** String to show in the label during the 133 * action. */ 134 char label_str[1800]; 135 136 /** String to show in the label when the action 137 * is complete (progress == 1.0). */ 138 char label_done_str[1800]; 139 140 /** 141 * String to show in a popup when 142 * GenericProgressInfo.has_error is true. 143 */ 144 char error_str[1800]; 145 } GenericProgressInfo; 146 147 typedef enum AudioValueFormat 148 { 149 /** 0 to 2, amplitude. */ 150 AUDIO_VALUE_AMPLITUDE, 151 152 /** dbFS. */ 153 AUDIO_VALUE_DBFS, 154 155 /** 0 to 1, suitable for drawing. */ 156 AUDIO_VALUE_FADER, 157 } AudioValueFormat; 158 159 /** 160 * @} 161 */ 162 163 #endif 164