#! /usr/bin/env ruby # -*- mode: ruby; coding: utf-8 -*- # Last updated: <2021/08/13 21:49:19 +0900> # # Vox.rb sample (ogg play sample) # # it worked. # Windows10 x64 21H1 # Ruby 1.8.7 p330 x86 (i386-mswin32) + DXRuby 1.0.9 x86 # Ruby 1.9.3 p551 x86 (i386-mingw32) + DXRuby 1.4.1 x86 # Ruby 2.3.3 p222 x86 (i386-mingw32) + DXRuby 1.4.6 x86 # Ruby 2.6.8 p205 x86 (i386-mingw32) + DXRuby 1.4.7 x86 # Ruby 2.7.4 p191 x86 (i386-mingw32) + DXRuby 1.4.7 x86 # Ruby 3.0.2 p107 x86 (i386-mingw32) + DXRuby 1.4.7 x86 require "dxruby" if RUBY_VERSION.to_f <= 1.8 require "Vox" else require_relative "Vox" end Window.caption = "Ogg play sample with Vox.rb" fnt = Font.new(24) # load ogg file v = Vox.new("loop_bgm.ogg") # set loop v.setLoop(9999) # get total time (msec) tt = v.getTotalTime # main loop Window.loop do break if Input.keyPush?(K_ESCAPE) v.play if Input.keyPush?(K_Z) # play v.pause if Input.keyPush?(K_X) # pasue v.fade(10000, 0, 300) if Input.keyPush?(K_C) # fadeout v.fade(0, 10000, 300) if Input.keyPush?(K_V) # fadein # draw text y = 8 [ "Ogg play sample with Vox.rb", "", "Z : play", "X : pause", "C : fadeout", "V : fadein", "ESC : exit", ].each do |m| Window.drawFont(8, y, m, fnt) y += 30 end y += 30 # get status and draw s = (v.getStatus == 0) ? "stopped" : "playing" Window.drawFont(8, y, s, fnt) y += 30 # get current time and draw Window.drawFont(8, y, "#{v.getCurrentTime} / #{tt}", fnt) y += 30 end v.delete