public static void enforce_margin(final float[] lsp,
                                    final int len,
                                    final float margin)
  {
    int i;
    
    if (lsp[0]<margin)
      lsp[0]=margin;
    
    if (lsp[len-1]>(float)Math.PI-margin)
      lsp[len-1]=(float)Math.PI-margin;
    
    for (i=1;i<len-1;i++)
    {
      if (lsp[i]<lsp[i-1]+margin)
        lsp[i]=lsp[i-1]+margin;

      if (lsp[i]>lsp[i+1]-margin)
        lsp[i]= .5f * (lsp[i] + lsp[i+1]-margin);
    }
  }