void UpdateDisplay() { if (Channels.Count == 0) { BallPosition = new Point(100, 100); return; } foreach (var channel in Channels) { // If the channel's playing then update it's position if (Bass.ChannelIsActive(channel.Handle) == PlaybackState.Playing) { // Check if channel has reached the max distance if (channel.Position.Z >= MaxDist || channel.Position.Z <= -MaxDist) { channel.Velocity.Z = -channel.Velocity.Z; } if (channel.Position.X >= MaxDist || channel.Position.X <= -MaxDist) { channel.Velocity.X = -channel.Velocity.X; } // Update channel position channel.Position.Z += channel.Velocity.Z * TimerPeriod / 1000; channel.Position.X += channel.Velocity.X * TimerPeriod / 1000; Bass.ChannelSet3DPosition(channel.Handle, channel.Position, null, channel.Velocity); } // Draw the channel position indicator BallPosition = new Point(100 + (int)((100 - 10) * channel.Position.X / MaxDist), 100 - (int)((100 - 10) * channel.Position.Z / MaxDist)); } Bass.Apply3D(); }