fmod 0.9.1 → 0.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/HISTORY.txt +23 -1
  3. data/README.md +1 -3
  4. data/Rakefile +2 -1
  5. data/bin/console +1 -0
  6. data/fmod.gemspec +1 -2
  7. data/lib/fmod/channel_control.rb +47 -0
  8. data/lib/fmod/core.rb +1 -0
  9. data/lib/fmod/core/bool_description.rb +9 -4
  10. data/lib/fmod/core/channel_mask.rb +61 -0
  11. data/lib/fmod/core/data_description.rb +44 -0
  12. data/lib/fmod/core/dsp_description.rb +172 -1
  13. data/lib/fmod/core/dsp_index.rb +13 -0
  14. data/lib/fmod/core/dsp_type.rb +154 -0
  15. data/lib/fmod/core/extensions.rb +19 -0
  16. data/lib/fmod/core/file_system.rb +1 -0
  17. data/lib/fmod/core/filter_type.rb +62 -0
  18. data/lib/fmod/core/float_description.rb +38 -0
  19. data/lib/fmod/core/guid.rb +27 -0
  20. data/lib/fmod/core/init_flags.rb +66 -0
  21. data/lib/fmod/core/integer_description.rb +22 -2
  22. data/lib/fmod/core/output_type.rb +81 -2
  23. data/lib/fmod/core/parameter_info.rb +36 -0
  24. data/lib/fmod/core/parameter_type.rb +15 -0
  25. data/lib/fmod/core/reverb.rb +113 -2
  26. data/lib/fmod/core/reverb_index.rb +105 -0
  27. data/lib/fmod/core/sound_ex_info.rb +4 -0
  28. data/lib/fmod/core/sound_group_behavior.rb +14 -0
  29. data/lib/fmod/core/sound_type.rb +1 -0
  30. data/lib/fmod/core/spectrum_data.rb +35 -0
  31. data/lib/fmod/core/structures.rb +10 -4
  32. data/lib/fmod/core/tag.rb +72 -11
  33. data/lib/fmod/core/tag_data_type.rb +30 -0
  34. data/lib/fmod/core/tag_type.rb +55 -0
  35. data/lib/fmod/core/time_unit.rb +3 -0
  36. data/lib/fmod/core/vector.rb +40 -3
  37. data/lib/fmod/core/window_type.rb +46 -0
  38. data/lib/fmod/dsp.rb +427 -98
  39. data/lib/fmod/dsp_connection.rb +3 -0
  40. data/lib/fmod/effects.rb +51 -37
  41. data/lib/fmod/error.rb +3 -0
  42. data/lib/fmod/geometry.rb +7 -0
  43. data/lib/fmod/handle.rb +82 -0
  44. data/lib/fmod/reverb3D.rb +25 -26
  45. data/lib/fmod/sound.rb +21 -1
  46. data/lib/fmod/sound_group.rb +79 -3
  47. data/lib/fmod/system.rb +301 -154
  48. data/lib/fmod/version.rb +4 -1
  49. metadata +6 -3
@@ -1,18 +1,84 @@
1
1
  module FMOD
2
2
  module Core
3
+
4
+ ##
5
+ # Initialization flags. Use them with System.create in the flags parameter
6
+ # to change various behavior.
7
+ #
8
+ # Use System advanced settings to adjust settings for some of the features
9
+ # that are enabled by these flags.
3
10
  module InitFlags
11
+
12
+ ##
13
+ # Initialize normally.
4
14
  NORMAL = 0x00000000
15
+
16
+ ##
17
+ # No stream thread is created internally. Streams are driven from
18
+ # System.update. Mainly used with non-realtime outputs.
5
19
  STREAM_FROM_UPDATE = 0x00000001
20
+
21
+ ##
22
+ # No mixer thread is created internally. Mixing is driven from
23
+ # System.update.
6
24
  MIX_FROM_UPDATE = 0x00000002
