ffi-openmpt 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 06607b1145d777c793ee96ca49e70132f74dd3ec2289957909519a109a64f7d7
4
- data.tar.gz: f5ef317907e2ff4866a1d0832ba64b820f409dc03dce32613321bc3767cc5c9b
3
+ metadata.gz: cff9c1335f501d6c4567b5f3fd9f314413426608f2fd83ff43c40cd8ac3430d5
4
+ data.tar.gz: 6bc3d44745d502705a18b8b85bf6608ac94f9315ed4dcfb4b8bf56f048462709
5
5
  SHA512:
6
- metadata.gz: 5a03b9aa048cfcb588e36b147b396d04653fb5d55780d2f6ff879954ae7d0a783ee414c003477f3b5e3693c930baad0d400c755a428bc5aa2528264f9c7064fb
7
- data.tar.gz: bd5d1f18bdaa730e22b38f281d2281c3eb544631a79fedf10dc32bc1f7e897afe3a54da726c83cc7f19398f527fc9810f5038ff9df0a1dd04ec1b86663c8a86c
6
+ metadata.gz: 39aa9577df5787ffb062a2a0045e4fc2f374343a32246f6f383bcfde63ad7722c3b99b01f0affe244e68973c80a59905a95c3339865f2ed9f74dd7cfd730a504
7
+ data.tar.gz: 72e57d5e865ab26e44b72727b9bb2a05a05b930a4c5a4155fbdcb753c07c965647a32d1abf4565a18ee95ea9e3581ea57df4d294182982a2dfda9685440ca690
data/.gitignore CHANGED
@@ -7,4 +7,6 @@
7
7
  /spec/reports/
8
8
  /tmp/
9
9
 
10
+ /.vscode/
11
+
10
12
  Gemfile.lock
data/.travis.yml CHANGED
@@ -1,7 +1,6 @@
1
+ dist: xenial
1
2
  language: ruby
2
3
 
3
- sudo: false
4
-
5
4
  cache: bundler
6
5
 
7
6
  before_install:
@@ -11,13 +10,26 @@ before_install:
11
10
 
12
11
  rvm:
13
12
  - 2.2.10
14
- - 2.3.7
15
- - 2.4.4
16
- - 2.5.1
13
+ - 2.3.8
14
+ - 2.4.5
15
+ - 2.5.3
17
16
  - rbx-3
18
17
  - ruby-head
19
18
 
19
+ env:
20
+ - TEST_LIBOPENMPT_VERSION=0.3.11
21
+ - TEST_LIBOPENMPT_VERSION=0.3.12
22
+
20
23
  matrix:
24
+ fast_finish: true
21
25
  allow_failures:
22
26
  - rvm: rbx-3
23
27
  - rvm: ruby-head
28
+ - env: TEST_LIBOPENMPT_VERSION=0.3.12
29
+ exclude:
30
+ - rvm: rbx-3
31
+ env: TEST_LIBOPENMPT_VERSION=0.3.12
32
+ - rvm: 2.2.10
33
+ env: TEST_LIBOPENMPT_VERSION=0.3.12
34
+ - rvm: 2.3.8
35
+ env: TEST_LIBOPENMPT_VERSION=0.3.12
data/CHANGES.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # Changes log for the Ruby OpenMPT library (ffi-openmpt)
2
2
 
3
+ ## Version 0.3.0
4
+
5
+ * Wrap the libopenmpt module read mono functions.
6
+ * Add mono read (short/float) calls to the ruby interface.
7
+ * Move the string get method to its own namespace.
8
+ * Allow getting informational strings directly.
9
+ * Wrap Module#metadata_keys.
10
+ * Directly query module metadata keys.
11
+ * Update test version of libopenmpt to 0.3.13.
12
+ * Parameterize the test libopenmpt version.
13
+ * Update Travis config to use latest rubies.
14
+ * Turn on `fast_finish` in the Travis config.
15
+ * Switch to use latest dist (Xenial) in Travis.
16
+ * Test multiple versions of the libopenmpt library.
17
+ * Wrap libopenmpt module repeat functions.
18
+ * Add repeat_count to the ruby interface.
19
+ * Wrap libopenmpt module positional calls.
20
+ * Add positional calls to the ruby interface.
21
+
3
22
  ## Version 0.2.0
4
23
 
5
24
  * Add a Gem version badge to the README.md.
data/ffi-openmpt.gemspec CHANGED
@@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
16
16
 
17
17
  spec.summary = 'A Ruby library to interface with libopenmpt.'
18
18
  spec.description = 'libopenmpt is a library to render tracker music ' \
19
- '(MOD, XM, S3M, IT MPTM and dozens of other legacy formats) to a ' \
19
+ '(MOD, XM, S3M, IT, MPTM and dozens of other legacy formats) to a ' \
20
20
  'PCM audio stream. See https://openmpt.org/ for more information.'
21
21
  spec.homepage = 'https://github.com/hainesr/ffi-openmpt'
22
22
  spec.license = 'BSD'
data/lib/ffi/openmpt.rb CHANGED
@@ -14,4 +14,5 @@ end
14
14
  require 'ffi/openmpt/version'
15
15
  require 'ffi/openmpt/api'
16
16
  require 'ffi/openmpt/openmpt'
17
+ require 'ffi/openmpt/string'
17
18
  require 'ffi/openmpt/module'
@@ -139,7 +139,24 @@ module FFI
139
139
  attach_function :openmpt_module_set_render_param,
140
140
  [:pointer, :int, :int], :int
141
141
 
142
+ # Repeat module calls
143
+ attach_function :openmpt_module_get_repeat_count, [:pointer], :int
144
+ attach_function :openmpt_module_set_repeat_count, [:pointer, :int], :void
145
+
146
+ # Positional module calls
147
+ attach_function :openmpt_module_get_position_seconds, [:pointer], :double
148
+ attach_function :openmpt_module_set_position_seconds,
149
+ [:pointer, :double], :double
150
+ attach_function :openmpt_module_set_position_order_row,
151
+ [:pointer, :int, :int], :double
152
+
142
153
  # Read module calls
154
+ attach_function :openmpt_module_read_mono,
155
+ [:pointer, :int, :int, :pointer],
156
+ :int
157
+ attach_function :openmpt_module_read_float_mono,
158
+ [:pointer, :int, :int, :pointer],
159
+ :int
143
160
  attach_function :openmpt_module_read_stereo,
144
161
  [:pointer, :int, :int, :pointer, :pointer],
145
162
  :int
@@ -10,20 +10,6 @@ module FFI
10
10
 
11
11
  include API
12
12
 
13
- METADATA_KEYS = [
14
- :type,
15
- :type_long,
16
- :container,
17
- :container_long,
18
- :tracker,
19
- :artist,
20
- :title,
21
- :date,
22
- :message,
23
- :message_raw,
24
- :warnings
25
- ].freeze
26
-
27
13
  attr_reader :sample_rate
28
14
 
29
15
  def initialize(filename, sample_rate = 48_000)
@@ -32,7 +18,7 @@ module FFI
32
18
  @sample_rate = sample_rate
33
19
 
34
20
  # Allocate a reusable single int buffer.
35
- # This for use by the 'get_render_params'-type calls.
21
+ # This is for use by the 'get_render_params'-type calls.
36
22
  @int_value = ::FFI::MemoryPointer.new(:int, 1)
37
23
  end
38
24
 
@@ -89,9 +75,43 @@ module FFI
89
75
  openmpt_module_get_num_samples(@mod)
90
76
  end
91
77
 
78
+ def repeat_count
79
+ openmpt_module_get_repeat_count(@mod)
80
+ end
81
+
82
+ def repeat_count=(count)
83
+ openmpt_module_set_repeat_count(@mod, count)
84
+ end
85
+
86
+ def position
87
+ return if closed?
88
+ openmpt_module_get_position_seconds(@mod)
89
+ end
90
+
91
+ def position=(param)
92
+ if param.is_a?(Array)
93
+ openmpt_module_set_position_order_row(@mod, param[0], param[1])
94
+ else
95
+ openmpt_module_set_position_seconds(@mod, param)
96
+ end
97
+ end
98
+
99
+ def metadata_keys
100
+ ptr = openmpt_module_get_metadata_keys(@mod)
101
+ str = ptr.read_string
102
+ openmpt_free_string(ptr)
103
+
104
+ str.split(';').map(&:to_sym)
105
+ end
106
+
92
107
  def metadata(key)
93
- return if closed? || !METADATA_KEYS.include?(key)
94
- get_openmpt_string(:openmpt_module_get_metadata, key.to_s)
108
+ return if closed? || !metadata_keys.include?(key)
109
+
110
+ ptr = openmpt_module_get_metadata(@mod, key.to_s)
111
+ str = ptr.read_string
112
+ openmpt_free_string(ptr)
113
+
114
+ str
95
115
  end
96
116
 
97
117
  def gain
@@ -150,6 +170,14 @@ module FFI
150
170
  )
151
171
  end
152
172
 
