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_AUDIO_CONTAINER_H__ 21 #define __AGS_AUDIO_CONTAINER_H__ 22 23 #include <glib.h> 24 #include <glib-object.h> 25 26 #include <ags/libags.h> 27 28 G_BEGIN_DECLS 29 30 #define AGS_TYPE_AUDIO_CONTAINER (ags_audio_container_get_type()) 31 #define AGS_AUDIO_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), AGS_TYPE_AUDIO_CONTAINER, AgsAudioContainer)) 32 #define AGS_AUDIO_CONTAINER_CLASS(class) (G_TYPE_CHECK_CLASS_CAST((class), AGS_TYPE_AUDIO_CONTAINER, AgsAudioContainerClass)) 33 #define AGS_IS_AUDIO_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), AGS_TYPE_AUDIO_CONTAINER)) 34 #define AGS_IS_AUDIO_CONTAINER_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE((class), AGS_TYPE_AUDIO_CONTAINER)) 35 #define AGS_AUDIO_CONTAINER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), AGS_TYPE_AUDIO_CONTAINER, AgsAudioContainerClass)) 36 37 #define AGS_AUDIO_CONTAINER_GET_OBJ_MUTEX(obj) (&(((AgsAudioContainer *) obj)->obj_mutex)) 38 39 typedef struct _AgsAudioContainer AgsAudioContainer; 40 typedef struct _AgsAudioContainerClass AgsAudioContainerClass; 41 42 /** 43 * AgsAudioContainerFlags: 44 * @AGS_AUDIO_CONTAINER_ADDED_TO_REGISTRY: the audio container was added to registry, see #AgsConnectable::add_to_registry() 45 * @AGS_AUDIO_CONTAINER_CONNECTED: indicates the audio container was connected by calling #AgsConnectable::connect() 46 * 47 * Enum values to control the behavior or indicate internal state of #AgsAudioContainer by 48 * enable/disable as flags. 49 */ 50 typedef enum{ 51 AGS_AUDIO_CONTAINER_ADDED_TO_REGISTRY = 1, 52 AGS_AUDIO_CONTAINER_CONNECTED = 1 << 1, 53 }AgsAudioContainerFlags; 54 55 struct _AgsAudioContainer 56 { 57 GObject gobject; 58 59 guint flags; 60 61 GRecMutex obj_mutex; 62 63 AgsUUID *uuid; 64 65 GObject *soundcard; 66 67 gchar *filename; 68 gchar *preset; 69 gchar *instrument; 70 gchar *sample; 71 72 guint file_audio_channels; 73 guint file_samplerate; 74 guint file_frame_count; 75 76 guint samplerate; 77 guint buffer_size; 78 guint format; 79 80 gint audio_channel; 81 82 GObject *sound_container; 83 84 GList *audio_signal; 85 GList *wave; 86 }; 87 88 struct _AgsAudioContainerClass 89 { 90 GObjectClass gobject; 91 }; 92 93 GType ags_audio_container_get_type(); 94 95 gboolean ags_audio_container_test_flags(AgsAudioContainer *audio_container, guint flags); 96 void ags_audio_container_set_flags(AgsAudioContainer *audio_container, guint flags); 97 void ags_audio_container_unset_flags(AgsAudioContainer *audio_container, guint flags); 98 99 gboolean ags_audio_container_check_suffix(gchar *filename); 100 101 GList* ags_audio_container_find_sound_resource(AgsAudioContainer *audio_container, 102 gchar *preset, 103 gchar *instrument, 104 gchar *sample); 105 106 /* fields */ 107 void ags_audio_container_add_audio_signal(AgsAudioContainer *audio_container, GObject *audio_signal); 108 void ags_audio_container_remove_audio_signal(AgsAudioContainer *audio_container, GObject *audio_signal); 109 110 void ags_audio_container_add_wave(AgsAudioContainer *audio_container, GObject *wave); 111 void ags_audio_container_remove_wave(AgsAudioContainer *audio_container, GObject *wave); 112 113 /* IO functions */ 114 gboolean ags_audio_container_open(AgsAudioContainer *audio_container); 115 gboolean ags_audio_container_open_from_data(AgsAudioContainer *audio_container, gchar *data); 116 gboolean ags_audio_container_rw_open(AgsAudioContainer *audio_container, 117 gboolean create); 118 void ags_audio_container_close(AgsAudioContainer *audio_container); 119 120 void* ags_audio_container_read(AgsAudioContainer *audio_container, 121 guint audio_channel, 122 guint format, 123 GError **error); 124 GList* ags_audio_container_read_audio_signal(AgsAudioContainer *audio_container); 125 GList* ags_audio_container_read_wave(AgsAudioContainer *audio_container, 126 guint64 x_offset, 127 gdouble delay, guint attack); 128 void ags_audio_container_seek(AgsAudioContainer *audio_container, guint frames, gint whence); 129 void ags_audio_container_write(AgsAudioContainer *audio_container, 130 void *buffer, guint buffer_size, 131 guint format); 132 void ags_audio_container_flush(AgsAudioContainer *audio_container); 133 134 /* instantiate */ 135 AgsAudioContainer* ags_audio_container_new(gchar *filename, 136 gchar *preset, 137 gchar *instrument, 138 gchar *sample, 139 GObject *soundcard, 140 gint audio_channel); 141 142 G_END_DECLS 143 144 #endif /*__AGS_AUDIO_CONTAINER_H__*/ 145