ffi-openmpt 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.rubocop.yml +43 -0
- data/.rubocop_ffi-openmpt.yml +13 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +23 -0
- data/CHANGES.md +41 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +5 -0
- data/LICENCE +32 -0
- data/README.md +88 -0
- data/Rakefile +19 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/ffi-openmpt.gemspec +40 -0
- data/lib/ffi/openmpt.rb +16 -0
- data/lib/ffi/openmpt/api.rb +105 -0
- data/lib/ffi/openmpt/openmpt.rb +18 -0
- data/lib/ffi/openmpt/version.rb +11 -0
- metadata +149 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 1051eb2d63c430d769cba4769ad283817d1b615276d5529d6bd4e4f253ceb57e
|
4
|
+
data.tar.gz: 32518a3a258ac8bc43b9da89aa91f750f874dbc70349c7e541f3d1637e67a583
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6f5f6fa54e93a5e93e0f8e8364a2cc00b8a285abd168546269783b7c877f6b395462f255f2ac33a5a74e2758ac5dac526dfdffac2544486ebf913a51f7e45a2a
|
7
|
+
data.tar.gz: 1dd220d1b5d7271b11e6d8daff950f017af642bf67ca1716d164d3b9516cd8bdd3ff6995ed0a418edb22ad4869380546c91c7fb67e7933536a0d0cb545d23da2
|
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
inherit_from: .rubocop_ffi-openmpt.yml
|
2
|
+
|
3
|
+
# Turn this off for now. CI checks different versions of ruby anyway.
|
4
|
+
Gemspec/RequiredRubyVersion:
|
5
|
+
Exclude:
|
6
|
+
- 'ffi-openmpt.gemspec'
|
7
|
+
|
8
|
+
# Force ruby19 style hash keys, but be consistent within a hash.
|
9
|
+
Style/HashSyntax:
|
10
|
+
EnforcedStyle: ruby19_no_mixed_keys
|
11
|
+
|
12
|
+
# Use brackets style for symbol arrays.
|
13
|
+
Style/SymbolArray:
|
14
|
+
EnforcedStyle: brackets
|
15
|
+
|
16
|
+
# Enforce empty lines at the beginning of classes.
|
17
|
+
Layout/EmptyLinesAroundClassBody:
|
18
|
+
EnforcedStyle: beginning_only
|
19
|
+
|
20
|
+
# Allow empty lines, or not, around module bodies. I like a line at the
|
21
|
+
# beginning, but not the end, but this is not an option in RuboCop.
|
22
|
+
Layout/EmptyLinesAroundModuleBody:
|
23
|
+
Enabled: false
|
24
|
+
|
25
|
+
# Allow compact child definitions in the tests for brevity.
|
26
|
+
Style/ClassAndModuleChildren:
|
27
|
+
Exclude:
|
28
|
+
- 'test/**/*'
|
29
|
+
|
30
|
+
# Ignore ABC failures in the tests.
|
31
|
+
Metrics/AbcSize:
|
32
|
+
Exclude:
|
33
|
+
- 'test/**/*.rb'
|
34
|
+
|
35
|
+
# Set a more reasonable method length and ignore failures in the tests.
|
36
|
+
Metrics/MethodLength:
|
37
|
+
Exclude:
|
38
|
+
- 'test/**/*.rb'
|
39
|
+
|
40
|
+
# Set a more reasonable class length and ignore failures in the tests.
|
41
|
+
Metrics/ClassLength:
|
42
|
+
Exclude:
|
43
|
+
- 'test/**/*.rb'
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# This configuration was generated by
|
2
|
+
# `rubocop --auto-gen-config`
|
3
|
+
# on 2018-08-18 15:19:51 +0100 using RuboCop version 0.58.2.
|
4
|
+
# The point is for the user to remove these configuration records
|
5
|
+
# one by one as the offenses are removed from the code base.
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
8
|
+
|
9
|
+
# Offense count: 1
|
10
|
+
Style/Documentation:
|
11
|
+
Exclude:
|
12
|
+
- 'test/**/*'
|
13
|
+
- 'lib/**/*'
|
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ffi-openmpt
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby-2.5.1
|
data/.travis.yml
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
language: ruby
|
2
|
+
|
3
|
+
sudo: false
|
4
|
+
|
5
|
+
cache: bundler
|
6
|
+
|
7
|
+
before_install:
|
8
|
+
- gem install bundler -v 1.16.1
|
9
|
+
- ./test/install-libopenmpt.sh
|
10
|
+
- export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$TRAVIS_BUILD_DIR/usr/lib
|
11
|
+
|
12
|
+
rvm:
|
13
|
+
- 2.2.10
|
14
|
+
- 2.3.7
|
15
|
+
- 2.4.4
|
16
|
+
- 2.5.1
|
17
|
+
- rbx-3
|
18
|
+
- ruby-head
|
19
|
+
|
20
|
+
matrix:
|
21
|
+
allow_failures:
|
22
|
+
- rvm: rbx-3
|
23
|
+
- rvm: ruby-head
|
data/CHANGES.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# Changes log for the Ruby OpenMPT library (ffi-openmpt)
|
2
|
+
|
3
|
+
## Version 0.1.0
|
4
|
+
|
5
|
+
* Add Code of Conduct.
|
6
|
+
* Add Travis configuration.
|
7
|
+
* Add a Travis badge to the README.
|
8
|
+
* Set up Coveralls integration.
|
9
|
+
* Add a Coveralls badge to the README.
|
10
|
+
* Add a CodeClimate badge to the README.
|
11
|
+
* Add rubocop configuration files.
|
12
|
+
* Add rubocop tasks to the Rakefile.
|
13
|
+
* Many rubocop fixes.
|
14
|
+
* Add ffi as a dependency.
|
15
|
+
* Wrap the libopenmpt version methods.
|
16
|
+
* Wrap the libopenmpt logging callbacks.
|
17
|
+
* Add tests for the API module.
|
18
|
+
* Test the logging API functions.
|
19
|
+
* Wrap the libopenmpt error callbacks.
|
20
|
+
* Wrap libopenmpt module create/destroy functions.
|
21
|
+
* Add a helper method to test against mod files.
|
22
|
+
* Wrap the libopenmpt module duration function.
|
23
|
+
* Wrap the libopenmpt module read stereo functions.
|
24
|
+
* Test the module_read functions against real data.
|
25
|
+
* Add libopenmpt to the Travis config.
|
26
|
+
* Switch to old Travis architecture to install dependencies.
|
27
|
+
* Install libopenmpt manually on Travis.
|
28
|
+
* Wrap the libopenmpt module read interleaved stereo functions.
|
29
|
+
* Wrap the libopenmpt string functions.
|
30
|
+
* Wrap the libopenmpt extension querying functions.
|
31
|
+
* Wrap the libopenmpt informational error functions.
|
32
|
+
* Wrap the libopenmpt module error functions.
|
33
|
+
* Wrap the libopenmpt module metadata functions.
|
34
|
+
|
35
|
+
## About this file
|
36
|
+
|
37
|
+
This file is, at least in part, generated by the following command:
|
38
|
+
|
39
|
+
```shell
|
40
|
+
$ git log --pretty=format:"* %s" --reverse --no-merges <commit-hash>..
|
41
|
+
```
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at rhaines@manchester.ac.uk. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENCE
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
The Ruby OpenMPT code (ffi-openmpt) is released under the BSD licence.
|
2
|
+
|
3
|
+
Copyright (c) 2018, Robert Haines
|
4
|
+
All rights reserved.
|
5
|
+
|
6
|
+
The OpenMPT code (libopenmpt) is released under the same licence.
|
7
|
+
|
8
|
+
Copyright (c) 2004-2018, OpenMPT contributors
|
9
|
+
Copyright (c) 1997-2003, Olivier Lapicque
|
10
|
+
All rights reserved.
|
11
|
+
|
12
|
+
Redistribution and use in source and binary forms, with or without
|
13
|
+
modification, are permitted provided that the following conditions are met:
|
14
|
+
* Redistributions of source code must retain the above copyright
|
15
|
+
notice, this list of conditions and the following disclaimer.
|
16
|
+
* Redistributions in binary form must reproduce the above copyright
|
17
|
+
notice, this list of conditions and the following disclaimer in the
|
18
|
+
documentation and/or other materials provided with the distribution.
|
19
|
+
* Neither the name of the OpenMPT project nor the
|
20
|
+
names of its contributors may be used to endorse or promote products
|
21
|
+
derived from this software without specific prior written permission.
|
22
|
+
|
23
|
+
THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS ``AS IS'' AND ANY
|
24
|
+
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
25
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
26
|
+
DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
27
|
+
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
28
|
+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
29
|
+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
30
|
+
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
31
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
32
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/README.md
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
# Ruby OpenMPT (ffi-openmpt)
|
2
|
+
## Robert Haines
|
3
|
+
|
4
|
+
### Synopsys
|
5
|
+
|
6
|
+
A ruby interface to `libopenmpt` - part of [OpenMPT][mpt-home].
|
7
|
+
|
8
|
+
See the [libopenmpt homepage][lib-home] for more information.
|
9
|
+
|
10
|
+
[![Build Status](https://travis-ci.org/hainesr/ffi-openmpt.svg?branch=master)](https://travis-ci.org/hainesr/ffi-openmpt)
|
11
|
+
[![Maintainability](https://api.codeclimate.com/v1/badges/919bd8b421798dbd2719/maintainability)](https://codeclimate.com/github/hainesr/ffi-openmpt/maintainability)
|
12
|
+
[![Coverage Status](https://coveralls.io/repos/github/hainesr/ffi-openmpt/badge.svg?branch=master)](https://coveralls.io/github/hainesr/ffi-openmpt)
|
13
|
+
|
14
|
+
### Prerequisits
|
15
|
+
|
16
|
+
#### libopenmpt
|
17
|
+
|
18
|
+
You must have `libopenmpt` installed. On Ubuntu this is done with:
|
19
|
+
|
20
|
+
```shell
|
21
|
+
$ sudo apt install libopenmpt0
|
22
|
+
```
|
23
|
+
|
24
|
+
You do not need the `libopenmpt` development libraries to be installed.
|
25
|
+
|
26
|
+
Instructions for installing `libopenmpt` from source are available on the [libopenmpt homepage][lib-home].
|
27
|
+
|
28
|
+
#### Ruby FFI
|
29
|
+
|
30
|
+
This library uses [Ruby FFI][ruby-ffi] (foreign function interface) to wrap the C API for `libopenmpt`. It will be installed automatically if you install this package via [Ruby Gems][rubygems], otherwise:
|
31
|
+
|
32
|
+
```shell
|
33
|
+
$ gem install ffi
|
34
|
+
```
|
35
|
+
|
36
|
+
will do the trick.
|
37
|
+
|
38
|
+
### Installation
|
39
|
+
|
40
|
+
Add `ffi-openmpt` to your `.gemspec` or `Gemfile` as appropriate, or install directly from [Ruby Gems][rubygems]:
|
41
|
+
|
42
|
+
```shell
|
43
|
+
$ gem install ffi-openmpt
|
44
|
+
```
|
45
|
+
|
46
|
+
### Usage
|
47
|
+
|
48
|
+
The library wraps the C `libopenmpt` API directly: methods have the same name and signature as their C counterparts. A more friendly ruby-like interface is in development, which will hide the FFI details as much as possible.
|
49
|
+
|
50
|
+
Not all `libopenmpt` methods are wrapped yet, but enough functionality is supplied to load a module, interogate it and render it to a PCM stream.
|
51
|
+
|
52
|
+
#### A note on strings returned by `libopenmpt`
|
53
|
+
|
54
|
+
`libopenmpt` manages the memory of any strings it returns. This means that you must free up such memory explicitly after you have finished with them. Such strings are returned to ruby as [`FFI::Pointer`][ffi-pointer] objects, so the string value can be copied to a ruby string as follows:
|
55
|
+
|
56
|
+
```ruby
|
57
|
+
include FFI::OpenMPT::API
|
58
|
+
ptr = openmpt_get_string('url')
|
59
|
+
str = ptr.read_string
|
60
|
+
openmpt_free_string(ptr)
|
61
|
+
puts str
|
62
|
+
```
|
63
|
+
|
64
|
+
### Library versions
|
65
|
+
|
66
|
+
Until this library reaches version 1.0.0 the API may be subject to breaking changes. When version 1.0.0 is released, then the principles of [semantic versioning][semver] will be applied.
|
67
|
+
|
68
|
+
### Licence
|
69
|
+
|
70
|
+
The Ruby OpenMPT code (ffi-openmpt) is released under the BSD licence.
|
71
|
+
|
72
|
+
Copyright (c) 2018, Robert Haines
|
73
|
+
All rights reserved.
|
74
|
+
|
75
|
+
See LICENCE for more details.
|
76
|
+
|
77
|
+
### Acknowledgements
|
78
|
+
|
79
|
+
For testing purposes, this library uses and distributes ['The Last Sun'][lastsun] by Frederic Hahn. It is believed to be in the Public Domain, but if this is not the case please [raise an issue][issues] to let me know.
|
80
|
+
|
81
|
+
[ffi-pointer]: https://www.rubydoc.info/github/ffi/ffi/FFI/Pointer
|
82
|
+
[issues]: https://github.com/hainesr/ffi-openmpt/issues
|
83
|
+
[lastsun]: https://modarchive.org/module.php?47521
|
84
|
+
[lib-home]: https://lib.openmpt.org
|
85
|
+
[mpt-home]: https://openmpt.org/
|
86
|
+
[ruby-ffi]: https://rubygems.org/gems/ffi
|
87
|
+
[rubygems]: https://rubygems.org
|
88
|
+
[semver]: https://semver.org/
|
data/Rakefile
ADDED
@@ -0,0 +1,19 @@
|
|
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
|
+
require 'bundler/gem_tasks'
|
8
|
+
require 'rake/testtask'
|
9
|
+
require 'rubocop/rake_task'
|
10
|
+
|
11
|
+
task default: :test
|
12
|
+
|
13
|
+
Rake::TestTask.new(:test) do |t|
|
14
|
+
t.libs << 'test'
|
15
|
+
t.libs << 'lib'
|
16
|
+
t.test_files = FileList['test/**/*_test.rb']
|
17
|
+
end
|
18
|
+
|
19
|
+
RuboCop::RakeTask.new
|
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'ffi/openmpt'
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require 'pry'
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require 'irb'
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/ffi-openmpt.gemspec
ADDED
@@ -0,0 +1,40 @@
|
|
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
|
+
lib = File.expand_path('lib', __dir__)
|
8
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
9
|
+
require 'ffi/openmpt/version'
|
10
|
+
|
11
|
+
Gem::Specification.new do |spec|
|
12
|
+
spec.name = 'ffi-openmpt'
|
13
|
+
spec.version = FFI::OpenMPT::VERSION
|
14
|
+
spec.authors = ['Robert Haines']
|
15
|
+
spec.email = ['robert.haines@manchester.ac.uk']
|
16
|
+
|
17
|
+
spec.summary = 'A Ruby library to interface with libopenmpt.'
|
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 ' \
|
20
|
+
'PCM audio stream. See https://openmpt.org/ for more information.'
|
21
|
+
spec.homepage = 'https://github.com/hainesr/ffi-openmpt'
|
22
|
+
spec.license = 'BSD'
|
23
|
+
|
24
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
25
|
+
f.match(%r{^(test|spec|features)/})
|
26
|
+
end
|
27
|
+
spec.bindir = 'exe'
|
28
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
29
|
+
spec.require_paths = ['lib']
|
30
|
+
|
31
|
+
spec.required_ruby_version = '>= 2.2.0'
|
32
|
+
|
33
|
+
spec.add_runtime_dependency 'ffi', '~> 1.9'
|
34
|
+
|
35
|
+
spec.add_development_dependency 'bundler', '~> 1.16'
|
36
|
+
spec.add_development_dependency 'coveralls', '~> 0.8'
|
37
|
+
spec.add_development_dependency 'minitest', '~> 5.0'
|
38
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
39
|
+
spec.add_development_dependency 'rubocop', '~> 0.54'
|
40
|
+
end
|
data/lib/ffi/openmpt.rb
ADDED
@@ -0,0 +1,16 @@
|
|
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
|
+
require 'ffi'
|
8
|
+
|
9
|
+
module FFI
|
10
|
+
module OpenMPT
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
require 'ffi/openmpt/version'
|
15
|
+
require 'ffi/openmpt/api'
|
16
|
+
require 'ffi/openmpt/openmpt'
|
@@ -0,0 +1,105 @@
|
|
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 API
|
10
|
+
extend FFI::Library
|
11
|
+
|
12
|
+
ffi_lib 'libopenmpt.so.0'
|
13
|
+
|
14
|
+
# Top-level (library) informational API calls
|
15
|
+
attach_function :openmpt_get_library_version, [], :uint
|
16
|
+
attach_function :openmpt_get_core_version, [], :uint
|
17
|
+
attach_function :openmpt_free_string, [:pointer], :void
|
18
|
+
attach_function :openmpt_get_string, [:string], :pointer
|
19
|
+
attach_function :openmpt_get_supported_extensions, [], :pointer
|
20
|
+
attach_function :openmpt_is_extension_supported, [:string], :int
|
21
|
+
|
22
|
+
# Logging API calls
|
23
|
+
LogDefault =
|
24
|
+
attach_function :openmpt_log_func_default, [:string, :pointer], :void
|
25
|
+
LogSilent =
|
26
|
+
attach_function :openmpt_log_func_silent, [:string, :pointer], :void
|
27
|
+
|
28
|
+
# Error handling API calls
|
29
|
+
OPENMPT_ERROR_OK = 0
|
30
|
+
OPENMPT_ERROR_BASE = 256
|
31
|
+
|
32
|
+
OPENMPT_ERROR_UNKNOWN = OPENMPT_ERROR_BASE + 1
|
33
|
+
OPENMPT_ERROR_EXCEPTION = OPENMPT_ERROR_BASE + 11
|
34
|
+
OPENMPT_ERROR_OUT_OF_MEMORY = OPENMPT_ERROR_BASE + 21
|
35
|
+
|
36
|
+
OPENMPT_ERROR_RUNTIME = OPENMPT_ERROR_BASE + 30
|
37
|
+
OPENMPT_ERROR_RANGE = OPENMPT_ERROR_BASE + 31
|
38
|
+
OPENMPT_ERROR_OVERFLOW = OPENMPT_ERROR_BASE + 32
|
39
|
+
OPENMPT_ERROR_UNDERFLOW = OPENMPT_ERROR_BASE + 33
|
40
|
+
|
41
|
+
OPENMPT_ERROR_LOGIC = OPENMPT_ERROR_BASE + 40
|
42
|
+
OPENMPT_ERROR_DOMAIN = OPENMPT_ERROR_BASE + 41
|
43
|
+
OPENMPT_ERROR_LENGTH = OPENMPT_ERROR_BASE + 42
|
44
|
+
OPENMPT_ERROR_OUT_OF_RANGE = OPENMPT_ERROR_BASE + 43
|
45
|
+
OPENMPT_ERROR_INVALID_ARGUMENT = OPENMPT_ERROR_BASE + 44
|
46
|
+
|
47
|
+
OPENMPT_ERROR_GENERAL = OPENMPT_ERROR_BASE + 101
|
48
|
+
OPENMPT_ERROR_INVALID_MODULE_POINTER = OPENMPT_ERROR_BASE + 102
|
49
|
+
OPENMPT_ERROR_ARGUMENT_NULL_POINTER = OPENMPT_ERROR_BASE + 103
|
50
|
+
|
51
|
+
attach_function :openmpt_error_is_transient, [:int], :int
|
52
|
+
attach_function :openmpt_error_string, [:int], :pointer
|
53
|
+
|
54
|
+
OPENMPT_ERROR_FUNC_RESULT_NONE = 0
|
55
|
+
OPENMPT_ERROR_FUNC_RESULT_LOG = (1 << 0)
|
56
|
+
OPENMPT_ERROR_FUNC_RESULT_STORE = (1 << 1)
|
57
|
+
OPENMPT_ERROR_FUNC_RESULT_DEFAULT =
|
58
|
+
(OPENMPT_ERROR_FUNC_RESULT_LOG | OPENMPT_ERROR_FUNC_RESULT_STORE)
|
59
|
+
|
60
|
+
ErrorDefault =
|
61
|
+
attach_function :openmpt_error_func_default, [:int, :pointer], :int
|
62
|
+
ErrorLog =
|
63
|
+
attach_function :openmpt_error_func_log, [:int, :pointer], :int
|
64
|
+
ErrorStore =
|
65
|
+
attach_function :openmpt_error_func_store, [:int, :pointer], :int
|
66
|
+
ErrorIgnore =
|
67
|
+
attach_function :openmpt_error_func_ignore, [:int, :pointer], :int
|
68
|
+
|
69
|
+
# Module API calls
|
70
|
+
# Creational module calls
|
71
|
+
attach_function :openmpt_module_create_from_memory2,
|
72
|
+
[
|
73
|
+
:pointer, :int, :pointer, :pointer, :pointer,
|
74
|
+
:pointer, :pointer, :pointer, :pointer
|
75
|
+
],
|
76
|
+
:pointer
|
77
|
+
attach_function :openmpt_module_destroy, [:pointer], :void
|
78
|
+
|
79
|
+
# Informational/error module calls
|
80
|
+
attach_function :openmpt_module_get_duration_seconds, [:pointer], :double
|
81
|
+
attach_function :openmpt_module_get_metadata_keys, [:pointer], :pointer
|
82
|
+
attach_function :openmpt_module_get_metadata,
|
83
|
+
[:pointer, :string], :pointer
|
84
|
+
attach_function :openmpt_module_error_get_last, [:pointer], :int
|
85
|
+
attach_function :openmpt_module_error_set_last, [:pointer, :int], :void
|
86
|
+
attach_function :openmpt_module_error_get_last_message,
|
87
|
+
[:pointer], :pointer
|
88
|
+
attach_function :openmpt_module_error_clear, [:pointer], :void
|
89
|
+
|
90
|
+
# Read module calls
|
91
|
+
attach_function :openmpt_module_read_stereo,
|
92
|
+
[:pointer, :int, :int, :pointer, :pointer],
|
93
|
+
:int
|
94
|
+
attach_function :openmpt_module_read_interleaved_stereo,
|
95
|
+
[:pointer, :int, :int, :pointer],
|
96
|
+
:int
|
97
|
+
attach_function :openmpt_module_read_float_stereo,
|
98
|
+
[:pointer, :int, :int, :pointer, :pointer],
|
99
|
+
:int
|
100
|
+
attach_function :openmpt_module_read_interleaved_float_stereo,
|
101
|
+
[:pointer, :int, :int, :pointer],
|
102
|
+
:int
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
@@ -0,0 +1,18 @@
|
|
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
|
+
def self.library_version
|
10
|
+
maj, min, pat = [API.openmpt_get_library_version].pack('L>').unpack('CCS')
|
11
|
+
[maj, min, pat >> 8]
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.core_version
|
15
|
+
[API.openmpt_get_core_version].pack('L>').unpack('CCCC')
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
metadata
ADDED
@@ -0,0 +1,149 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ffi-openmpt
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Robert Haines
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-08-25 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: ffi
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.9'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.9'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.16'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.16'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: coveralls
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.8'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.8'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: minitest
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '5.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '5.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '10.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '10.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rubocop
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0.54'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0.54'
|
97
|
+
description: libopenmpt is a library to render tracker music (MOD, XM, S3M, IT MPTM
|
98
|
+
and dozens of other legacy formats) to a PCM audio stream. See https://openmpt.org/
|
99
|
+
for more information.
|
100
|
+
email:
|
101
|
+
- robert.haines@manchester.ac.uk
|
102
|
+
executables: []
|
103
|
+
extensions: []
|
104
|
+
extra_rdoc_files: []
|
105
|
+
files:
|
106
|
+
- ".gitignore"
|
107
|
+
- ".rubocop.yml"
|
108
|
+
- ".rubocop_ffi-openmpt.yml"
|
109
|
+
- ".ruby-gemset"
|
110
|
+
- ".ruby-version"
|
111
|
+
- ".travis.yml"
|
112
|
+
- CHANGES.md
|
113
|
+
- CODE_OF_CONDUCT.md
|
114
|
+
- Gemfile
|
115
|
+
- LICENCE
|
116
|
+
- README.md
|
117
|
+
- Rakefile
|
118
|
+
- bin/console
|
119
|
+
- bin/setup
|
120
|
+
- ffi-openmpt.gemspec
|
121
|
+
- lib/ffi/openmpt.rb
|
122
|
+
- lib/ffi/openmpt/api.rb
|
123
|
+
- lib/ffi/openmpt/openmpt.rb
|
124
|
+
- lib/ffi/openmpt/version.rb
|
125
|
+
homepage: https://github.com/hainesr/ffi-openmpt
|
126
|
+
licenses:
|
127
|
+
- BSD
|
128
|
+
metadata: {}
|
129
|
+
post_install_message:
|
130
|
+
rdoc_options: []
|
131
|
+
require_paths:
|
132
|
+
- lib
|
133
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - ">="
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: 2.2.0
|
138
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
139
|
+
requirements:
|
140
|
+
- - ">="
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
version: '0'
|
143
|
+
requirements: []
|
144
|
+
rubyforge_project:
|
145
|
+
rubygems_version: 2.7.7
|
146
|
+
signing_key:
|
147
|
+
specification_version: 4
|
148
|
+
summary: A Ruby library to interface with libopenmpt.
|
149
|
+
test_files: []
|