zynaddsubfx

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

Fl_Osc_Numeric_Input.cpp (1136B)


      1 /*
      2   ZynAddSubFX - a software synthesizer
      3 
      4   Fl_Osc_Numeric_Input.cpp - OSC Based Numeric Input
      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 <stdlib.h>
     13 #include "Fl_Osc_Numeric_Input.H"
     14 
     15 Fl_Osc_Numeric_Input::Fl_Osc_Numeric_Input(int X, int Y, int W, int H, const char *label)
     16     :Fl_Input(X,Y,W,H, label), Fl_Osc_Widget(this)
     17 {
     18     callback(numeric_callback);
     19 }
     20 
     21 Fl_Osc_Numeric_Input::~Fl_Osc_Numeric_Input(void)
     22 {}
     23 
     24 void Fl_Osc_Numeric_Input::init(const char *path)
     25 {
     26     ext = path;
     27     oscRegister(path);
     28 }
     29 
     30 void Fl_Osc_Numeric_Input::OSC_value(float f)
     31 {
     32     OSC_value((int)f);
     33 }
     34 
     35 void Fl_Osc_Numeric_Input::OSC_value(int i)
     36 {
     37     char buf[128];
     38     snprintf(buf, 128, "%d", i);
     39     value(buf);
     40 }
     41 
     42 void Fl_Osc_Numeric_Input::numeric_callback(Fl_Widget *w)
     43 {
     44     auto &ww = *(Fl_Osc_Numeric_Input *)w;
     45     int x = atoi(ww.value());
     46     if(x)
     47         ww.oscWrite(ww.ext, "i", x);
     48 }