プログラムリスト
SYS/EX6SEQUENCER
トップメニュー「SmileBASICでプログラムを作る」から、LOAD"SYS/EX6SEQUENCER"↵
でプログラムが読み込まれます。キーボードの「EDIT」キーを押すと、このプログラムが自由に編集できます。
'
' EXAMPLE6
' SEQUENCER
'
XSCREEN 2,16,2
FOR I=0 TO 1
DISPLAY I:GCLS:VISIBLE 0,0,0,0
NEXT
FOR I=0 TO 3:BREPEAT I,15,4:NEXT
BGMSTOP
'---
TRK=12
SCO=16
DIM S[TRK,SCO]
DIM F[TRK,SCO],V[TRK,SCO],P[TRK,SCO]
'--- voice
@VOICE
DATA 52,0 'BD
DATA 30,1 'SD
DATA 27,2 'CHH
DATA 26,3 'OHH
DATA 25,4 'CYMB
DATA 28,5 'CLAP
DATA 47,6 'TOM
DATA 62,7 'COW
DATA 60,8 'BELLTREE
DATA 103,9 'SPLASH
DATA 68,10 'DOG
DATA 19,11 'SYNBASS
DIM VCE[TRK,2]
COPY VCE,"@VOICE"
'---
MD=1
GOSUB @SCINIT
GOSUB @INIT
GOSUB @SCPUT
'---
TMP=120:TT=1/60:TC=TT
GOSUB @CLCTMP
OFS=0:PLY=FALSE
DISPLAY 0:VISIBLE 1,1,1,1
DISPLAY 1:VISIBLE 1,1,1,1
'---
@LOOP
B=BUTTON(1)
OLDST=TST:OTX=TX:OTY=TY
TOUCH OUT TST,TX,TY
GOSUB @CTRL
GOSUB @SEQEDIT
GOSUB @SEQPLAY
GOSUB @PUTST
VSYNC 1
GOTO @LOOP
'---
@PUTST
DISPLAY 0
LOCATE 0,20
PRINT FORMAT$(" SPD:%3D",TMP)
PRINT FORMAT$("TMAX:%5.3F",TMAX)
PRINT FORMAT$(" TI:%5.3F",TT)
PRINT FORMAT$(" TC:%5.3F",TC)
RETURN
'---
@CTRL
OT=TMP
IF B==64 THEN GOSUB @SCCLR
IF B==4 THEN TMP=TMP-1
IF B==8 THEN TMP=TMP+1
IF TMP<10 THEN TMP=10
IF TMP>240 THEN TMP=240
IF OT!=TMP THEN GOSUB @CLCTMP
RETURN
'---
@SCCLR
GOSUB @SCINIT
FOR I=0 TO TRK-1
FOR O=0 TO 15
GOSUB @SCPUT1
NEXT
NEXT
RETURN
'---
@SEQEDIT
IF TST==FALSE THEN RETURN
'---
X=FLOOR((TX-(SX*8))/16)
Y=FLOOR((TY-(SY*8))/16)
IF Y>=TRK THEN
IF TX>160 THEN
MD=1
ELSE
MD=0
ENDIF
GOSUB @PUTMODE
RETURN
ENDIF
'---
IF Y<0 THEN RETURN
IF Y>=TRK THEN RETURN
IF X<0 THEN RETURN
IF X>=16 THEN RETURN
'---
O=X:I=Y:S[I,O]=MD
GOSUB @SCPUT1
RETURN
'---
@CLCTMP
T=60*60 '(VSYNC 1)=(1/60SEC)
E=TMP*4 '16
TMAX=T/E/48
RETURN
'---
@SEQPLAY
TC=TC-TT
IF TC>0 THEN RETURN
GOSUB @SCPLAY
TC=TC+TMAX
RETURN
'---
@SCPLAY
FOR I=0 TO TRK-1
IF S[I,OFS] THEN
BEEP VCE[I,0],F[I,OFS],V[I,OFS],P[I,OFS]
ENDIF
NEXT
'---
OFS=OFS+1
OFS=OFS AND 15
DISPLAY 1
FOR I=0 TO TRK-1
SPOFS I,SPX+OFS*16,SPY+I*16
NEXT
RETURN
'---
@SCINIT
FOR I=0 TO TRK-1
FOR O=0 TO 15
S[I,O]=0:'RND(2)
F[I,O]=0:'RND(8192)-4096
V[I,O]=127:'RND(100)+27
P[I,O]=64:'RND(128)
NEXT
NEXT
RETURN
'---
@SCPUT1 'I=TRK,O=SCO
DISPLAY 1
NO=SPSCO+I*SCO+O
IF S[I,O]==0 THEN @SCOFF1
SPSHOW NO
RETURN
'---
@SCOFF1
SPHIDE NO
RETURN
'---
@SCPUT
FOR I=0 TO TRK-1
FOR O=0 TO 15
GOSUB @SCPUT1
NEXT
NEXT
RETURN
'---
@INIT
DISPLAY 0
CLS:COLOR 15
PRINT ""
PRINT " "
PRINT "
PRINT " "
PRINT "version 3.0"
LOCATE 0,29
PRINT ":CHANGE TEMPO :ALL CLEAR";
'---
DISPLAY 1
TXX=6:TXY=1:LOCATE TXX,TXY
PRINT "0 1 2 3 4 5 6 7 8 9 A B C D E F";
X=TXX:Y=TXY+1:SX=X:SY=Y
FOR I=0 TO TRK-1
LOCATE 0,Y+1:PRINT VCE[I,0]
LOCATE X,Y+0:PRINT ""*16;"";
LOCATE X,Y+1:PRINT " "*16+"";
Y=Y+2
NEXT
LOCATE X,Y:PRINT ""*32
COLOR 15
'--- play cursor
SPX=3*16:SPY=16
FOR I=0 TO TRK-1
SPSET I,241 '306
SPOFS I,SPX,SPY+I*16,-100
SPCOLOR I,RGB(128,255,255,255)
J=I+TRK
SPSET J,VCE[I,1]
SPOFS J,SPX-16,SPY+I*16,-100
NEXT
'--- score
SPSCO=TRK*2
FOR Y=0 TO TRK-1
FOR X=0 TO SCO-1
I=SPSCO+X+Y*SCO
SPSET I,VCE[Y,1]:SPHIDE I
SPOFS I,SPX+X*16,SPY+Y*16,0
NEXT
NEXT
'---
@PUTMODE
DISPLAY 1
S1$="":S2$=""
IF MD==1 THEN SWAP S1$,S2$
X=20:Y=27
LOCATE X,Y+0:PRINT "";
LOCATE X,Y+1:PRINT "";S1$;"WRITE";
LOCATE X,Y+2:PRINT "";
X=12:Y=27
LOCATE X,Y+0:PRINT "";
LOCATE X,Y+1:PRINT "";S2$;"ERASE";
LOCATE X,Y+2:PRINT "";
RETURN