1 /* GSequencer - Advanced GTK Sequencer 2 * Copyright (C) 2005-2019 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_SAMPLE_H__ 21 #define __AGS_SFZ_SAMPLE_H__ 22 23 #include <glib.h> 24 #include <glib-object.h> 25 26 #include <ags/libags.h> 27 28 #include <sndfile.h> 29 30 G_BEGIN_DECLS 31 32 #define AGS_TYPE_SFZ_SAMPLE (ags_sfz_sample_get_type()) 33 #define AGS_SFZ_SAMPLE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), AGS_TYPE_SFZ_SAMPLE, AgsSFZSample)) 34 #define AGS_SFZ_SAMPLE_CLASS(class) (G_TYPE_CHECK_CLASS_CAST((class), AGS_TYPE_SFZ_SAMPLE, AgsSFZSampleClass)) 35 #define AGS_IS_SFZ_SAMPLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), AGS_TYPE_SFZ_SAMPLE)) 36 #define AGS_IS_SFZ_SAMPLE_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), AGS_TYPE_SFZ_SAMPLE)) 37 #define AGS_SFZ_SAMPLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), AGS_TYPE_SFZ_SAMPLE, AgsSFZSampleClass)) 38 39 #define AGS_SFZ_SAMPLE_GET_OBJ_MUTEX(obj) (&(((AgsSFZSample *) obj)->obj_mutex)) 40 41 typedef struct _AgsSFZSample AgsSFZSample; 42 typedef struct _AgsSFZSampleClass AgsSFZSampleClass; 43 44 /** 45 * AgsSFZSampleFlags: 46 * @AGS_SFZ_SAMPLE_ADDED_TO_REGISTRY: the sfz sample was added to registry, see #AgsConnectable::add_to_registry() 47 * @AGS_SFZ_SAMPLE_CONNECTED: indicates the sfz sample was connected by calling #AgsConnectable::connect() 48 * 49 * Enum values to control the behavior or indicate internal state of #AgsSFZSample by 50 * enable/disable as flags. 51 */ 52 typedef enum{ 53 AGS_SFZ_SAMPLE_ADDED_TO_REGISTRY = 1, 54 AGS_SFZ_SAMPLE_CONNECTED = 1 << 1, 55 }AgsSFZSampleFlags; 56 57 /** 58 * AgsSFZSampleLoopMode: 59 * @AGS_SFZ_SAMPLE_LOOP_ONE_SHOT: one shot 60 * @AGS_SFZ_SAMPLE_LOOP_CONTINUOUS: loop continuous 61 * @AGS_SFZ_SAMPLE_LOOP_SUSTAIN: loop sustain 62 * 63 * Enum values to control the behavior or indicate internal state of #AgsSFZSample by 64 * enable/disable as flags. 65 */ 66 typedef enum{ 67 AGS_SFZ_SAMPLE_LOOP_ONE_SHOT, 68 AGS_SFZ_SAMPLE_LOOP_CONTINUOUS, 69 AGS_SFZ_SAMPLE_LOOP_SUSTAIN, 70 }AgsSFZSampleLoopMode; 71 72 struct _AgsSFZSample 73 { 74 GObject gobject; 75 76 guint flags; 77 78 GRecMutex obj_mutex; 79 80 AgsUUID *uuid; 81 82 gchar *filename; 83 84 guint audio_channels; 85 gint64 *audio_channel_written; 86 87 guint buffer_size; 88 guint format; 89 90 guint loop_start; 91 guint loop_end; 92 93 guint offset; 94 guint64 buffer_offset; 95 96 void *full_buffer; 97 void *buffer; 98 99 guchar *pointer; 100 guchar *current; 101 gsize length; 102 103 SF_INFO *info; 104 SNDFILE *file; 105 106 GObject *group; 107 GObject *region; 108 }; 109 110 struct _AgsSFZSampleClass 111 { 112 GObjectClass gobject; 113 }; 114 115 GType ags_sfz_sample_get_type(); 116 117 gboolean ags_sfz_sample_test_flags(AgsSFZSample *sfz_sample, guint flags); 118 void ags_sfz_sample_set_flags(AgsSFZSample *sfz_sample, guint flags); 119 void ags_sfz_sample_unset_flags(AgsSFZSample *sfz_sample, guint flags); 120 121 gint ags_sfz_sample_get_key(AgsSFZSample *sfz_sample); 122 123 gint ags_sfz_sample_get_hikey(AgsSFZSample *sfz_sample); 124 gint ags_sfz_sample_get_lokey(AgsSFZSample *sfz_sample); 125 126 gint ags_sfz_sample_get_pitch_keycenter(AgsSFZSample *sfz_sample); 127 128 guint ags_sfz_sample_get_loop_mode(AgsSFZSample *sfz_sample); 129 guint ags_sfz_sample_get_loop_start(AgsSFZSample *sfz_sample); 130 guint ags_sfz_sample_get_loop_end(AgsSFZSample *sfz_sample); 131 132 /* instantiate */ 133 AgsSFZSample* ags_sfz_sample_new(); 134 135 G_END_DECLS 136 137 #endif /*__AGS_SFZ_SAMPLE_H__*/ 138