1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
/* GSL - Generic Sound Layer
* Copyright (C) 2001 Tim Janik
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __GSL_WAVE_CHUNK_H__
#define __GSL_WAVE_CHUNK_H__
#include <gsl/gsldefs.h>
#include <gsl/gsldatacache.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/* --- typedefs & structures --- */
typedef enum /*< skip >*/
{
GSL_WAVE_LOOP_NONE,
GSL_WAVE_LOOP_JUMP,
GSL_WAVE_LOOP_PINGPONG
} GslWaveLoopType;
typedef struct
{
GslLong start, end, length;
gfloat *mem;
} GslWaveChunkMem;
struct _GslWaveChunk
{
/* wave chunk data residency */
GslDataCache *dcache;
GslLong length; /* number of per-channel-values * n-channels */
/* chunk specific parameters */
gint n_channels;
GslLong n_pad_values; /* guaranteed pad values around blocks */
GslLong wave_length; /* start + loop duration + end (single channel) */
/* flags */
guint pploop_ends_backwards : 1;
guint mini_loop : 1;
/* loop spec */
GslWaveLoopType loop_type;
GslLong loop_first;
GslLong loop_last;
guint loop_count;
/* preformatted blocks */
GslWaveChunkMem head;
GslWaveChunkMem enter;
GslWaveChunkMem wrap;
GslWaveChunkMem ppwrap;
GslWaveChunkMem leave;
GslWaveChunkMem tail;
GslLong leave_end_norm;
GslLong tail_start_norm;
GslWaveLoopType requested_loop_type;
GslLong requested_loop_first;
GslLong requested_loop_last;
guint requested_loop_count;
guint ref_count;
guint open_count;
/* legacy */
gfloat mix_freq; /* recorded with mix_freq */
gfloat osc_freq; /* while oscillating at osc_freq */
};
struct _GslWaveChunkBlock
{
/* requisition (in) */
gint play_dir; /* usually +1 */
GslLong offset; /* requested offset into wave */
/* result (out) */
GslLong length; /* resulting signed? length of block in # values */
gboolean is_silent; /* sample end reached, values are 0 */
gint dirstride; /* >0 => increment, <0 => decrement */
gfloat *start; /* first data value location */
gfloat *end; /* last data value location +1 */
GslLong next_offset; /* offset of next adjunct block */
/*< private >*/
gpointer node;
};
/* --- prototypes --- */
void gsl_wave_chunk_use_block (GslWaveChunk *wave_chunk,
GslWaveChunkBlock *block);
void gsl_wave_chunk_unuse_block (GslWaveChunk *wave_chunk,
GslWaveChunkBlock *block);
GslWaveChunk* gsl_wave_chunk_new (GslDataCache *dcache,
gfloat osc_freq,
gfloat mix_freq,
GslWaveLoopType loop_type,
GslLong loop_first,
GslLong loop_end,
guint loop_count);
GslWaveChunk* gsl_wave_chunk_ref (GslWaveChunk *wchunk);
void gsl_wave_chunk_unref (GslWaveChunk *wchunk);
GslErrorType gsl_wave_chunk_open (GslWaveChunk *wchunk);
void gsl_wave_chunk_close (GslWaveChunk *wchunk);
void gsl_wave_chunk_debug_block (GslWaveChunk *wchunk,
GslLong offset,
GslLong length,
gfloat *block);
GslWaveChunk* _gsl_wave_chunk_copy (GslWaveChunk *wchunk);
const gchar* gsl_wave_loop_type_to_string (GslWaveLoopType wave_loop);
GslWaveLoopType gsl_wave_loop_type_from_string (const gchar *string);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GSL_WAVE_CHUNK_H__ */
|