Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

all they need to do is to add an "autoloop" option to a track. people won't notice that it loops every minute or so


People will definitely notice the loop point if they're trying to sleep.

My Android app (Chroma Doze, est. 2010) uses this algorithm to splice noise segments together:

    When adding two streams together, the perceived amplitude stays constant
    if x^2 + y^2 == 1 for amplitudes x, y.
    
    A useful identity is: sin(x)^2 + cos(x)^2 == 1.
    
    Thus, we can perform a constant-amplitude crossfade using:
      result = fade_out * cos(x) + fade_in * sin(x)
      for x in [0, pi/2]
    
    But we also need to prevent clipping.  The maximum of sin(x) + cos(x)
    occurs at the midpoint, with a result of sqrt(2), or ~1.414.
    
    Thus, for a 16-bit output stream in the range +/-32767, we need to keep the
    individual streams below 32767 / sqrt(2), or ~23170.




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: