1 /* gAlan - Graphical Audio Language
2 * Copyright (C) 1999 Tony Garnock-Jones
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 #include "generator.h"
34 #define GENERATOR_CLASS_NAME "reverse"
35 #define GENERATOR_CLASS_PATH "Timebase/Reverse"
40 PRIVATE SAMPLETIME
output_range(Generator
*g
, OutputSignalDescriptor
*sig
) {
41 return gen_get_randomaccess_input_range(g
, SIG_INPUT
, 0);
44 PRIVATE gboolean
output_generator(Generator
*g
, OutputSignalDescriptor
*sig
,
45 SAMPLETIME offset
, SAMPLE
*buf
, int buflen
) {
47 SAMPLETIME len
= gen_get_randomaccess_input_range(g
, SIG_INPUT
, 0);
48 int inbuflen
= buflen
;
52 inoffset
= len
- offset
- buflen
;
54 if (inoffset
<= -buflen
)
58 memset(buf
, 0, -inoffset
* sizeof(SAMPLE
));
59 inbuflen
+= inoffset
; /* *decrease* inbuflen */
60 inbuf
+= (-inoffset
); /* *advance* inbuf */
64 if (!gen_read_randomaccess_input(g
, SIG_INPUT
, 0, inoffset
, inbuf
, inbuflen
))
67 for (i
= 0, j
= (buflen
- 1); i
< j
; i
++, j
--) {
76 PRIVATE InputSignalDescriptor input_sigs
[] = {
77 { "Input", SIG_FLAG_RANDOMACCESS
},
81 PRIVATE OutputSignalDescriptor output_sigs
[] = {
82 { "Output", SIG_FLAG_RANDOMACCESS
, { NULL
, { output_range
, output_generator
} } },
86 PRIVATE ControlDescriptor controls
[] = {
87 /* { kind, name, min,max,step,page, size,editable, is_dst,queue_number,
88 init,destroy,refresh,refresh_data }, */
89 { CONTROL_KIND_NONE
, }
92 PRIVATE
void setup_class(void) {
93 GeneratorClass
*k
= gen_new_generatorclass(GENERATOR_CLASS_NAME
, FALSE
, 0, 0,
94 input_sigs
, output_sigs
, controls
,
95 NULL
, NULL
, NULL
, NULL
);
97 gencomp_register_generatorclass(k
, FALSE
, GENERATOR_CLASS_PATH
,
102 PUBLIC
void init_plugin(void) {