Creating arrays of wave formulas with BWise

Theo Verelst

Granted, it sounds a bit scienfic, but it's actually quite generally useful and quite followable. Like with the fairly quickly programmed experiments on Creating wave formulas with BWise and for window users a major part can run also via the code refered to on Wave player for formulas from BWise and Maxima on Windows XP the idea is to create

   bwise graph --> tcl list --> maxima formula --> fortran --> linked C program --> sound program on Linux with jack and Alsa midi
   of wave         of complete                               |---> latex   --> gif prettyprinted formula
   formulas        formula

where most of these tools are automatically called by tcl, under Tk button control.

In this case it is fun to play with the BWise blocks creating the signal-determining formula, or instance sine waves as connected blocks, for instance I created this bwise graph automatically:

Image Bwise scrarr1.png

You need the startup sources of the above pages, and bwise first, because they contain the necessary proc definitions !

 #
 # Make a ten input maxima formula addition block
 #
 proc_toblock add10 {} {} 700 100
 #
 # The output block which multiplies the final formula with the final volume, which has a name linked with the Run button
 #
 newproc {set mult11.out "((${mult11.a})*(${mult11.b}))"} mult11 {a b} out 40 {} {} 800 100
 set mult11.b (1/10)
 connect {} add10 out mult11 a
 #
 # First column
 #
 for {set i 1} {$i < 11} {incr i} { proc_toblock sinea [list {f 440*$i} {m 0} {a (1/$i)}] sine${i}_1 [expr 400] [expr 50+75*$i] ; connect {} sine${i}_1 out add10 i[expr $i] }
 #
 # Second column
 #
 for {set i 1} {$i < 11} {incr i} { proc_toblock sinea [list {f 440*$i} {m 0} {a (1/(1000*$i))}] sine${i}_2 [expr 300] [expr 50+75*$i] ; connect {} sine${i}_2 out sine${i}_1 m }

 # Create entries with modulation formulas of first column (where v is the velocity of the keypress, [0,1])
 #
 toplevel .if1
 for {set i 1} {$i < 11} {incr i} { pack [entry .if1.e1$i -textvar sine${i}_2.a -width 16] -side top -expand 1 -fill x }
 #
 # Set the variables
 #
 for {set i 1} {$i < 11} {incr i} { set sine${i}_2.a "(v/(2000*$i))" }

For Fortran interested people, this is the fortran file generated by the tcl routine after applying the Run button to the BWise graph:

      subroutine sayhello(x,r,v)
        double precision x,r,v
        r =        (sin(2.764601535159018d+4*(v*sin(2.764601535159018d+4*x)/2.d+4+x))
     1   /1.d+1+sin(2.4881413816431164d+4*(v*sin(2.4881413816431164d+4*x
     2   )/1.8d+4+x))/9.d+0+sin(2.2116812281272147d+4*(v*sin(2.211681228
     3   1272147d+4*x)/1.6d+4+x))/8.d+0+sin(1.9352210746113127d+4*(v*sin
     4   (1.9352210746113127d+4*x)/1.3999999999999999d+4+x))/7.d+0+sin(1
     5   .6587609210954105d+4*(v*sin(1.6587609210954105d+4*x)/1.2d+4+x))
     6   /6.d+0+sin(1.382300767579509d+4*(v*sin(1.382300767579509d+4*x)/
     7   1.d+4+x))/5.d+0+sin(1.1058406140636072d+4*(v*sin(1.105840614063
     8   6072d+4*x)/8.d+3+x))/4.d+0+sin(8.293804605477053d+3*(v*sin(8.29
     9   3804605477053d+3*x)/6.d+3+x))/3.d+0+sin(5.529203070318036d+3*(v
*sin(5.529203070318036d+3*x)/4.d+3+x))/2.d+0+sin(2.764601535159
     ;   018d+3*(v*sin(2.764601535159018d+3*x)/8.d+3+x)))/1.d+1
        return
      end

When you have Latex installed, use from bwise:

  newimage /dev/shm/formula.gif

to see the formula.

During trying the column creation or otherwise it may be handy to delete per column, to do this for the second one:

  for {set i 1} {$i < 11} {incr i} { cbbox sine${i}_2}
  delete_selblocks

To also delete the associated variables:

  foreach i [info var *sine*_2.*] {unset $i}

Yesterday evening I also tried a real big graph, how about a hundred sine wave FM algorithm?

Image Bwise scrarr2.png

That gives this [1 ] fortran function, and this http://www.theover.org/Bwise/Arr1/formula.gif formula (watch out, very big gif file!) and the algorithm has been turned into a succesfull executable using the aforementioned tcl scripts, except on a not so slow machine I could only have monophonic sound (1 100-oscilator voice at the time).

TV (sept 30 10)

For a musical experiment, see this wiki page ( http://www.theover.org/wiki/index.php/Chords_from_math_waves ) which will also contain pointers to code for making pop-up menus for creating math blocks automatically, and on a recent page on bwise I´ve made a "select all left" option to delete parts of graphs like above with only popup menus.