def pluck(string): """ Pluck the given guitar string by replacing the buffer with white noise. """ ring_buffer.dequeue(string) ring_buffer.enqueue(string, random.randrange(-0.5, 0.5))
def pluck(string): """ Pluck the given guitar string by replacing the buffer with white noise. """ string_size = ring_buffer.size(string) for i in range(0, string_size): ring_buffer.dequeue(string) ring_buffer.enqueue(string, random.uniform(-0.5, 0.5))
def pluck(string): """ Pluck the given guitar string by replacing the buffer with white noise. """ ring_buffer.dequeue(string) random_entry = random.uniform(-0.5, 0.5) print(random_entry) ring_buffer.enqueue(string, random_entry)
def pluck(string): """ Pluck the given guitar string by replacing the buffer with white noise. Replace each value (dequeue followed by enqueue) in the given ring buffer with a random number from the interval [-0.5, 0.5]. """ ring_buffer.dequeue(string) r = random.uniform(-0.5, 0.5) ring_buffer.enqueue(string, r)
def pluck(string): """ Pluck the given guitar string by replacing the buffer with white noise. """ # All elements in ring buffer replaced with random float. for v in range(ring_buffer.capacity(string)): v = random.uniform(-0.5, 0.5) ring_buffer.dequeue(string) ring_buffer.enqueue(string, v)
def tic(string): """ Advance the simulation one time step on the given guitar string by applying the Karplus-Strong update. """ a = ring_buffer.dequeue(string) b = ring_buffer.peek(string) ring_buffer.enqueue(string, 0.996 * 0.5 * (a + b))
def tic(string): """ Advance the simulation one time step on the given guitar string by applying the Karplus-Strong update. """ x1 = ring_buffer.dequeue(string) x2 = ring_buffer.peek(string) x3 = 0.5 * (x1 + x2) * 0.996 ring_buffer.enqueue(string, x3)
def tic(string): """ Advance the simulation one time step on the given guitar string by applying the Karplus-Strong update. Dequeue a value a in the given ring buffer and peek at the next value b. Enqueue the value 0.996 * 0.5 * (a+b) into the ring buffer. """ a = ring_buffer.dequeue(string) b = ring_buffer.peek(string) ring_buffer.enqueue(string, 0.996 * 0.5 * (a + b))
def tic(string): """ Advance the simulation one time step on the given guitar string by applying the Karplus-Strong update. """ # set x with removed value of the ring buffer. x = ring_buffer.dequeue(string) # set y without removing value of rg. y = ring_buffer.peek(string) # set z as with Karplus-Strong update. # invoke enqueue with string and z z = 0.996 * 0.5 * (x + y) ring_buffer.enqueue(string, z)