zynaddsubfx

ZynAddSubFX open source synthesizer
Log | Files | Refs | Submodules | LICENSE

Fl_Osc_Roller.cpp (1276B)


      1 /*
      2   ZynAddSubFX - a software synthesizer
      3 
      4   Fl_Osc_Roller.cpp - OSC Powered Roller
      5   Copyright (C) 2016 Mark McCurry
      6 
      7   This program is free software; you can redistribute it and/or
      8   modify it under the terms of the GNU General Public License
      9   as published by the Free Software Foundation; either version 2
     10   of the License, or (at your option) any later version.
     11 */
     12 #include "Fl_Osc_Roller.H"
     13 #include <cstdlib>
     14 #include <cstring>
     15 #include <cmath>
     16 #include <cassert>
     17 #include <sstream>
     18 
     19 static void callback_fn_roller(Fl_Widget *w, void *)
     20 {
     21     ((Fl_Osc_Roller*)w)->cb();
     22 }
     23 
     24 Fl_Osc_Roller::Fl_Osc_Roller(int X, int Y, int W, int H, const char *label)
     25     :Fl_Roller(X,Y,W,H, label), Fl_Osc_Widget(this)
     26 {
     27     Fl_Roller::callback(callback_fn_roller);
     28     bounds(0.0, 127.0f);
     29 }
     30 
     31 
     32 void Fl_Osc_Roller::init(const char *path)
     33 {
     34     name = path;
     35     oscRegister(path);
     36 };
     37 
     38 Fl_Osc_Roller::~Fl_Osc_Roller(void)
     39 {}
     40 
     41 void Fl_Osc_Roller::callback(Fl_Callback *cb, void *p)
     42 {
     43     cb_data.first = cb;
     44     cb_data.second = p;
     45 }
     46 
     47 void Fl_Osc_Roller::OSC_value(char v)
     48 {
     49     value(v);
     50 }
     51 
     52 void Fl_Osc_Roller::update(void)
     53 {
     54     oscWrite(name);
     55 }
     56 
     57 void Fl_Osc_Roller::cb(void)
     58 {
     59     oscWrite(name, "i", (int)value());
     60 
     61     if(cb_data.first)
     62         cb_data.first(this, cb_data.second);
     63 }