Browse Source

Tonal/Noise preserve

master
Nasca Octavian PAUL 11 years ago
parent
commit
5192e3ed1c
4 changed files with 97 additions and 7 deletions
  1. +32
    -6
      GUI.fl
  2. +49
    -1
      ProcessedStretch.cpp
  3. +13
    -0
      ProcessedStretch.h
  4. +3
    -0
      readme.txt

+ 32
- 6
GUI.fl View File

@@ -188,7 +188,7 @@ rendering=false;} {}
} {
Fl_Window window {
label {Paul's Extreme Sound Stretch} open
xywh {54 265 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
} {
Fl_Menu_Bar {} {open
@@ -385,7 +385,7 @@ stretch_slider->do_callback();}
}
}
Fl_Group {} {
label Process
label Process open
xywh {5 70 985 400} hide
} {
Fl_Group {} {open
@@ -469,19 +469,19 @@ control.update_process_parameters();}
}
}
Fl_Group {} {open
xywh {605 75 120 65} box BORDER_BOX
xywh {750 75 120 65} box BORDER_BOX
} {
Fl_Check_Button compressor_enabled {
label Compress
callback {control.ppar.compressor.enabled=o->value();
control.update_process_parameters();}
xywh {610 80 90 15} down_box DOWN_BOX labelfont 1
xywh {755 80 90 15} down_box DOWN_BOX labelfont 1
}
Fl_Slider compressor_power {
label Power
callback {control.ppar.compressor.power=o->value();
control.update_process_parameters();}
xywh {610 100 110 15} type {Horz Knob}
xywh {755 100 110 15} type {Horz Knob}
}
}
Fl_Slider {} {
@@ -489,7 +489,7 @@ control.update_process_parameters();}
callback {REALTYPE x=o->value();
x=pow(10.0,pow(x,1.5)-1.0)-0.1;
control.set_volume(x);}
xywh {605 155 120 40} type {Horz Knob} labelfont 1 minimum 0.3 maximum 1.6 value 1
xywh {750 155 120 40} type {Horz Knob} labelfont 1 minimum 0.3 maximum 1.6 value 1
}
Fl_Group {} {open
xywh {415 75 185 100} box BORDER_BOX
@@ -591,6 +591,28 @@ control.update_process_parameters();}
class FreeEditControls
} {}
}
Fl_Group {} {open
xywh {605 75 140 105} box BORDER_BOX
} {
Fl_Check_Button tonal_vs_noise_enabled {
label {Tonal/Noise}
callback {control.ppar.tonal_vs_noise.enabled=o->value();
control.update_process_parameters();}
xywh {610 80 115 20} down_box DOWN_BOX labelfont 1
}
Fl_Slider tonal_vs_noise_bandwidth {
label Bandwidth
callback {control.ppar.tonal_vs_noise.bandwidth=o->value();
control.update_process_parameters();}
xywh {610 141 130 15} type {Horz Knob} minimum 0.75 value 0.9
}
Fl_Slider tonal_vs_noise_preserve {
label {noise <-->tonal}
callback {control.ppar.tonal_vs_noise.preserve=o->value();
control.update_process_parameters();}
xywh {610 105 130 15} type {Horz Knob} minimum -1 value 0.5
}
}
}
Fl_Group {} {
label {Binaural beats}
@@ -861,6 +883,10 @@ spread_enabled->value(control.ppar.spread.enabled);
spread_bandwidth->value(control.ppar.spread.bandwidth);


tonal_vs_noise_enabled->value(control.ppar.tonal_vs_noise.enabled);
tonal_vs_noise_preserve->value(control.ppar.tonal_vs_noise.preserve);
tonal_vs_noise_bandwidth->value(control.ppar.tonal_vs_noise.bandwidth);

bbpar_mono->value(control.bbpar.mono);
bbpar_stereo_mode->value(control.bbpar.stereo_mode);



+ 49
- 1
ProcessedStretch.cpp View File

@@ -55,6 +55,10 @@ void ProcessParameters::add2XML(XMLwrapper *xml){

xml->addparbool("spread.enabled",spread.enabled);
xml->addparreal("spread.bandwidth",spread.bandwidth);
xml->addparbool("tonal_vs_noise.enabled",tonal_vs_noise.enabled);
xml->addparreal("tonal_vs_noise.bandwidth",tonal_vs_noise.bandwidth);
xml->addparreal("tonal_vs_noise.preserve",tonal_vs_noise.preserve);

xml->beginbranch("FREE_FILTER");
free_filter.add2XML(xml);
@@ -99,6 +103,11 @@ void ProcessParameters::getfromXML(XMLwrapper *xml){

spread.enabled=xml->getparbool("spread.enabled",spread.enabled);
spread.bandwidth=xml->getparreal("spread.bandwidth",spread.bandwidth);
tonal_vs_noise.enabled=xml->getparbool("tonal_vs_noise.enabled",tonal_vs_noise.enabled);
tonal_vs_noise.preserve=xml->getparreal("tonal_vs_noise.preserve",tonal_vs_noise.bandwidth);
tonal_vs_noise.bandwidth=xml->getparreal("tonal_vs_noise.bandwidth",tonal_vs_noise.bandwidth);


if (xml->enterbranch("FREE_FILTER")){
free_filter.getfromXML(xml);
@@ -169,6 +178,11 @@ void ProcessedStretch::process_spectrum(REALTYPE *freq){
do_harmonics(infreq,freq);
};

if (pars.tonal_vs_noise.enabled){
copy(freq,infreq);
do_tonal_vs_noise(infreq,freq);
};

if (pars.freq_shift.enabled) {
copy(freq,infreq);
do_freq_shift(infreq,freq);
@@ -365,6 +379,10 @@ void ProcessedStretch::do_free_filter(REALTYPE *freq1,REALTYPE *freq2){
};

void ProcessedStretch::do_spread(REALTYPE *freq1,REALTYPE *freq2){
spread(freq1,freq2,pars.spread.bandwidth);
};

void ProcessedStretch::spread(REALTYPE *freq1,REALTYPE *freq2,REALTYPE spread_bandwidth){
//convert to log spectrum
REALTYPE minfreq=20.0;
REALTYPE maxfreq=0.5*samplerate;
@@ -387,7 +405,7 @@ void ProcessedStretch::do_spread(REALTYPE *freq1,REALTYPE *freq2){

//increase the bandwidth of each harmonic (by smoothing the log spectrum)
int n=2;
REALTYPE bandwidth=pars.spread.bandwidth;
REALTYPE bandwidth=spread_bandwidth;
REALTYPE a=1.0-pow(2.0,-bandwidth*bandwidth*10.0);
a=pow(a,8192.0/nfreq*n);

@@ -431,4 +449,34 @@ void ProcessedStretch::do_compressor(REALTYPE *freq1,REALTYPE *freq2){
for (int i=0;i<nfreq;i++) freq2[i]=freq1[i]*rap;
};

void ProcessedStretch::do_tonal_vs_noise(REALTYPE *freq1,REALTYPE *freq2){
spread(freq1,tmpfreq1,pars.tonal_vs_noise.bandwidth);

if (pars.tonal_vs_noise.preserve>=0.0){
REALTYPE mul=(pow(10.0,pars.tonal_vs_noise.preserve)-1.0);
for (int i=0;i<nfreq;i++) {
REALTYPE x=freq1[i];
REALTYPE smooth_x=tmpfreq1[i]+1e-6;

REALTYPE result=0.0;
result=x-smooth_x*mul;
if (result<0.0) result=0.0;
freq2[i]=result;
};
}else{
REALTYPE mul=(pow(5.0,1.0+pars.tonal_vs_noise.preserve)-1.0);
for (int i=0;i<nfreq;i++) {
REALTYPE x=freq1[i];
REALTYPE smooth_x=tmpfreq1[i]+1e-6;

REALTYPE result=0.0;
result=x-smooth_x*mul+0.1*mul;
if (result<0.0) result=x;
else result=0.0;

freq2[i]=result;
};
};

};


+ 13
- 0
ProcessedStretch.h View File

@@ -58,6 +58,10 @@ struct ProcessParameters{
/// waveinfo.n_transients=1;
/// waveinfo.transients_data=new REALTYPE[1];
/// waveinfo.transients_data[0]=0;

tonal_vs_noise.enabled=false;
tonal_vs_noise.preserve=0.5;
tonal_vs_noise.bandwidth=0.9;
};
~ProcessParameters(){
/// delete []waveinfo.transients_data;
@@ -119,6 +123,13 @@ struct ProcessParameters{
bool enabled;
REALTYPE bandwidth;
}spread;

struct{
bool enabled;
REALTYPE preserve;
REALTYPE bandwidth;
}tonal_vs_noise;

FreeEdit free_filter;
FreeEdit stretch_multiplier;

@@ -147,10 +158,12 @@ class ProcessedStretch:public Stretch{
void do_free_filter(REALTYPE *freq1,REALTYPE *freq2);
void do_compressor(REALTYPE *freq1,REALTYPE *freq2);
void do_spread(REALTYPE *freq1,REALTYPE *freq2);
void do_tonal_vs_noise(REALTYPE *freq1,REALTYPE *freq2);

void copy(REALTYPE *freq1,REALTYPE *freq2);
void add(REALTYPE *freq2,REALTYPE *freq1,REALTYPE a=1.0);
void zero(REALTYPE *freq1);
void spread(REALTYPE *freq1,REALTYPE *freq2,REALTYPE spread_bandwidth);

void update_free_filter();
int nfreq;


+ 3
- 0
readme.txt View File

@@ -71,6 +71,9 @@ History:

20110211(2.1-0)
- Increased the precision of a paremeter for extreme long stretches
2011????(2.)
- Added an option to preserve the tonal part or noise part

Enjoy! :)
Paul


Loading…
Cancel
Save