Skip to content
This repository has been archived by the owner on Mar 18, 2024. It is now read-only.

Commit

Permalink
Fix for stereo position calculations
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason Crawford committed Feb 22, 2021
1 parent 0c3fa83 commit 1d8cab3
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions panning/position.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ func MakeStereoPosition(value float32, leftValue float32, rightValue float32) Po
panic("leftValue and rightValue should be distinct")
}
d := float64(rightValue - leftValue)
t := (d - float64(value)) / d
t := float64(value-leftValue) / d
// we're using a 2d rotation matrix to calcuate the left and right channels, so we really want the half angle
prad := t * math.Pi / 2.0
prad := (1 - t) * math.Pi / 2.0

return Position{
Angle: float32(prad),
Expand All @@ -37,9 +37,6 @@ func FromStereoPosition(pos Position, leftValue float32, rightValue float32) flo
panic("leftValue and rightValue should be distinct")
}
prad := pos.Angle
t := float64(prad*2.0) / math.Pi
d := float64(rightValue - leftValue)
value := d - (t * d)

return float32(value)
t := 1 - (float64(prad*2.0) / math.Pi)
return leftValue + float32(t)*(rightValue-leftValue)
}

0 comments on commit 1d8cab3

Please sign in to comment.