home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 112.lha / Director_Midi / miditest < prev    next >
Text File  |  1986-11-20  |  2KB  |  105 lines

  1.  
  2.     rem   midi sound module test example
  3.     rem   to run, an 'assign mod:  ---'  must have been done to let
  4.     rem      the Director know where the sound module is. (see chapter 2)
  5.  
  6.     rem  When you run, wait until all disk activity stops, then 
  7.     rem  it should respond to MIDI note commands on channel 1
  8.  
  9.     rem  first, we create an array big enough to hold a note period table
  10.     rem  and note number to sample-buffe    `r table
  11.  
  12.     array 200,2
  13.  
  14.     rem  now setup the pics
  15.     rem  create pics 1-4 by blitting from loaded pic in 5
  16.  
  17.  
  18.     setblack 1
  19.     load 5,"Pictures:flash5.pic"
  20.     new 1,5
  21.     display 1
  22.     blit 5,29,14,29,14,153,105
  23.     new 2,5
  24.     display 2
  25.     blit 5,198,0,158,20,153,133
  26.     new 3,5
  27.     display 3
  28.     blit 5,49,120,49,100,157,119
  29.     new 4,5
  30.     display 4
  31.     blit 5,209,134,169,94,142,105
  32.     free 5
  33.  
  34.     rem  loadup the sound samples
  35.     module "sound"
  36.     sound perioda,"load",1,0,"Sound:hammer1.snd"
  37.     sound periodb,"load",2,0,"Sound:switch.snd"
  38.     sound periodc,"load",3,0,"Sound:mtcymb.snd"
  39.     sound periodd,"load",4,0,"Sound:snare.snd"
  40.  
  41.     rem  setup midi
  42.     sound a,"midi",1,1
  43.  
  44.     position -1,-1:rem   adjust for overscan
  45.  
  46.     rem  setup a default period in the notetable
  47.     for i=0 to 99:@(i) = perioda:@(i+100)=1:next
  48.  
  49.     rem build table of note sample-periods in the array from 0-99
  50.  
  51.     i = 42:rem  starting location for this octave
  52.     @(i) = 508
  53.     i=i+1:@(i) = 480
  54.     i=i+1:@(i) = 453
  55.     i=i+1:@(i) = 428
  56.     i=i+1:@(i) = 404
  57.     i=i+1:@(i) = 381
  58.     i=i+1:@(i) = 360
  59.     i=i+1:@(i) = 339
  60.     i=i+1:@(i) = 320
  61.     i=i+1:@(i) = 302
  62.     i=i+1:@(i) = 285
  63.     i=i+1:@(i) = 269
  64.     i=i+1
  65.  
  66.     rem  generate upper two octaves
  67.     for i=i to i+24
  68.         @(i)=@(i-12)/2
  69.     next
  70.  
  71.     rem  generate lower octaves
  72.     for i=41 to 0
  73.         @(i)=@(i+12)*2
  74.     next
  75.  
  76. rem  fill the note table with sound buffer numbers
  77.     for i=100 to 199
  78.         @(i)=1+i%4
  79.     next
  80.  
  81.     speed 1
  82. 10    sound note,"wait"
  83.     velo = note/512:rem  convert to 0-63 volume from 0-128
  84.     note = note%256
  85.  
  86.     if velo:rem  a note on
  87.  
  88.         rem  play sample selected by  @(100+note)
  89.         rem  at period selected by @(note)
  90.         b = @(100+note)
  91.         sound a,"play",b,1,velo-1,@(note)
  92.  
  93.         display b
  94.         for i=1 to 3
  95.             color -1,1,i,1+?15,1+?15,1+?15
  96.         next
  97.         setblack 0
  98.         goto 10
  99.  
  100.     else:rem  a note off
  101.         setblack 1
  102.         goto 10
  103.     endif
  104.  
  105.