def sample(string): """ Return the current sample from the given guitar string. """ # return ring buffer return ring_buffer.peek(string)
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)
def sample(string): """ Peek and return the current sample from the given guitar string. """ return ring_buffer.peek(string)