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