HSP
とりあえず HSPでの簡易サンプラーが一通り完成、 フェードアウト&オールフェードアウト機能を実装
基本操作は 各ボタン上で、「左クリックで再生」「右クリックでストップ」「中央ボタンでフェードアウト」
まぁ 各種設定はソース直接書き換えの不親切設計 笑)
とはいっても HSPインストールしてれば すぐに設定変更できるしね 笑)
前回に引き続き MIAさんの HSP Direct Sound Extensionを使っているので それは使えるようにしておけば普通に動くかな
もしかすると Windowsの設定で 内容を表示したままウインドウを移動できるようにしてるとちゃんと動かないかもです
以下サンプルプログラム
基本操作は 各ボタン上で、「左クリックで再生」「右クリックでストップ」「中央ボタンでフェードアウト」
まぁ 各種設定はソース直接書き換えの不親切設計 笑)
とはいっても HSPインストールしてれば すぐに設定変更できるしね 笑)
前回に引き続き MIAさんの HSP Direct Sound Extensionを使っているので それは使えるようにしておけば普通に動くかな
もしかすると Windowsの設定で 内容を表示したままウインドウを移動できるようにしてるとちゃんと動かないかもです
以下サンプルプログラム
width 150,355 title "簡易サンプラー" #include "dsoundex.as" #uselib "user32.dll" #func SetTimer "SetTimer" int, int, int, int #func KillTimer "KillTimer" int, int #cfunc WindowFromPoint "WindowFromPoint" int, int #define FALSE 0 #define TRUE 1 #define WM_TIMER 0x0113 #define WM_MOVE 0x0003 #define WM_MOVING 0x0216 #define ID_TIMER 1 #define NUMBER_OF_BUTTON 20 #define MOUSE_N 0 #define MOUSE_L 1 #define MOUSE_M 2 #define MOUSE_R 3 dim ButtonTitle,NUMBER_OF_BUTTON dim SoundFile ,NUMBER_OF_BUTTON dim PlayType ,NUMBER_OF_BUTTON ;---------------------------------------------------------------------------------------- #define TYPE_NORMAL 0 ; クリックする毎、再生中の音をキャンセルして再生 #define TYPE_REPEAT 1 ; 押し続けている間リピート状態 #define TYPE_LOOP 2 ; ループし続ける #define TYPE_WAIT 3 ; クリックする毎、再生中の音が終わるまで再生しない ;---------------------------------------------------------------------------------------- ; ボタンのタイトル と ファイル名 と 再生タイプ ;---------------------------------------------------------------------------------------- ButtonTitle.0 = "" SoundFile.0 = "" PlayType.0 = TYPE_NORMAL ButtonTitle.1 = "" SoundFile.1 = "" PlayType.1 = TYPE_REPEAT ButtonTitle.2 = "" SoundFile.2 = "" PlayType.2 = TYPE_NORMAL ButtonTitle.3 = "" SoundFile.3 = "" PlayType.3 = TYPE_NORMAL ButtonTitle.4 = "" SoundFile.4 = "" PlayType.4 = TYPE_WAIT ButtonTitle.5 = "" SoundFile.5 = "" PlayType.5 = TYPE_WAIT ButtonTitle.6 = "" SoundFile.6 = "" PlayType.6 = TYPE_WAIT ButtonTitle.7 = "" SoundFile.7 = "" PlayType.7 = TYPE_WAIT ButtonTitle.8 = "" SoundFile.8 = "" PlayType.8 = TYPE_WAIT ButtonTitle.9 = "" SoundFile.9 = "" PlayType.9 = TYPE_LOOP ButtonTitle.10 = "" SoundFile.10 = "" PlayType.10 = TYPE_WAIT ButtonTitle.11 = "" SoundFile.11 = "" PlayType.11 = TYPE_NORMAL ButtonTitle.12 = "" SoundFile.12 = "" PlayType.12 = TYPE_WAIT ButtonTitle.13 = "" SoundFile.13 = "" PlayType.13 = TYPE_WAIT ButtonTitle.14 = "" SoundFile.14 = "" PlayType.14 = TYPE_WAIT ButtonTitle.15 = "" SoundFile.15 = "" PlayType.15 = TYPE_WAIT ButtonTitle.16 = "" SoundFile.16 = "" PlayType.16 = TYPE_LOOP ButtonTitle.17 = "" SoundFile.17 = "" PlayType.17 = TYPE_LOOP ButtonTitle.18 = "" SoundFile.18 = "" PlayType.18 = TYPE_LOOP ButtonTitle.19 = "" SoundFile.19 = "" PlayType.19 = TYPE_LOOP ;---------------------------------------------------------------------------------------- dim Volume, NUMBER_OF_BUTTON repeat NUMBER_OF_BUTTON Volume.cnt = 100 loop dim IsFadeOut, NUMBER_OF_BUTTON repeat NUMBER_OF_BUTTON IsFadeOut.cnt = FALSE loop ds_init repeat NUMBER_OF_BUTTON ds_load SoundFile.cnt, cnt ds_vol cnt, Volume.cnt loop hCurrentWindow = 0 LastMouseButton = MOUSE_N IsMoving = 0 pos 5, 5 : button gosub "All Stop",*btnAllStop_OnClick : hbtnAllStop = objinfo (stat, 2) pos 80, 5 : button gosub "All FO",*btnAllFO_OnClick : hbtnAllFO = objinfo (stat, 2) dim hButton, NUMBER_OF_BUTTON pos 5, 50 : button gosub ButtonTitle.0 ,*Button_OnClick : hButton.0 = objinfo (stat, 2) pos 80, 50 : button gosub ButtonTitle.1 ,*Button_OnClick : hButton.1 = objinfo (stat, 2) pos 5, 80 : button gosub ButtonTitle.2 ,*Button_OnClick : hButton.2 = objinfo (stat, 2) pos 80, 80 : button gosub ButtonTitle.3 ,*Button_OnClick : hButton.3 = objinfo (stat, 2) pos 5, 110 : button gosub ButtonTitle.4 ,*Button_OnClick : hButton.4 = objinfo (stat, 2) pos 80, 110 : button gosub ButtonTitle.5 ,*Button_OnClick : hButton.5 = objinfo (stat, 2) pos 5, 140 : button gosub ButtonTitle.6 ,*Button_OnClick : hButton.6 = objinfo (stat, 2) pos 80, 140 : button gosub ButtonTitle.7 ,*Button_OnClick : hButton.7 = objinfo (stat, 2) pos 5, 170 : button gosub ButtonTitle.8 ,*Button_OnClick : hButton.8 = objinfo (stat, 2) pos 80, 170 : button gosub ButtonTitle.9 ,*Button_OnClick : hButton.9 = objinfo (stat, 2) pos 5, 200 : button gosub ButtonTitle.10,*Button_OnClick : hButton.10 = objinfo (stat, 2) pos 80, 200 : button gosub ButtonTitle.11,*Button_OnClick : hButton.11 = objinfo (stat, 2) pos 5, 230 : button gosub ButtonTitle.12,*Button_OnClick : hButton.12 = objinfo (stat, 2) pos 80, 230 : button gosub ButtonTitle.13,*Button_OnClick : hButton.13 = objinfo (stat, 2) pos 5, 260 : button gosub ButtonTitle.14,*Button_OnClick : hButton.14 = objinfo (stat, 2) pos 80, 260 : button gosub ButtonTitle.15,*Button_OnClick : hButton.15 = objinfo (stat, 2) pos 5, 290 : button gosub ButtonTitle.16,*Button_OnClick : hButton.16 = objinfo (stat, 2) pos 80, 290 : button gosub ButtonTitle.17,*Button_OnClick : hButton.17 = objinfo (stat, 2) pos 5, 320 : button gosub ButtonTitle.18,*Button_OnClick : hButton.18 = objinfo (stat, 2) pos 80, 320 : button gosub ButtonTitle.19,*Button_OnClick : hButton.19 = objinfo (stat, 2) onexit gosub *_OnExit oncmd gosub *_OnTimer, WM_TIMER oncmd gosub *_OnMoving, WM_MOVING oncmd gosub *_OnMove, WM_MOVE SetTimer hwnd, ID_TIMER, 50, 0 stop #deffunc PlayStart int ButtonNumber switch PlayType.ButtonNumber case TYPE_NORMAL if LastMouseButton = MOUSE_L { return }else{ ds_stop ButtonNumber ds_play ButtonNumber LastMouseButton = MOUSE_L return } case TYPE_REPEAT ds_stop ButtonNumber ds_play ButtonNumber return case TYPE_LOOP if LastMouseButton = MOUSE_L { return }else{ ds_stat ButtonNumber if stat { return }else{ ds_stop ButtonNumber ds_loop ButtonNumber LastMouseButton = MOUSE_L return } } case TYPE_WAIT if LastMouseButton = MOUSE_L { return }else{ ds_stat ButtonNumber if stat { return }else{ ds_stop ButtonNumber ds_play ButtonNumber LastMouseButton = MOUSE_L return } } swend return *_OnTimer if IsMoving { return } ; if ginfo(2) = -1 { return } getkey IsL, 1 : getkey IsR, 2 : getkey IsM, 4 hCurrentWindow = WindowFromPoint(ginfo(0),ginfo(1)) repeat NUMBER_OF_BUTTON if hCurrentWindow = hButton.cnt { if IsL { IsFadeOut.cnt = FALSE ds_vol cnt, 100 Volume.cnt = 100 PlayStart cnt } if IsR { ds_stop cnt ds_vol cnt, 100 Volume.cnt = 100 IsFadeOut.cnt = FALSE } if IsM { IsFadeOut.cnt = TRUE } } if IsFadeOut.cnt { Volume.cnt = Volume.cnt - 2 if Volume.cnt = 0 { ds_vol cnt, 0 ds_stop cnt ds_vol cnt, 100 Volume.cnt = 100 IsFadeOut.cnt = FALSE }else{ ds_vol cnt, Volume.cnt } } loop if (IsL + IsR + IsM) = 0 { LastMouseButton = MOUSE_N } return *_OnExit KillTimer hwnd, ID_TIMER end *btnAllStop_OnClick repeat NUMBER_OF_BUTTON ds_vol cnt, 100 Volume.cnt = 100 ds_stop cnt loop return *_OnMoving if IsMoving { return }else{ IsMoving = 1 } return *_OnMove IsMoving = 0 return *btnAllFO_OnClick repeat NUMBER_OF_BUTTON IsFadeOut.cnt = TRUE loop return *Button_OnClick return |