Sha256: e0d66c1898767179cd6b69016d6b76c28093be471d148486861375332c0ddb11

Contents?: true

Size: 1.44 KB

Versions: 3

Compression:

Stored size: 1.44 KB

Contents

#!/usr/bin/env ruby
# frozen_string_literal: true

# Copyright (c) 2018 Robert Haines.
#
# Licensed under the BSD License. See LICENCE for details.

require 'ffi/openmpt'

if ARGV[0].nil?
  puts 'Please supply a filename to interrogate.'
  exit(1)
end

mod_path = ARGV[0].chomp

# Does this file exist? Is it readable?
unless ::File.readable?(mod_path)
  puts "'#{mod_path}' does not exist, or is not readable."
  exit(1)
end

mod_file = ::File.basename(mod_path)
mod_size = ::File.size(mod_path) / 1_024

# Can libopenmpt open this file?
unless ::FFI::OpenMPT.probe_file(mod_path)
  puts 'libopenmpt can not open this file. Are you sure it is a mod?'
  exit(1)
end

::FFI::OpenMPT::Module.open(mod_path) do |mod|
  duration = mod.duration
  duration_mins = duration.floor / 60
  duration_secs = duration % 60

  puts
  puts 'Ruby OpenMPT (ffi-openmpt) file interrogator.'
  puts '---------------------------------------------'
  puts
  puts "Filename...: #{mod_file}"
  puts "Size.......: #{mod_size}k"
  puts "Type.......: #{mod.type}"
  puts "Format.....: #{mod.type_long}"
  puts "Tracker....: #{mod.tracker}"
  puts "Title......: #{mod.title}"
  puts "Duration...: #{duration_mins}:#{duration_secs.round(3)}"
  puts "Subsongs...: #{mod.num_subsongs}"
  puts "Channels...: #{mod.num_channels}"
  puts "Orders.....: #{mod.num_orders}"
  puts "Patterns...: #{mod.num_patterns}"
  puts "Instruments: #{mod.num_instruments}"
  puts "Samples....: #{mod.num_samples}"
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ffi-openmpt-0.5.0 examples/mod-info
ffi-openmpt-0.4.1 examples/mod-info
ffi-openmpt-0.4.0 examples/mod-info