home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Club Amiga de Montreal - CAM
/
CAM_CD_1.iso
/
files
/
112.lha
/
Director_Midi
/
miditest
< prev
next >
Wrap
Text File
|
1986-11-20
|
2KB
|
105 lines
rem midi sound module test example
rem to run, an 'assign mod: ---' must have been done to let
rem the Director know where the sound module is. (see chapter 2)
rem When you run, wait until all disk activity stops, then
rem it should respond to MIDI note commands on channel 1
rem first, we create an array big enough to hold a note period table
rem and note number to sample-buffe `r table
array 200,2
rem now setup the pics
rem create pics 1-4 by blitting from loaded pic in 5
setblack 1
load 5,"Pictures:flash5.pic"
new 1,5
display 1
blit 5,29,14,29,14,153,105
new 2,5
display 2
blit 5,198,0,158,20,153,133
new 3,5
display 3
blit 5,49,120,49,100,157,119
new 4,5
display 4
blit 5,209,134,169,94,142,105
free 5
rem loadup the sound samples
module "sound"
sound perioda,"load",1,0,"Sound:hammer1.snd"
sound periodb,"load",2,0,"Sound:switch.snd"
sound periodc,"load",3,0,"Sound:mtcymb.snd"
sound periodd,"load",4,0,"Sound:snare.snd"
rem setup midi
sound a,"midi",1,1
position -1,-1:rem adjust for overscan
rem setup a default period in the notetable
for i=0 to 99:@(i) = perioda:@(i+100)=1:next
rem build table of note sample-periods in the array from 0-99
i = 42:rem starting location for this octave
@(i) = 508
i=i+1:@(i) = 480
i=i+1:@(i) = 453
i=i+1:@(i) = 428
i=i+1:@(i) = 404
i=i+1:@(i) = 381
i=i+1:@(i) = 360
i=i+1:@(i) = 339
i=i+1:@(i) = 320
i=i+1:@(i) = 302
i=i+1:@(i) = 285
i=i+1:@(i) = 269
i=i+1
rem generate upper two octaves
for i=i to i+24
@(i)=@(i-12)/2
next
rem generate lower octaves
for i=41 to 0
@(i)=@(i+12)*2
next
rem fill the note table with sound buffer numbers
for i=100 to 199
@(i)=1+i%4
next
speed 1
10 sound note,"wait"
velo = note/512:rem convert to 0-63 volume from 0-128
note = note%256
if velo:rem a note on
rem play sample selected by @(100+note)
rem at period selected by @(note)
b = @(100+note)
sound a,"play",b,1,velo-1,@(note)
display b
for i=1 to 3
color -1,1,i,1+?15,1+?15,1+?15
next
setblack 0
goto 10
else:rem a note off
setblack 1
goto 10
endif