As it often happens, you start the implementation of an algorithm that initially seems to be straightforward and eventually a number of challenges emerge, making the implementation more difficult and intriguing.

This is what happened to me with the implementation of a windowless granulator based on zero-crossing (ZC) detection and delay lines. I will briefly summarise the main points below, depicting what seems to be a fairly advanced stage of the implementation that has given good results.

  • The content of a delay line of size L can be static: such delay line should be filled with the output of a feedback loop of period L that is, in turn, filled with an input signal x. The gains of the input signal and feedback path are mutually exclusive to transition from live to looped inputs.
  • For a given pitch shift and time transposition factors, the complement of such factors determines the slopes of line functions that are used, respectively, to modulate the delay and to offset the delay start.
  • For proper continuity in the signal, both the end of the current grain and the beginning of the next one must at a ZC.
  • For proper continuity in the signal, both the derivatives at the end of the current grain and at the beginning of the next one must have the same sign.
  • For proper continuity in the signal, the position of the next grain must be corrected to avoid the repetition of samples – two samples at a ZC. 
  • The sample position correction can be obtained as the ratio between the derivatives at the end and the beginning of grains. This prevents the derivative of the signal to suddenly change in sign when transitioning from a high-rate grain to a slower-rate one.
  • Negative pitch transposition factors result in grains being read backwards, which in turn result in a change of sign in the derivative of the signal. This must be taken into account to select the next grains with the right derivative sign, and the right direction for the sample position correction – either forward or backward.