Debian Codegraph @

src/mixer2/sleid0r/sleid0r_push-left.c

raw symbols SCIP
1 /*
2 Copyright (C) 2013 Vadim Druzhin <[email protected]>
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
8
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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 #include <stdlib.h>
19 #include <stdint.h>
20 #include <string.h>
21 #include <frei0r.h>
22
23 typedef struct instance_s
24 {
25 unsigned w;
26 unsigned h;
27 double pos;
28 } instance_t;
29
30 int f0r_init(void)
31 {
32 return 1;
33 }
34
35 void f0r_deinit(void) {}
36
37 void f0r_get_plugin_info(f0r_plugin_info_t *info)
38 {
39 info->name = "push-left";
40 info->author = "Vadim Druzhin";
41 info->plugin_type = F0R_PLUGIN_TYPE_MIXER2;
42 info->color_model = F0R_COLOR_MODEL_PACKED32;
43 info->frei0r_version = FREI0R_MAJOR_VERSION;
44 info->major_version = 0;
45 info->minor_version = 1;
46 info->num_params = 1;
47 info->explanation = "Push from right to left";
48 }
49
50 void f0r_get_param_info(f0r_param_info_t *info, int index)
51 {
52 if(0 == index)
53 {
54 info->name = "position";
55 info->type = F0R_PARAM_DOUBLE;
56 info->explanation = "Push position";
57 }
58 }
59
60 f0r_instance_t f0r_construct(unsigned width, unsigned height)
61 {
62 instance_t *inst;
63
64 inst = calloc(1, sizeof(*inst));
65 if(NULL == inst)
66 return NULL;
67
68 inst->w = width;
69 inst->h = height;
70 inst->pos = 0.0;
71
72 return inst;
73 }
74
75 void f0r_destruct(f0r_instance_t inst)
76 {
77 free(inst);
78 }
79
80 void f0r_set_param_value(f0r_instance_t instance, f0r_param_t param, int param_index)
81 {
82 instance_t *inst = instance;
83
84 if(0 == param_index)
85 inst->pos = *(f0r_param_double *)param;
86 }
87
88 void f0r_get_param_value(f0r_instance_t instance, f0r_param_t param, int param_index)
89 {
90 instance_t *inst = instance;
91
92 if(0 == param_index)
93 *(f0r_param_double *)param = inst->pos;
94 }
95
96 void f0r_update2(
97 f0r_instance_t instance,
98 double time,
99 const uint32_t* inframe1,
100 const uint32_t* inframe2,
101 const uint32_t* inframe3,
102 uint32_t* outframe
103 )
104 {
105 instance_t *inst = instance;
106 unsigned y, off;
107 double t;
108
109 (void)time; /* Unused */
110 (void)inframe3; /* Unused */
111
112 if(inst->pos < 0.5)
113 {
114 t = inst->pos;
115 t = t * t * 2.0;
116 }
117 else
118 {
119 t = 1.0 - inst->pos;
120 t = 1.0 - t * t * 2.0;
121 }
122 off = (unsigned)(inst->w * t + 0.5);
123
124 for(y = 0; y < inst->h; ++y)
125 {
126 memcpy(outframe + inst->w * y, inframe1 + inst->w * y + off,
127 (inst->w - off) * sizeof(*outframe));
128 memcpy(outframe + inst->w * y + inst->w - off, inframe2 + inst->w * y,
129 off * sizeof(*outframe));
130 }
131 }
132
133
134