Timeline: Add "Disabled" fade type to disable both fade and declicking for cases where regions need to be abutted perfectly.

This commit is contained in:
Jonathan Moore Liles 2020-10-23 22:08:13 -07:00
parent 655ccf94c3
commit 0157734a30
3 changed files with 27 additions and 12 deletions

View File

@ -224,6 +224,8 @@ Audio_Region::menu_cb ( const Fl_Menu_ *m )
_fade_in.type = Fade::Logarithmic; _fade_in.type = Fade::Logarithmic;
else if ( ! strcmp( picked, "Fade/In/Parabolic" ) ) else if ( ! strcmp( picked, "Fade/In/Parabolic" ) )
_fade_in.type = Fade::Parabolic; _fade_in.type = Fade::Parabolic;
else if ( ! strcmp( picked, "Fade/In/Disabled" ) )
_fade_in.type = Fade::Disabled;
else if ( ! strcmp( picked, "Fade/Out/Linear" ) ) else if ( ! strcmp( picked, "Fade/Out/Linear" ) )
_fade_out.type = Fade::Linear; _fade_out.type = Fade::Linear;
else if ( ! strcmp( picked, "Fade/Out/Sigmoid" ) ) else if ( ! strcmp( picked, "Fade/Out/Sigmoid" ) )
@ -232,6 +234,8 @@ Audio_Region::menu_cb ( const Fl_Menu_ *m )
_fade_out.type = Fade::Logarithmic; _fade_out.type = Fade::Logarithmic;
else if ( ! strcmp( picked, "Fade/Out/Parabolic" ) ) else if ( ! strcmp( picked, "Fade/Out/Parabolic" ) )
_fade_out.type = Fade::Parabolic; _fade_out.type = Fade::Parabolic;
else if ( ! strcmp( picked, "Fade/Out/Disabled" ) )
_fade_out.type = Fade::Disabled;
else if ( ! strcmp( picked, "/Color" ) ) else if ( ! strcmp( picked, "/Color" ) )
box_color( fl_show_colormap( box_color() ) ); box_color( fl_show_colormap( box_color() ) );
else if ( ! strcmp( picked, "/Split at mouse" ) ) else if ( ! strcmp( picked, "/Split at mouse" ) )
@ -351,12 +355,16 @@ Audio_Region::menu ( void )
{ "Sigmoid", 0, 0, 0, FL_MENU_RADIO | ( it == Fade::Sigmoid ? FL_MENU_VALUE : 0 ) }, { "Sigmoid", 0, 0, 0, FL_MENU_RADIO | ( it == Fade::Sigmoid ? FL_MENU_VALUE : 0 ) },
{ "Logarithmic", 0, 0, 0, FL_MENU_RADIO | ( it == Fade::Logarithmic ? FL_MENU_VALUE : 0 ) }, { "Logarithmic", 0, 0, 0, FL_MENU_RADIO | ( it == Fade::Logarithmic ? FL_MENU_VALUE : 0 ) },
{ "Parabolic", 0, 0, 0, FL_MENU_RADIO | ( it == Fade::Parabolic ? FL_MENU_VALUE : 0 ) }, { "Parabolic", 0, 0, 0, FL_MENU_RADIO | ( it == Fade::Parabolic ? FL_MENU_VALUE : 0 ) },
{ "Disabled", 0, 0, 0, FL_MENU_RADIO | ( it == Fade::Disabled ? FL_MENU_VALUE : 0 ) },
{ 0 }, { 0 },
{ "Out", 0, 0, 0, FL_SUBMENU }, { "Out", 0, 0, 0, FL_SUBMENU },
{ "Linear", 0, 0, 0, FL_MENU_RADIO | ( ot == Fade::Linear ? FL_MENU_VALUE : 0 ) }, { "Linear", 0, 0, 0, FL_MENU_RADIO | ( ot == Fade::Linear ? FL_MENU_VALUE : 0 ) },
{ "Sigmoid", 0, 0, 0, FL_MENU_RADIO | ( ot == Fade::Sigmoid ? FL_MENU_VALUE : 0 ) }, { "Sigmoid", 0, 0, 0, FL_MENU_RADIO | ( ot == Fade::Sigmoid ? FL_MENU_VALUE : 0 ) },
{ "Logarithmic", 0, 0, 0, FL_MENU_RADIO | ( ot == Fade::Logarithmic ? FL_MENU_VALUE : 0 ) }, { "Logarithmic", 0, 0, 0, FL_MENU_RADIO | ( ot == Fade::Logarithmic ? FL_MENU_VALUE : 0 ) },
{ "Parabolic", 0, 0, 0, FL_MENU_RADIO | ( ot == Fade::Parabolic ? FL_MENU_VALUE : 0 ) }, { "Parabolic", 0, 0, 0, FL_MENU_RADIO | ( ot == Fade::Parabolic ? FL_MENU_VALUE : 0 ) },
{ "Disabled", 0, 0, 0, FL_MENU_RADIO | ( ot == Fade::Disabled ? FL_MENU_VALUE : 0 ) },
{ 0 }, { 0 },
{ 0 }, { 0 },
{ "Color", 0, 0, 0, inherit_track_color ? FL_MENU_INACTIVE : 0 }, { "Color", 0, 0, 0, inherit_track_color ? FL_MENU_INACTIVE : 0 },
@ -398,6 +406,9 @@ Audio_Region::draw_fade ( const Fade &fade, Fade::fade_dir_e dir, bool line, int
const int height = dh; const int height = dh;
const int width = timeline->ts_to_x( fade.length ); const int width = timeline->ts_to_x( fade.length );
if ( Fade::Disabled == fade.type )
return;
if ( width < 4 ) if ( width < 4 )
/* too small to draw */ /* too small to draw */
return; return;

View File

@ -42,7 +42,7 @@ public:
struct Fade struct Fade
{ {
enum fade_type_e { Linear = 0, Sigmoid, Logarithmic, Parabolic }; enum fade_type_e { Linear = 0, Sigmoid, Logarithmic, Parabolic, Disabled };
enum fade_dir_e { In, Out }; enum fade_dir_e { In, Out };
fade_type_e type; fade_type_e type;

View File

@ -271,6 +271,9 @@ Audio_Region::read ( sample_t *buf, bool buf_is_empty, nframes_t pos, nframes_t
Fade fade; Fade fade;
/* disabling fade also disables de-clicking for perfectly abutted edits. */
if ( fade.type != Fade::Disabled )
{
fade = declick < _fade_in ? _fade_in : declick; fade = declick < _fade_in ? _fade_in : declick;
/* do fade in if necessary */ /* do fade in if necessary */
@ -283,6 +286,7 @@ Audio_Region::read ( sample_t *buf, bool buf_is_empty, nframes_t pos, nframes_t
if ( sO + cnt + fade.length > r.length ) if ( sO + cnt + fade.length > r.length )
apply_fade( cbuf, _clip->channels(), fade, bS, bE, rE, Fade::Out ); apply_fade( cbuf, _clip->channels(), fade, bS, bE, rE, Fade::Out );
} }
}
if ( buf != cbuf ) if ( buf != cbuf )
{ {