// Update is called once per frame
    void Update()
    {
        float bufferValue = audioPeer._audioBandBuffer[bandBufferIndex];
        float scale       = bufferValue * sphereScale;

        transform.localScale          = new Vector3(scale, scale, scale);
        trailRenderer.widthMultiplier = bufferValue * trailScale;

        color = Color.HSVToRGB(h, 1.5f - audioPeer._audioBandBuffer[bandBufferIndex], v);
        meshRenderer.material.SetColor("_Color", color);

        lerpedSpeed = Mathf.Lerp(0, speed, audioPeer._audioBandBuffer[bandBufferIndex]);

        if (beatCounter.NewBeat())
        {
            xyz[0] = 0;
            xyz[1] = 0;
            xyz[2] = 0;
            int index = Random.Range(0, 3);
            int value = Random.Range(0, 2) * 2 - 1;
            xyz[index] = value;

            direction = new Vector3(xyz[0], xyz[1], xyz[2]);
            isMoving  = true;
            trailRenderer.startWidth = scale;
        }

        if (isMoving)
        {
            Vector3 newPosition = transform.position + direction * Time.deltaTime * lerpedSpeed;
            if (containerBounds.Contains(newPosition))
            {
                transform.position += direction * Time.deltaTime * lerpedSpeed;
            }
            else
            {
                direction = containerBounds.center - transform.position;
                int index = Random.Range(0, 3);
                if (index == 0)
                {
                    direction[1] = 0; direction[2] = 0;
                }
                else if (index == 1)
                {
                    direction[0] = 0; direction[2] = 0;
                }
                else if (index == 2)
                {
                    direction[0] = 0; direction[1] = 0;
                }

                direction           = direction.normalized;
                transform.position += direction * Time.deltaTime * lerpedSpeed;
            }
        }
    }