fmod 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (105) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +14 -0
  3. data/.travis.yml +5 -0
  4. data/.yardopts +2 -0
  5. data/CODE_OF_CONDUCT.md +74 -0
  6. data/Gemfile +5 -0
  7. data/LICENSE.txt +21 -0
  8. data/README.md +96 -0
  9. data/Rakefile +1 -0
  10. data/bin/console +28 -0
  11. data/bin/setup +8 -0
  12. data/ext/fmod.dll +0 -0
  13. data/ext/fmod64.dll +0 -0
  14. data/ext/libfmod.dylib +0 -0
  15. data/ext/llbfmod.zip +0 -0
  16. data/extras/FMOD Studio Programmers API for Windows.chm +0 -0
  17. data/fmod.gemspec +58 -0
  18. data/lib/fmod.rb +564 -0
  19. data/lib/fmod/channel.rb +151 -0
  20. data/lib/fmod/channel_control.rb +821 -0
  21. data/lib/fmod/channel_group.rb +61 -0
  22. data/lib/fmod/core.rb +35 -0
  23. data/lib/fmod/core/bool_description.rb +18 -0
  24. data/lib/fmod/core/channel_mask.rb +24 -0
  25. data/lib/fmod/core/data_description.rb +14 -0
  26. data/lib/fmod/core/driver.rb +59 -0
  27. data/lib/fmod/core/dsp_description.rb +7 -0
  28. data/lib/fmod/core/dsp_index.rb +9 -0
  29. data/lib/fmod/core/dsp_type.rb +43 -0
  30. data/lib/fmod/core/extensions.rb +28 -0
  31. data/lib/fmod/core/file_system.rb +86 -0
  32. data/lib/fmod/core/filter_type.rb +19 -0
  33. data/lib/fmod/core/float_description.rb +16 -0
  34. data/lib/fmod/core/guid.rb +50 -0
  35. data/lib/fmod/core/init_flags.rb +19 -0
  36. data/lib/fmod/core/integer_description.rb +26 -0
  37. data/lib/fmod/core/mode.rb +36 -0
  38. data/lib/fmod/core/output_type.rb +30 -0
  39. data/lib/fmod/core/parameter_info.rb +41 -0
  40. data/lib/fmod/core/parameter_type.rb +10 -0
  41. data/lib/fmod/core/result.rb +88 -0
  42. data/lib/fmod/core/reverb.rb +217 -0
  43. data/lib/fmod/core/sound_ex_info.rb +7 -0
  44. data/lib/fmod/core/sound_format.rb +30 -0
  45. data/lib/fmod/core/sound_group_behavior.rb +9 -0
  46. data/lib/fmod/core/sound_type.rb +80 -0
  47. data/lib/fmod/core/speaker_index.rb +18 -0
  48. data/lib/fmod/core/speaker_mode.rb +16 -0
  49. data/lib/fmod/core/spectrum_data.rb +12 -0
  50. data/lib/fmod/core/structure.rb +23 -0
  51. data/lib/fmod/core/structures.rb +41 -0
  52. data/lib/fmod/core/tag.rb +51 -0
  53. data/lib/fmod/core/tag_data_type.rb +14 -0
  54. data/lib/fmod/core/time_unit.rb +40 -0
  55. data/lib/fmod/core/vector.rb +42 -0
  56. data/lib/fmod/core/window_type.rb +12 -0
  57. data/lib/fmod/dsp.rb +510 -0
  58. data/lib/fmod/dsp_connection.rb +113 -0
  59. data/lib/fmod/effects.rb +38 -0
  60. data/lib/fmod/effects/channel_mix.rb +101 -0
  61. data/lib/fmod/effects/chorus.rb +30 -0
  62. data/lib/fmod/effects/compressor.rb +52 -0
  63. data/lib/fmod/effects/convolution_reverb.rb +31 -0
  64. data/lib/fmod/effects/delay.rb +44 -0
  65. data/lib/fmod/effects/distortion.rb +16 -0
  66. data/lib/fmod/effects/dsps.rb +10 -0
  67. data/lib/fmod/effects/echo.rb +37 -0
  68. data/lib/fmod/effects/envelope_follower.rb +31 -0
  69. data/lib/fmod/effects/fader.rb +16 -0
  70. data/lib/fmod/effects/fft.rb +38 -0
  71. data/lib/fmod/effects/flange.rb +37 -0
  72. data/lib/fmod/effects/high_pass.rb +24 -0
  73. data/lib/fmod/effects/high_pass_simple.rb +25 -0
  74. data/lib/fmod/effects/it_echo.rb +56 -0
  75. data/lib/fmod/effects/it_lowpass.rb +36 -0
  76. data/lib/fmod/effects/ladspa_plugin.rb +14 -0
  77. data/lib/fmod/effects/limiter.rb +32 -0
  78. data/lib/fmod/effects/loudness_meter.rb +19 -0
  79. data/lib/fmod/effects/low_pass.rb +25 -0
  80. data/lib/fmod/effects/low_pass_simple.rb +26 -0
  81. data/lib/fmod/effects/mixer.rb +11 -0
  82. data/lib/fmod/effects/multiband_eq.rb +153 -0
  83. data/lib/fmod/effects/normalize.rb +47 -0
  84. data/lib/fmod/effects/object_pan.rb +62 -0
  85. data/lib/fmod/effects/oscillator.rb +52 -0
  86. data/lib/fmod/effects/pan.rb +166 -0
  87. data/lib/fmod/effects/param_eq.rb +36 -0
  88. data/lib/fmod/effects/pitch_shift.rb +47 -0
  89. data/lib/fmod/effects/return.rb +18 -0
  90. data/lib/fmod/effects/send.rb +21 -0
  91. data/lib/fmod/effects/sfx_reverb.rb +87 -0
  92. data/lib/fmod/effects/three_eq.rb +41 -0
  93. data/lib/fmod/effects/transceiver.rb +57 -0
  94. data/lib/fmod/effects/tremolo.rb +67 -0
  95. data/lib/fmod/effects/vst_plugin.rb +12 -0
  96. data/lib/fmod/effects/winamp_plugin.rb +12 -0
  97. data/lib/fmod/error.rb +108 -0
  98. data/lib/fmod/geometry.rb +380 -0
  99. data/lib/fmod/handle.rb +129 -0
  100. data/lib/fmod/reverb3D.rb +98 -0
  101. data/lib/fmod/sound.rb +810 -0
  102. data/lib/fmod/sound_group.rb +54 -0
  103. data/lib/fmod/system.rb +1242 -0
  104. data/lib/fmod/version.rb +3 -0
  105. metadata +220 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c772ecf5f77aade5c16621fe21270b20abec3078
