[sdiy] karplus-strong drum synthesis

Joel B onephatcat at earthlink.net
Sun Aug 21 20:55:21 CEST 2011


On Aug 20, 2011, at 8:21 PM, Olivier Gillet wrote:

>> Would that be random 16 bit integers for 16 bit sound?
> 
> yes
> 
>> % in this context is the modulo function if I'm not mistaken?
> 
> yes
> 
>> so this is how you do the wrapping on the wavetable. Very nice, no "if ptr > 880 then ptr=0" statement.
> 
> the "if" form might be faster on architectures with slow divisions.
> 
>> if the pitch is A440, then that would be an array of size 880 samples.
> 
> You are mixing up frequency and period. A440 = 440 Hz. In the paper p
> is the period, in samples. To get a 440 Hz tone, p = fs / 440 ; for
> example 100 if your output signal is at 44.1kHz.
> 
>> while i < outputLength
>> 
>> r=rnd(65536)-32768
>> //seems perhaps redundant to run a second random number generator when we already have an array full of random numbers?
> 
> After some time, I don't think your array will be full of random
> numbers, otherwise it wouldn't be "karplus strong synthesis" but just
> "noise synthesis".
> 
>> if r > blend
>> //if blend is usually < 1 and rnd is either a positive or negative integer, seems like this is to determine if we dealing with positive or negative number
> 
> Looks like you are mixing up the random numbers used to initialize the
> table, and the random number to decide which "branch" of the equation
> on page 46 to use. The eq on page 46 says that at each sample, you
> toss a coin to decide whether you'll use the equation with the
> positive sign, or the negative sign ; and b controls how fair the coin
> is.
> 
> So r is a floating point number between 0 and 1. Since you want the
> test to be always true when b is equal to 1, the test would be "if rnd
> < b" (I got that wrong in my first email). This choice is independent
> of the generated signal itself.


Thanks Oliver, I'll post the results once I get it all working.

 - Joel


More information about the Synth-diy mailing list