25
+
26
+ ##
27
+ # 3D calculations will be performed in right-handed coordinates.
7
28
  RIGHT_HANDED_3D = 0x00000004
29
+
30
+ ##
31
+ # Enables usage of Channel low-pass gain, Channel occlusion, or automatic
32
+ # usage by the Geometry API. All voices will add a software low-pass
33
+ # filter effect into the DSP chain which is idle unless one of the
34
+ # previous functions/features are used.
8
35
  CHANNEL_LOW_PASS = 0x00000100
36
+
37
+ ##
38
+ # All FMOD 3D based voices will add a software low-pass and high-pass
39
+ # filter effect into the DSP chain which will act as a distance-automated
40
+ # bandpass filter. Use System advanced settings to adjust the center
41
+ # frequency.
9
42
  CHANNEL_DISTANCE_FILTER = 0x00000200
43
+
44
+ ##
45
+ # Enable TCP/IP based host which allows FMOD Designer or FMOD Profiler to
46
+ # connect to it, and view memory, CPU and the DSP network graph in
47
+ # real-time.
10
48
  PROFILE_ENABLE = 0x00010000
49
+
50
+ ##
51
+ # Any sounds that are 0 volume will go virtual and not be processed except
52
+ # for having their positions updated virtually. Use System advanced
53
+ # settings to adjust what volume besides zero to switch to virtual at.
11
54
  VOL0_BECOMES_VIRTUAL = 0x00020000
55
+
56
+ ##
57
+ # With the geometry engine, only process the closest polygon rather than
58
+ # accumulating all polygons the sound to listener line intersects.
12
59
  GEOMETRY_USE_CLOSEST = 0x00040000
60
+
61
+ ##
62
+ # When using a 5.1 speaker mode with a stereo output device, use the Dolby
63
+ # Pro Logic II down-mix algorithm instead of the SRS Circle Surround
64
+ # algorithm.
13
65
  PREFER_DOLBY_DOWN_MIX = 0x00080000
66
+
67
+ ##
68
+ # Disables thread safety for API calls. Only use this if FMOD low level is
69
+ # being called from a single thread, and if Studio API is not being used!
14
70
  THREAD_UNSAFE = 0x00100000
71
+
72
+ ##
73
+ # Slower, but adds level metering for every single DSP unit in the graph.
15
74
  PROFILE_METER_ALL = 0x00200000
75
+
76
+ ##
77
+ # Using a 5.1 speaker mode with a stereo output device will enable the SRS
78
+ # Circle Surround down-mixer. By default the SRS down-mixer applies a high
79
+ # pass filter with a cutoff frequency of 80Hz. Use this flag to disable
80
+ # the high pass filter, or use {PREFER_DOLBY_DOWN_MIX} to use the Dolby
81
+ # Pro Logic II down-mix algorithm instead.
16
82
  DISABLE_SRS_HIGH_PASS_FILTER = 0x00400000
17
83
  end
18
84
  end
@@ -1,22 +1,42 @@
1
1
  module FMOD
2
2
  module Core
3
+
4
+ ##
5
+ # Structure describing a integer parameter for a DSP unit.
3
6
  class IntegerDescription < Structure
4
7
 
8
+ ##
9
+ # @param address [Pointer, Integer, String, nil] The address in memory
10
+ # where the structure will be created from. If no address is given, new
11
+ # memory will be allocated.
5
12
  def initialize(address = nil)
6
13
  types = [TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_VOIDP]
7
14
  members = [:min, :max, :default, :infinite, :names]
8
15
  super(address, types, members)
9
16
  end
10
17
 
18
+ # @!attribute min
19
+ # @return [Integer] the minimum parameter value.
20
+
21
+ # @!attribute max
22
+ # @return [Integer] the maximum parameter value.
23
+
24
+ # @!attribute default
25
+ # @return [Integer] the default parameter value.
26
+
11
27
  [:min, :max, :default].each do |symbol|
