| Here is the code of FLsetVal (k-rate)
//////////////// MANUAL
FLsetVal ktrig, kvalue, ihandle
////////////// entry.c
{ "FLsetVal",S(FL_SET_WIDGET_VALUE), 3, "", "kki",
fl_setWidgetValue_set, fl_setWidgetValue },
////////////// widgets.h
typedef struct {
OPDS h;
MYFLT *ktrig, *kvalue, *ihandle;
MYFLT log_base, min, max;
void *WidgAddress, *opcode;
int exp;
} FL_SET_WIDGET_VALUE;
///////////// widgets.cpp
extern "C" void fl_setWidgetValue_set(FL_SET_WIDGET_VALUE *p)
{
ADDR_SET_VALUE v = AddrSetValue[(int) *p->ihandle];
MYFLT /* val = *p->ivalue, */ range, base;
p->max = v.max;
p->min = v.min;
p->WidgAddress = v.WidgAddress;
p->opcode = v.opcode;
switch (v.exponential) {
case LIN_: //linear
p->exp = LIN_;
break;
case EXP_: //exponential
p->exp = EXP_;
range = v.max-v.min;
base = pow(v.max / v.min, 1/range);
//val = (log(val/v.min) / log(base)) ;
p->log_base = log(base);
break;
default:
warning("not implemented yet");
}
}
extern "C" void fl_setWidgetValue(FL_SET_WIDGET_VALUE *p)
{
if(*p->ktrig) {
MYFLT val = *p->kvalue;
switch (p->exp) {
case LIN_: //linear
if (val > p->max) val = p->max;
else if (val < p->min) val = p->min;
break;
case EXP_: //exponential
val = (log(val/p->min) / p->log_base) ;
break;
default:
warning("not implemented yet");
}
Fl_Widget *o = (Fl_Widget *) p->WidgAddress;
FLlock();
((Fl_Valuator *)o)->value(val);
o->do_callback(o, p->opcode);
FLunlock();
#ifdef WIN32
PostMessage(callback_target,0,0,0);
#endif
}
}
jpff@codemist.co.uk wrote:
> I searched the net and eventually found some code for FLsetVal in the
> k-rate case, and modified to Csound5 structure and added it to the
> cvs. In was not in csound4, as the code was never provided. I have
> not checked the implementation as I do not know what to do with it.
> ==John ffitch
>
>
--
Gabriel Maldonado
http://csounds.com/maldonado
-- |