BEAST - Free Software Audio Synthesizer and Tracker  0.9.2
gslwavechunk.hh
Go to the documentation of this file.
1  // Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
2 #ifndef __GSL_WAVE_CHUNK_H__
3 #define __GSL_WAVE_CHUNK_H__
4 
5 #include <bse/gsldefs.hh>
6 #include <bse/gsldatacache.hh>
7 #include <bse/gsldatahandle.hh>
8 
9 G_BEGIN_DECLS
10 
11 /* --- typedefs & structures --- */
12 typedef enum /*< skip >*/
13 {
14  GSL_WAVE_LOOP_NONE,
15  GSL_WAVE_LOOP_JUMP,
16  GSL_WAVE_LOOP_PINGPONG
17 } GslWaveLoopType;
18 typedef struct
19 {
20  GslLong first, last, length;
21  gfloat *mem;
24 {
25  /* wave chunk data residency */
26  GslDataCache *dcache;
27  GslLong length; /* number of per-channel-values * n-channels */
28 
29  /* chunk specific parameters */
30  gint n_channels;
31  GslLong n_pad_values; /* guaranteed pad values around blocks */
32  GslLong wave_length; /* start + loop duration + end (single channel) */
33 
34  /* flags */
35  guint pploop_ends_backwards : 1;
36  guint mini_loop : 1;
37 
38  /* loop spec */
39  GslWaveLoopType loop_type;
40  GslLong loop_first;
41  GslLong loop_last;
42  guint loop_count;
43 
44  /* preformatted blocks */
45  GslWaveChunkMem head;
46  GslWaveChunkMem enter;
47  GslWaveChunkMem wrap;
48  GslWaveChunkMem ppwrap;
49  GslWaveChunkMem leave;
50  GslWaveChunkMem tail;
51  GslLong leave_end_norm;
52  GslLong tail_start_norm;
53 
54  GslWaveLoopType requested_loop_type;
55  GslLong requested_loop_first;
56  GslLong requested_loop_last;
57  guint requested_loop_count;
58  guint ref_count;
59  guint open_count;
60  /* cached data handle setup */
61  gfloat mix_freq; /* recorded with mix_freq */
62  gfloat osc_freq; /* while oscillating at osc_freq */
63  gdouble volume_adjust; /* cache of dhandle->xinfo["volume"], only valid when opened */
64  gdouble fine_tune_factor; /* cached factor from dhandle->xinfo["fine-tune"], valid when opened */
65 };
67 {
68  /* requisition (in) */
69  gint play_dir; /* usually +1 */
70  GslLong offset; /* requested offset into wave */
71  /* result (out) */
72  GslLong length; /* resulting signed? length of block in # values */
73  gboolean is_silent; /* sample end reached, values are 0 */
74  gint dirstride; /* >0 => increment, <0 => decrement */
75  gfloat *start; /* first data value location */
76  gfloat *end; /* last data value location +1 */
77  GslLong next_offset; /* offset of next adjunct block */
78  /*< private >*/
79  gpointer node;
80 };
81 
82 
83 /* --- prototypes --- */
84 void gsl_wave_chunk_use_block (GslWaveChunk *wave_chunk,
85  GslWaveChunkBlock *block);
86 void gsl_wave_chunk_unuse_block (GslWaveChunk *wave_chunk,
87  GslWaveChunkBlock *block);
88 GslWaveChunk* gsl_wave_chunk_new (GslDataCache *dcache,
89  gfloat mix_freq,
90  gfloat osc_freq,
91  GslWaveLoopType loop_type,
92  GslLong loop_first,
93  GslLong loop_end,
94  guint loop_count);
95 GslWaveChunk* gsl_wave_chunk_ref (GslWaveChunk *wchunk);
96 void gsl_wave_chunk_unref (GslWaveChunk *wchunk);
97 Bse::ErrorType gsl_wave_chunk_open (GslWaveChunk *wchunk);
98 void gsl_wave_chunk_close (GslWaveChunk *wchunk);
99 void gsl_wave_chunk_debug_block (GslWaveChunk *wchunk,
100  GslLong offset,
101  GslLong length,
102  gfloat *block);
103 GslWaveChunk* _gsl_wave_chunk_copy (GslWaveChunk *wchunk);
104 const gchar* gsl_wave_loop_type_to_string (GslWaveLoopType wave_loop);
105 GslWaveLoopType gsl_wave_loop_type_from_string (const gchar *string);
106 
107 
108 G_END_DECLS
109 
110 #endif /* __GSL_WAVE_CHUNK_H__ */
Definition: gslwavechunk.hh:66
Definition: gslwavechunk.hh:23
Definition: gslwavechunk.hh:18