12
28
  define_method(symbol) { self[symbol] }
13
29
  end
14
30
 
15
- def infinite
31
+ ##
32
+ # @return [Boolean] flag indicating if the last value represents infinity.
33
+ def infinite?
16
34
  self[:infinite] != 0
17
35
  end
18
36
 
19
- def names
37
+ ##
38
+ # @return [Array<String>] the names for each value.
39
+ def value_names
20
40
  return [] if self[:names].null?
21
41
  count = max - min + 1
22
42
  (0...count).map { |i| (self[:names] + (i * SIZEOF_INTPTR_T)).ptr.to_s }
@@ -1,29 +1,108 @@
1
1
  module FMOD
2
2
  module Core
3
+
4
+ ##
5
+ # Strongly-typed supported output types.
3
6
  module OutputType
4
- AUTODETECT = 0
7
+
8
+ ##
9
+ # Picks the best output mode for the platform. This is the default.
10
+ AUTO_DETECT = 0
11
+
12
+ ##
13
+ # All - 3rd party plugin, unknown.
5
14
  UNKNOWN = 1
15
+
16
+ ##
17
+ # All - Perform all mixing but discard the final output.
6
18
  NO_SOUND = 2
19
+
20
+ ##
21
+ # All - Writes output to a .wav file.
7
22
  WAV_WRITER = 3
8
- NOSOUND_NRT = 4
23
+
24
+ ##
25
+ # All - Non-realtime version of {NO_SOUND}. User can drive mixer with
26
+ # System.update at whatever rate they want.
27
+ NO_SOUND_NRT = 4
28
+
29
+ ##
30
+ # All - Non-realtime version of {WAV_WRITER}. User can drive mixer with
31
+ # System.update at whatever rate they want.
9
32
  WAV_WRITER_NRT = 5
33
+
34
+ ##
35
+ # Windows only - Direct Sound. (Default on Windows XP and below)
10
36
  DSOUND = 6
37
+
38
+ ##
39
+ # Windows only - Windows Multimedia.
11
40
  WINMM = 7
41
+
42
+ ##
43
+ # Win/WinStore/XboxOne - Windows Audio Session API. (Default on Windows
44
+ # Vista and above, Xbox One and Windows Store Applications)
12
45
  WASAPI = 8
46
+
47
+ ##
48
+ # Windows only - Low latency ASIO 2.0.
13
49
  ASIO = 9
50
+
51
+ ##
52
+ # Linux - Pulse Audio. (Default on Linux if available)
14
53
  PULSE_AUDIO = 10
54
+
55
+ ##
56
+ # Linux - Advanced Linux Sound Architecture. (Default on Linux if
57
+ # PulseAudio isn't available)
15
58
  ALSA = 11
59
+
60
+ ##
61
+ # Mac/iOS - Core Audio. (Default on Mac and iOS)
16
62
  CORE_AUDIO = 12
63
+
64
+ ##
65
+ # Xbox 360 - XAudio. (Default on Xbox 360)
17
66
  X_AUDIO = 13
67
+
68
+ ##
69
+ # PS3 - Audio Out. (Default on PS3)
18
70
  PS3 = 14
71
+
72
+ ##
73
+ # Android - Java Audio Track. (Default on Android 2.2 and below)
19
74
  AUDIO_TRACK = 15
75
+
76
+ ##
77
+ # Android - OpenSL ES. (Default on Android 2.3 and above)
20
78
  OPEN_SL = 16
79
+
80
+ ##
81
+ # Wii U - AX. (Default on Wii U)
21
82
  WII_U = 17
83
+
84
+ ##
85
+ # PS4/PSVita - Audio Out. (Default on PS4 and PS Vita)
22
86
  AUDIO_OUT, = 18
87
+
88
+ ##
89
+ # PS4 - Audio3D.
23
90
  AUDIO3D = 19
91
+
92
+ ##
93
+ # Windows - Dolby Atmos (WASAPI).
24
94
  ATMOS = 20
