Browse Source

Onset detection

master
Nasca Octavian PAUL 13 years ago
parent
commit
8db997ce08
4 changed files with 16 additions and 12 deletions
  1. +4
    -5
      GUI.fl
  2. +9
    -7
      Stretch.cpp
  3. +2
    -0
      Stretch.h
  4. +1
    -0
      readme.txt

+ 4
- 5
GUI.fl View File

@@ -187,7 +187,7 @@ rendering=false;} {}
Function {make_window()} {open private
} {
Fl_Window window {
label {Paul's Extreme Sound Stretch}
label {Paul's Extreme Sound Stretch} open
xywh {192 131 995 550} type Double resizable
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
} {
Fl_Group {} {
label Parameters open
label Parameters open selected
xywh {5 70 985 400}
} {
Fl_Slider stretch_slider {
@@ -387,7 +387,7 @@ stretch_slider->do_callback();}
label {Onset sensitivity:}
callback {refresh();
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 {} {
@@ -900,8 +900,7 @@ bbpar_stereo_mode->value(control.bbpar.stereo_mode);

stretch_multiplier_control->refresh();
arbitrary_filter_control->refresh();
binaural_beats_control->refresh();} {selected
}
binaural_beats_control->refresh();} {}
}
Function {tickrefresh()} {} {
code {seek_slider->value(seek_slider->maximum()*control.get_seek_pos());


+ 9
- 7
Stretch.cpp View File

@@ -177,6 +177,7 @@ Stretch::Stretch(REALTYPE rap_,int bufsize_,FFTWindow w,bool bypass_,REALTYPE sa
window_type=w;
require_new_buffer=false;
c_pos_percents=0.0;
extra_onset_time_credit=0.0;
};

Stretch::~Stretch(){
@@ -215,9 +216,7 @@ void Stretch::do_next_inbuf_smps(REALTYPE *smps){
};
};

//static bool kuku=false;
REALTYPE Stretch::do_detect_onset(){
//kuku=!kuku;
REALTYPE result=0.0;
if (onset_detection_sensitivity>1e-3){
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>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;
if (os>os_strength_h){
result=(os-os_strength_h)/(os_strength-os_strength_h);
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;
};
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 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;
remained_samples+=r;
@@ -339,8 +341,8 @@ REALTYPE Stretch::process(REALTYPE *smps,int nsmps){
void Stretch::here_is_onset(REALTYPE onset){
if (onset>0.5){
require_new_buffer=true;
extra_onset_time_credit+=1.0-remained_samples;
remained_samples=0.0;
//aici sa pun creditul
};
};



+ 2
- 0
Stretch.h View File

@@ -85,6 +85,7 @@ class Stretch{

void set_onset_detection_sensitivity(REALTYPE detection_sensitivity){
onset_detection_sensitivity=detection_sensitivity;
if (detection_sensitivity<1e-3) extra_onset_time_credit=0.0;
};
void here_is_onset(REALTYPE onset);

@@ -111,6 +112,7 @@ class Stretch{
FFT *infft,*outfft;
FFT *fft;
long double remained_samples;//0..1
long double extra_onset_time_credit;
REALTYPE c_pos_percents;
bool require_new_buffer;
bool bypass;


+ 1
- 0
readme.txt View File

@@ -72,6 +72,7 @@ History:
- Added an option to preserve the tonal part or noise part
- Ignored the commandline parameters starting with "-" (usefull for macosx)
- Improved the algorithm
- Added onset detection

Enjoy! :)
Paul


Loading…
Cancel
Save