OggVorbis再生ライブラリVoxラッパクラス

HSPのほうでメジャーらしいVox.dllを使ってOggVorbisを再生するラッパクラスを作った。
使わないと思われる関数は無視した。
使い方は・・・コメント見たらわかるだろう。
再生しながらsetVolumeすると音量の変更が少し遅れるのは仕様だろうか。
Voxのダウンロードはこちら。作者さまのサイトは何も無い状態になっている。
http://www.vector.co.jp/soft/win95/prog/se246017.html

#!ruby -Ks
# RubyからVox.dllを使うラッパクラス Vox.rb
require "Win32API"

class Vox
  VoxLoad = Win32API.new("vox", "VoxLoad", "P", "I")
  VoxPlay = Win32API.new("vox", "VoxPlay", "I", "I")
  VoxPause = Win32API.new("vox", "VoxPause", "I", "I")
  VoxSetLoop = Win32API.new("vox", "VoxSetLoop", "II", "I")
  VoxSetVolume = Win32API.new("vox", "VoxSetVolume", "II", "I")
  VoxFade = Win32API.new("vox", "VoxFade", "IIII", "I")
  VoxDelete = Win32API.new("vox", "VoxDelete", "I", "I")
  VoxGetTotalTime = Win32API.new("vox", "VoxGetTotalTime", "I", "I")
  VoxGetCurrentTime = Win32API.new("vox", "VoxGetCurrentTime", "I", "I")
  VoxSeek = Win32API.new("vox", "VoxSeek", "II", "I")
  VoxGetStatus = Win32API.new("vox", "VoxGetStatus", "I", "I")

  # ファイル読み込み
  def initialize(filename)
    if filename.class != String then
      raise "ファイル名が不正です(#{filename}) - initialize"
    end
    @id = VoxLoad.call(filename)
    if @id == -1 then
      raise "ファイルの読み込みに失敗しました(#{filename}) - initialize"
    end
  end

  # 再生
  def play
    if VoxPlay.call(@id) == 0 then
      raise "再生に失敗しました - play"
    end
    self
  end

  # 一時停止
  def pause
    if VoxPause.call(@id) == 0 then
      raise "一時停止に失敗しました - pause"
    end
    self
  end

  # ループ回数設定
  def setLoop(count)
    if VoxSetLoop.call(@id, count) == 0 then
      raise "ループ回数設定に失敗しました - setLoop"
    end
    self
  end

  # 音量設定(0〜10000)
  def setVolume(volume)
    if VoxSetVolume.call(@id, volume) == 0 then
      raise "音量設定に失敗しました - setVolume"
    end
    self
  end

  # フェード(開始時の音量、終了時の音量、フェード時間(mSec)
  def fade(startvolume, endvolume, fadetime)
    if VoxFade.call(@id, startvolume, endvolume, fadetime) == 0 then
      raise "フェードに失敗しました - fade"
    end
    self
  end

  # メモリ解放
  def delete
    if VoxDelete.call(@id) == 0 then
      raise "メモリ解放に失敗しました - delete"
    end
    self
  end

  # 曲の全長取得(mSec)
  def getTotalTime
    totaltime = VoxGetTotalTime.call(@id)
    if  totaltime == -1 then
      raise "全長取得に失敗しました - getTotalTime"
    end
    return totaltime
  end

  # 曲の現在再生位置を取得(mSec)
  def getCurrentTime
    currenttime = VoxGetCurrentTime.call(@id)
    if  currenttime== -1 then
      raise "全長取得に失敗しました - getCurrentTime"
    end
    return currenttime
  end

  # 再生位置を変更する(mSec)
  def seek(time)
    if VoxSeek.call(@id, time) == 0 then
      raise "再生位置の変更に失敗しました - seek"
    end
    self
  end

  # 再生状態を調べる(0:停止中 1:再生中)
  def getStatus
    status = VoxGetStatus.call(@id)
    if status == -1 then
      raise "再生状態の取得に失敗しました - getStatus"
    end
    return status
  end
end

# v = Vox.new("test.ogg")
# v.play  # 再生
# v.pause # 停止
# v.fade(10000, 0, 3000) # 3秒かけて最大から無音へフェードアウト

このコードはパブリックドメインとするので、そのまま使うなり改造するなりご自由にどうぞ。
全部テストしてないからバグあるかもしれないけど見つけたら直して使ってください。
教えてもらえたら記事を修正するかも。