BEAST/BSE - Better Audio System and Sound Engine
0.8.2
|
00001 // Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html 00002 #ifndef __GSL_WAVE_CHUNK_H__ 00003 #define __GSL_WAVE_CHUNK_H__ 00004 00005 #include <bse/gsldefs.hh> 00006 #include <bse/gsldatacache.hh> 00007 #include <bse/gsldatahandle.hh> 00008 00009 G_BEGIN_DECLS 00010 00011 /* --- typedefs & structures --- */ 00012 typedef enum /*< skip >*/ 00013 { 00014 GSL_WAVE_LOOP_NONE, 00015 GSL_WAVE_LOOP_JUMP, 00016 GSL_WAVE_LOOP_PINGPONG 00017 } GslWaveLoopType; 00018 typedef struct 00019 { 00020 GslLong first, last, length; 00021 gfloat *mem; 00022 } GslWaveChunkMem; 00023 struct _GslWaveChunk 00024 { 00025 /* wave chunk data residency */ 00026 GslDataCache *dcache; 00027 GslLong length; /* number of per-channel-values * n-channels */ 00028 00029 /* chunk specific parameters */ 00030 gint n_channels; 00031 GslLong n_pad_values; /* guaranteed pad values around blocks */ 00032 GslLong wave_length; /* start + loop duration + end (single channel) */ 00033 00034 /* flags */ 00035 guint pploop_ends_backwards : 1; 00036 guint mini_loop : 1; 00037 00038 /* loop spec */ 00039 GslWaveLoopType loop_type; 00040 GslLong loop_first; 00041 GslLong loop_last; 00042 guint loop_count; 00043 00044 /* preformatted blocks */ 00045 GslWaveChunkMem head; 00046 GslWaveChunkMem enter; 00047 GslWaveChunkMem wrap; 00048 GslWaveChunkMem ppwrap; 00049 GslWaveChunkMem leave; 00050 GslWaveChunkMem tail; 00051 GslLong leave_end_norm; 00052 GslLong tail_start_norm; 00053 00054 GslWaveLoopType requested_loop_type; 00055 GslLong requested_loop_first; 00056 GslLong requested_loop_last; 00057 guint requested_loop_count; 00058 guint ref_count; 00059 guint open_count; 00060 /* cached data handle setup */ 00061 gfloat mix_freq; /* recorded with mix_freq */ 00062 gfloat osc_freq; /* while oscillating at osc_freq */ 00063 gdouble volume_adjust; /* cache of dhandle->xinfo["volume"], only valid when opened */ 00064 gdouble fine_tune_factor; /* cached factor from dhandle->xinfo["fine-tune"], valid when opened */ 00065 }; 00066 struct _GslWaveChunkBlock 00067 { 00068 /* requisition (in) */ 00069 gint play_dir; /* usually +1 */ 00070 GslLong offset; /* requested offset into wave */ 00071 /* result (out) */ 00072 GslLong length; /* resulting signed? length of block in # values */ 00073 gboolean is_silent; /* sample end reached, values are 0 */ 00074 gint dirstride; /* >0 => increment, <0 => decrement */ 00075 gfloat *start; /* first data value location */ 00076 gfloat *end; /* last data value location +1 */ 00077 GslLong next_offset; /* offset of next adjunct block */ 00078 /*< private >*/ 00079 gpointer node; 00080 }; 00081 00082 00083 /* --- prototypes --- */ 00084 void gsl_wave_chunk_use_block (GslWaveChunk *wave_chunk, 00085 GslWaveChunkBlock *block); 00086 void gsl_wave_chunk_unuse_block (GslWaveChunk *wave_chunk, 00087 GslWaveChunkBlock *block); 00088 GslWaveChunk* gsl_wave_chunk_new (GslDataCache *dcache, 00089 gfloat mix_freq, 00090 gfloat osc_freq, 00091 GslWaveLoopType loop_type, 00092 GslLong loop_first, 00093 GslLong loop_end, 00094 guint loop_count); 00095 GslWaveChunk* gsl_wave_chunk_ref (GslWaveChunk *wchunk); 00096 void gsl_wave_chunk_unref (GslWaveChunk *wchunk); 00097 BseErrorType gsl_wave_chunk_open (GslWaveChunk *wchunk); 00098 void gsl_wave_chunk_close (GslWaveChunk *wchunk); 00099 void gsl_wave_chunk_debug_block (GslWaveChunk *wchunk, 00100 GslLong offset, 00101 GslLong length, 00102 gfloat *block); 00103 GslWaveChunk* _gsl_wave_chunk_copy (GslWaveChunk *wchunk); 00104 const gchar* gsl_wave_loop_type_to_string (GslWaveLoopType wave_loop); 00105 GslWaveLoopType gsl_wave_loop_type_from_string (const gchar *string); 00106 00107 00108 G_END_DECLS 00109 00110 #endif /* __GSL_WAVE_CHUNK_H__ */