95
+
96
+ ##
97
+ # Web Browser - JavaScript webaudio output. (Default on JavaScript)
25
98
  WEB_AUDIO = 21
99
+
100
+ ##
101
+ # NX - NX nn::audio. (Default on NX)
26
102
  NN_AUDIO = 22
103
+
104
+ ##
105
+ # Win10 / XboxOne - Windows Sonic.
27
106
  WIN_SONIC = 23
28
107
  end
29
108
  end
@@ -1,31 +1,67 @@
1
1
  module FMOD
2
2
  module Core
3
+
4
+ ##
5
+ # Base Structure for DSP parameter descriptions.
3
6
  class ParameterInfo < Structure
4
7
 
5
8
  include Fiddle
6
9
 
10
+ ##
11
+ # @param address [Pointer, Integer, String, nil] The address in memory
12
+ # where the structure will be created from. If no address is given, new
13
+ # memory will be allocated.
7
14
  def initialize(address = nil)
8
15
  types = [TYPE_INT, [TYPE_CHAR, 16], [TYPE_CHAR, 16], TYPE_VOIDP, TYPE_VOIDP]
9
16
  members = [:type, :name, :label, :description, :info]
10
17
  super(address, types, members)
11
18
  end
12
19
 
20
+ ##
21
+ # @!attribute [r] type
22
+ # @return [Integer] the type of this parameter.
23
+ # @see ParameterType
24
+
13
25
  def type
14
26
  self[:type]
15
27
  end
16
28
 
29
+ ##
30
+ # @!attribute [r] name
31
+ # @return [String] the of the parameter to be displayed (ie "Cutoff
32
+ # frequency").
33
+
17
34
  def name
18
35
  (self + SIZEOF_INT).to_s(16).delete("\0").force_encoding('UTF-8')
19
36
  end
20
37
 
38
+ ##
39
+ # @!attribute [r] label
40
+ # @return [String] a string to be put next to value to denote the unit
41
+ # type (ie "Hz").
42
+
21
43
  def label
22
44
  (self + SIZEOF_INT + 16).to_s(16).delete("\0")
23
45
  end
24
46
 
47
+ ##
48
+ # @!attribute [r] description
49
+ # @return [String] the description of the parameter to be displayed as a
50
+ # help item / tooltip for this parameter.
25
51
  def description
26
52
  self[:description].to_s
27
53
  end
28
54
 
55
+ ##
56
+ # Struct containing information about the parameter. The type of info
57
+ # will vary depending on the {#type} value.
58
+ # * {ParameterType::FLOAT} => {FloatDescription}
59
+ # * {ParameterType::INT} => {IntegerDescription}
60
+ # * {ParameterType::BOOL} => {BoolDescription}
61
+ # * {ParameterType::DATA} => {DataDescription}
62
+ #
63
+ # @return [FloatDescription, IntegerDescription, BoolDescription,
64
+ # DataDescription] the parameter type description.
29
65
  def info
30
66
  pointer = self + SIZEOF_INT + (SIZEOF_CHAR * 32) + SIZEOF_INTPTR_T
31
67
  case self[:type]
@@ -1,9 +1,24 @@
1
1
  module FMOD
2
2
  module Core
3
+
4
+ ##
5
+ # DSP parameter types.
3
6
  module ParameterType
7
+
8
+ ##
9
+ # A float type parameter.
4
10
  FLOAT = 0
11
+
12
+ ##
13
+ # An integer type parameter.
5
14
  INT = 1
15
+
16
+ ##
17
+ # A boolean type parameter.
6
18
  BOOL = 2
19
+
20
+ ##
21
+ # A data type parameter.
7
22
  DATA = 3
8
23
  end
9
24
  end
@@ -3,14 +3,19 @@
3
3
  module FMOD
4
4
 
5
5
  module Core
6
+
6
7
  ##
