1 /**
2  * File name: mixer.h
3  * Project: Geonkick (A kick synthesizer)
4  *
5  * Copyright (C) 2020 Iurie Nistor <http://iuriepage.wordpress.com>
6  *
7  * This file is part of Geonkick.
8  *
9  * GeonKick is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22  */
23 
24 #ifndef GKICK_MIXER_H
25 #define GKICK_MIXER_H
26 
27 #include "audio_output.h"
28 
29 struct gkick_mixer {
30 	struct gkick_audio_output **audio_outputs;
31 	size_t connection_matrix[127];
32         _Atomic int solo;
33 	_Atomic int limiter;
34         void (*limiter_callback) (void*, size_t index, gkick_real val);
35         void *limiter_callback_arg;
36         _Atomic size_t limiter_callback_index;
37 };
38 
39 enum geonkick_error
40 gkick_mixer_create(struct gkick_mixer **mixer);
41 
42 enum geonkick_error
43 gkick_mixer_key_pressed(struct gkick_mixer *mixer,
44 			struct gkick_note_info *note);
45 
46 enum geonkick_error
47 gkick_mixer_tune_output(struct gkick_mixer *mixer,
48                         size_t index,
49                         bool tune);
50 
51 enum geonkick_error
52 gkick_mixer_is_output_tuned(struct gkick_mixer *mixer,
53                             size_t index,
54                             bool *tune);
55 
56 enum geonkick_error
57 gkick_mixer_get_frame(struct gkick_mixer *mixer,
58 		      int channel,
59 		      gkick_real *val);
60 
61 enum geonkick_error
62 gkick_mixer_process(struct gkick_mixer *mixer,
63                     float** out,
64                     size_t offset,
65                     size_t size);
66 
67 void
68 gkick_mixer_set_leveler(struct gkick_mixer *mixer,
69                         size_t index,
70                         gkick_real val);
71 
72 
73 void
74 gkick_mixer_free(struct gkick_mixer **mixer);
75 
76 enum geonkick_error
77 gkick_mixer_limiter_set(struct gkick_mixer *mixer,
78                         size_t index,
79                         gkick_real val);
80 
81 enum geonkick_error
82 gkick_mixer_limiter_get(struct gkick_mixer *mixer,
83                         size_t index,
84                         gkick_real *val);
85 
86 enum geonkick_error
87 gkick_mixer_mute(struct gkick_mixer *mixer, size_t id, bool b);
88 
89 enum geonkick_error
90 gkick_mixer_is_muted(struct gkick_mixer *mixer, size_t id, bool *b);
91 
92 enum geonkick_error
93 gkick_mixer_solo(struct gkick_mixer *mixer, size_t id, bool b);
94 
95 enum geonkick_error
96 gkick_mixer_is_solo(struct gkick_mixer *mixer, size_t id, bool *b);
97 
98 enum geonkick_error
99 gkick_mixer_set_limiter_callback(struct gkick_mixer *mixer,
100 				 void (*callback)(void*, size_t index, gkick_real val),
101 				 void *arg);
102 
103 #endif // GKICK_MIXER_H
104