commit 59cd9466ab93dd2cbc2de6a5d59cb2eb861ef692
parent 78bbd632c964f29fde5d777596307efd4d6126e5
Author: paulnasca <paulnasca>
Date: Sat, 13 Dec 2003 22:28:13 +0000
Added LFO frequency randomness parameter
Diffstat:
9 files changed, 61 insertions(+), 19 deletions(-)
diff --git a/ChangeLog b/ChangeLog
@@ -503,3 +503,4 @@
05 Dec 2003 - Facute cateva modificari la jack
08 Dec 2003 - Inceput sa incerc sa fac rt-safe sub jack, dar in stadiul actual suportul jack este nefunctional
11 Dec 2003 - Adaugat aleatorism la amplitudinile armonicelor
+13 Dec 2003 - Adaugat LFO frequency randomness
diff --git a/examples/analogpiano.mas_zyn b/examples/analogpiano.mas_zyn
Binary files differ.
diff --git a/src/Output/JACKaudiooutput.C b/src/Output/JACKaudiooutput.C
@@ -99,6 +99,11 @@ void JACKaudiooutputinit(Master *master_){
void *thread_blocked(void *arg){
int datasize=SOUND_BUFFER_SIZE*sizeof (REALTYPE);
+
+ //try to get realtime
+ sched_param sc;
+ sc.sched_priority=50;
+ int err=sched_setscheduler(0,SCHED_FIFO,&sc);
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS,NULL);
pthread_mutex_lock(&zyn_thread_lock);
@@ -125,8 +130,29 @@ int jackprocess(jack_nframes_t nframes,void *arg){
jack_default_audio_sample_t *outr=(jack_default_audio_sample_t *) jack_port_get_buffer (outport_right, nframes);
int datasize=nframes*sizeof (REALTYPE);
-// printf("%d\n",nframes);
- if (jack_ringbuffer_read_space(rb)>=datasize){
+ int incoming_datasize=SOUND_BUFFER_SIZE*sizeof (REALTYPE);
+ int data_read=0;
+
+
+ if (jack_ringbuffer_read_space(rb)>=(2*incoming_datasize)){
+ if (datasize>incoming_datasize){
+ data_read=0;
+ while (data_read < datasize){
+ jack_ringbuffer_read(rb, (char *) outl+data_read,datasize);
+ jack_ringbuffer_read(rb, (char *) outr+data_read,datasize);
+ data_read+=incoming_datasize;
+ };
+ } else if (datasize==incoming_datasize){
+ jack_ringbuffer_read(rb, (char *) outl,datasize);
+ jack_ringbuffer_read(rb, (char *) outr,datasize);
+ } else {
+ };
+ } else {//the ringbuffer is empty or there are too small amount of samples in it
+ for (int i=0;i<nframes;i++){
+ outl[i]=0.0;outr[i]=0.0;
+ };
+ };
+/* if (jack_ringbuffer_read_space(rb)>=datasize){
jack_ringbuffer_read(rb, (char *) outl,datasize);
jack_ringbuffer_read(rb, (char *) outr,datasize);
} else {//the ringbuffer is empty or there are too small amount of samples in it
@@ -134,7 +160,7 @@ int jackprocess(jack_nframes_t nframes,void *arg){
outl[i]=0.0;outr[i]=0.0;
};
};
-
+*/
if (pthread_mutex_trylock(&zyn_thread_lock)==0){
pthread_cond_signal(&more_data);
pthread_mutex_unlock(&zyn_thread_lock);
diff --git a/src/Params/LFOParams.C b/src/Params/LFOParams.C
@@ -35,6 +35,7 @@ LFOParams::LFOParams(char Pfreq_,char Pintensity_,char Pstartphase_, char PLFOty
Prandomness=Prandomness_;
Pdelay=Pdelay_;
Pcontinous=Pcontinous_;
+ Pfreqrand=0;
fel=fel_;
time=0;
};
@@ -79,6 +80,8 @@ void LFOParams::saveloadbuf(Buffer *buf){
break;
case 0x86: buf->rwbytepar(n,&Pcontinous);
break;
+ case 0x87: buf->rwbytepar(n,&Pfreqrand);
+ break;
};
};
diff --git a/src/Params/LFOParams.h b/src/Params/LFOParams.h
@@ -38,6 +38,7 @@ class LFOParams{
unsigned char Pstartphase;// start phase (0=random)
unsigned char PLFOtype; // LFO typpe (sin,triangle,square,ramp,...)
unsigned char Prandomness;// randomness (0=off)
+ unsigned char Pfreqrand;// frequency randomness (0=off)
unsigned char Pdelay; // delay (0=off)
unsigned char Pcontinous; // 1 if LFO is continous
diff --git a/src/Synth/LFO.C b/src/Synth/LFO.C
@@ -46,6 +46,8 @@ LFO::LFO(LFOParams *lfopars){
lfornd=lfopars->Prandomness/127.0;
if (lfornd<0.0) lfornd=0.0; else if (lfornd>1.0) lfornd=1.0;
+ lfofreqrnd=pow(lfopars->Pfreqrand/127.0,2.0)*2.0*4.0;
+
switch (lfopars->fel){
case 1:lfointensity=lfopars->Pintensity/127.0;break;
case 2:lfointensity=lfopars->Pintensity/127.0*4.0;break;//in octave
@@ -58,6 +60,7 @@ LFO::LFO(LFOParams *lfopars){
amp2=(1-lfornd)+lfornd*RND;
lfotype=lfopars->PLFOtype;
lfodelay=lfopars->Pdelay/127.0*4.0;//0..4 sec
+ incrnd=1.0;
};
LFO::~LFO(){
@@ -95,14 +98,16 @@ REALTYPE LFO::lfoout(){
if ((lfotype==0)||(lfotype==1)) out*=lfointensity*(amp1+x*(amp2-amp1));
else out*=lfointensity*amp2;
if (lfodelay<0.00001) {
- x+=incx;
+ x+=incx*incrnd;
if (x>1) {
x-=1;
amp1=amp2;
amp2=(1-lfornd)+lfornd*RND;
- };
- }
- else lfodelay-=(REALTYPE)SOUND_BUFFER_SIZE/(REALTYPE)SAMPLE_RATE;
+
+ incrnd=pow(2.0,(RND-0.5)*lfofreqrnd);
+ if (incrnd*incx>=0.49999999) incrnd=1.0;
+ };
+ } else lfodelay-=(REALTYPE)SOUND_BUFFER_SIZE/(REALTYPE)SAMPLE_RATE;
return(out);
};
diff --git a/src/Synth/LFO.h b/src/Synth/LFO.h
@@ -35,10 +35,10 @@ class LFO{
REALTYPE amplfoout();
private:
REALTYPE x;
- REALTYPE incx;
+ REALTYPE incx,incrnd;
REALTYPE amp1,amp2;// used for randomness
REALTYPE lfointensity;
- REALTYPE lfornd;
+ REALTYPE lfornd,lfofreqrnd;
REALTYPE lfodelay;
char lfotype;
diff --git a/src/UI/LFOUI.fl b/src/UI/LFOUI.fl
@@ -1,5 +1,5 @@
# data file for the Fltk User Interface Designer (fluid)
-version 1.0103
+version 1.0104
header_name {.h}
code_name {.cc}
decl {//Copyright (c) 2002-2003 Nasca Octavian Paul} {}
@@ -45,7 +45,7 @@ delete (lfoui);} {}
}
Function {make_window()} {} {
Fl_Window lfoui {
- xywh {354 365 231 70} color 50 labelfont 1 hide
+ xywh {212 373 230 70} color 50 labelfont 1 hide
class Fl_Group
} {
Fl_Group lfoparamswindow {
@@ -81,16 +81,16 @@ delete (lfoui);} {}
class WidgetPDial
}
Fl_Dial {} {
- label RND
- callback {pars->Prandomness=(int)o->value();}
- tooltip {LFO Randomness} xywh {145 20 30 30} box ROUND_UP_BOX labelsize 11 maximum 127 step 1
+ label {A.R.}
+ callback {pars->Prandomness=(int)o->value();} selected
+ tooltip {LFO Amplitude Randomness} xywh {180 7 20 20} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
code0 {o->value(pars->Prandomness);}
class WidgetPDial
}
Fl_Choice {} {
label Type
callback {pars->PLFOtype=(int)o->value();}
- tooltip {LFO function} xywh {180 35 45 15} down_box BORDER_BOX labelsize 10 align 2 textsize 8
+ tooltip {LFO function} xywh {180 40 45 15} down_box BORDER_BOX labelsize 10 align 2 textsize 8
code0 {o->value(pars->PLFOtype);}
} {
menuitem {} {
@@ -123,11 +123,18 @@ delete (lfoui);} {}
}
}
Fl_Check_Button {} {
- label {Cnt.}
+ label {C.}
callback {pars->Pcontinous=(int)o->value();}
- tooltip {Continous LFO} xywh {180 15 40 15} down_box DOWN_BOX labelsize 11
+ tooltip {Continous LFO} xywh {145 30 30 15} down_box DOWN_BOX labelsize 11
code0 {o->value(pars->Pcontinous);}
}
+ Fl_Dial {} {
+ label {F.R.}
+ callback {pars->Pfreqrand=(int)o->value();}
+ tooltip {LFO Frequency Randomness} xywh {205 7 20 20} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
+ code0 {o->value(pars->Pfreqrand);}
+ class WidgetPDial
+ }
}
}
}
@@ -139,8 +146,7 @@ end();
lfoui->resize(this->x(),this->y(),this->w(),this->h());
-lfoparamswindow->label(this->label());} {selected
- }
+lfoparamswindow->label(this->label());} {}
}
decl {LFOParams *pars;} {}
}
diff --git a/src/default.bnk_zyn b/src/default.bnk_zyn
Binary files differ.