1 /* GSequencer - Advanced GTK Sequencer
2  * Copyright (C) 2005-2021 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 #ifndef __AGS_SFZ_SYNTH_GENERATOR_H__
21 #define __AGS_SFZ_SYNTH_GENERATOR_H__
22 
23 #include <glib.h>
24 #include <glib-object.h>
25 
26 #include <ags/libags.h>
27 
28 #include <ags/audio/ags_sfz_util.h>
29 
30 G_BEGIN_DECLS
31 
32 #define AGS_TYPE_SFZ_SYNTH_GENERATOR                (ags_sfz_synth_generator_get_type())
33 #define AGS_SFZ_SYNTH_GENERATOR(obj)                (G_TYPE_CHECK_INSTANCE_CAST((obj), AGS_TYPE_SFZ_SYNTH_GENERATOR, AgsSFZSynthGenerator))
34 #define AGS_SFZ_SYNTH_GENERATOR_CLASS(class)        (G_TYPE_CHECK_CLASS_CAST((class), AGS_TYPE_SFZ_SYNTH_GENERATOR, AgsSFZSynthGeneratorClass))
35 #define AGS_IS_SFZ_SYNTH_GENERATOR(obj)             (G_TYPE_CHECK_INSTANCE_TYPE((obj), AGS_TYPE_SFZ_SYNTH_GENERATOR))
36 #define AGS_IS_SFZ_SYNTH_GENERATOR_CLASS(class)     (G_TYPE_CHECK_CLASS_TYPE((class), AGS_TYPE_SFZ_SYNTH_GENERATOR))
37 #define AGS_SFZ_SYNTH_GENERATOR_GET_CLASS(obj)      (G_TYPE_INSTANCE_GET_CLASS((obj), AGS_TYPE_SFZ_SYNTH_GENERATOR, AgsSFZSynthGeneratorClass))
38 
39 #define AGS_SFZ_SYNTH_GENERATOR_GET_OBJ_MUTEX(obj) (&(((AgsSFZSynthGenerator *) obj)->obj_mutex))
40 
41 #define AGS_SFZ_SYNTH_GENERATOR_DEFAULT_SAMPLERATE ((guint) AGS_SOUNDCARD_DEFAULT_SAMPLERATE)
42 #define AGS_SFZ_SYNTH_GENERATOR_DEFAULT_BUFFER_SIZE (AGS_SOUNDCARD_DEFAULT_BUFFER_SIZE)
43 #define AGS_SFZ_SYNTH_GENERATOR_DEFAULT_FORMAT (AGS_SOUNDCARD_DEFAULT_FORMAT)
44 
45 #define AGS_SFZ_SYNTH_GENERATOR_DEFAULT_VOLUME (1.0)
46 
47 #define AGS_SFZ_SYNTH_GENERATOR_DEFAULT_BASE_KEY (-48.0)
48 #define AGS_SFZ_SYNTH_GENERATOR_DEFAULT_TUNING (0.0)
49 
50 typedef struct _AgsSFZSynthGenerator AgsSFZSynthGenerator;
51 typedef struct _AgsSFZSynthGeneratorClass AgsSFZSynthGeneratorClass;
52 
53 struct _AgsSFZSynthGenerator
54 {
55   AgsFunction function;
56 
57   guint flags;
58 
59   GRecMutex obj_mutex;
60 
61   gchar *filename;
62 
63   guint samplerate;
64   guint buffer_size;
65   guint format;
66 
67   guint pitch_type;
68 
69   guint frame_count;
70   guint loop_start;
71   guint loop_end;
72 
73   gdouble delay;
74   guint attack;
75 
76   gdouble volume;
77 
78   gdouble base_key;
79   gdouble tuning;
80 
81   AgsSFZ *sfz;
82 
83   GObject *timestamp;
84 };
85 
86 struct _AgsSFZSynthGeneratorClass
87 {
88   AgsFunctionClass function;
89 };
90 
91 GType ags_sfz_synth_generator_get_type();
92 
93 GRecMutex* ags_sfz_synth_generator_get_obj_mutex(AgsSFZSynthGenerator *sfz_synth_generator);
94 
95 gchar* ags_sfz_synth_generator_get_filename(AgsSFZSynthGenerator *sfz_synth_generator);
96 void ags_sfz_synth_generator_set_filename(AgsSFZSynthGenerator *sfz_synth_generator, gchar *filename);
97 
98 guint ags_sfz_synth_generator_get_samplerate(AgsSFZSynthGenerator *sfz_synth_generator);
99 void ags_sfz_synth_generator_set_samplerate(AgsSFZSynthGenerator *sfz_synth_generator, guint samplerate);
100 
101 guint ags_sfz_synth_generator_get_buffer_size(AgsSFZSynthGenerator *sfz_synth_generator);
102 void ags_sfz_synth_generator_set_buffer_size(AgsSFZSynthGenerator *sfz_synth_generator, guint buffer_size);
103 
104 guint ags_sfz_synth_generator_get_format(AgsSFZSynthGenerator *sfz_synth_generator);
105 void ags_sfz_synth_generator_set_format(AgsSFZSynthGenerator *sfz_synth_generator, guint format);
106 
107 guint ags_sfz_synth_generator_get_pitch_type(AgsSFZSynthGenerator *sfz_synth_generator);
108 void ags_sfz_synth_generator_set_pitch_type(AgsSFZSynthGenerator *sfz_synth_generator, guint pitch_type);
109 
110 gdouble ags_sfz_synth_generator_get_delay(AgsSFZSynthGenerator *sfz_synth_generator);
111 void ags_sfz_synth_generator_set_delay(AgsSFZSynthGenerator *sfz_synth_generator, gdouble delay);
112 
113 guint ags_sfz_synth_generator_get_frame_count(AgsSFZSynthGenerator *sfz_synth_generator);
114 void ags_sfz_synth_generator_set_frame_count(AgsSFZSynthGenerator *sfz_synth_generator, guint frame_count);
115 
116 guint ags_sfz_synth_generator_get_loop_start(AgsSFZSynthGenerator *sfz_synth_generator);
117 void ags_sfz_synth_generator_set_loop_start(AgsSFZSynthGenerator *sfz_synth_generator, guint loop_start);
118 
119 guint ags_sfz_synth_generator_get_loop_end(AgsSFZSynthGenerator *sfz_synth_generator);
120 void ags_sfz_synth_generator_set_loop_end(AgsSFZSynthGenerator *sfz_synth_generator, guint loop_end);
121 
122 gdouble ags_sfz_synth_generator_get_base_key(AgsSFZSynthGenerator *sfz_synth_generator);
123 void ags_sfz_synth_generator_set_base_key(AgsSFZSynthGenerator *sfz_synth_generator, gdouble base_key);
124 
125 gdouble ags_sfz_synth_generator_get_tuning(AgsSFZSynthGenerator *sfz_synth_generator);
126 void ags_sfz_synth_generator_set_tuning(AgsSFZSynthGenerator *sfz_synth_generator, gdouble tuning);
127 
128 AgsTimestamp* ags_sfz_synth_generator_get_timestamp(AgsSFZSynthGenerator *sfz_synth_generator);
129 void ags_sfz_synth_generator_set_timestamp(AgsSFZSynthGenerator *sfz_synth_generator,
130 					   AgsTimestamp *timestamp);
131 
132 void ags_sfz_synth_generator_compute(AgsSFZSynthGenerator *sfz_synth_generator,
133 				     GObject *audio_signal,
134 				     gdouble note);
135 
136 AgsSFZSynthGenerator* ags_sfz_synth_generator_new();
137 
138 G_END_DECLS
139 
140 #endif /*__AGS_SFZ_SYNTH_GENERATOR_H__*/
141