summaryrefslogtreecommitdiff
path: root/apps/codecs/dumb/docs/deprec.txt
diff options
context:
space:
mode:
authorMichiel Van Der Kolk <not.valid@email.address>2005-03-17 20:50:03 +0000
committerMichiel Van Der Kolk <not.valid@email.address>2005-03-17 20:50:03 +0000
commit27be5bc72855a0fbbdae230bc144624c9eb85f5e (patch)
treeb553f1321df924c4b744ffcab48dce5f4f081f7d /apps/codecs/dumb/docs/deprec.txt
parent7e7662bb716917ca431204f0113d400c1014f2e8 (diff)
downloadrockbox-27be5bc72855a0fbbdae230bc144624c9eb85f5e.tar.gz
rockbox-27be5bc72855a0fbbdae230bc144624c9eb85f5e.zip
Initial check in dumb 0.9.2 - has a few usages of floating point that should
be rewritten to fixed point. seems to compile cleanly for iriver. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6197 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codecs/dumb/docs/deprec.txt')
-rw-r--r--apps/codecs/dumb/docs/deprec.txt281
1 files changed, 281 insertions, 0 deletions
diff --git a/apps/codecs/dumb/docs/deprec.txt b/apps/codecs/dumb/docs/deprec.txt
new file mode 100644
index 0000000000..88ca2e9fda
--- /dev/null
+++ b/apps/codecs/dumb/docs/deprec.txt
@@ -0,0 +1,281 @@
1/* _______ ____ __ ___ ___
2 * \ _ \ \ / \ / \ \ / / ' ' '
3 * | | \ \ | | || | \/ | . .
4 * | | | | | | || ||\ /| |
5 * | | | | | | || || \/ | | ' ' '
6 * | | | | | | || || | | . .
7 * | |_/ / \ \__// || | |
8 * /_______/ynamic \____/niversal /__\ /____\usic /| . . ibliotheque
9 * / \
10 * / . \
11 * deprec.txt - Deprecated functions, why they / / \ \
12 * were deprecated, and what to do | < / \_
13 * instead. | \/ /\ /
14 * \_ / > /
15 * | \ / /
16 * | ' /
17 * \__/
18 */
19
20
21**********************************************
22*** How the functions have been deprecated ***
23**********************************************
24
25
26 GCC 3.1 and later provide a very useful attribute. The following:
27
28 __attribute__((__deprecated__))
29
30 when written alongside a function prototype, variable declaration or type
31 definition, will result in a warning from GCC if any such part of the API
32 is used. The warning will even tell you where the declaration is, and I
33 have inserted comments by all the deprecated declarations, telling you
34 what to do.
35
36 Unfortunately, GCC 2.x and 3.0.x and MSVC do not have any means to
37 deprecate things. The approach I have taken with these compilers is to
38 avoid prototyping the declared functions. This means you will get
39 warnings and errors, and they won't be very helpful. If your program
40 compiles, you may get strange crashes when you run it, since the compiler
41 needs the declarations in order to make sure function calls are carried
42 out correctly.
43
44 If you would like the deprecated parts of the API to be declared, you can
45 compile with the -DDUMB_DECLARE_DEPRECATED switch for GCC, or the
46 -D"DUMB_DECLARE_DEPRECATED" switch for MSVC. This will be accepted by
47 GCC 3.x but is unnecessary. Use this switch with other people's projects
48 if necessary, but please make the effort to update your own projects to
49 use the new API, as the deprecated parts may be removed in the future.
50
51 The rest of this file explains why some parts of the API were deprecated,
52 and how to adapt your code.
53
54
55**************************************
56*** What happened to DUH_RENDERER? ***
57**************************************
58
59
60 The DUH_RENDERER struct was designed for rendering audio to an end-user
61 format - 8-bit or 16-bit, signed or unsigned, with stereo samples
62 interleaved. In order for it to do this, it was built on top of the
63 hitherto undocumented DUH_SIGRENDERER struct, which rendered audio in
64 DUMB's internal 32-bit signed format with channels (left/right) stored
65 separately. The DUH_RENDERER struct contained a pointer to a
66 DUH_SIGRENDERER struct, along with some other data like the position and
67 number of channels.
68
69 There were then some developments in the API. The DUH_SIGRENDERER struct
70 also stored the position and the number of channels, so I decided to write
71 functions for returning these. Suddenly there was no need to store them in
72 the DUH_RENDERER struct. Before long, the DUH_RENDERER struct contained
73 nothing but a pointer to a DUH_SIGRENDERER.
74
75 I decided it would be a good idea to unify the structs. After all, there
76 really is no difference between the data stored in each, and it would be
77 easy to make duh_render(DUH_RENDERER *dr, ...) and
78 duh_render_signal(DUH_SIGRENDERER *sr, ...) work on the same type of
79 struct. (Note that duh_render_signal() is now deprecated too; see the next
80 section.) It took some deliberation, but I decided I didn't want functions
81 to be #defined (it prevents you from using these names for member
82 functions in C++ classes), and that meant they had to be defined
83 somewhere. Defining redundant functions is a source of bloat, inefficiency
84 and general inelegance. After weighing things up, I decided it was better
85 to deprecate the redundant functions and have people begin to use the more
86 efficient versions, and eventually the redundant functions will be able to
87 be removed.
88
89 So why did I choose to keep the more complicated name, DUH_SIGRENDERER?
90 The reason has to do with what DUMB will become in the future. Signals are
91 an inherent part of the DUH struct and how .duh files will be constructed.
92 It will be possible to have multiple signals in a single DUH struct, and
93 you will be able to choose which one you want to play (this is the 'sig'
94 parameter passed to duh_start_sigrenderer()). But don't hold your breath;
95 we still have a long way to go before .duh files will start to appear...
96
97
98typedef DUH_SIGRENDERER DUH_RENDERER;
99
100 Wherever you are using DUH_RENDERER in your program, simply replace it
101 with DUH_SIGRENDERER. An automated (case-sensitive!) search and replace
102 operation should get this done.
103
104
105DUH_RENDERER *duh_start_renderer(DUH *duh, int n_channels, long pos);
106
107 Use duh_start_sigrenderer() instead. It takes an extra parameter, 'sig',
108 which comes after 'duh' and before 'n_channels'; pass 0 for this. So an
109 example would be, replace:
110
111 sr = duh_start_renderer(duh, 2, 0);
112
113 with:
114
115 sr = duh_start_sigrenderer(duh, 0, 2, 0);
116
117
118int duh_renderer_get_n_channels(DUH_RENDERER *dr);
119long duh_renderer_get_position(DUH_RENDERER *dr);
120void duh_end_renderer(DUH_RENDERER *dr);
121
122 These are easy enough to fix; all you have to do is replace 'renderer'
123 with 'sigrenderer'. So the new functions are:
124
125 int duh_sigrenderer_get_n_channels(DUH_SIGRENDERER *sigrenderer);
126 long duh_sigrenderer_get_position(DUH_SIGRENDERER *sigrenderer);
127 void duh_end_sigrenderer(DUH_SIGRENDERER *sigrenderer);
128
129
130Note that duh_render() has NOT been deprecated. It now uses DUH_SIGRENDERER
131instead of DUH_RENDERER, but its functionality is unchanged. You do not have
132to change calls to this function in any way.
133
134
135DUH_RENDERER *duh_renderer_encapsulate_sigrenderer(DUH_SIGRENDERER *sr);
136DUH_SIGRENDERER *duh_renderer_get_sigrenderer(DUH_RENDERER *dr);
137DUH_SIGRENDERER *duh_renderer_decompose_to_sigrenderer(DUH_RENDERER *dr);
138
139 These functions did not exist in the last release of DUMB, so you are
140 probably not using them, but they are included here for completeness. All
141 you have to do here is unwrap the function, since the structs have been
142 unified. So, for instance, replace:
143
144 duh_renderer_encapsulate_sigrenderer(my_sigrenderer)
145
146 with:
147
148 my_sigrenderer
149
150 Simple!
151
152
153AL_DUH_PLAYER *al_duh_encapsulate_renderer(DUH_RENDERER *dr,
154 float volume, long bufsize, int freq);
155DUH_RENDERER *al_duh_get_renderer(AL_DUH_PLAYER *dp);
156DUH_RENDERER *al_duh_decompose_to_renderer(AL_DUH_PLAYER *dp);
157
158 Again, these functions were not in the last release, so you probably
159 aren't using them. Nevertheless, the fix is simple as always: simply
160 replace 'renderer' with 'sigrenderer'. So the new functions are:
161
162 AL_DUH_PLAYER *al_duh_encapsulate_sigrenderer(DUH_SIGRENDERER *sr,
163 float volume, long bufsize, int freq);
164 DUH_SIGRENDERER *al_duh_get_sigrenderer(AL_DUH_PLAYER *dp);
165 DUH_SIGRENDERER *al_duh_decompose_to_sigrenderer(AL_DUH_PLAYER *dp);
166
167
168*********************
169*** Miscellaneous ***
170*********************
171
172
173long duh_render_signal(DUH_SIGRENDERER *sigrenderer,
174 float volume, float delta,
175 long size, sample_t **samples);
176
177 This function used to return samples in DUMB's internal format. This
178 format consisted of 32-bit integers whose 'normal range' was -0x8000 to
179 0x7FFF (any samples outside this range would have to be clipped when sent
180 to the sound card).
181
182 DUMB's internal format has changed. DUMB still uses 32-bit integers, but
183 now the normal range is -0x800000 to 0x7FFFFF. The lowest eight bits are
184 discarded at the final stage by duh_render() when you ask for 16-bit
185 output. A new function, duh_sigrenderer_get_samples(), will return samples
186 in DUMB's new internal format. It takes exactly the same parameters, so
187 all you have to do to the call itself is change the name; however, you
188 will most likely have to change your code to account for the new
189 normalised range.
190
191 duh_render_signal() will still be able to give you the samples in DUMB's
192 old internal format, but it is inefficient. You should change your code as
193 soon as possible.
194
195
196typedef void (*DUH_SIGRENDERER_CALLBACK)(void *data, sample_t **samples,
197 int n_channels, long length);
198
199void duh_sigrenderer_set_callback(DUH_SIGRENDERER *sigrenderer,
200 DUH_SIGRENDERER_CALLBACK callback, void *data);
201
202 This callback was intended to allow you to analyse the output. It was by
203 no means intended to let you modify the output. For this reason, the names
204 have been changed to DUH_SIGRENDERER_ANALYSER_CALLBACK and
205 duh_sigrenderer_set_analyser_callback, and the 'samples' parameter to your
206 callback should now be specified as follows:
207
208 const sample_t *const *samples
209
210 The first 'const' indicates that you must not modify the samples. The
211 second indicates that you must not modify the pointers to each channel.
212
213 There is a second reason why this change was necessary, and it is the one
214 described further up for duh_render_signal()'s entry: the format in which
215 the samples themselves are stored has changed. They are 256 times as
216 large, with a normal range from -0x800000 to 0x7FFFFF. You will most
217 likely need to change your code to account for this.
218
219 If you try to call the old function, it will print a message to stderr
220 directing you to this file, and it will not install the callback. You
221 shouldn't be able to get this far without a compiler warning (or, if you
222 don't have GCC 3.1 or later, some compiler errors).
223
224 If you wanted to use this callback to apply a DSP effect, don't worry;
225 there is a better way of doing this. It is undocumented, so contact me
226 and I shall try to help. Contact details are at the bottom of this file.
227
228 For reference, here are the new definitions:
229
230 typedef void (*DUH_SIGRENDERER_ANALYSER_CALLBACK)(void *data,
231 const sample_t *const *samples, int n_channels, long length);
232
233 void duh_sigrenderer_set_analyser_callback(DUH_SIGRENDERER *sigrenderer,
234 DUH_SIGRENDERER_ANALYSER_CALLBACK callback, void *data);
235
236
237int dumb_resampling_quality;
238
239 This variable has changed meaning. It used to hold a value from 0 to 4,
240 whose meaning was as follows:
241
242 0 - aliasing
243 1,2 - linear interpolation
244 3 - quadratic interpolation
245 4 - cubic interpolation
246
247 0,1 - always use a straightforward interpolation algorithm
248 2,3,4 - when decimating (increasing the pitch), use a linear average
249 algorithm designed to reduce frequencies that would otherwise
250 reflect off the Nyquist
251
252 Now the variable only holds values from 0 to 2, and these values have
253 preprocessor constants associated with them. The somewhat inappropriate
254 quadratic interpolation has been removed. The linear average algorithm has
255 also been removed, and may or may not come back; there are probably more
256 efficient ways of achieving the same effect, which I shall be
257 investigating in the future.
258
259 This change will have hardly any noticeable effect on existing programs.
260 Levels 2, 3 and 4 used considerably more processor time because of the
261 linear average algorithm. Likewise, Level 2 in the new scheme (cubic) uses
262 considerably more processor time than Levels 1 and 0, and Levels 3 and 4
263 will behave identically to Level 2.
264
265
266******************
267*** Conclusion ***
268******************
269
270
271"I conclude that... DUMB is the bestest music player in the world because...
272Complete this sentence in fifteen words or fewer... D'OH!"
273
274The preceding conclusion formerly appeared in dumb.txt, and is deprecated
275because it's lame.
276
277
278Ben Davis
279entheh@users.sf.net
280IRC EFnet #dumb
281See readme.txt for details on using IRC.