def rebound(x, low=1, high=2, octave=2):
    """
    Rescale x within given octave bounds.

    x: int
        represents a peak value
    low: int
        Lower bound. Defaults to 1. 
    high: int
        Higher bound. Defaults to 2.
    octave: int
        Value of an octave
    """
    while x >= high:
        x = x/octave
    while x <= low:
        x = x*octave
    return x