LMMS
Loading...
Searching...
No Matches
Fl_Osc_Counter.cpp
Go to the documentation of this file.
1/*
2 ZynAddSubFX - a software synthesizer
3
4 Fl_Osc_Counter.cpp - OSC Powered Counter
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_Counter.H"
13
14static void callback_fn_counter(Fl_Widget *w, void *)
15{
16 ((Fl_Osc_Counter*)w)->cb();
17}
18
19Fl_Osc_Counter::Fl_Osc_Counter(int x, int y, int w, int h, const char *label)
20 :Fl_Counter(x,y,w,h,label), Fl_Osc_Widget(this), offset(0)
21{
22 Fl_Counter::callback(callback_fn_counter);
23}
24
26{
28}
29
30void Fl_Osc_Counter::init(const char *path_, char type_, int display_off)
31{
32 offset = display_off;
33 oscRegister(path_);
34 ext = path_;
35 cb_type = type_;
36}
37
38void Fl_Osc_Counter::callback(Fl_Callback *cb, void *p)
39{
40 cb_data.first = cb;
41 cb_data.second = p;
42}
43
45{
46 value(v+offset);
47}
48
50{
51 value(v+offset);
52}
53
55{
56 assert(osc);
57
58 if(cb_type == 'c') {
59 fprintf(stderr, "invalid `c' from counter %s%s, using `i'\n", loc.c_str(), ext.c_str());
60 oscWrite(ext, "i", (int)(value()-offset));
61 }
62 else
63 oscWrite(ext, "i", (int)(value()-offset));
64
65 if(cb_data.first)
66 cb_data.first(this, cb_data.second);
67}
static void callback_fn_counter(Fl_Widget *w, void *)
Definition Fl_Osc_Counter.cpp:14
assert(0)
Definition Fl_Osc_Counter.H:18
void init(const char *path_, char type_='i', int display_off=0)
Definition Fl_Osc_Counter.cpp:30
void cb(void)
Definition Fl_Osc_Counter.cpp:54
char cb_type
Definition Fl_Osc_Counter.H:31
void callback(Fl_Callback *cb, void *p=NULL)
Definition Fl_Osc_Counter.cpp:38
std::pair< Fl_Callback *, void * > cb_data
Definition Fl_Osc_Counter.H:34
void update(void)
Definition Fl_Osc_Counter.cpp:25
void OSC_value(char)
Definition Fl_Osc_Counter.cpp:49
int offset
Definition Fl_Osc_Counter.H:33
Fl_Osc_Counter(int x, int y, int w, int h, const char *label=0)
Definition Fl_Osc_Counter.cpp:19
Fl_Osc_Interface * osc
Definition Fl_Osc_Widget.H:65
std::string ext
Definition Fl_Osc_Widget.H:64
Fl_Osc_Widget(void)
Definition Fl_Osc_Widget.cpp:16
std::string loc
Definition Fl_Osc_Widget.H:62
void oscRegister(const char *path)
Definition Fl_Osc_Widget.cpp:91
void oscWrite(std::string path, const char *args,...)
Definition Fl_Osc_Widget.cpp:60
UINT_D64 w
Definition inflate.c:942
int y
Definition inflate.c:1588
unsigned v[N_MAX]
Definition inflate.c:1584
unsigned x[BMAX+1]
Definition inflate.c:1586
static PuglViewHint int value
Definition pugl.h:1708
uch * p
Definition crypt.c:594
uch h[RAND_HEAD_LEN]
Definition crypt.c:459