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_FILE_H__ 21 #define __AGS_AUDIO_FILE_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_FILE (ags_audio_file_get_type()) 31 #define AGS_AUDIO_FILE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), AGS_TYPE_AUDIO_FILE, AgsAudioFile)) 32 #define AGS_AUDIO_FILE_CLASS(class) (G_TYPE_CHECK_CLASS_CAST((class), AGS_TYPE_AUDIO_FILE, AgsAudioFileClass)) 33 #define AGS_IS_AUDIO_FILE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), AGS_TYPE_AUDIO_FILE)) 34 #define AGS_IS_AUDIO_FILE_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE((class), AGS_TYPE_AUDIO_FILE)) 35 #define AGS_AUDIO_FILE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), AGS_TYPE_AUDIO_FILE, AgsAudioFileClass)) 36 37 #define AGS_AUDIO_FILE_GET_OBJ_MUTEX(obj) (&(((AgsAudioFile *) obj)->obj_mutex)) 38 39 typedef struct _AgsAudioFile AgsAudioFile; 40 typedef struct _AgsAudioFileClass AgsAudioFileClass; 41 42 /** 43 * AgsAudioFileFlags: 44 * @AGS_AUDIO_FILE_ADDED_TO_REGISTRY: the audio file was added to registry, see #AgsConnectable::add_to_registry() 45 * @AGS_AUDIO_FILE_CONNECTED: indicates the audio file was connected by calling #AgsConnectable::connect() 46 * 47 * Enum values to control the behavior or indicate internal state of #AgsAudioFile by 48 * enable/disable as flags. 49 */ 50 typedef enum{ 51 AGS_AUDIO_FILE_ADDED_TO_REGISTRY = 1, 52 AGS_AUDIO_FILE_CONNECTED = 1 << 1, 53 }AgsAudioFileFlags; 54 55 struct _AgsAudioFile 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 69 guint file_audio_channels; 70 guint file_samplerate; 71 guint file_frame_count; 72 73 guint samplerate; 74 guint buffer_size; 75 guint format; 76 77 gint audio_channel; 78 79 GObject *sound_resource; 80 81 GList *audio_signal; 82 GList *wave; 83 }; 84 85 struct _AgsAudioFileClass 86 { 87 GObjectClass gobject; 88 }; 89 90 GType ags_audio_file_get_type(); 91 92 gboolean ags_audio_file_test_flags(AgsAudioFile *audio_file, guint flags); 93 void ags_audio_file_set_flags(AgsAudioFile *audio_file, guint flags); 94 void ags_audio_file_unset_flags(AgsAudioFile *audio_file, guint flags); 95 96 gboolean ags_audio_file_check_suffix(gchar *filename); 97 98 /* fields */ 99 void ags_audio_file_add_audio_signal(AgsAudioFile *audio_file, GObject *audio_signal); 100 void ags_audio_file_remove_audio_signal(AgsAudioFile *audio_file, GObject *audio_signal); 101 102 void ags_audio_file_add_wave(AgsAudioFile *audio_file, GObject *wave); 103 void ags_audio_file_remove_wave(AgsAudioFile *audio_file, GObject *wave); 104 105 /* IO functions */ 106 gboolean ags_audio_file_open(AgsAudioFile *audio_file); 107 gboolean ags_audio_file_open_from_data(AgsAudioFile *audio_file, gchar *data); 108 gboolean ags_audio_file_rw_open(AgsAudioFile *audio_file, 109 gboolean create); 110 void ags_audio_file_close(AgsAudioFile *audio_file); 111 112 void* ags_audio_file_read(AgsAudioFile *audio_file, 113 guint audio_channel, 114 guint format, 115 GError **error); 116 void ags_audio_file_read_audio_signal(AgsAudioFile *audio_file); 117 void ags_audio_file_read_wave(AgsAudioFile *audio_file, 118 guint64 x_offset, 119 gdouble delay, guint attack); 120 void ags_audio_file_seek(AgsAudioFile *audio_file, guint frames, gint whence); 121 void ags_audio_file_write(AgsAudioFile *audio_file, 122 void *buffer, guint buffer_size, 123 guint format); 124 void ags_audio_file_flush(AgsAudioFile *audio_file); 125 126 /* instantiate */ 127 AgsAudioFile* ags_audio_file_new(gchar *filename, 128 GObject *soundcard, 129 gint audio_channel); 130 131 G_END_DECLS 132 133 #endif /*__AGS_AUDIO_FILE_H__*/ 134