Advertisement
Guest User

zebra-spectroblend.py

a guest
Apr 25th, 2015
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.76 KB | None | 0 0
  1. import sys
  2.  
  3. fmt_head = """
  4. #defaults=no
  5. #patchname=no
  6. <?
  7.  
  8. int OSC_WAVEFORM_SPECTROBLEND = 3;
  9. int i;
  10.  
  11. float w1[128];
  12. """
  13.  
  14. fmt_el = "w1[%d]=%.03f; "
  15.  
  16. fmt_foot = """
  17.  
  18. for( i = 1; i <= 1; i++ )
  19. {
  20.  if (Oscillator[i].WaveForm == OSC_WAVEFORM_SPECTROBLEND)
  21.  {
  22.    Oscillator[i].WaveTable.set(1,w1);
  23.  }
  24. }
  25.  
  26. ?>
  27. """[:-1]
  28.  
  29. if __name__ == "__main__":
  30.    w = sys.stdout.write
  31.    w(fmt_head)
  32.    # Specify first 3 partials by hand (zero indexed)
  33.    w(fmt_el % (0, 142.0/160))
  34.    w(fmt_el % (1, 160.0/160))
  35.    w(fmt_el % (2, 150.0/160))
  36.    w("\n")
  37.    # Partials 4 - 128 follow the 1/n algorithm
  38.    for n in range(3,128):
  39.        partial = 1.0 / (n - 2)
  40.        w(fmt_el % (n, partial))
  41.        if n > 0 and n % 8 == 0:
  42.            w("\n")
  43.    w(fmt_foot)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement