;---------------------- ;typedef struct _MMCKINFO ;{ ; FOURCC ckid; /* chunk ID */ ; DWORD cksize; /* chunk size */ ; FOURCC fccType; /* form type or list type */ ; DWORD dwDataOffset; /* offset of data portion of chunk */ ; DWORD dwFlags; /* flags used by MMIO functions */ ;} MMCKINFO, *PMMCKINFO, NEAR *NPMMCKINFO, FAR *LPMMCKINFO; #define _ckid 0 #define _cksize 4 #define _fccType 8 #define _dwDataOffset 12 #define _dwFlags 16 ;---------------------- #uselib "winmm.dll" //WAVE操作関数 #func waveOutOpen "waveOutOpen" sptr, sptr, sptr, sptr, sptr, sptr #define WAVE_MAPPER 0xFFFFFFFF #define CALLBACK_NULL 0x00000000 #func waveOutPrepareHeader "waveOutPrepareHeader" sptr, sptr, sptr #func waveOutWrite "waveOutWrite" sptr, sptr, sptr #func waveOutReset "waveOutReset" sptr #func waveOutUnprepareHeader "waveOutUnprepareHeader" sptr, sptr, sptr #func waveOutClose "waveOutClose" sptr //Waveファイル読み取り関数 #func mmioOpen "mmioOpenA" sptr,sptr,sptr #define MMIO_READ 0x00000000 #func mmioRead "mmioRead" sptr,sptr,sptr #func mmioSeek "mmioSeek" sptr,sptr,sptr #define SEEK_SET 0 //ファイル先端 #define SEEK_END 2 //ファイル終端 #func mmioClose "mmioClose" sptr,sptr #func mmioDescend "mmioDescend" sptr,sptr,sptr,sptr #define MMIO_FINDRIFF 0x0020 #define MMIO_FINDCHUNK 0x0010 #func mmioAscend "mmioAscend" sptr,sptr,sptr //FOURCC型変換関数 #cfunc mmioStringToFOURCC "mmioStringToFOURCCA" sptr,sptr alloc WAVEHDR,8*4 gosub*ReadWaveFile//データ取得 hwo=0;ウェーブフォームオーディオ出力デバイスのハンドル waveOutOpen varptr(hwo),WAVE_MAPPER,varptr(WAVEFORMATEX),0,0,CALLBACK_NULL if stat=0{mes "WAVEOUT OPEN:OK"}else{end} wpoke WAVEHDR,0,varptr(Data)// 0:lpdata wpoke WAVEHDR,4,DataSize// 4:dwBufferLength wpoke WAVEHDR,16,0//16:dwFlags waveOutPrepareHeader hwo,varptr(WAVEHDR),32 if stat=0{mes "WAVE PREPARE:OK"}else{end} waveOutWrite hwo,0,32 waveOutWrite hwo,varptr(WAVEHDR),32 stop *ReadWaveFile//ReadWaveFileで最終的に使うのはWAVEFORMATEX構造体、DATA,DataSizeの3つ// FileName="sample.wav" alloc mmckRiff,4*5 alloc mmckFmt,4*5 alloc mmckData,4*5 alloc WAVEFORMATEX,18 //ファイルオープン String=FileName mmioOpen FileName,NULL,MMIO_READ hmmio = stat if hmmio = 0 {end}else{mes "MMIO OPEN:OK,FILE:"+Name} //RIFFチャンクへアクセス lpoke mmckRiff,_ffcType,mmioStringToFOURCC("WAVE",0) mmioDescend hmmio,varptr(mmckkRiff),0,MMIO_FINDRIFF if stat=0{mes "RIFF DESCEND:OK"}else{end} //fmt チャンクへアクセス->解除 lpoke mmckFmt,_ckid,mmioStringToFOURCC("fmt ",0) mmioDescend hmmio,varptr(mmckFmt),0,MMIO_FINDCHUNK if stat=0{mes "fmt DESCEND:OK"}else{end} mmioRead hmmio,varptr(WAVEFORMATEX),wpeek(mmckFmt,_cksize) if stat<=0{end}else{mes "GET WAVEFORMATEX:OK"} mmioAscend hmmio,varptr(mmckFmt),0 if stat=0{mes "fmt ASCEND:OK"}else{end} if wpeek(WAVEFORMATEX,0)=1{mes "THIS IS PCMDATA"}else{mes "THIS IS NOT PCMDATA"}//このデータがPCMデータかどうか確かめる //DATAチャンクへアクセス->解除 lpoke mmckData,_ckid,mmioStringToFOURCC("data",0) mmioDescend hmmio,varptr(mmckData),0,MMIO_FINDCHUNK if stat=0{mes "DATA DESCEND:OK"}else{end} Alloc Data,wpeek(mmckData,_cksize)//WAVEデータ格納スペース mmioRead hmmio,varptr(Data),wpeek(mmckData,_cksize) if stat=0{end}else{mes "GET DATA:OK"} mmioAscend hmmio,varptr(mmckData),0 //RIFFチャンクアクセス解除 mmioAscend hmmio,varptr(mmckData),0 mmioClose hmmio,0 DataSize=wpeek(mmckData,_cksize)//WAVEデータサイズ return