I understand to find the length of the grain I need to perform an FFT over the source to find the fundamental harmonic, I can do that and find an accurate grain length, but now I need to find a start and end point of each grain and I'm not sure how to decide how to do it.

From what I can think of I have the following options

  • Always cut at the zero cross over point, ignoring the accurate grain length.
  • Cut the first grain at zero, from then on rely on the FFT information to cut accurate grain lengths and hope each start and end will be close to zero.
  • Find the centre of each grain using an average of amplitude, then use the accurate grain length (this would put duplicate data in grains next to each other, as each grain would not care where the last grain ended, this doesn't seem right)
  • The above but guarantee each grain starts where the other ended, and sacrifice both zero crossover AND grain length
  • Nothing, just use grain length and not care about zero crossings or being anywhere near them.
  • 1
    $\begingroup$ uhm, this looks a lot like it's about Lent's algorithm (also credited to Hamon) for shifting pitch without shifting the spectral envelope. back in 1995, i had a paper about this. Lent's original paper is 1989 in Computer Music Journal. you want to window off two adjacent periods and use a complementary window (like Hann) to define the grain. you likely also want to position the center of the window around where, in the waveform, there is maximum energy. $\endgroup$ – robert bristow-johnson Aug 11 '19 at 21:35
  • 1
    $\begingroup$ and i wouldn't bother with an FFT. use a time-domain pitch detection technique and isolate your overlapping and adjacent grains from that information. $\endgroup$ – robert bristow-johnson Aug 11 '19 at 21:36
  • $\begingroup$ I see. I've inherited this project that uses FFT, but I think I can still do what you've suggested, look for the maximum energy in two grains and slice inbetween. I'm feeling confident now, thanks. $\endgroup$ – cool mr croc Aug 12 '19 at 19:22
  • $\begingroup$ i have a pretty good description of a time domain pitch detection alg here which will help you parse the boundaries or "epochs" of each cycle. remember that two adjacent cycles windowed with a Hann window makes a grain. And here you can get a copy of an old paper of mine describing the algorithm i call "grains" little "wavelets". $\endgroup$ – robert bristow-johnson Aug 12 '19 at 20:21
  • $\begingroup$ and you might be able to read Lent's paper here. $\endgroup$ – robert bristow-johnson Aug 12 '19 at 20:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.