Class: Ramekin::SPCPlayer::WindowsSPCPlayer

Inherits:
SPCPlayer
  • Object
show all
Defined in:
lib/ramekin/spc_player.rb

Constant Summary

Constants included from Util

Util::KNOWN_LENGTHS

Instance Method Summary collapse

Methods included from Util

#adsr_value, #extra_nice_length_amk, #nice_length_amk

Constructor Details

#initializeWindowsSPCPlayer



35
36
37
38
# File 'lib/ramekin/spc_player.rb', line 35

def initialize
  @spcplay_dir = "#{HOME}/spcplay"
  @smwc_url = "https://dl.smwcentral.net/35673/spcplay-2.20.1.8272.zip"
end

Instance Method Details

#play(fname, offset_ = 0) ⇒ Object



44
45
46
47
48
49
# File 'lib/ramekin/spc_player.rb', line 44

def play(fname, offset_=0)
  fname = File.expand_path(fname)
  Dir.chdir(@spcplay_dir) do
    sys "spcplay.exe", fname
  end
end

#setup!Object



51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/ramekin/spc_player.rb', line 51

def setup!
  return if setup_ok?

  FileUtils.mkdir_p(@spcplay_dir)

  Dir.chdir @spcplay_dir do
    $stderr.puts "extracting spcplay from #@smwc_url"
    $stderr.puts "into #$spcplay_dir"
    zip = URI.open(@smwc_url).read
    unpack_zip_here(zip) do |entry|
      $stderr.puts "  -> #{entry}"
    end
  end
end

#setup_ok?Boolean



40
41
42
# File 'lib/ramekin/spc_player.rb', line 40

def setup_ok?
  File.exist?("#@spcplay_dir/spcplay.exe")
end