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_RESAMPLE_UTIL_H__ 21 #define __AGS_RESAMPLE_UTIL_H__ 22 23 #include <glib.h> 24 #include <glib-object.h> 25 26 #include <ags/libags.h> 27 28 #include <ags/audio/ags_audio_buffer_util.h> 29 30 #include <samplerate.h> 31 32 G_BEGIN_DECLS 33 34 #define AGS_TYPE_RESAMPLE_UTIL (ags_resample_util_get_type()) 35 #define AGS_RESAMPLE_UTIL(ptr) ((AgsResampleUtil *)(ptr)) 36 37 #define AGS_RESAMPLE_UTIL_DEFAULT_FORMAT (AGS_SOUNDCARD_SIGNED_16_BIT) 38 #define AGS_RESAMPLE_UTIL_DEFAULT_SAMPLERATE (AGS_SOUNDCARD_DEFAULT_SAMPLERATE) 39 40 #define AGS_RESAMPLE_UTIL_DEFAULT_AUDIO_BUFFER_UTIL_FORMAT (AGS_AUDIO_BUFFER_UTIL_S16) 41 #define AGS_RESAMPLE_UTIL_DEFAULT_TARGET_SAMPLERATE (AGS_SOUNDCARD_DEFAULT_SAMPLERATE) 42 43 typedef struct _AgsResampleUtil AgsResampleUtil; 44 45 struct _AgsResampleUtil 46 { 47 SRC_DATA secret_rabbit; 48 49 gpointer destination; 50 guint destination_stride; 51 52 gpointer source; 53 guint source_stride; 54 55 guint buffer_length; 56 guint format; 57 guint samplerate; 58 59 guint audio_buffer_util_format; 60 61 guint target_samplerate; 62 }; 63 64 GType ags_resample_util_get_type(void); 65 66 AgsResampleUtil* ags_resample_util_alloc(); 67 68 gpointer ags_resample_util_copy(AgsResampleUtil *ptr); 69 void ags_resample_util_free(AgsResampleUtil *ptr); 70 71 /* getter/setter */ 72 gpointer ags_resample_util_get_destination(AgsResampleUtil *resample_util); 73 void ags_resample_util_set_destination(AgsResampleUtil *resample_util, 74 gpointer destination); 75 76 guint ags_resample_util_get_destination_stride(AgsResampleUtil *resample_util); 77 void ags_resample_util_set_destination_stride(AgsResampleUtil *resample_util, 78 guint destination_stride); 79 80 gpointer ags_resample_util_get_source(AgsResampleUtil *resample_util); 81 void ags_resample_util_set_source(AgsResampleUtil *resample_util, 82 gpointer source); 83 84 guint ags_resample_util_get_source_stride(AgsResampleUtil *resample_util); 85 void ags_resample_util_set_source_stride(AgsResampleUtil *resample_util, 86 guint source_stride); 87 88 guint ags_resample_util_get_buffer_length(AgsResampleUtil *resample_util); 89 void ags_resample_util_set_buffer_length(AgsResampleUtil *resample_util, 90 guint buffer_length); 91 92 guint ags_resample_util_get_format(AgsResampleUtil *resample_util); 93 void ags_resample_util_set_format(AgsResampleUtil *resample_util, 94 guint format); 95 96 guint ags_resample_util_get_samplerate(AgsResampleUtil *resample_util); 97 void ags_resample_util_set_samplerate(AgsResampleUtil *resample_util, 98 guint samplerate); 99 100 guint ags_resample_util_get_audio_buffer_util_format(AgsResampleUtil *resample_util); 101 void ags_resample_util_set_audio_buffer_util_format(AgsResampleUtil *resample_util, 102 guint audio_buffer_util_format); 103 104 guint ags_resample_util_get_target_samplerate(AgsResampleUtil *resample_util); 105 void ags_resample_util_set_target_samplerate(AgsResampleUtil *resample_util, 106 guint target_samplerate); 107 108 /* compute */ 109 void ags_resample_util_compute_s8(AgsResampleUtil *resample_util); 110 void ags_resample_util_compute_s16(AgsResampleUtil *resample_util); 111 void ags_resample_util_compute_s24(AgsResampleUtil *resample_util); 112 void ags_resample_util_compute_s32(AgsResampleUtil *resample_util); 113 void ags_resample_util_compute_s64(AgsResampleUtil *resample_util); 114 void ags_resample_util_compute_float(AgsResampleUtil *resample_util); 115 void ags_resample_util_compute_double(AgsResampleUtil *resample_util); 116 void ags_resample_util_compute_complex(AgsResampleUtil *resample_util); 117 118 void ags_resample_util_compute(AgsResampleUtil *resample_util); 119 120 G_END_DECLS 121 122 #endif /*__AGS_RESAMPLE_UTIL_H__*/ 123