2013/02/16

Sound file loader

Play all supported sound files sequentially.
At that time, it playes each type.

// Sound player
// for X-BASIC for iOS v1.7 later

width(64)
//
vpriority(TPAGE,GPAGE0,GPAGE1,GPAGE2,GPAGE3)
vpage(B_TPAGE or B_GPAGE0 or B_GPAGE1 or B_GPAGE2 or B_GPAGE3,YES)
apage(GPAGE0)
//
// Get all file list
dim str fileList(256):// max file
int allcnt
int i,ret
str ext
//
// Extension (case sensitive)
// Regular expression
ext="PCM|pcm|wav|WAV|aiff|AIFF|M44|P16|M30":
allcnt=files(fileList,"",ext,YES,FILES_FILE,YES)
if allcnt<=0 then {
 locate(0,0)
 print localizedString("音声ファイルがありません":"Sound file not found.")
} else {
 int no
 for i=0 to allcnt-1
  locate(0,0):print fileList(i)
  str pext=pathExtension(fileList(i))
  strupr(pext)
  if pext="PCM" then {
   print "(ADPCM)"
   no=a_setPlayData(fileList(i),0)
  } else {
   no=a_setPlayData(fileList(i))
  }
  a_play(no)
  hitKey()
  a_end(no)
 next
}
end
//---------
func hitKey()
 setFunctionKey(0,localizedString("ここを押してください","Hit This Button"),'!')
 displayFunctionKey(YES,0,0)
 while inkey()=0
 endwhile
 cls()
 displayFunctionKey(NO,0,0)
endfunc
//---------
func str localizedString(js;str,es;str)
 if isLocalizeJapan() then return(js)
 return (es)
endfunc
//---------
Zip file including sample sound files is here : XBsoundloader.zip

No comments:

Post a Comment