HSP

 とりあえず最低限の機能がついたサンプラーを作ってみました
再生モードが4つ位あれば 特に困る事も無いかな
ボタン名とか ファイル名は まだソースファイルを直接書き換える必要があるけど
ソースファイル見れば どう書き換えたらいいかは すぐ分かるから まぁこれでいいか
左クリックで再生開始、 右クリックで再生停止が 基本操作です
あと MIAさんの HSP DirectSound Extension を 使っているので使えるようにしててください
repeatを使って簡潔に書けるんだけど それで書くと意味不明の落ち方する所があるんで あえて同じような文を何度も書いてる部分があります

以下サンプル
width 150,355
#include "dsoundex.as"
#uselib "user32.dll"
    #func SetTimer  "SetTimer"  int, int, int, int
    #func KillTimer "KillTimer" int, int
    #cfunc WindowFromPoint "WindowFromPoint" int, int
#define WM_TIMER         0x0113
#define WM_MOVE          0x0003
#define WM_MOVING        0x0216
#define ID_TIMER         1
#define NUMBER_OF_BUTTON 20
#define MODE_NORMAL  0
#define MODE_FADEIN  1
#define MODE_FADEOUT 2
#define MODE_STOP    3
#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_REPEAT

ButtonTitle.3  = ""
SoundFile.3    = ""
PlayType.3     = TYPE_NORMAL

ButtonTitle.4  = ""
SoundFile.4    = ""
PlayType.4     = TYPE_NORMAL

ButtonTitle.5  = ""
SoundFile.5    = ""
PlayType.5     = TYPE_NORMAL

ButtonTitle.6  = ""
SoundFile.6    = ""
PlayType.6     = TYPE_LOOP

ButtonTitle.7  = ""
SoundFile.7    = ""
PlayType.7     = TYPE_LOOP

ButtonTitle.8  = ""
SoundFile.8    = ""
PlayType.8     = TYPE_LOOP

ButtonTitle.9  = ""
SoundFile.9    = ""
PlayType.9     = TYPE_LOOP

ButtonTitle.10 = ""
SoundFile.10   = ""
PlayType.10     = TYPE_LOOP

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 PlayMode, NUMBER_OF_BUTTON
repeat NUMBER_OF_BUTTON
    PlayMode.cnt = 0
loop

dim Volume, NUMBER_OF_BUTTON
repeat NUMBER_OF_BUTTON
    Volume.cnt = 100
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 "未実装",*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 StartPlay 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 }
    hCurrentWindow = WindowFromPoint(ginfo(0),ginfo(1))
    getkey IsL, 1
    if IsL {
        if hButton.0  = hCurrentWindow { StartPlay(0)  : return }
        if hButton.1  = hCurrentWindow { StartPlay(1)  : return }
        if hButton.2  = hCurrentWindow { StartPlay(2)  : return }
        if hButton.3  = hCurrentWindow { StartPlay(3)  : return }
        if hButton.4  = hCurrentWindow { StartPlay(4)  : return }
        if hButton.5  = hCurrentWindow { StartPlay(5)  : return }
        if hButton.6  = hCurrentWindow { StartPlay(6)  : return }
        if hButton.7  = hCurrentWindow { StartPlay(7)  : return }
        if hButton.8  = hCurrentWindow { StartPlay(8)  : return }
        if hButton.9  = hCurrentWindow { StartPlay(9)  : return }
        if hButton.10 = hCurrentWindow { StartPlay(10) : return }
        if hButton.11 = hCurrentWindow { StartPlay(11) : return }
        if hButton.12 = hCurrentWindow { StartPlay(12) : return }
        if hButton.13 = hCurrentWindow { StartPlay(13) : return }
        if hButton.14 = hCurrentWindow { StartPlay(14) : return }
        if hButton.15 = hCurrentWindow { StartPlay(15) : return }
        if hButton.16 = hCurrentWindow { StartPlay(16) : return }
        if hButton.17 = hCurrentWindow { StartPlay(17) : return }
        if hButton.18 = hCurrentWindow { StartPlay(18) : return }
        if hButton.19 = hCurrentWindow { StartPlay(19) : return }
    }
    getkey IsR, 2
    if IsR {
        if hButton.0  = hCurrentWindow { ds_stop  0 : return }
        if hButton.1  = hCurrentWindow { ds_stop  1 : return }
        if hButton.2  = hCurrentWindow { ds_stop  2 : return }
        if hButton.3  = hCurrentWindow { ds_stop  3 : return }
        if hButton.4  = hCurrentWindow { ds_stop  4 : return }
        if hButton.5  = hCurrentWindow { ds_stop  5 : return }
        if hButton.6  = hCurrentWindow { ds_stop  6 : return }
        if hButton.7  = hCurrentWindow { ds_stop  7 : return }
        if hButton.8  = hCurrentWindow { ds_stop  8 : return }
        if hButton.9  = hCurrentWindow { ds_stop  9 : return }
        if hButton.10 = hCurrentWindow { ds_stop 10 : return }
        if hButton.11 = hCurrentWindow { ds_stop 11 : return }
        if hButton.12 = hCurrentWindow { ds_stop 12 : return }
        if hButton.13 = hCurrentWindow { ds_stop 13 : return }
        if hButton.14 = hCurrentWindow { ds_stop 14 : return }
        if hButton.15 = hCurrentWindow { ds_stop 15 : return }
        if hButton.16 = hCurrentWindow { ds_stop 16 : return }
        if hButton.17 = hCurrentWindow { ds_stop 17 : return }
        if hButton.18 = hCurrentWindow { ds_stop 18 : return }
        if hButton.19 = hCurrentWindow { ds_stop 19 : return }
    }
    getkey IsM, 4
    LastMouseButton = MOUSE_N
return

*_OnExit
KillTimer hwnd, ID_TIMER
end

*btnAllStop_OnClick
    repeat NUMBER_OF_BUTTON
        ds_stop cnt
    loop
return

*_OnMoving
    if IsMoving {
        return
    }else{
        IsMoving = 1
    }
return

*_OnMove
    IsMoving = 0
return

*btnAllFO_OnClick
return

*Button_OnClick
return