最初にあるa_setPlayData()に、手持ちの音声ファイルを指定してください。
サンプル曲は満開製作所の「Muff&Huff」より拝借しています(自由に利用できる曲)。
// audio test
// ↓手持ちの音声ファイルを指定してください
// サンプルは満開製作所「Muff&Huff」より
int sno=a_setPlayData("EARTH SONG #1.mp3")
if (sno=-2) then {
print "sound file not found."
end
}
int wx
//
dim int touchNo(10) :// タッチエリア番号
int touchCnt :// タッチエリア数
font("IPAGothic")
int fzenhan
int WX=64:if deviceType()<>1 then WX=48
int WY=width(WX,,fzenhan)
int xw=1:/* 全角1文字の桁数
if fzenhan then xw=2
str exit$
if isLocalizeJapan() then {
exit$="中断"
} else {
exit$="exit"
}
int x=WX/2-18
int y=WY/2
// 012345678901234567890123456789
locate(x,y+0):print " ┏━┓"
locate(x,y+1):print " ┃8┃"
locate(x,y+2):print " ┗━┛"
locate(x,y+3):print "┏━┓┏━┓┏━┓ ┏━━┓"
locate(x,y+4):print "┃4┃┃?┃┃6┃ ┃";exit$;"┃"
locate(x,y+5):print "┗━┛┗━┛┗━┛ ┗━━┛"
locate(x,y+6):print " ┏━┓"
locate(x,y+7):print " ┃2┃"
locate(x,y+8):print " ┗━┛"
int i=0
touchNo(inc(i))=setTouchArea(textX2Gx(x+ 6),textY2Gy(y ),textX2Gx(xw*3),textY2Gy(3),'8',YES, 0,50,55,220)
touchNo(inc(i))=setTouchArea(textX2Gx(x+ 6),textY2Gy(y+6),textX2Gx(xw*3),textY2Gy(3),'2',YES, 0,50,55,220)
touchNo(inc(i))=setTouchArea(textX2Gx(x ),textY2Gy(y+3),textX2Gx(xw*3),textY2Gy(3),'4',YES, 0,50,55,220)
touchNo(inc(i))=setTouchArea(textX2Gx(x+12),textY2Gy(y+3),textX2Gx(xw*3),textY2Gy(3),'6',YES, 0,50,55,220)
//
touchNo(inc(i))=setTouchArea(textX2Gx(x+ 6),textY2Gy(y+3),textX2Gx(xw*3),textY2Gy(3),'?',YES,150,50, 5,120)
touchNo(inc(i))=setTouchArea(textX2Gx(x+22),textY2Gy(y+3),textX2Gx(xw*4),textY2Gy(3),'!',YES,150, 5 ,5,120)
touchCnt=i
//
keyRepeatTime(0,0):// リピート無し
//
setFunctionKey(0,exit$,'!')
setFunctionKey(1,"V-UP",'u')
setFunctionKey(2,"V-DN",'d')
setFunctionKey(3,"SPD",'S')
setFunctionKey(4,"LP=1",'1')
setFunctionKey(5,"LP∞" ,'0')
setFunctionKey(6,"LP=2",'2')
setFunctionKey(7,"PAN",'c')
setFunctionKey(8,"stop",'s')
setFunctionKey(9,"cont",'C')
setFunctionKeyBackgroundImage("funcBack.png")
displayFunctionKeyAll(YES)
int speed=0
int pan=0
str cs
int dt=0,t
int ts=time():/* 開始時間
locate(20,1)
a_play(sno)
while YES
// while a_stat(sno)
// キー入力待ちしながら時計を回す
while (not kbhit())
/* キー入力の無い間
t=time()
if t-ts>dt then { :/* 秒が変った
dt=dt+1
locate(20,0):print dt;
beep2(0)
locate(20,1)
}
endwhile
// キー操作判定
cs=inkey$()
switch cs
case "u":a_volume(sno,1.0):break
case "d":a_volume(sno,0.05):break
case "S":
switch speed
case 0:a_speed(sno,2.0):break
case 1:a_speed(sno,0.5):break
case 2:a_speed(sno,1.0):break
endswitch
speed=speed+1
break
case "1":
a_loop(sno,1):print "loop=1"
break
case "2":
a_loop(sno,2):print "loop=2"
break
case "0":
a_loop(sno,0):print "loop=∞"
break
case "c":
switch pan
case 0:a_pan(sno,-1.0):inc(pan):break
case 1:a_pan(sno, 0.0):inc(pan):break
case 2:a_pan(sno, 1.0):pan=0:break
endswitch
break
case "r"
break
case "s":a_stop(sno):break
case "C":a_cont(sno):break
endswitch
print cs;
if cs="!" then break
endwhile
a_end(sno)
print "end"
end
func resetTouchArea()
// タッチエリアの解除
int i
for i=0 to touchCnt
removeTouchArea(touchNo(i))
next
touchCnt=0
endfunc
サンプル音声ファイル入り圧縮ファイル:XBaudioTest.zip
0 件のコメント:
コメントを投稿