Exemplo n.º 1
0
def create_from_samples(init):
    """
    Create and return a guitar string whose size and initial values are given
    by the list init.
    """

    n = len(init)
    rb = ring_buffer.create(n)
    for v in init:
        ring_buffer.enqueue(rb, v)
    return rb
def create_from_samples(init):
    """
    Create and return a guitar string whose size and initial values are given
    by the list init. Populate the ring buffer with values from init.
    Return the ring buffer.
    """

    capacity = len(init)
    rb = ring_buffer.create(capacity)
    for i in init:
        ring_buffer.enqueue(rb, i)
    return rb
def create_from_samples(init):
    """
    Create and return a guitar string whose size and initial values are given
    by the list init.
    """

    # create a sample ring buffer
    # use for loop and make it equal to init
    samp_rg = ring_buffer.create(len(init))
    for v in init:
        ring_buffer.enqueue(samp_rg, v)

    return samp_rg
def create(frequency):
    """
    Create and return a guitar string of the given frequency, using a sampling
    rate given by SPS. A guitar string is represented as a ring buffer of
    of capacity N (SPS divided by frequency, rounded up to the nearest
    integer), with all values initialized to 0.0.
    """

    N = int(math.ceil(SPS / frequency))
    rb = ring_buffer.create(N)
    for i in range(N):
        ring_buffer.enqueue(rb, 0.0)
    return rb
def create(frequency):
    """
    Create and return a guitar string of the given frequency, using a sampling
    rate given by SPS. A guitar string is represented as a ring buffer of
    of capacity N (SPS divided by frequency, rounded up to the nearest
    integer), with all values initialized to 0.0.
    """

    # calculating N then rouned up.
    N = int(math.ceil(SPS / frequncy))

    # create a guitar string by using ring buffer.
    string = ring_buffer.create(N)

    # use for loop for enqeue N.
    for v in range(N):
        ring_buffer.enqueue(string, 0.0)

    # return string
    return string