1 /* GSequencer - Advanced GTK Sequencer 2 * Copyright (C) 2005-2020 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_SOUND_RESOURCE_H__ 21 #define __AGS_SOUND_RESOURCE_H__ 22 23 #include <glib.h> 24 #include <glib-object.h> 25 26 #include <ags/libags.h> 27 28 #include <unistd.h> 29 30 G_BEGIN_DECLS 31 32 #define AGS_TYPE_SOUND_RESOURCE (ags_sound_resource_get_type()) 33 #define AGS_SOUND_RESOURCE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), AGS_TYPE_SOUND_RESOURCE, AgsSoundResource)) 34 #define AGS_SOUND_RESOURCE_INTERFACE(vtable) (G_TYPE_CHECK_CLASS_CAST((vtable), AGS_TYPE_SOUND_RESOURCE, AgsSoundResourceInterface)) 35 #define AGS_IS_SOUND_RESOURCE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), AGS_TYPE_SOUND_RESOURCE)) 36 #define AGS_IS_SOUND_RESOURCE_INTERFACE(vtable) (G_TYPE_CHECK_CLASS_TYPE((vtable), AGS_TYPE_SOUND_RESOURCE)) 37 #define AGS_SOUND_RESOURCE_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE((obj), AGS_TYPE_SOUND_RESOURCE, AgsSoundResourceInterface)) 38 39 typedef struct _AgsSoundResource AgsSoundResource; 40 typedef struct _AgsSoundResourceInterface AgsSoundResourceInterface; 41 42 struct _AgsSoundResourceInterface 43 { 44 GTypeInterface ginterface; 45 46 gboolean (*open)(AgsSoundResource *sound_resource, 47 gchar *filename); 48 gboolean (*rw_open)(AgsSoundResource *sound_resource, 49 gchar *filename, 50 guint audio_channels, guint samplerate, 51 gboolean create); 52 53 void (*load)(AgsSoundResource *sound_resource); 54 55 void (*info)(AgsSoundResource *sound_resource, 56 guint *frame_count, 57 guint *loop_start, guint *loop_end); 58 59 void (*set_presets)(AgsSoundResource *sound_resource, 60 guint channels, 61 guint samplerate, 62 guint buffer_size, 63 guint format); 64 void (*get_presets)(AgsSoundResource *sound_resource, 65 guint *channels, 66 guint *samplerate, 67 guint *buffer_size, 68 guint *format); 69 70 /* read sample data */ 71 guint (*read)(AgsSoundResource *sound_resource, 72 void *dbuffer, guint daudio_channels, 73 guint audio_channel, 74 guint frame_count, guint format); 75 76 /* write sample data */ 77 void (*write)(AgsSoundResource *sound_resource, 78 void *sbuffer, guint saudio_channels, 79 guint audio_channel, 80 guint frame_count, guint format); 81 void (*flush)(AgsSoundResource *sound_resource); 82 83 /* position */ 84 void (*seek)(AgsSoundResource *sound_resource, 85 gint64 frame_count, gint whence); 86 87 /* close */ 88 void (*close)(AgsSoundResource *sound_resource); 89 }; 90 91 GType ags_sound_resource_get_type(); 92 93 gboolean ags_sound_resource_open(AgsSoundResource *sound_resource, 94 gchar *filename); 95 gboolean ags_sound_resource_rw_open(AgsSoundResource *sound_resource, 96 gchar *filename, 97 guint audio_channels, guint samplerate, 98 gboolean create); 99 100 void ags_sound_resource_load(AgsSoundResource *sound_resource); 101 102 void ags_sound_resource_info(AgsSoundResource *sound_resource, 103 guint *frame_count, 104 guint *loop_start, guint *loop_end); 105 106 void ags_sound_resource_set_presets(AgsSoundResource *sound_resource, 107 guint channels, 108 guint samplerate, 109 guint buffer_size, 110 guint format); 111 void ags_sound_resource_get_presets(AgsSoundResource *sound_resource, 112 guint *channels, 113 guint *samplerate, 114 guint *buffer_size, 115 guint *format); 116 117 /* read sample data */ 118 guint ags_sound_resource_read(AgsSoundResource *sound_resource, 119 void *dbuffer, guint daudio_channels, 120 guint audio_channel, 121 guint frame_count, guint format); 122 123 /* write sample data */ 124 void ags_sound_resource_write(AgsSoundResource *sound_resource, 125 void *sbuffer, guint saudio_channels, 126 guint audio_channel, 127 guint frame_count, guint format); 128 void ags_sound_resource_flush(AgsSoundResource *sound_resource); 129 130 /* position */ 131 void ags_sound_resource_seek(AgsSoundResource *sound_resource, 132 gint64 frame_count, gint whence); 133 134 /* read audio signal */ 135 GList* ags_sound_resource_read_audio_signal(AgsSoundResource *sound_resource, 136 GObject *soundcard, 137 gint audio_channel); 138 GList* ags_sound_resource_read_wave(AgsSoundResource *sound_resource, 139 GObject *soundcard, 140 gint audio_channel, 141 guint64 x_offset, 142 gdouble delay, guint attack); 143 144 /* close */ 145 void ags_sound_resource_close(AgsSoundResource *sound_resource); 146 147 G_END_DECLS 148 149 #endif /*__AGS_SOUND_RESOURCE_H__*/ 150