Output session fading fixed for OSC and animation.

Linear interpolation (instead of dichotomy converge) for fading at Session update. Mixing View update reads value of session fading to animate the cursor (which was preventing other manipulation of fading). Cleanup fading in OSC controller, with animation options and fade-in and fade-out controls.
This commit is contained in:
Bruno Herbelin
2021-12-26 00:41:02 +01:00
parent 3d05444f30
commit 1cb448c42e
11 changed files with 124 additions and 64 deletions

View File

@@ -321,18 +321,8 @@ void MixingView::update(float dt)
limbo_->scale_ = glm::vec3(p, p, 1.f);
//
// Set slider to match the actual fading of the session
//
float f = Mixer::manager().session()->empty() ? 0.f : Mixer::manager().session()->fading();
// reverse calculate angle from fading & move slider
slider_root_->rotation_.z = SIGN(slider_root_->rotation_.z) * asin(f) * 2.f;
// visual feedback on mixing circle
f = 1.f - f;
mixingCircle_->shader()->color = glm::vec4(f, f, f, 1.f);
// prevent invalid scaling
//
float s = CLAMP(scene.root()->scale_.x, MIXING_MIN_SCALE, MIXING_MAX_SCALE);
scene.root()->scale_.x = s;
scene.root()->scale_.y = s;
@@ -342,22 +332,16 @@ void MixingView::update(float dt)
if (Mixer::manager().view() == this ){
//
// Set session fading to match the slider angle (during animation)
// Set slider to match the actual fading of the session
//
float f = Mixer::manager().session()->fading();
// calculate fading from angle
float f = sin( ABS(slider_root_->rotation_.z) * 0.5f);
// reverse calculate angle from fading & move slider
slider_root_->rotation_.z = SIGN(-slider_root_->rotation_.z) * asin(f) * -2.f;
// apply fading
if ( ABS_DIFF( f, Mixer::manager().session()->fading()) > EPSILON )
{
// apply fading to session
Mixer::manager().session()->setFading(f);
// visual feedback on mixing circle
f = 1.f - f;
mixingCircle_->shader()->color = glm::vec4(f, f, f, 1.f);
}
// visual feedback on mixing circle
f = 1.f - f;
mixingCircle_->shader()->color = glm::vec4(f, f, f, 1.f);
// update the selection overlay
updateSelectionOverlay();
@@ -374,18 +358,14 @@ std::pair<Node *, glm::vec2> MixingView::pick(glm::vec2 P)
// deal with internal interactive objects
if ( pick.first == button_white_ || pick.first == button_black_ ) {
RotateToCallback *anim = nullptr;
if (pick.first == button_white_)
anim = new RotateToCallback(0.f, 500.f);
else
anim = new RotateToCallback(SIGN(slider_root_->rotation_.z) * M_PI, 500.f);
// animate clic
pick.first->update_callbacks_.push_back(new BounceScaleCallback(0.3f));
// reset & start animation
slider_root_->update_callbacks_.clear();
slider_root_->update_callbacks_.push_back(anim);
// animated fading in session
if (pick.first == button_white_)
Mixer::manager().session()->setFadingTarget(0.f, 500.f);
else
Mixer::manager().session()->setFadingTarget(1.f, 500.f);
}
else if ( overlay_selection_icon_ != nullptr && pick.first == overlay_selection_icon_ ) {
@@ -470,10 +450,14 @@ View::Cursor MixingView::grab (Source *s, glm::vec2 from, glm::vec2 to, std::pai
// animate slider (rotation angle on its parent)
slider_root_->rotation_.z = angle;
// calculate fading from angle
float f = sin( ABS(angle) * 0.5f);
Mixer::manager().session()->setFadingTarget(f);
// cursor feedback
slider_->color = glm::vec4( COLOR_CIRCLE_OVER, 0.9f );
std::ostringstream info;
info << "Output " << 100 - int(Mixer::manager().session()->fading() * 100.0) << " %";
info << "Output " << 100 - int(f * 100.0) << " %";
return Cursor(Cursor_Hand, info.str() );
}
else if (pick.first == limbo_slider_) {