aboutsummaryrefslogtreecommitdiff
path: root/src/wrap.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/wrap.c')
-rw-r--r--src/wrap.c31
1 files changed, 18 insertions, 13 deletions
diff --git a/src/wrap.c b/src/wrap.c
index 1ecc7c1..fb1c598 100644
--- a/src/wrap.c
+++ b/src/wrap.c
@@ -1,4 +1,4 @@
-/*
+/*
* wrap: wrap floats between two limits
*
* (c) 1999-2011 IOhannes m zmölnig, forum::für::umläute, institute of electronic music and acoustics (iem)
@@ -7,12 +7,12 @@
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
- *
+ *
* This program 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 General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@@ -28,18 +28,22 @@ typedef struct _wrap {
static void wrap_float(t_wrap *x, t_float f)
{
- if (x->f_lower==x->f_upper)
+ if (x->f_lower==x->f_upper) {
outlet_float(x->x_obj.ob_outlet, x->f_lower);
- else {
+ } else {
t_float modulo = fmod((f-x->f_lower),(x->f_upper-x->f_lower));
- if (modulo<0)modulo+=(x->f_upper-x->f_lower);
-
+ if (modulo<0) {
+ modulo+=(x->f_upper-x->f_lower);
+ }
+
outlet_float(x->x_obj.ob_outlet, x->f_lower+modulo);
}
}
-static void wrap_set(t_wrap *x, t_symbol* UNUSED(s), int argc, t_atom *argv){
+static void wrap_set(t_wrap *x, t_symbol* UNUSED(s), int argc,
+ t_atom *argv)
+{
t_float f1, f2;
- switch (argc){
+ switch (argc) {
case 0:
f1=0.0;
f2=1.0;
@@ -72,11 +76,12 @@ static void wrap_help(t_wrap*x)
post("\n"HEARTSYMBOL" wrap\t\t:: wrap a float between to boundaries");
}
-void wrap_setup(void) {
+void wrap_setup(void)
+{
wrap_class = class_new(gensym("wrap"),
- (t_newmethod)wrap_new,
- 0, sizeof(t_wrap),
- CLASS_DEFAULT, A_GIMME, A_NULL);
+ (t_newmethod)wrap_new,
+ 0, sizeof(t_wrap),
+ CLASS_DEFAULT, A_GIMME, A_NULL);
class_addfloat (wrap_class, wrap_float);
class_addmethod(wrap_class, (t_method)wrap_set, gensym("set"), A_GIMME, 0);