adjust segment math

This commit is contained in:
Josh Hawkins 2024-03-04 13:41:44 -06:00
parent 282c92c9c8
commit a4c406c911
2 changed files with 18 additions and 22 deletions

View File

@ -217,10 +217,8 @@ export function MotionSegment({
className={`h-[2px] rounded-full bg-motion_review`}
onClick={segmentClick}
style={{
width:
maxSegmentWidth -
interpolateMotionAudioData(
getMotionSegmentValue(segmentTime - segmentDuration / 2),
width: interpolateMotionAudioData(
getMotionSegmentValue(segmentTime),
0,
100,
1,
@ -236,7 +234,7 @@ export function MotionSegment({
onClick={segmentClick}
style={{
width: interpolateMotionAudioData(
getAudioSegmentValue(segmentTime - segmentDuration / 2),
getAudioSegmentValue(segmentTime),
-100,
0,
1,
@ -254,10 +252,8 @@ export function MotionSegment({
className={`h-[2px] rounded-full bg-motion_review`}
onClick={segmentClick}
style={{
width:
maxSegmentWidth -
interpolateMotionAudioData(
getMotionSegmentValue(segmentTime),
width: interpolateMotionAudioData(
getMotionSegmentValue(segmentTime - segmentDuration / 2),
0,
100,
1,
@ -273,7 +269,7 @@ export function MotionSegment({
onClick={segmentClick}
style={{
width: interpolateMotionAudioData(
getAudioSegmentValue(segmentTime),
getAudioSegmentValue(segmentTime - segmentDuration / 2),
-100,
0,
1,

View File

@ -45,13 +45,13 @@ export const useMotionSegmentUtils = (
const matchingEvent = motion_events.find((event) => {
return (
time >= getSegmentStart(event.start_time) &&
time < getSegmentEnd(event.end_time)
time < getSegmentEnd(event.start_time + segmentDuration / 2)
);
});
return matchingEvent?.motionValue ?? 0;
},
[motion_events, getSegmentStart, getSegmentEnd],
[motion_events, getSegmentStart, getSegmentEnd, segmentDuration],
);
const getAudioSegmentValue = useCallback(