@@ -187,7 +187,7 @@ rendering=false;} {} | |||||
Function {make_window()} {open private | Function {make_window()} {open private | ||||
} { | } { | ||||
Fl_Window window { | Fl_Window window { | ||||
label {Paul's Extreme Sound Stretch} | |||||
label {Paul's Extreme Sound Stretch} open | |||||
xywh {192 131 995 550} type Double resizable | xywh {192 131 995 550} type Double resizable | ||||
code0 {if(strlen(VERSION)<2) {o->color(FL_BLUE); o->label("VERSION NOT SET!!!!!!!!!!!!");};} visible | code0 {if(strlen(VERSION)<2) {o->color(FL_BLUE); o->label("VERSION NOT SET!!!!!!!!!!!!");};} visible | ||||
} { | } { | ||||
@@ -267,7 +267,7 @@ render();} | |||||
xywh {5 50 985 420} box BORDER_BOX | xywh {5 50 985 420} box BORDER_BOX | ||||
} { | } { | ||||
Fl_Group {} { | Fl_Group {} { | ||||
label Parameters open | |||||
label Parameters open selected | |||||
xywh {5 70 985 400} | xywh {5 70 985 400} | ||||
} { | } { | ||||
Fl_Slider stretch_slider { | Fl_Slider stretch_slider { | ||||
@@ -387,7 +387,7 @@ stretch_slider->do_callback();} | |||||
label {Onset sensitivity:} | label {Onset sensitivity:} | ||||
callback {refresh(); | callback {refresh(); | ||||
control.update_player_stretch();} | control.update_player_stretch();} | ||||
xywh {135 213 140 17} type {Horz Knob} box FLAT_BOX align 4 | |||||
xywh {135 213 140 15} type {Horz Knob} box FLAT_BOX align 4 | |||||
} | } | ||||
} | } | ||||
Fl_Group {} { | Fl_Group {} { | ||||
@@ -900,8 +900,7 @@ bbpar_stereo_mode->value(control.bbpar.stereo_mode); | |||||
stretch_multiplier_control->refresh(); | stretch_multiplier_control->refresh(); | ||||
arbitrary_filter_control->refresh(); | arbitrary_filter_control->refresh(); | ||||
binaural_beats_control->refresh();} {selected | |||||
} | |||||
binaural_beats_control->refresh();} {} | |||||
} | } | ||||
Function {tickrefresh()} {} { | Function {tickrefresh()} {} { | ||||
code {seek_slider->value(seek_slider->maximum()*control.get_seek_pos()); | code {seek_slider->value(seek_slider->maximum()*control.get_seek_pos()); | ||||
@@ -177,6 +177,7 @@ Stretch::Stretch(REALTYPE rap_,int bufsize_,FFTWindow w,bool bypass_,REALTYPE sa | |||||
window_type=w; | window_type=w; | ||||
require_new_buffer=false; | require_new_buffer=false; | ||||
c_pos_percents=0.0; | c_pos_percents=0.0; | ||||
extra_onset_time_credit=0.0; | |||||
}; | }; | ||||
Stretch::~Stretch(){ | Stretch::~Stretch(){ | ||||
@@ -215,9 +216,7 @@ void Stretch::do_next_inbuf_smps(REALTYPE *smps){ | |||||
}; | }; | ||||
}; | }; | ||||
//static bool kuku=false; | |||||
REALTYPE Stretch::do_detect_onset(){ | REALTYPE Stretch::do_detect_onset(){ | ||||
//kuku=!kuku; | |||||
REALTYPE result=0.0; | REALTYPE result=0.0; | ||||
if (onset_detection_sensitivity>1e-3){ | if (onset_detection_sensitivity>1e-3){ | ||||
REALTYPE os=0.0,osinc=0.0; | REALTYPE os=0.0,osinc=0.0; | ||||
@@ -238,16 +237,13 @@ REALTYPE Stretch::do_detect_onset(){ | |||||
if (os<0.0) os=0.0; | if (os<0.0) os=0.0; | ||||
//if (os>1.0) os=1.0; | //if (os>1.0) os=1.0; | ||||
REALTYPE os_strength=pow(20.0,sqrt(1.0-onset_detection_sensitivity))-1.0; | |||||
REALTYPE os_strength=pow(20.0,1.0-onset_detection_sensitivity)-1.0; | |||||
REALTYPE os_strength_h=os_strength*0.75; | REALTYPE os_strength_h=os_strength*0.75; | ||||
if (os>os_strength_h){ | if (os>os_strength_h){ | ||||
result=(os-os_strength_h)/(os_strength-os_strength_h); | result=(os-os_strength_h)/(os_strength-os_strength_h); | ||||
if (result>1.0) result=1.0; | if (result>1.0) result=1.0; | ||||
}; | }; | ||||
//if (kuku) printf("%g\n",result); | |||||
//if (kuku) printf("(%g %g) %g => %g\n",os_strength,os_strength_h,os,result); | |||||
if (result>1.0) result=1.0; | if (result>1.0) result=1.0; | ||||
}; | }; | ||||
return result; | return result; | ||||
@@ -320,6 +316,12 @@ REALTYPE Stretch::process(REALTYPE *smps,int nsmps){ | |||||
long double used_rap=rap*get_stretch_multiplier(c_pos_percents); | long double used_rap=rap*get_stretch_multiplier(c_pos_percents); | ||||
long double r=1.0/used_rap; | long double r=1.0/used_rap; | ||||
if (extra_onset_time_credit>0){ | |||||
REALTYPE credit_get=0.5*r;//must be smaller than r | |||||
extra_onset_time_credit-=credit_get; | |||||
if (extra_onset_time_credit<0.0) extra_onset_time_credit=0.0; | |||||
r-=credit_get; | |||||
}; | |||||
long double old_remained_samples_test=remained_samples; | long double old_remained_samples_test=remained_samples; | ||||
remained_samples+=r; | remained_samples+=r; | ||||
@@ -339,8 +341,8 @@ REALTYPE Stretch::process(REALTYPE *smps,int nsmps){ | |||||
void Stretch::here_is_onset(REALTYPE onset){ | void Stretch::here_is_onset(REALTYPE onset){ | ||||
if (onset>0.5){ | if (onset>0.5){ | ||||
require_new_buffer=true; | require_new_buffer=true; | ||||
extra_onset_time_credit+=1.0-remained_samples; | |||||
remained_samples=0.0; | remained_samples=0.0; | ||||
//aici sa pun creditul | |||||
}; | }; | ||||
}; | }; | ||||
@@ -85,6 +85,7 @@ class Stretch{ | |||||
void set_onset_detection_sensitivity(REALTYPE detection_sensitivity){ | void set_onset_detection_sensitivity(REALTYPE detection_sensitivity){ | ||||
onset_detection_sensitivity=detection_sensitivity; | onset_detection_sensitivity=detection_sensitivity; | ||||
if (detection_sensitivity<1e-3) extra_onset_time_credit=0.0; | |||||
}; | }; | ||||
void here_is_onset(REALTYPE onset); | void here_is_onset(REALTYPE onset); | ||||
@@ -111,6 +112,7 @@ class Stretch{ | |||||
FFT *infft,*outfft; | FFT *infft,*outfft; | ||||
FFT *fft; | FFT *fft; | ||||
long double remained_samples;//0..1 | long double remained_samples;//0..1 | ||||
long double extra_onset_time_credit; | |||||
REALTYPE c_pos_percents; | REALTYPE c_pos_percents; | ||||
bool require_new_buffer; | bool require_new_buffer; | ||||
bool bypass; | bool bypass; | ||||
@@ -72,6 +72,7 @@ History: | |||||
- Added an option to preserve the tonal part or noise part | - Added an option to preserve the tonal part or noise part | ||||
- Ignored the commandline parameters starting with "-" (usefull for macosx) | - Ignored the commandline parameters starting with "-" (usefull for macosx) | ||||
- Improved the algorithm | - Improved the algorithm | ||||
- Added onset detection | |||||
Enjoy! :) | Enjoy! :) | ||||
Paul | Paul | ||||