4
+ data.tar.gz: f01973742360bb5ac77e442ce6167f2d60f540f3
5
+ SHA512:
6
+ metadata.gz: 8c8ed671237062f1b82ddff1abb2d1b6db181ce908cb7a16c98679b7ac9b74cdf9c91fb245a7aa42592cfbccf278c8850d6dc42be21a6c81e477e4abd6ba4123
7
+ data.tar.gz: 6546ee0eee3da8627a77500d2bd2ee82287f441830749f44fa4a8ef96e61e08dfd2e604fbf1db23f41d47f5ec071e92fd1fb55d925f462e49c95f6cfa2b2bc16
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ /.idea
10
+
11
+ /**/*.mp3
12
+
13
+ # rspec failure tracking
14
+ .rspec_status
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.4
5
+ before_install: gem install bundler -v 1.16.2
@@ -0,0 +1,2 @@
1
+ --title "FMOD"
2
+ --charset UTF-8
@@ -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 efreed09@gmail.com. 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
@@ -0,0 +1,5 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Eric Freed
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,96 @@
1
+ # FMOD
2
+
3
+
4
+
5
+ A full-featured (*complete* Ruby wrapper) of the ultra-powerful FMOD Low-Level API. Uses the built-in Fiddle library (Ruby 2.0+), and has no external gem dependencies, all that is needed is the native FMOD platform-specific native FMOD libraries.
6
+
7
+ Supports a host of audio formats including:
8
+ * Audio Interchange File Format (.aiff )
9
+ * Advanced Systems Format (.asf)
10
+ * Advanced Stream Redirector (.asx)
11
+ * Downloadable Sound (.dls)
12
+ * Free Loss-less Audio Codec (.flac)
13
+ * FMOD Sound Bank (.fsb)
14
+ * Impulse Tracker (.it)
15
+ * MPEG Audio Layer 3 URL (.m3u)
16
+ * Musical Instrument Digital Interface (.mid, .midi)
17
+ * Module Format (.mod)
18
+ * MPEG Audio Layer 2 (.mp2)
19
+ * MPEG Audio Layer 3 (.mp3)
20
+ * OGG Vorbis (.ogg)
21
+ * Playlist (.pls)
22
+ * ScreamTracker 3 Module (.s3m )
23
+ * PS2/PSP Format (.vag )
24
+ * Waveform Audio File Forma (.wav )
25
+ * Windows Media Audio Redirector (.wax )
26
+ * Windows Media Audio (.wma )
27
+ * Extended Module (.xm )
28
+ * Windows Media Audio (Xbox 360) (.xma)
29
+
30
+ FMOD is most widely known for its application in video games for sound effects, as it fully supports 3D sound, and can be found in all popular video game consoles (Sony, Microsoft, and Nintendo), as well as a large number of popular PC and mobile games. Built-in is a large collection of audio effects that can be applied to a sound, including various equalizers, advanced reverb environments, pitch-shifting, frequency, flange, chorus, and many, many more.
31
+
32
+ The wrapper supports callbacks for various events, such as sync-points in wave files, sound playback ending (either by user or end of data), and various other scenarios. It additionally supports access to raw PCM data directly from the sound card, for creating visualizations or examining the sound in real-time.
33
+
34
+ ## Installation
35
+
36
+ Add this line to your application's Gemfile:
37
+
38
+ ```ruby
39
+ gem 'fmod'
40
+ ```
41
+
42
+ And then execute:
43
+
44
+ $ bundle
45
+
46
+ Or install it yourself as:
47
+
48
+ $ gem install fmod
49
+
50
+ The dependent binaries will be loaded automatically on Windows and Mac without further action, and are included within the gem. Linux user will need to locate the `./ext` directory within the gem file and extract `libfmod.zip` into the `./ext` directory. Due to symbolic linking, this process needs done on the host machine, and will hopefully be automated in future releases.
51
+
52
+ ## Usage
53
+
54
+ Including in the `/extras` folder is the compiled help documentation for the actual FMOD library, which can be helpful for understanding how the API works if you are unfamiliar.
55
+
56
+ Those who are familiar with FMOD will find the structure and syntax familiar, though performed in the object-oriented "Ruby" way. All base core FMOD data types have been created as classes, and mostly share the same names with their C counterpart though in Ruby "snake_case" style as opposed to "UpperCamelCase". Being object-oriented each class is wrapped around using the functions that relate to it, and doesn't require the use of passing pointers or the object to the methods.
57
+
58
+ So creating and working with objects has been simplied..
59
+
60
+ ```ruby
61
+ require 'fmod'
62
+
63
+ FMOD.load_library
64
+
65
+ system = FMOD::System.create
66
+ sound = system.create_sound("./myFile.mp3")
67
+ sound.play
68
+ ```
69
+
70
+ Each get/set method in the FMOD API has been converted to an "attribute" that can be accessed in the Ruby way. So instead of`FMOD_Channel_GetVolume` and `FMOD_Channel_SetVolume`, it is simply `channel.volume` and `channel.volume = value`.
71
+
72
+ ## Future Releases
73
+
74
+ As of the first release, only slightly better than 50% of documentation is complete. The scripts are highly technical, and good documentation takes time, but it is actively being updated, and will be completed at the highest priority level. If you are using version `1.0.0`, you will have to rely more heavily upon the included FMOD Low-Level API Reference that is included in the `./extras` folder.
75
+
76
+ There is still yet to be a few areas that need completed, and are in active development. Included are the following known issues:
77
+ * FMOD plugin support (including 3rd party codecs)
78
+ * Loading custom sound formats (related to plugin support)
79
+ * Custom file-system support to piggyback and monitor FMOD's read/write callbacks
80
+ * Creation of custom effects (Digital Sound Processors) (also related to plugins)
81
+
82
+ None of these incomplete areas will have any effect on the existing code-base, and existing code will be unaffected by their implementation in future versions.
83
+
84
+ ## Contributing
85
+
86
+ Bug reports and pull requests are welcome on [GitHub](https://github.com/ForeverZer0/fmod). This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
87
+
88
+ ## License
89
+
90
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
91
+
92
+ The FMOD library is under a free license for non-commercial use, and a proprietary license otherwise. See the [FMOD License Page](https://www.fmod.com/licensing) for details on pricing if you plan to use this commercially.
93
+
94
+ ## Code of Conduct
95
+
96
+ Everyone interacting in the FMOD project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/ForeverZer0/fmod/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'fmod'
5
+ require 'irb'
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
+ if $0 == __FILE__
15
+ include FMOD
16
+
17
+ FMOD.load_library
18
+
19
+ mp3 = Dir.glob("#{Dir.home}/Music/**/*.mp3").sample
20
+ unless mp3.nil?
21
+ puts("Now playing \"#{File.basename(mp3)}...\"")
22
+ $system = System.create
23
+ $sound = $system.create_stream(mp3)
24
+ $channel = $system.play_sound($sound)
25
+ end
26
+
27
+ IRB.start(__FILE__)
28
+ end
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,58 @@
1
+
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'fmod/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'fmod'
8
+ spec.version = FMOD::VERSION
9
+ spec.authors = ['Eric "ForeverZero" Freed']
10
+ spec.email = ['efreed09@gmail.com']
11
+ spec.summary = %q{Ruby wrapper around the high performance, cross-platform FMOD low-level sound library. You get all the benefits of the FMOD library, but in the object-oriented Ruby way!}
12
+ spec.description = %q{A full-featured (complete Ruby wrapper) of the ultra-powerful FMOD Low-Level API. Uses the built-in Fiddle library (Ruby 2.0+), and has no external gem dependencies, all that is needed is the native FMOD platform-specific native FMOD libraries (included).
13
+
14
+ FMOD supports a host of audio formats including:
15
+
16
+ - Audio Interchange File Format (.aiff )
17
+ - Advanced Systems Format (.asf)
18
+ - Advanced Stream Redirector (.asx)
19
+ - Downloadable Sound (.dls)
20
+ - Free Lossless Audio Codec (.flac)
21
+ - FMOD Sound Bank (.fsb)
22
+ - Impulse Tracker (.it)
23
+ - MPEG Audio Layer 3 URL (.m3u)
24
+ - Musical Instrument Digital Interface (.mid, .midi)
25
+ - Module Format (.mod)
26
+ - MPEG Audio Layer 2 (.mp2)
27
+ - MPEG Audio Layer 3 (.mp3)
28
+ - OGG Vorbis (.ogg)
29
+ - Playlist (.pls)
30
+ - ScreamTracker 3 Module (.s3m )
31
+ - PS2/PSP Format (.vag )
32
+ - Waveform Audio File Forma (.wav )
33
+ - Windows Media Audio Redirector (.wax )
34
+ - Windows Media Audio (.wma )
35
+ - Extended Module (.xm )
36
+ - Windows Media Audio (Xbox 360) (.xma)
37
+
38
+ FMOD is most widely known for its application in video games for sound effects, as it fully supports 3D sound, and can be found in all popular video game consoles (Sony, Microsoft, and Nintendo), as well as a large number of popular PC and mobile games. Built-in is a large collection of audio effects that can be applied to a sound, including various equalizers, advanced reverb environments, pitch-shifting, frequency, flange, chorus, and many, many more.
39
+
40
+ The wrapper supports callbacks for various events, such as sync-points in wave files, sound playback ending (either by user or end of data), and various other scenarios. It additionally supports access to raw PCM data directly from the sound card, for creating visualizations or examining the sound in real-time.}
41
+
42
+ spec.homepage = 'https://github.com/ForeverZer0/fmod'
43
+ spec.license = 'MIT'
44
+ spec.has_rdoc = 'yard'
45
+
46
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
47
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
48
+ end
49
+ spec.bindir = 'exe'
50
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
51
+ spec.require_paths = ['lib']
52
+
53
+ spec.required_ruby_version = '>= 2.0.0'
54
+
55
+ spec.add_development_dependency 'bundler', '~> 1.16'
56
+ spec.add_development_dependency 'rake', '~> 10.0'
57
+ spec.add_development_dependency 'yard', '~> 0.9'
58
+ end
@@ -0,0 +1,564 @@
1
+
2
+ require 'fiddle'
3
+ require 'fiddle/import'
4
+ require 'rbconfig'
5
+
6
+ module FMOD
7
+
8
+ include Fiddle
9
+
10
+ ##
11
+ # Null-pointer (address of 0)
12
+ NULL = Pointer.new(0).freeze
13
+
14
+ ##
15
+ # Version number of the wave format codec.
16
+ #
17
+ # Use this for binary compatibility and for future expansion.
18
+ WAVE_FORMAT_VERSION = 3
19
+
20
+ ##
21
+ # Array of extensions for supported formats.
22
+ #
23
+ # Additional formats may be supported, or added via plug-ins.
24
+ SUPPORTED_EXTENSIONS = %w(.aiff .asf .asx .dls .flac .fsb .it .m3u .midi .mod .mp2 .mp3 .ogg .pls .s3m .vag .wav .wax .wma .xm .xma)
25
+
26
+ ##
27
+ # The maximum number of channels per frame of audio supported by audio files,
28
+ # buffers, connections and DSPs.
29
+ MAX_CHANNEL_WIDTH = 32
30
+
31
+ ##
32
+ # The maximum number of listeners supported.
33
+ MAX_LISTENERS = 8
34
+
35
+ ##
36
+ # The maximum number of {System} objects allowed.
37
+ MAX_SYSTEMS = 8
38
+
39
+ ##
40
+ # The maximum number of global/physical reverb instances.
41
+ #
42
+ # Each instance of a physical reverb is an instance of a {Effects::SfxReverb }
43
+ # DSP in the mix graph. This is unrelated to the number of possible {Reverb3D}
44
+ # objects, which is unlimited.
45
+ MAX_REVERB = 4
46
+
47
+ ##
48
+ # Null value for a port index. Use when a port index is not required.
49
+ PORT_INDEX_NONE = 0xFFFFFFFFFFFFFFFF
50
+
51
+ require_relative 'fmod/version.rb'
52
+ require_relative 'fmod/core'
53
+ require_relative 'fmod/error'
54
+ require_relative 'fmod/handle'
55
+ require_relative 'fmod/channel_control'
56
+ require_relative 'fmod/channel.rb'
57
+ require_relative 'fmod/channel_group.rb'
58
+ require_relative 'fmod/dsp.rb'
59
+ require_relative 'fmod/effects.rb'
60
+ require_relative 'fmod/dsp_connection.rb'
61
+ require_relative 'fmod/geometry.rb'
62
+ require_relative 'fmod/reverb3D.rb'
63
+ require_relative 'fmod/sound.rb'
64
+ require_relative 'fmod/sound_group.rb'
65
+ require_relative 'fmod/system.rb'
66
+
67
+ @function_signatures = {
68
+ ############################################################################
69
+ # Channel
70
+ ############################################################################
71
+ Channel_GetChannelGroup: [TYPE_VOIDP, TYPE_VOIDP],
72
+ Channel_GetCurrentSound: [TYPE_VOIDP, TYPE_VOIDP],
73
+ Channel_GetFrequency: [TYPE_VOIDP, TYPE_VOIDP],
74
+ Channel_GetIndex: [TYPE_VOIDP, TYPE_VOIDP],
75
+ Channel_GetLoopCount: [TYPE_VOIDP, TYPE_VOIDP],
76
+ Channel_GetLoopPoints: [TYPE_VOIDP, TYPE_VOIDP, TYPE_INT, TYPE_VOIDP, TYPE_INT],
77
+ Channel_GetPosition: [TYPE_VOIDP, TYPE_VOIDP, TYPE_INT],
78
+ Channel_GetPriority: [TYPE_VOIDP, TYPE_VOIDP],
79
+ Channel_IsVirtual: [TYPE_VOIDP, TYPE_VOIDP],
80
+ Channel_SetChannelGroup: [TYPE_VOIDP, TYPE_VOIDP],
81
+ Channel_SetFrequency: [TYPE_VOIDP, TYPE_FLOAT],
82
+ Channel_SetLoopCount: [TYPE_VOIDP, TYPE_INT],
83
+ Channel_SetLoopPoints: [TYPE_VOIDP, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT],
84
+ Channel_SetPosition: [TYPE_VOIDP, TYPE_INT, TYPE_INT],
85
+ Channel_SetPriority: [TYPE_VOIDP, TYPE_INT],
86
+ ############################################################################
87
+ # ChannelGroup
88
+ ############################################################################
89
+ ChannelGroup_AddGroup: [TYPE_VOIDP, TYPE_VOIDP, TYPE_INT, TYPE_VOIDP],
90
+ ChannelGroup_GetChannel: [TYPE_VOIDP, TYPE_INT, TYPE_VOIDP],
91
+ ChannelGroup_GetGroup: [TYPE_VOIDP, TYPE_INT, TYPE_VOIDP],
92
+ ChannelGroup_GetName: [TYPE_VOIDP, TYPE_VOIDP, TYPE_INT],
93
+ ChannelGroup_GetNumChannels: [TYPE_VOIDP, TYPE_VOIDP],
94
+ ChannelGroup_GetNumGroups: [TYPE_VOIDP, TYPE_VOIDP],
95
+ ChannelGroup_GetParentGroup: [TYPE_VOIDP, TYPE_VOIDP],
96
+ ############################################################################
97
+ # ChannelControl
98
+ ############################################################################
99
+ ChannelGroup_AddDSP: [TYPE_VOIDP, TYPE_INT, TYPE_VOIDP],
100
+ ChannelGroup_AddFadePoint: [TYPE_VOIDP, TYPE_LONG_LONG, TYPE_FLOAT],
101
+ ChannelGroup_Get3DAttributes: Array.new(4, TYPE_VOIDP),
102
+ ChannelGroup_Get3DConeOrientation: [TYPE_VOIDP, TYPE_VOIDP],
103
+ ChannelGroup_Get3DConeSettings: Array.new(4, TYPE_VOIDP),
104
+ ChannelGroup_Get3DCustomRolloff: [TYPE_VOIDP, TYPE_VOIDP, TYPE_VOIDP],
105
+ ChannelGroup_Get3DDistanceFilter: Array.new(4, TYPE_VOIDP),
106
+ ChannelGroup_Get3DDopplerLevel: [TYPE_VOIDP, TYPE_VOIDP],
107
+ ChannelGroup_Get3DLevel: [TYPE_VOIDP, TYPE_VOIDP],
108
+ ChannelGroup_Get3DMinMaxDistance: Array.new(3, TYPE_VOIDP),
109
+ ChannelGroup_Get3DOcclusion: [TYPE_VOIDP, TYPE_VOIDP, TYPE_VOIDP],
110
+ ChannelGroup_Get3DSpread: [TYPE_VOIDP, TYPE_VOIDP],
111
+ ChannelGroup_GetAudibility: [TYPE_VOIDP, TYPE_VOIDP],
112
+ ChannelGroup_GetDelay: [TYPE_VOIDP, TYPE_VOIDP, TYPE_VOIDP, TYPE_VOIDP],
113
+ ChannelGroup_GetDSP: [TYPE_VOIDP, TYPE_INT, TYPE_VOIDP],
114
+ ChannelGroup_GetDSPClock: [TYPE_VOIDP, TYPE_VOIDP, TYPE_VOIDP],
115
+ ChannelGroup_GetDSPIndex: [TYPE_VOIDP, TYPE_VOIDP, TYPE_VOIDP],
116
+ ChannelGroup_GetFadePoints: Array.new(4, TYPE_VOIDP),
117
+ ChannelGroup_GetLowPassGain: [TYPE_VOIDP, TYPE_VOIDP],
118
+ ChannelGroup_GetMixMatrix: [TYPE_VOIDP, TYPE_VOIDP, TYPE_VOIDP, TYPE_VOIDP, TYPE_INT],
119
+ ChannelGroup_GetMode: [TYPE_VOIDP, TYPE_VOIDP],
120
+ ChannelGroup_GetMute: [TYPE_VOIDP, TYPE_VOIDP],
121
+ ChannelGroup_GetNumDSPs: [TYPE_VOIDP, TYPE_VOIDP],
122
+ ChannelGroup_GetPaused: [TYPE_VOIDP, TYPE_VOIDP],
123
+ ChannelGroup_GetPitch: [TYPE_VOIDP, TYPE_VOIDP],
124
+ ChannelGroup_GetReverbProperties: [TYPE_VOIDP, TYPE_INT, TYPE_VOIDP],
125
+ ChannelGroup_GetSystemObject: [TYPE_VOIDP, TYPE_VOIDP],
126
+ ChannelGroup_GetUserData: [TYPE_VOIDP, TYPE_VOIDP],
127
+ ChannelGroup_GetVolume: [TYPE_VOIDP, TYPE_VOIDP],
128
+ ChannelGroup_GetVolumeRamp: [TYPE_VOIDP, TYPE_VOIDP],
129
+ ChannelGroup_IsPlaying: [TYPE_VOIDP, TYPE_VOIDP],
130
+ ChannelGroup_Release: [TYPE_VOIDP],
131
+ ChannelGroup_RemoveDSP: [TYPE_VOIDP, TYPE_VOIDP],
132
+ ChannelGroup_RemoveFadePoints: [TYPE_VOIDP, TYPE_LONG_LONG, TYPE_LONG_LONG],
133
+ ChannelGroup_Set3DAttributes: Array.new(4, TYPE_VOIDP),
134
+ ChannelGroup_Set3DConeOrientation: [TYPE_VOIDP, TYPE_VOIDP],
135
+ ChannelGroup_Set3DConeSettings: [TYPE_VOIDP, TYPE_FLOAT, TYPE_FLOAT, TYPE_FLOAT],
136
+ ChannelGroup_Set3DCustomRolloff: [TYPE_VOIDP, TYPE_VOIDP, TYPE_INT],
137
+ ChannelGroup_Set3DDistanceFilter: [TYPE_VOIDP, TYPE_INT, TYPE_FLOAT, TYPE_FLOAT],
138
+ ChannelGroup_Set3DDopplerLevel: [TYPE_VOIDP, TYPE_FLOAT],
139
+ ChannelGroup_Set3DLevel: [TYPE_VOIDP, TYPE_FLOAT],
140
+ ChannelGroup_Set3DMinMaxDistance: [TYPE_VOIDP, TYPE_FLOAT, TYPE_FLOAT],
141
+ ChannelGroup_Set3DOcclusion: [TYPE_VOIDP, TYPE_FLOAT, TYPE_FLOAT],
142
+ ChannelGroup_Set3DSpread: [TYPE_VOIDP, TYPE_FLOAT],
143
+ ChannelGroup_SetCallback: [TYPE_VOIDP, TYPE_VOIDP],
144
+ ChannelGroup_SetDelay: [TYPE_VOIDP, TYPE_LONG_LONG, TYPE_LONG_LONG, TYPE_INT],
145
+ ChannelGroup_SetDSPIndex: [TYPE_VOIDP, TYPE_VOIDP, TYPE_INT],
146
+ ChannelGroup_SetFadePointRamp: [TYPE_VOIDP, TYPE_LONG_LONG, TYPE_FLOAT],
147
+ ChannelGroup_SetLowPassGain: [TYPE_VOIDP, TYPE_FLOAT],
148
+ ChannelGroup_SetMixLevelsInput: [TYPE_VOIDP, TYPE_VOIDP, TYPE_INT],
149
+ ChannelGroup_SetMixLevelsOutput: [TYPE_VOIDP] + Array.new(8, TYPE_FLOAT),
150
+ ChannelGroup_SetMixMatrix: [TYPE_VOIDP, TYPE_VOIDP, TYPE_INT, TYPE_INT, TYPE_INT],
151
+ ChannelGroup_SetMode: [TYPE_VOIDP, TYPE_INT],
152
+ ChannelGroup_SetMute: [TYPE_VOIDP, TYPE_INT],
153
+ ChannelGroup_SetPan: [TYPE_VOIDP, TYPE_FLOAT],
154
+ ChannelGroup_SetPaused: [TYPE_VOIDP, TYPE_INT],
155
+ ChannelGroup_SetPitch: [TYPE_VOIDP, TYPE_FLOAT],
156
+ ChannelGroup_SetReverbProperties: [TYPE_VOIDP, TYPE_INT, TYPE_FLOAT],
157
+ ChannelGroup_SetUserData: [TYPE_VOIDP, TYPE_VOIDP],
158
+ ChannelGroup_SetVolume: [TYPE_VOIDP, TYPE_FLOAT],
159
+ ChannelGroup_SetVolumeRamp: [TYPE_VOIDP, TYPE_INT],
160
+ ChannelGroup_Stop: [TYPE_VOIDP],
161
+ ############################################################################
162
+ # Debug
163
+ ############################################################################
164
+ # Debug_Initialize: [TYPE_VOIDP],
165
+ ############################################################################
166
+ # Dsp
167
+ ############################################################################
168
+ DSP_AddInput: [TYPE_VOIDP, TYPE_VOIDP, TYPE_VOIDP, TYPE_INT],
169
+ DSP_DisconnectAll: [TYPE_VOIDP, TYPE_INT, TYPE_INT],
170
+ DSP_DisconnectFrom: [TYPE_VOIDP, TYPE_VOIDP, TYPE_VOIDP],
171
+ DSP_GetActive: [TYPE_VOIDP, TYPE_VOIDP],
172
+ DSP_GetBypass: [TYPE_VOIDP, TYPE_VOIDP],
173
+ DSP_GetChannelFormat: Array.new(4, TYPE_VOIDP),
174
+ # DSP_GetDataParameterIndex: [TYPE_VOIDP],
175
+ DSP_GetIdle: [TYPE_VOIDP, TYPE_VOIDP],
176
+ DSP_GetInfo: [TYPE_VOIDP, TYPE_VOIDP, TYPE_VOIDP, TYPE_VOIDP, TYPE_VOIDP, TYPE_VOIDP],
177
+ DSP_GetInput: [TYPE_VOIDP, TYPE_INT, TYPE_VOIDP, TYPE_VOIDP],
178
+ DSP_GetMeteringEnabled: Array.new(3, TYPE_VOIDP),
179
+ # DSP_GetMeteringInfo: [TYPE_VOIDP],
180
+ DSP_GetNumInputs: [TYPE_VOIDP, TYPE_VOIDP],
181
+ DSP_GetNumOutputs: [TYPE_VOIDP, TYPE_VOIDP],
182
+ DSP_GetNumParameters: [TYPE_VOIDP, TYPE_VOIDP],
183
+ DSP_GetOutput: [TYPE_VOIDP, TYPE_INT, TYPE_VOIDP, TYPE_VOIDP],
184
+ DSP_GetOutputChannelFormat: [TYPE_VOIDP, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_VOIDP, TYPE_VOIDP, TYPE_VOIDP],
185
+ DSP_GetParameterBool: [TYPE_VOIDP, TYPE_INT, TYPE_VOIDP, TYPE_VOIDP, TYPE_INT],
186
+ DSP_GetParameterData: [TYPE_VOIDP, TYPE_INT, TYPE_VOIDP, TYPE_VOIDP, TYPE_VOIDP, TYPE_INT],
187
+ DSP_GetParameterFloat: [TYPE_VOIDP, TYPE_INT, TYPE_VOIDP, TYPE_VOIDP, TYPE_INT],
188
+ DSP_GetParameterInfo: [TYPE_VOIDP, TYPE_INT, TYPE_VOIDP],
189
+ DSP_GetParameterInt: [TYPE_VOIDP, TYPE_INT, TYPE_VOIDP, TYPE_VOIDP, TYPE_INT],
190
+ DSP_GetSystemObject: [TYPE_VOIDP, TYPE_VOIDP],
191
+ DSP_GetType: [TYPE_VOIDP, TYPE_VOIDP],
192
+ DSP_GetUserData: [TYPE_VOIDP, TYPE_VOIDP],
193
+ DSP_GetWetDryMix: Array.new(4, TYPE_VOIDP),
194
+ DSP_Release: [TYPE_VOIDP],
195
+ DSP_Reset: [TYPE_VOIDP],
196
+ DSP_SetActive: [TYPE_VOIDP, TYPE_INT],
197
+ DSP_SetBypass: [TYPE_VOIDP, TYPE_INT],
198
+ DSP_SetChannelFormat: [TYPE_VOIDP, TYPE_INT, TYPE_INT, TYPE_INT],
199
+ DSP_SetMeteringEnabled: [TYPE_VOIDP, TYPE_INT, TYPE_INT],
200
+ DSP_SetParameterBool: [TYPE_VOIDP, TYPE_INT, TYPE_INT],
201
+ DSP_SetParameterData: [TYPE_VOIDP, TYPE_INT, TYPE_VOIDP, TYPE_INT],
202
+ DSP_SetParameterFloat: [TYPE_VOIDP, TYPE_INT, TYPE_FLOAT],
203
+ DSP_SetParameterInt: [TYPE_VOIDP, TYPE_INT, TYPE_INT],
204
+ DSP_SetUserData: [TYPE_VOIDP, TYPE_VOIDP],
205
+ DSP_SetWetDryMix: [TYPE_VOIDP, TYPE_FLOAT, TYPE_FLOAT, TYPE_FLOAT],
206
+ DSP_ShowConfigDialog: [TYPE_VOIDP, TYPE_VOIDP, TYPE_INT],
207
+ ############################################################################
208
+ # DspConnection
209
+ ############################################################################
210
+ DSPConnection_GetInput: [TYPE_VOIDP, TYPE_VOIDP],
211
+ DSPConnection_GetMix: [TYPE_VOIDP, TYPE_VOIDP],
212
+ DSPConnection_GetMixMatrix: [TYPE_VOIDP, TYPE_VOIDP, TYPE_VOIDP, TYPE_VOIDP, TYPE_INT],
213
+ DSPConnection_GetOutput: [TYPE_VOIDP, TYPE_VOIDP],
214
+ DSPConnection_GetType: [TYPE_VOIDP, TYPE_VOIDP],
215
+ DSPConnection_GetUserData: [TYPE_VOIDP, TYPE_VOIDP],
216
+ DSPConnection_SetMix: [TYPE_VOIDP, TYPE_FLOAT],
217
+ DSPConnection_SetMixMatrix: [TYPE_VOIDP, TYPE_VOIDP, TYPE_INT, TYPE_INT, TYPE_INT],
218
+ DSPConnection_SetUserData: [TYPE_VOIDP, TYPE_VOIDP],
219
+ ############################################################################
220
+ # File
221
+ ############################################################################
222
+ # File_GetDiskBusy: [TYPE_VOIDP],
223
+ # File_SetDiskBusy: [TYPE_VOIDP],
224
+ ############################################################################
225
+ # Geometry
226
+ ############################################################################
227
+ Geometry_AddPolygon: [TYPE_VOIDP, TYPE_FLOAT, TYPE_FLOAT, TYPE_INT, TYPE_INT, TYPE_VOIDP, TYPE_VOIDP],
228
+ Geometry_GetActive: [TYPE_VOIDP, TYPE_VOIDP],
229
+ Geometry_GetMaxPolygons: [TYPE_VOIDP, TYPE_VOIDP],
230
+ Geometry_GetNumPolygons: [TYPE_VOIDP, TYPE_VOIDP],
231
+ Geometry_GetPolygonAttributes: [TYPE_VOIDP, TYPE_INT, TYPE_VOIDP, TYPE_VOIDP, TYPE_VOIDP],
232
+ Geometry_GetPolygonNumVertices: [TYPE_VOIDP, TYPE_INT, TYPE_VOIDP],
233
+ Geometry_GetPolygonVertex: [TYPE_VOIDP, TYPE_INT, TYPE_INT, TYPE_VOIDP],
234
+ Geometry_GetPosition: [TYPE_VOIDP, TYPE_VOIDP],
235
+ Geometry_GetRotation: Array.new(3, TYPE_VOIDP),
236
+ Geometry_GetScale: [TYPE_VOIDP, TYPE_VOIDP],
237
+ Geometry_GetUserData: [TYPE_VOIDP, TYPE_VOIDP],
238
+ Geometry_Release: [TYPE_VOIDP],
239
+ Geometry_Save: [TYPE_VOIDP, TYPE_VOIDP, TYPE_VOIDP],
240
+ Geometry_SetActive: [TYPE_VOIDP, TYPE_INT],
241
+ Geometry_SetPolygonAttributes: [TYPE_VOIDP, TYPE_INT, TYPE_FLOAT, TYPE_FLOAT, TYPE_INT],
242
+ Geometry_SetPolygonVertex: [TYPE_VOIDP, TYPE_INT, TYPE_INT, TYPE_VOIDP],
243
+ Geometry_SetPosition: [TYPE_VOIDP, TYPE_VOIDP],
244
+ Geometry_SetRotation: Array.new(3, TYPE_VOIDP),
245
+ Geometry_SetScale: [TYPE_VOIDP, TYPE_VOIDP],
246
+ Geometry_SetUserData: [TYPE_VOIDP, TYPE_VOIDP],
247
+ ############################################################################
248
+ # Memory
249
+ ############################################################################
250
+ # Memory_GetStats: [TYPE_VOIDP],
251
+ # Memory_Initialize: [TYPE_VOIDP],
252
+ ############################################################################
253
+ # Reverb3D
254
+ ############################################################################
255
+ Reverb3D_Get3DAttributes: Array.new(4, TYPE_VOIDP),
256
+ Reverb3D_GetActive: [TYPE_VOIDP, TYPE_VOIDP],
257
+ Reverb3D_GetProperties: [TYPE_VOIDP, TYPE_VOIDP],
258
+ Reverb3D_GetUserData: [TYPE_VOIDP, TYPE_VOIDP],
259
+ Reverb3D_Release: [TYPE_VOIDP],
260
+ Reverb3D_Set3DAttributes: [TYPE_VOIDP, TYPE_VOIDP, TYPE_FLOAT, TYPE_FLOAT],
261
+ Reverb3D_SetActive: [TYPE_VOIDP, TYPE_INT],
262
+ Reverb3D_SetProperties: [TYPE_VOIDP, TYPE_VOIDP],
263
+ Reverb3D_SetUserData: [TYPE_VOIDP, TYPE_VOIDP],
264
+ ############################################################################
265
+ # Sound
266
+ ############################################################################
267
+ Sound_AddSyncPoint: [TYPE_VOIDP, TYPE_INT, TYPE_INT, TYPE_VOIDP, TYPE_VOIDP],
268
+ Sound_DeleteSyncPoint: [TYPE_VOIDP, TYPE_VOIDP],
269
+ Sound_Get3DConeSettings: Array.new(4, TYPE_VOIDP),
270
+ Sound_Get3DCustomRolloff: [TYPE_VOIDP, TYPE_VOIDP, TYPE_VOIDP],
271
+ Sound_Get3DMinMaxDistance: [TYPE_VOIDP, TYPE_VOIDP, TYPE_VOIDP],
272
+ Sound_GetDefaults: [TYPE_VOIDP, TYPE_VOIDP, TYPE_VOIDP],
273
+ Sound_GetFormat: Array.new(5, TYPE_VOIDP),
274
+ Sound_GetLength: [TYPE_VOIDP, TYPE_VOIDP, TYPE_INT],
275
+ Sound_GetLoopCount: [TYPE_VOIDP, TYPE_VOIDP],
276
+ Sound_GetLoopPoints: [TYPE_VOIDP, TYPE_VOIDP, TYPE_INT, TYPE_VOIDP, TYPE_INT],
277
+ Sound_GetMode: [TYPE_VOIDP, TYPE_VOIDP],
278
+ Sound_GetMusicChannelVolume: [TYPE_VOIDP, TYPE_INT, TYPE_VOIDP],
279
+ Sound_GetMusicNumChannels: [TYPE_VOIDP, TYPE_VOIDP],
280
+ Sound_GetMusicSpeed: [TYPE_VOIDP, TYPE_VOIDP],
281
+ Sound_GetName: [TYPE_VOIDP, TYPE_VOIDP, TYPE_INT],
282
+ Sound_GetNumSubSounds: [TYPE_VOIDP, TYPE_VOIDP],
283
+ Sound_GetNumSyncPoints: [TYPE_VOIDP, TYPE_VOIDP],
284
+ Sound_GetNumTags: [TYPE_VOIDP, TYPE_VOIDP, TYPE_VOIDP],
285
+ Sound_GetOpenState: Array.new(5, TYPE_VOIDP),
286
+ Sound_GetSoundGroup: [TYPE_VOIDP, TYPE_VOIDP],
287
+ Sound_GetSubSound: [TYPE_VOIDP, TYPE_INT, TYPE_VOIDP],
288
+ Sound_GetSubSoundParent: [TYPE_VOIDP, TYPE_VOIDP],
289
+ Sound_GetSyncPoint: [TYPE_VOIDP, TYPE_INT, TYPE_VOIDP],
290
+ Sound_GetSyncPointInfo: [TYPE_VOIDP, TYPE_VOIDP, TYPE_VOIDP, TYPE_INT, TYPE_VOIDP, TYPE_INT],
291
+ Sound_GetSystemObject: [TYPE_VOIDP, TYPE_VOIDP],
292
+ Sound_GetTag: [TYPE_VOIDP, TYPE_VOIDP, TYPE_INT, TYPE_VOIDP],
293
+ Sound_GetUserData: [TYPE_VOIDP, TYPE_VOIDP],
294
+ Sound_Lock: [TYPE_VOIDP, TYPE_INT, TYPE_INT] + Array.new(4, TYPE_VOIDP),
295
+ Sound_ReadData: [TYPE_VOIDP, TYPE_VOIDP, TYPE_INT, TYPE_VOIDP],
296
+ Sound_Release: [TYPE_VOIDP],
297
+ Sound_SeekData: [TYPE_VOIDP, TYPE_INT],
298
+ Sound_Set3DConeSettings: [TYPE_VOIDP, TYPE_FLOAT, TYPE_FLOAT, TYPE_FLOAT],
299
+ Sound_Set3DCustomRolloff: [TYPE_VOIDP, TYPE_VOIDP, TYPE_INT],
300
+ Sound_Set3DMinMaxDistance: [TYPE_VOIDP, TYPE_FLOAT, TYPE_FLOAT],
301
+ Sound_SetDefaults: [TYPE_VOIDP, TYPE_FLOAT, TYPE_INT],
302
+ Sound_SetLoopCount: [TYPE_VOIDP, TYPE_INT],
303
+ Sound_SetLoopPoints: [TYPE_VOIDP] + Array.new(4, TYPE_INT),
304
+ Sound_SetMode: [TYPE_VOIDP, TYPE_INT],
305
+ Sound_SetMusicChannelVolume: [TYPE_VOIDP, TYPE_INT, TYPE_FLOAT],
306
+ Sound_SetMusicSpeed: [TYPE_VOIDP, TYPE_FLOAT],
307
+ Sound_SetSoundGroup: [TYPE_VOIDP, TYPE_VOIDP],
308
+ Sound_SetUserData: [TYPE_VOIDP, TYPE_VOIDP],
309
+ Sound_Unlock: [TYPE_VOIDP, TYPE_VOIDP, TYPE_VOIDP, TYPE_INT, TYPE_INT],
310
+ ############################################################################
311
+ # SoundGroup
312
+ ############################################################################
313
+ SoundGroup_GetMaxAudible: [TYPE_VOIDP, TYPE_VOIDP],
314
+ SoundGroup_GetMaxAudibleBehavior: [TYPE_VOIDP, TYPE_VOIDP],
315
+ SoundGroup_GetMuteFadeSpeed: [TYPE_VOIDP, TYPE_VOIDP],
316
+ SoundGroup_GetName: [TYPE_VOIDP, TYPE_VOIDP, TYPE_INT],
317
+ SoundGroup_GetNumPlaying: [TYPE_VOIDP, TYPE_VOIDP],
318
+ SoundGroup_GetNumSounds: [TYPE_VOIDP, TYPE_VOIDP],
319
+ SoundGroup_GetSound: [TYPE_VOIDP, TYPE_INT, TYPE_VOIDP],
320
+ SoundGroup_GetSystemObject: [TYPE_VOIDP, TYPE_VOIDP],
321
+ SoundGroup_GetUserData: [TYPE_VOIDP, TYPE_VOIDP],
322
+ SoundGroup_GetVolume: [TYPE_VOIDP, TYPE_VOIDP],
323
+ SoundGroup_Release: [TYPE_VOIDP],
324
+ SoundGroup_SetMaxAudible: [TYPE_VOIDP, TYPE_INT],
325
+ SoundGroup_SetMaxAudibleBehavior: [TYPE_VOIDP, TYPE_INT],
326
+ SoundGroup_SetMuteFadeSpeed: [TYPE_VOIDP, TYPE_FLOAT],
327
+ SoundGroup_SetUserData: [TYPE_VOIDP, TYPE_VOIDP],
328
+ SoundGroup_SetVolume: [TYPE_VOIDP, TYPE_FLOAT],
329
+ SoundGroup_Stop: [TYPE_VOIDP],
330
+ ############################################################################
331
+ # System
332
+ ############################################################################
333
+ System_AttachChannelGroupToPort: [TYPE_VOIDP, TYPE_INT, TYPE_INT, TYPE_VOIDP, TYPE_INT],
334
+ System_AttachFileSystem: Array.new(5, TYPE_VOIDP),
335
+ System_Close: [TYPE_VOIDP],
336
+ System_Create: [TYPE_VOIDP],
337
+ System_CreateChannelGroup: [TYPE_VOIDP, TYPE_VOIDP, TYPE_VOIDP],
338
+ # System_CreateDSP: [TYPE_VOIDP],
339
+ # System_CreateDSPByPlugin: [TYPE_VOIDP],
340
+ System_CreateDSPByType: [TYPE_VOIDP, TYPE_INT, TYPE_VOIDP],
341
+ System_CreateGeometry: [TYPE_VOIDP, TYPE_INT, TYPE_INT, TYPE_VOIDP],
342
+ System_CreateReverb3D: [TYPE_VOIDP, TYPE_VOIDP],
343
+ System_CreateSound: [TYPE_VOIDP, TYPE_VOIDP, TYPE_INT, TYPE_VOIDP, TYPE_VOIDP],
344
+ System_CreateSoundGroup: [TYPE_VOIDP, TYPE_VOIDP, TYPE_VOIDP],
345
+ System_CreateStream: [TYPE_VOIDP, TYPE_VOIDP, TYPE_INT, TYPE_VOIDP, TYPE_VOIDP],
346
+ System_DetachChannelGroupFromPort: [TYPE_VOIDP, TYPE_VOIDP],
347
+ # System_Get3DListenerAttributes: [TYPE_VOIDP],
348
+ System_Get3DNumListeners: [TYPE_VOIDP, TYPE_VOIDP],
349
+ System_Get3DSettings: Array.new(4, TYPE_VOIDP),
350
+ # System_GetAdvancedSettings: [TYPE_VOIDP],
351
+ System_GetChannel: [TYPE_VOIDP, TYPE_INT, TYPE_VOIDP],
352
+ System_GetChannelsPlaying: Array.new(3, TYPE_VOIDP),
353
+ System_GetCPUUsage: Array.new(6, TYPE_VOIDP),
354
+ System_GetDefaultMixMatrix: [TYPE_VOIDP, TYPE_INT, TYPE_INT, TYPE_VOIDP, TYPE_INT],
355
+ System_GetDriver: [TYPE_VOIDP, TYPE_VOIDP],
356
+ System_GetDriverInfo: [TYPE_VOIDP, TYPE_INT, TYPE_VOIDP, TYPE_INT, TYPE_VOIDP] + Array.new(3, TYPE_VOIDP),
357
+ System_GetDSPBufferSize: Array.new(3, TYPE_VOIDP),
358
+ System_GetDSPInfoByPlugin: [TYPE_VOIDP, TYPE_INT, TYPE_VOIDP],
359
+ System_GetFileUsage: Array.new(4, TYPE_VOIDP),
360
+ System_GetGeometryOcclusion: Array.new(5, TYPE_VOIDP),
361
+ System_GetGeometrySettings: [TYPE_VOIDP, TYPE_VOIDP],
362
+ System_GetMasterChannelGroup: [TYPE_VOIDP, TYPE_VOIDP],
363
+ System_GetMasterSoundGroup: [TYPE_VOIDP, TYPE_VOIDP],
364
+ System_GetNestedPlugin: [TYPE_VOIDP, TYPE_INT, TYPE_INT, TYPE_VOIDP],
365
+ System_GetNetworkProxy: [TYPE_VOIDP, TYPE_VOIDP, TYPE_INT],
366
+ System_GetNetworkTimeout: [TYPE_VOIDP, TYPE_VOIDP],
367
+ System_GetNumDrivers: [TYPE_VOIDP, TYPE_VOIDP],
368
+ System_GetNumNestedPlugins: [TYPE_VOIDP, TYPE_INT, TYPE_VOIDP],
369
+ System_GetNumPlugins: [TYPE_VOIDP, TYPE_INT, TYPE_VOIDP],
370
+ System_GetOutput: [TYPE_VOIDP, TYPE_VOIDP],
371
+ System_GetOutputByPlugin: [TYPE_VOIDP, TYPE_VOIDP],
372
+ System_GetOutputHandle: [TYPE_VOIDP, TYPE_VOIDP],
373
+ System_GetPluginHandle: [TYPE_VOIDP, TYPE_INT, TYPE_INT, TYPE_VOIDP],
374
+ System_GetPluginInfo: [TYPE_VOIDP, TYPE_INT, TYPE_VOIDP, TYPE_VOIDP, TYPE_INT, TYPE_VOIDP],
375
+ System_GetRecordDriverInfo: [TYPE_VOIDP, TYPE_INT, TYPE_VOIDP, TYPE_INT, TYPE_VOIDP] + Array.new(4, TYPE_VOIDP),
376
+ System_GetRecordNumDrivers: [TYPE_VOIDP, TYPE_VOIDP, TYPE_VOIDP],
377
+ System_GetRecordPosition: [TYPE_VOIDP, TYPE_INT, TYPE_VOIDP],
378
+ System_GetReverbProperties: [TYPE_VOIDP, TYPE_INT, TYPE_VOIDP],
379
+ System_GetSoftwareChannels: [TYPE_VOIDP, TYPE_VOIDP],
380
+ System_GetSoftwareFormat: Array.new(4, TYPE_VOIDP),
381
+ System_GetSoundRAM: Array.new(4, TYPE_VOIDP),
382
+ System_GetSpeakerModeChannels: [TYPE_VOIDP, TYPE_INT, TYPE_VOIDP],
383
+ System_GetSpeakerPosition: [TYPE_VOIDP, TYPE_INT, TYPE_VOIDP, TYPE_VOIDP, TYPE_VOIDP],
384
+ System_GetStreamBufferSize: Array.new(3, TYPE_VOIDP),
385
+ System_GetUserData: [TYPE_VOIDP, TYPE_VOIDP],
386
+ System_GetVersion: [TYPE_VOIDP, TYPE_VOIDP],
387
+ System_Init: [TYPE_VOIDP, TYPE_INT, TYPE_INT, TYPE_VOIDP],
388
+ System_IsRecording: [TYPE_VOIDP, TYPE_INT, TYPE_VOIDP],
389
+ System_LoadGeometry: [TYPE_VOIDP, TYPE_VOIDP, TYPE_INT, TYPE_VOIDP],
390
+ System_LoadPlugin: [TYPE_VOIDP, TYPE_VOIDP, TYPE_VOIDP, TYPE_INT],
391
+ System_LockDSP: [TYPE_VOIDP],
392
+ System_MixerResume: [TYPE_VOIDP],
393
+ System_MixerSuspend: [TYPE_VOIDP],
394
+ System_PlayDSP: [TYPE_VOIDP, TYPE_VOIDP, TYPE_VOIDP, TYPE_INT, TYPE_VOIDP],
395
+ System_PlaySound: [TYPE_VOIDP, TYPE_VOIDP, TYPE_VOIDP, TYPE_INT, TYPE_VOIDP],
396
+ System_RecordStart: [TYPE_VOIDP, TYPE_INT, TYPE_VOIDP, TYPE_INT],
397
+ System_RecordStop: [TYPE_VOIDP, TYPE_INT],
398
+ # System_RegisterCodec: [TYPE_VOIDP],
399
+ # System_RegisterDSP: [TYPE_VOIDP],
400
+ # System_RegisterOutput: [TYPE_VOIDP],
401
+ System_Release: [TYPE_VOIDP],
402
+ # System_Set3DListenerAttributes: [TYPE_VOIDP],
403
+ System_Set3DNumListeners: [TYPE_VOIDP, TYPE_INT],
404
+ System_Set3DRolloffCallback: [TYPE_VOIDP, TYPE_VOIDP],
405
+ System_Set3DSettings: [TYPE_VOIDP, TYPE_FLOAT, TYPE_FLOAT, TYPE_FLOAT],
406
+ # System_SetAdvancedSettings: [TYPE_VOIDP],
407
+ # System_SetCallback: [TYPE_VOIDP],
408
+ System_SetDriver: [TYPE_VOIDP, TYPE_INT],
409
+ System_SetDSPBufferSize: [TYPE_VOIDP, TYPE_INT, TYPE_INT],
410
+ # System_SetFileSystem: [TYPE_VOIDP],
411
+ System_SetGeometrySettings: [TYPE_VOIDP, TYPE_FLOAT],
412
+ System_SetNetworkProxy: [TYPE_VOIDP, TYPE_VOIDP],
413
+ System_SetNetworkTimeout: [TYPE_VOIDP, TYPE_INT],
414
+ System_SetOutput: [TYPE_VOIDP, TYPE_INT],
415
+ System_SetOutputByPlugin: [TYPE_VOIDP, TYPE_INT],
416
+ System_SetPluginPath: [TYPE_VOIDP, TYPE_VOIDP],
417
+ System_SetReverbProperties: [TYPE_VOIDP, TYPE_INT, TYPE_VOIDP],
418
+ System_SetSoftwareChannels: [TYPE_VOIDP, TYPE_INT],
419
+ System_SetSoftwareFormat: [TYPE_VOIDP, TYPE_INT, TYPE_INT, TYPE_INT],
420
+ System_SetSpeakerPosition: [TYPE_VOIDP, TYPE_INT, TYPE_FLOAT, TYPE_FLOAT, TYPE_INT],
421
+ System_SetStreamBufferSize: [TYPE_VOIDP, TYPE_INT, TYPE_INT],
422
+ System_SetUserData: [TYPE_VOIDP, TYPE_VOIDP],
423
+ System_UnloadPlugin: [TYPE_VOIDP, TYPE_INT],
424
+ System_UnlockDSP: [TYPE_VOIDP],
425
+ System_Update: [TYPE_VOIDP]
426
+ }
427
+
428
+ ##
429
+ # Invokes the specified native function.
430
+ #
431
+ # @param function [Symbol] Symbol name of an FMOD function, without the the
432
+ # leading "FMOD_" prefix.
433
+ # @raise [Error] if the result code returned by FMOD is not {Result::OK}.
434
+ # @return [void]
435
+ # @see invoke_protect
436
+ def self.invoke(function, *args)
437
+ result = @functions[function].call(*args)
438
+ raise Error, result unless result.zero?
439
+ end
440
+
441
+ ##
442
+ # Invokes the specified native function.
443
+ #
444
+ # The same as {FMOD.invoke}, but returns the result code instead of raising an
445
+ # exception.
446
+ #
447
+ # @param function [Symbol] Symbol name of an FMOD function, without the the
448
+ # leading "FMOD_" prefix.
449
+ # @return [Integer] the result code.
450
+ # @see Result
451
+ def self.invoke_protect(function, *args)
452
+ @functions[function].call(*args)
453
+ end
454
+
455
+ ##
456
+ # Loads the native FMOD library.
457
+ #
458
+ # @note This must be called before _ANY_ other function is called.
459
+ #
460
+ # @param library [String] The name of the library to load. If omitted, the
461
+ # default platform-specific library name will be used.
462
+ # @param directory [String] The directory where the library will be loaded
463
+ # from. By default this will be the "./ext" folder relative to the gem
464
+ # installation folder.
465
+ #
466
+ # @return [void]
467
+ def self.load_library(library = nil, directory = nil)
468
+ if library.nil?
469
+ library = case platform
470
+ when :WINDOWS then SIZEOF_INTPTR_T == 4 ? 'fmod.dll' : 'fmod64.dll'
471
+ when :MACOSX then 'libfmod.dylib'
472
+ when :LINUX then 'libfmod.so'
473
+ else 'fmod' # Will probably fail...
474
+ end
475
+ end
476
+ if directory.nil?
477
+ gem_directory = File.dirname(File.dirname(__FILE__))
478
+ directory = File.join(gem_directory, 'ext')
479
+ end
480
+ library = File.join(directory, library)
481
+ lib = Fiddle.dlopen(File.expand_path(library))
482
+ import_symbols(lib)
483
+ end
484
+
485
+ # @return [Symbol] a symbol representing the operating system. Will be either
486
+ # *:WINDOWS*, *:MACOSX*, or *:LINUX*.
487
+ def self.platform
488
+ @platform ||= case RbConfig::CONFIG['host_os']
489
+ when /mswin|msys|mingw|cygwin/ then :WINDOWS
490
+ when /darwin/ then :MACOSX
491
+ when /linux/ then :LINUX
492
+ else raise RuntimeError, 'Unsupported operating system.'
493
+ end
494
+ end
495
+
496
+ ##
497
+ # Imports the FMOD functions from the loaded library.
498
+ #
499
+ # @note This function is called automatically, not to be called by the user.
500
+ #
501
+ # @return [void]
502
+ def self.import_symbols(library)
503
+ @functions = {}
504
+ @function_signatures.each_pair do |sym, signature|
505
+ name = "FMOD_#{sym}"
506
+ begin
507
+ @functions[sym] = Function.new(library[name], signature, TYPE_INT)
508
+ rescue Fiddle::DLError
509
+ warn("Failed to import #{name}.")
510
+ end
511
+ end
512
+ const_set(:ABI, @functions.values.sample.abi)
513
+ end
514
+
515
+ ##
516
+ # Checks that the object is of the given type, optionally raising an exception
517
+ # if it is not.
518
+ #
519
+ # @param object [Object] The object to check.
520
+ # @param type [Class] The class to ensure it either is or derives from.
521
+ # @param exception [Boolean] Flag indicating if an exception should be raised
522
+ # in the event the object is not the correct type.
523
+ # @return [Boolean] +true+ if object is of the specified type, otherwise
524
+ # *false*.
525
+ # @raise [TypeError] when the type does not match and the exception parameter
526
+ # is +true+.
527
+ def self.type?(object, type, exception = true)
528
+ return true if object.is_a?(type)
529
+ return false unless exception
530
+ raise TypeError, "#{object} is not a #{type}."
531
+ end
532
+
533
+ ##
534
+ # Checks whether the specified index falls within the given range, optionally
535
+ # raises an exception if it does not.
536
+ #
537
+ # @param index [Integer] The value to check.
538
+ # @param min [Integer] The minimum valid value.
539
+ # @param max [Integer] The maximum valid value.
540
+ # @param exception [Boolean] Flag indicating if an exception should be raised
541
+ # in the event the value is not within the specified range.
542
+ # @return [Boolean] +true+ if object is within specified range, otherwise
543
+ # *false*.
544
+ # @raise [RangeError] when the value is out of range and the exception
545
+ # parameter is +true+.
546
+ def self.valid_range?(index, min, max, exception = true)
547
+ return true if index.between?(min, max)
548
+ return false unless exception
549
+ raise RangeError, "#{index} outside of valid range (#{min}..#{max})."
550
+ end
551
+
552
+ ##
553
+ # Converts an integer value to a version string representation.
554
+ # @param version [Integer] The version is a 32bit hexadecimal value formatted
555
+ # as 16:8:8, with the upper 16 bits being the major version, the middle
556
+ # 8bits being the minor version and the bottom 8 bits being the development
557
+ # version. For example a value of 00040106h is equal to 4.01.06.
558
+ # @return [String] the version string.
559
+ def self.uint2version(version)
560
+ version = version.unpack1('L') if version.is_a?(String)
561
+ vs = "%08X" % version
562
+ "#{vs[0, 4].to_i}.#{vs[4, 2].to_i}.#{vs[6, 2].to_i}"
563
+ end
564
+ end