Skip to content

Commit

Permalink
#226 Add transition bar reset parameter, refactor bar direction handling
Browse files Browse the repository at this point in the history
  • Loading branch information
SteffeyDev committed Nov 11, 2021
1 parent 030b337 commit 34f9616
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 19 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ By default, commands will be sent to the first mix effect block (M/E). To send
- **Auto** `/atem/transition/auto`
- **Fade to Black Toggle** `/atem/transition/ftb`
- **Preview Transition** `/atem/transition/preview <true|false>`
- **T-bar Reset to Transition Start Position** `/atem/transition/bar/reset`

To set the transition type of the Auto transition:

Expand Down
3 changes: 1 addition & 2 deletions atemOSC/FeedbackMonitors.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ class MixEffectBlockMonitor : public GenericMonitor<IBMDSwitcherMixEffectBlockCa
public:
MixEffectBlockMonitor(Switcher *switcher, int me) : GenericMonitor(switcher), me_(me) { }
HRESULT Notify(BMDSwitcherMixEffectBlockEventType eventType);
bool moveSliderDownwards() const;
bool mMoveSliderDownwards = false;
void updateSliderPosition();
void updatePreviewTransitionEnabled() const;
Expand All @@ -56,7 +55,7 @@ class MixEffectBlockMonitor : public GenericMonitor<IBMDSwitcherMixEffectBlockCa
void updateProgramButtonSelection() const;
void updatePreviewButtonSelection() const;
void updateInTransitionState();
bool mCurrentTransitionReachedHalfway_ = false;
bool mCurrentTransitionCompleted_ = false;
int me_;
};

Expand Down
27 changes: 13 additions & 14 deletions atemOSC/FeedbackMonitors.mm
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,13 @@
if (inTransition == false)
{
// Toggle the starting orientation of slider handle if a transition has passed through halfway
if (mCurrentTransitionReachedHalfway_)
if (mCurrentTransitionCompleted_)
{
mMoveSliderDownwards = ! mMoveSliderDownwards;
switcher.inverseHandle = !switcher.inverseHandle;
updateSliderPosition();
}

mCurrentTransitionReachedHalfway_ = false;
mCurrentTransitionCompleted_ = false;
}
}

Expand All @@ -121,14 +121,13 @@
double position;
switcher.mMixEffectBlocks[me_]->GetTransitionPosition(&position);

// Record when transition passes halfway so we can flip orientation of slider handle at the end of transition
mCurrentTransitionReachedHalfway_ = (position >= 0.50);
// Record when transition completes so we can flip orientation of slider handle at the end of transition
mCurrentTransitionCompleted_ = (position == 1);

double sliderPosition = position * 100;
if (mMoveSliderDownwards)
sliderPosition = 100 - position * 100; // slider handle moving in opposite direction

sendFeedbackMessage(switcher, @"/transition/bar", [OSCValue createWithFloat:1.0-sliderPosition/100], me_);
if (switcher.inverseHandle)
sendFeedbackMessage(switcher, @"/transition/bar", [OSCValue createWithFloat:1.0-position], me_);
else
sendFeedbackMessage(switcher, @"/transition/bar", [OSCValue createWithFloat:position], me_);
}

void MixEffectBlockMonitor::updatePreviewTransitionEnabled() const
Expand All @@ -153,10 +152,10 @@

double position;
switcher.mMixEffectBlocks[me_]->GetTransitionPosition(&position);
double sliderPosition = position * 100;
if (mMoveSliderDownwards)
sliderPosition = 100 - position * 100;
sendFeedbackMessage(switcher, @"/transition/bar", [OSCValue createWithFloat:1.0-sliderPosition/100], me_);
if (switcher.inverseHandle)
sendFeedbackMessage(switcher, @"/transition/bar", [OSCValue createWithFloat:1.0-position], me_);
else
sendFeedbackMessage(switcher, @"/transition/bar", [OSCValue createWithFloat:position], me_);

return 0.2;
}
Expand Down
11 changes: 8 additions & 3 deletions atemOSC/OSCReceiver.mm
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,15 @@ - (instancetype) initWithDelegate:(AppDelegate *) delegate

[self addEndpoint:@"/me/<me>/transition/bar" valueType: OSCValFloat handler:^void(Switcher *s, NSDictionary *d, OSCValue *v) {
int me = [[d objectForKey:@"<me>"] intValue];
if ([s mMixEffectBlockMonitors][me-1]->mMoveSliderDownwards)
[s mMixEffectBlocks][me-1]->SetTransitionPosition([v floatValue]);
else
if ([s inverseHandle])
[s mMixEffectBlocks][me-1]->SetTransitionPosition(1.0-[v floatValue]);
else
[s mMixEffectBlocks][me-1]->SetTransitionPosition([v floatValue]);
}];

[self addEndpoint:@"/me/<me>/transition/bar/reset" valueType: OSCValNil handler:^void(Switcher *s, NSDictionary *d, OSCValue *v) {
int me = [[d objectForKey:@"<me>"] intValue];
[s mMixEffectBlocks][me-1]->SetTransitionPosition(0);
}];

[self addEndpoint:@"/me/<me>/transition/cut" handler:^void(Switcher *s, NSDictionary *d, OSCValue *v) {
Expand Down
2 changes: 2 additions & 0 deletions atemOSC/Switcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic) bool isConnected;
@property (nonatomic, assign) NSString *connectionStatus;

@property (nonatomic) bool inverseHandle;

@property (assign, readonly) OSCOutPort* outPort;

@property (readonly) IBMDSwitcher* mSwitcher;
Expand Down
4 changes: 4 additions & 0 deletions atemOSC/Switcher.mm
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ @implementation Switcher
@synthesize isConnected;
@synthesize connectionStatus;

@synthesize inverseHandle;

@synthesize outPort;

@synthesize productName;
Expand Down Expand Up @@ -92,6 +94,8 @@ - (id)init

connectAutomatically = YES;

inverseHandle = NO;

return self;
}

Expand Down

0 comments on commit 34f9616

Please sign in to comment.