7
8
  # Structure defining a reverb environment.
8
9
  class Reverb < Structure
9
10
 
11
+ ##
12
+ # @param address [Pointer, Integer, String, nil] The address in memory
13
+ # where the structure will be created from. If no address is given, new
14
+ # memory will be allocated.
10
15
  def initialize(address = nil)
11
16
  types = Array.new(12, TYPE_FLOAT)
12
- members = [:decay_time, :early_delay, :late_delay,
13
- :hf_reference, :hf_decay_ratio, :diffusion, :density, :low_shelf_freq,
17
+ members = [:decay_time, :early_delay, :late_delay, :hf_reference,
18
+ :hf_decay_ratio, :diffusion, :density, :low_shelf_freq,
14
19
  :low_shelf_gain, :high_cut, :early_late_mix, :wet_level]
15
20
  super(address, types, members)
16
21
  end
@@ -21,54 +26,160 @@ module FMOD
21
26
  define_method(symbol) {self[symbol]}
22
27
  end
23
28
 
29
+ # @!attribute decay_time
30
+ # Reverberation decay time (ms).
31
+ # * *Minimum:* 0.0
32
+ # * *Maximum:* 20000.0
33
+ # * *Default:* 1500.0
24
34
  def decay_time=(value)
25
35
  self[:decay_time] = value.clamp(0.0, 20000.0)
26
36
  end
27
37
 
38
+ # @!attribute early_delay
39
+ # Initial reflection delay time (ms).
40
+ # * *Minimum:* 0.0
41
+ # * *Maximum:* 300.0
42
+ # * *Default:* 7.0
43
+ # @return [Float]
28
44
  def early_delay=(value)
29
45
  self[:early_delay] = value.clamp(0.0, 300.0)
30
46
  end
31
47
 
48
+ # @!attribute late_delay
49
+ # Late reverberation delay time relative to initial reflection (ms).
50
+ # * *Minimum:* 0.0
51
+ # * *Maximum:* 100.0
52
+ # * *Default:* 11.0
53
+ # @return [Float]
32
54
  def late_delay=(value)
33
55
  self[:late_delay] = value.clamp(0.0, 100.0)
34
56
  end
35
57
 
58
+ # @!attribute hf_reference
59
+ # Reference high frequency (Hz).
60
+ # * *Minimum:* 20.0
61
+ # * *Maximum:* 20000.0
62
+ # * *Default:* 5000.0
63
+ # @return [Float]
36
64
  def hf_reference=(value)
37
65
  self[:hf_reference] = value.clamp(20.0, 20000.0)
38
66
  end
39
67
 
68
+ # @!attribute hf_decay_ratio
69
+ # High-frequency to mid-frequency decay time ratio (%).
70
+ # * *Minimum:* 10.0
71
+ # * *Maximum:* 100.0
72
+ # * *Default:* 50.0
73
+ # @return [Float]
40
74
  def hf_decay_ratio=(value)
41
75
  self[:hf_decay_ratio] = value.clamp(10.0, 100.0)
42
76
  end
43
77
 
78
+ # @!attribute diffusion
79
+ # The echo density in the late reverberation decay (%).
80
+ # * *Minimum:* 0.0
81
+ # * *Maximum:* 100.0
82
+ # * *Default:* 100.0
83
+ # @return [Float]
44
84
  def diffusion=(value)
45
85
  self[:diffusion] = value.clamp(0.0, 100.0)
46
86
  end
47
87
 
88
+ # @!attribute density
89
+ # The modal density in the late reverberation decay (%).
90
+ # * *Minimum:* 0.0
91
+ # * *Maximum:* 100.0
92
+ # * *Default:* 100.0
93
+ # @return [Float]
48
94
  def density=(value)
49
95
  self[:density] = value.clamp(0.0, 100.0)
50
96
  end
51
97
 
98
+ # @!attribute low_shelf_freq
99
+ # Reference low frequency (Hz).
100
+ # * *Minimum:* 20.0
101
+ # * *Maximum:* 1000.0
102
+ # * *Default:* 250.0
103
+ # @return [Float]
52
104
  def low_shelf_freq=(value)
53
105
  self[:low_shelf_freq] = value.clamp(20.0, 1000.0)
54
106
  end
55
107
 
108
+ # @!attribute low_shelf_gain
109
+ # Relative room effect level at low frequencies (dB).
110
+ # * *Minimum:* -36.0
111
+ # * *Maximum:* 12.0
112
+ # * *Default:* 0.0
113
+ # @return [Float]
56
114
  def low_shelf_gain=(value)
57
115
  self[:low_shelf_gain] = value.clamp(-36.0, 12.0)
58
116
  end
59
117
 
118
+ # @!attribute high_cut
119
+ # Relative room effect level at high frequencies (Hz).
120
+ # * *Minimum:* 20.0
121
+ # * *Maximum:* 20000.0
122
+ # * *Default:* 20000.0
123
+ # @return [Float]
60
124
  def high_cut=(value)
61
125
  self[:high_cut] = value.clamp(20.0, 20000.0)
62
126
  end
63
127
 
128
+ # @!attribute early_late_mix
129
+ # Early reflections level relative to room effect (%).
130
+ # * *Minimum:* 0.0
131
+ # * *Maximum:* 100.0
132
+ # * *Default:* 50.0
133
+ # @return [Float]
64
134
  def early_late_mix=(value)
65
135
  self[:early_late_mix] = value.clamp(0.0, 100.0)
66
136
  end
67
137
 
138
+ # @!attribute wet_level
139
+ # Room effect level at mid frequencies (dB).
140
+ # * *Minimum:* -80.0
141
+ # * *Maximum:* 20.0
142
+ # * *Default:* -6.0
143
+ # @return [Float]
68
144
  def wet_level=(value)
69
145
  self[:wet_level] = value.clamp(-80.0, 20.0)
70
146
  end
71
147
 
148
+ ##
149
+ # Returns a pre-mad Reverb preset from the specified {ReverbIndex}.
150
+ #
151
+ # @param index [Integer] The index of the preset to retrieve.
152
+ #
153
+ # @return [Reverb] the reverb preset.
154
+ def self.from_index(index)
155
+ case index
156
+ when ReverbIndex::GENERIC then generic
157
+ when ReverbIndex::PADDED_CELL then padded_cell
158
+ when ReverbIndex::ROOM then room
159
+ when ReverbIndex::BATHROOM then bathroom
160
+ when ReverbIndex::LIVING_ROOM then living_room
161
+ when ReverbIndex::STONE_ROOM then stone_room
162
+ when ReverbIndex::AUDITORIUM then auditorium
163
+ when ReverbIndex::CONCERT_HALL then concert_hall
164
+ when ReverbIndex::CAVE then cave
165
+ when ReverbIndex::ARENA then arena
166
+ when ReverbIndex::HANGAR then hangar
167
+ when ReverbIndex::CARPETED_HALLWAY then carpeted_hallway
168
+ when ReverbIndex::HALLWAY then hallway
169
+ when ReverbIndex::STONE_CORRIDOR then stone_corridor
170
+ when ReverbIndex::ALLEY then alley
171
+ when ReverbIndex::FOREST then forest
172
+ when ReverbIndex::CITY then city
173
+ when ReverbIndex::MOUNTAINS then mountains
174
+ when ReverbIndex::QUARRY then quarry
175
+ when ReverbIndex::PLAIN then plain
176
+ when ReverbIndex::PARKING_LOT then parking_lot
177
+ when ReverbIndex::SEWER_PIPE then sewer_pipe
178
+ when ReverbIndex::UNDERWATER then underwater
179
+ else off
180
+ end
181
+ end
182
+
72
183
  ##
73
184
  # @return [Reverb] no reverberation.
74
185
  def self.off