Need a unique gift idea?
A Pastebin account makes a great Christmas gift
SHARE
TWEET

Untitled

a guest Dec 14th, 2017 303 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. /*
  2.     Curve file generator for the SunVox modules like MultiSynth, WaveShaper and MultiCtl.
  3.     by Alexander Zolotov / nightradio@gmail.com / warmplace.ru
  4.     License: CC BY https://creativecommons.org/licenses/by/4.0
  5.     How to use: change the SETUP part and run this program to generate the new file with the curve.
  6.     Changelog:
  7.     2017.10.11: v1.1 (fixed bugs; new curve function examples)
  8.     2017.08.16: v1.0
  9. */
  10.  
  11. // ########################################
  12. // ## SETUP ###############################
  13. // ########################################
  14.  
  15. //Filename:
  16. filename = "C"
  17.  
  18. //Format:
  19. format = 0
  20. if format == 0
  21. {
  22.     //MultiSynth: X = note; Y = velocity
  23.     type = INT8
  24.     items = 128
  25. }
  26. if format == 1
  27. {
  28.     //MultiSynth: X = velocity; Y = velocity
  29.     type = INT8
  30.     items = 257
  31. }
  32. if format == 2
  33. {
  34.     //WaveShaper
  35.     type = INT16
  36.     items = 256
  37. }
  38. if format == 3
  39. {
  40.     //MultiCtl
  41.     type = INT16
  42.     items = 257
  43.     max = 32768
  44. }
  45.  
  46. offset = 0 //note offset for creating type 0 curves that block out notes
  47.  
  48. //Function:
  49. //$x = 0 ... 1.0
  50. //$y = 0 ... 1.0
  51. fn curve_function( $x, $offset )
  52. {
  53.     //$y = sin( $x * M_PI * 2 ) / 2 + 0.5 //Sine
  54.     //$y = $x //Linear
  55.     //$y = pow( $x, 3 ) //Exponential
  56.     //$y = pow( $x, 6 ) //Exponential+
  57.     //$y = pow( $x, 0.5 )
  58.     //$y = $x * $x + pow( $x, 3 ) * ( 1 - $x ) //Something between the linear and the exponential curve
  59.    
  60.     if ($x - $offset) % 12 == 0
  61.     {
  62.         $y = 255
  63.     }
  64.     else
  65.     {
  66.         $y = 0
  67.     }
  68.    
  69.     ret( $y )
  70. }
  71.  
  72. // ########################################
  73. // ## SETUP COMPLETE ######################
  74. // ########################################
  75.  
  76. set_pixel_size( WINDOW_XSIZE / 480 )
  77. resize( get_screen(), WINDOW_XSIZE, WINDOW_YSIZE )
  78. scr = get_screen()
  79. xsize = get_xsize( scr )
  80. ysize = get_ysize( scr )
  81.  
  82. curve = new( items, 1, type )
  83. clean( curve )
  84. if max == 0
  85. {
  86.     if type == INT8 { max = 255 }
  87.     if type == INT16 { max = 65535 }
  88. }
  89. i = 0 while i < items
  90. {
  91.     v = curve_function( i / ( items - 1 ), offset )
  92.     if v < 0 { v = 0 }
  93.     if v > 1 { v = 1 }
  94.     if type == INT8 { v * max }
  95.     if type == INT16 { v * max }    
  96.     logf( "%d: %d\n", i, v )
  97.     curve[ i ] = v
  98.     i + 1
  99. }
  100. save( curve, filename, FORMAT_RAW )
  101.  
  102. clear( BLACK )
  103. i = 0 while i < items
  104. {
  105.     x = i / items * xsize - xsize / 2
  106.     y = - ( curve_function( i / items ) - 0.5 ) * ysize
  107.     dot( x, y, WHITE )
  108.     i + 1
  109. }
  110.  
  111. while 1
  112. {
  113.     frame( 100 )
  114.     while get_event() { if EVT[ EVT_TYPE ] == EVT_QUIT { halt } }
  115. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top