173
+ def read_mono(frames, buffer)
174
+ openmpt_module_read_mono(@mod, @sample_rate, frames, buffer)
175
+ end
176
+
177
+ def read_float_mono(frames, buffer)
178
+ openmpt_module_read_float_mono(@mod, @sample_rate, frames, buffer)
179
+ end
180
+
153
181
  def read_stereo(frames, left, right)
154
182
  openmpt_module_read_stereo(@mod, @sample_rate, frames, left, right)
155
183
  end
@@ -187,7 +215,7 @@ module FFI
187
215
  end
188
216
 
189
217
  def respond_to_missing?(name, *all)
190
- METADATA_KEYS.include?(name) || super
218
+ metadata_keys.include?(name) || super
191
219
  end
192
220
 
193
221
  private
@@ -203,14 +231,6 @@ module FFI
203
231
  @closed = (mod.address == 0)
204
232
  mod
205
233
  end
206
-
207
- def get_openmpt_string(method, *args)
208
- ptr = send(method, @mod, *args)
209
- str = ptr.read_string
210
- openmpt_free_string(ptr)
211
-
212
- str
213
- end
214
234
  end
215
235
  end
216
236
  end
@@ -15,14 +15,6 @@ module FFI
15
15
  [API.openmpt_get_core_version].pack('L>').unpack('CCCC')
16
16
  end
17
17
 
18
- def self.string(key)
19
- ptr = API.openmpt_get_string(key.to_s)
20
- str = ptr.read_string
21
- API.openmpt_free_string(ptr)
22
-
23
- str
24
- end
25
-
26
18
  def self.supported_extensions
27
19
  ptr = API.openmpt_get_supported_extensions
28
20
  exts = ptr.read_string.split(';').map(&:to_sym)
@@ -32,8 +24,7 @@ module FFI
32
24
  end
33
25
 
34
26
  def self.extension_supported?(ext)
35
- supported = API.openmpt_is_extension_supported(ext.to_s)
36
- supported == 1
27
+ API.openmpt_is_extension_supported(ext.to_s) == 1
37
28
  end
38
29
 
39
30
  def self.transient_error?(error)
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright (c) 2018 Robert Haines.
4
+ #
5
+ # Licensed under the BSD License. See LICENCE for details.
6
+
7
+ module FFI
8
+ module OpenMPT
9
+ module String
10
+ KEYS = [
11
+ :library_version,
12
+ :library_version_major,
13
+ :library_version_minor,
14
+ :library_version_patch,
15
+ :library_version_prerel,
16
+ :library_version_is_release,
17
+ :library_features,
18
+ :core_version,
19
+ :source_url,
20
+ :source_date,
21
+ :source_revision,
22
+ :source_is_modified,
23
+ :source_has_mixed_revisions,
24
+ :source_is_package,
25
+ :build,
26
+ :build_compiler,
27
+ :credits,
28
+ :contact,
29
+ :license,
30
+ :url,
31
+ :support_forum_url,
32
+ :bugtracker_url
33
+ ].freeze
34
+
35
+ def self.get(key)
36
+ ptr = API.openmpt_get_string(key.to_s)
37
+ str = ptr.read_string
38
+ API.openmpt_free_string(ptr)
39
+
40
+ str
41
+ end
42
+
43
+ def self.method_missing(name, *args)
44
+ respond_to?(name) ? get(name) : super
45
+ end
46
+
47
+ def self.respond_to_missing?(name, *all)
48
+ KEYS.include?(name) || super
49
+ end
50
+ end
51
+ end
52
+ end
@@ -6,6 +6,6 @@
6
6
 
7
7
  module FFI
8
8
  module OpenMPT
9
- VERSION = '0.2.0'
9
+ VERSION = '0.3.0'
10
10
  end
11
11
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ffi-openmpt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Haines
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-09-02 00:00:00.000000000 Z
11
+ date: 2019-03-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi
@@ -94,7 +94,7 @@ dependencies:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0.54'
97
- description: libopenmpt is a library to render tracker music (MOD, XM, S3M, IT MPTM
97
+ description: libopenmpt is a library to render tracker music (MOD, XM, S3M, IT, MPTM
98
98
  and dozens of other legacy formats) to a PCM audio stream. See https://openmpt.org/
99
99
  for more information.
100
100
  email:
@@ -125,6 +125,7 @@ files:
125
125
  - lib/ffi/openmpt/api.rb
126
126
  - lib/ffi/openmpt/module.rb
127
127
  - lib/ffi/openmpt/openmpt.rb
128
+ - lib/ffi/openmpt/string.rb
128
129
  - lib/ffi/openmpt/version.rb
129
130
  homepage: https://github.com/hainesr/ffi-openmpt
130
131
  licenses: