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
@@ -0,0 +1,105 @@
1
+ module FMOD
2
+ module Core
3
+
4
+ ##
5
+ # Strongly-typed indices for built-in reverb effects.
6
+ module ReverbIndex
7
+
8
+ ##
9
+ # No reverb.
10
+ OFF = 0
11
+
12
+ ##
13
+ # Generic reverb effect.
14
+ GENERIC = 1
15
+
16
+ ##
17
+ # Padded cell environment
18
+ PADDED_CELL = 2
19
+
20
+ ##
21
+ # Room environment
22
+ ROOM = 3
23
+
24
+ ##
25
+ # Bathroom environment
26
+ BATHROOM = 4
27
+
28
+ ##
29
+ # Living room environment
30
+ LIVING_ROOM = 5
31
+
32
+ ##
33
+ # Stone corridor environment
34
+ STONE_ROOM = 6
35
+
36
+ ##
37
+ # Auditorium environment
38
+ AUDITORIUM = 7
39
+
40
+ ##
41
+ # Concert hall environment
42
+ CONCERT_HALL = 8
43
+
44
+ ##
45
+ # Cave environment
46
+ CAVE = 9
47
+
48
+ ##
49
+ # Arena environment
50
+ ARENA = 10
51
+
52
+ ##
53
+ # Hangar environment
54
+ HANGAR = 11
55
+
56
+ ##
57
+ # Carpeted hallway environment
58
+ CARPETED_HALLWAY = 12
59
+
60
+ ##
61
+ # Hallway environment
62
+ HALLWAY = 13
63
+
64
+ ##
65
+ # Stone corridor environment
66
+ STONE_CORRIDOR = 14
67
+
68
+ ##
69
+ # Alley environment
70
+ ALLEY = 15
71
+
72
+ ##
73
+ # Forest environment
74
+ FOREST = 16
75
+
76
+ ##
77
+ # City environment
78
+ CITY = 17
79
+
80
+ ##
81
+ # Mountains environment
82
+ MOUNTAINS = 18
83
+
84
+ ##
85
+ # Quarry environment
86
+ QUARRY = 19
87
+
88
+ ##
89
+ # Plain environment
90
+ PLAIN = 20
91
+
92
+ ##
93
+ # Parking lot environment
94
+ PARKING_LOT = 21
95
+
96
+ ##
97
+ # Sewer pip environment
98
+ SEWER_PIPE = 22
99
+
100
+ ##
101
+ # Underwater environment
102
+ UNDERWATER = 23
103
+ end
104
+ end
105
+ end
@@ -1,5 +1,9 @@
1
1
  module FMOD
2
2
  module Core
3
+
4
+ ##
5
+ # Use this structure with System.create_sound when more control is needed
6
+ # over loading.
3
7
  class SoundExInfo < Structure
4
8
  # TODO
5
9
  end
@@ -1,8 +1,22 @@
1
1
  module FMOD
2
2
  module Core
3
+
4
+ ##
5
+ # These values are used with to determine what happens when more sounds are
6
+ # played than are specified.
3
7
  module SoundGroupBehavior
8
+
9
+ ##
10
+ # Will simply fail when attempting to play.
4
11
  FAIL = 0
12
+
13
+ ##
14
+ # Will be silent, then if another sound in the group stops the sound that
15
+ # was silent before becomes audible again.
5
16
  MUTE = 1
17
+
18
+ ##
19
+ # Will steal the quietest / least important sound playing in the group.
6
20
  STEAL_LOWEST = 2
7
21
  end
8
22
  end
@@ -4,6 +4,7 @@ module FMOD
4
4
  ##
5
5
  # These definitions describe the type of song being played.
6
6
  module SoundType
7
+
7
8
  ##
8
9
  # 3rd party / unknown plugin format.
9
10
  UNKNOWN = 0
@@ -1,12 +1,47 @@
1
1
  module FMOD
2
2
  module Core
3
+
4
+ ##
5
+ # Describes spectrum values between 0.0 and 1.0 for each "FFT bin".
3
6
  class SpectrumData < 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_FLOAT, 32]]
7
14
  members = [:length, :channel_count, :spectrum]
8
15
  super(address, types, members)
9
16
  end
17
+
18
+ # @!attribute [r] length
19
+ # @return [Integer] the number of entries in this spectrum window. Divide
20
+ # this by the output rate to get the hz per entry.
21
+ # @since 0.9.2
22
+
23
+ # @!attribute [r] channel_count
24
+ # @return [Integer] the number of channels in the spectrum.
25
+ # @since 0.9.2
26
+
27
+ # @!attribute [r] spectrum
28
+ # Values inside the float buffer are typically between 0.0 and 1.0.
29
+ #
30
+ # Each top level array represents one PCM channel of data.
31
+ #
32
+ # Address data as spectrum[channel][bin]. A bin is 1 FFT window entry.
33
+ #
34
+ # Only read/display half of the buffer typically for analysis as the 2nd
35
+ # half is usually the same data reversed due to the nature of the way FFT
36
+ # works.
37
+ #
38
+ # @todo Test for proper structure
39
+ # @return [Array<Float>] per channel spectrum arrays.
40
+ # @since 0.9.2
41
+
42
+ [:length, :channel_count, :spectrum].each do |symbol|
43
+ define_method(symbol) { self[symbol] }
44
+ end
10
45
  end
11
46
  end
12
47
  end
@@ -3,12 +3,18 @@ module FMOD
3
3
 
4
4
  module Core
5
5
 
6
- WetDryMix = Struct.new(:pre_wet, :post_wet, :dry)
7
-
6
+ ##
7
+ # Describes the loop points for the channel.
8
+ # @attr start [Integer] The loop start point, this point in time is played
9
+ # so it is inclusive.
10
+ # @attr start_unit [Integer] Time format used for the loop start point. See
11
+ # {TimeUnit}.
12
+ # @attr end [Integer] The loop end point, this point in time is played so it
13
+ # is inclusive.
14
+ # @attr end_unit [Integer] Time format used for the loop end point. See
15
+ # {TimeUnit}.
8
16
  LoopPoints = Struct.new(:start, :start_unit, :end, :end_unit)
9
17
 
10
- FadePoint = Struct.new(:clock, :volume)
11
-
12
18
  ##
13
19
  # Defines the sound projection cone including the volume when outside the
14
20
  # cone.
@@ -1,27 +1,95 @@
1
1
  module FMOD
2
2
  module Core
3
+
4
+ ##
5
+ # Structure describing a piece of tag data.
3
6
  class Tag < Structure
4
7
 
5
8
  include Fiddle
6
9
 
10
+ ##
11
+ # Strings for ID3v1 tags that use a number to represent the genre. That
12
+ # number can be used as an index into this array to retrieve the name for
13
+ # the genre.
14
+ #
15
+ # @since 0.9.2
16
+ ID3V1_GENRES = %w[
17
+ Blues Classic\ Rock Country Dance Disco Funk Grunge Hip-Hop Jazz Metal
18
+ New\ Age Oldies Other Pop R&B Rap Reggae Rock Techno Industrial
19
+ Alternative Ska Death\ Metal Pranks Soundtrack Euro-Techno Ambient
20
+ Trip-Hop Vocal Jazz+Funk Fusion Trance Classical Instrumental Acid House
21
+ Game Sound\ Clip Gospel Noise Alternative\ Rock Bass Soul Punk Space
22
+ Meditative Instrumental\ Pop Instrumental\ Rock Ethnic Gothic Darkwave
23
+ Techno-Industrial Electronic Pop-Folk Eurodance Dream Southern\ Rock
24
+ Comedy Cult Gangsta Top\ 40 Christian\ Rap Pop/Funk Jungle Native\
25
+ American Cabaret New\ Wave Psychedelic Rave Showtunes Trailer Lo-Fi
26
+ Tribal Acid\ Punk Acid\ Jazz Polka Retro Musical Rock\ &\ Roll Hard\
27
+ Rock Folk Folk/Rock National\ Folk Swing Fusion Bebob Latin Revival
28
+ Celtic Bluegrass Avantgarde Gothic\ Rock Progressive\ Rock Psychedelic\
29
+ Rock Symphonic\ Rock Slow\ Rock Big\ Band Chorus Easy\ Listening
30
+ Acoustic Humour Speech Chanson Opera Chamber\ Music Sonata Symphony
31
+ Booty\ Bass Primus Porn\ Groove Satire Slow\ Jam Club Tango Samba
32
+ Folklore Ballad Power\ Ballad Rhythmic\ Soul Freestyle Duet Punk\ Rock
33
+ Drum\ Solo A\ Cappella Euro-House Dance\ Hall Goa Drum\ &\ Bass
34
+ Club-House Hardcore Terror Indie BritPop Negerpunk Polsk\ Punk Beat
35
+ Christian\ Gangsta\ Rap Heavy\ Metal Black\ Metal Crossover
36
+ Contemporary\ Christian Christian\ Rock Merengue Salsa Thrash\ Metal
37
+ Anime Jpop Synthpop Abstract Art\ Rock Baroque Bhangra Big\ Beat
38
+ Breakbeat Chillout Downtempo Dub EBM Eclectic Electro Electroclash Emo
39
+ Experimental Garage Global IDM Illbient Industro-Goth Jam\ Band
40
+ Krautrock Leftfield Lounge Math\ Rock New\ Romantic Nu-Breakz Post-Punk
41
+ Post-Rock Psytrance Shoegaze Space\ Rock Trop\ Rock World\ Music
42
+ Neoclassical Audiobook Audio\ Theatre Neue\ Deutsche\ Welle Podcast
43
+ Indie-Rock G-Funk Dubstep Garage\ Rock Psybient
44
+ ].freeze
45
+
46
+ ##
47
+ # @param address [Pointer, Integer, String, nil] The address in memory
48
+ # where the structure will be created from. If no address is given, new
49
+ # memory will be allocated.
7
50
  def initialize(address = nil)
8
51
  types = [TYPE_INT, TYPE_INT, TYPE_VOIDP, TYPE_VOIDP, TYPE_INT, TYPE_INT]
9
52
  members = [:type, :data_type, :name, :data, :data_length, :updated]
10
53
  super(address, types, members)
11
54
  end
12
55
 
56
+ ##
57
+ # @!attribute [r] type
58
+ # @return [Integer] the type of this tag.
59
+ # @see TagType
60
+
61
+ ##
62
+ # @!attribute [r] data_type
63
+ # @return [Integer] the type of data that this tag contains.
64
+ # @see TagDataType
65
+
66
+ ##
67
+ # @!attribute [r] data_length
68
+ # @return [Integer] the length of the data contained in this tag in bytes.
69
+
13
70
  [:type, :data_type, :data_length].each do |symbol|
14
71
  define_method(symbol) { self[symbol] }
15
72
  end
16
73
 
74
+ ##
75
+ # @!attribute [r] name
76
+ # @return [String] the name of this tag i.e. "TITLE", "ARTIST" etc.
17
77
  def name
18
78
  self[:name].to_s
19
79
  end
20
80
 
21
- def updated
81
+ ##
82
+ # @return [Boolean] a flag indicating if this tag has been updated sinc
83
+ # last being accessed.
84
+ def updated?
22
85
  self[:updated] != 0
23
86
  end
24
87
 
88
+ ##
89
+ # Retrieves the tag data, which can vary depending on the value specified
90
+ # in {#data_type}.
91
+ # @return [String, Float, Integer] the tag data.
92
+ # @see TagDataType
25
93
  def value
26
94
  raw = self[:data].to_s(self[:data_length])
27
95
  raw.delete!("\0") unless self[:data_type] == TagDataType::BINARY
@@ -37,15 +105,8 @@ module FMOD
37
105
  else ''
38
106
  end
39
107
  end
40
-
41
- def to_s
42
- begin
43
- "#{value}"
44
- rescue Encoding::CompatibilityError
45
- value.inspect
46
- # TODO
47
- end
48
- end
49
108
  end
50
109
  end
51
- end
110
+ end
111
+
112
+
@@ -1,14 +1,44 @@
1
1
  module FMOD
2
2
  module Core
3
+
4
+ ##
5
+ # Strongly-typed values for indicating the data types used in music tags.
3
6
  module TagDataType
7
+
8
+ ##
9
+ # Raw binary data.
4
10
  BINARY = 0
11
+
12
+ ##
13
+ # A 32-bit integer
5
14
  INT = 1
15
+
16
+ ##
17
+ # A 32-bit floating point value
6
18
  FLOAT = 2
19
+
20
+ ##
21
+ # A string with no specified encoding.
7
22
  STRING = 3
23
+
24
+ ##
25
+ # A UTF-16 encoded string.
8
26
  STRING_UTF16 = 4
27
+
28
+ ##
29
+ # A UTF-16 Big-Endian string.
9
30
  STRING_UTF16BE = 5
31
+
32
+ ##
33
+ # A UTF-8 encoded string.
10
34
  STRING_UTF8 = 6
35
+
36
+ ##
37
+ # @deprecated Do not use.
38
+ # A CDTOC tag.
11
39
  CDTOC = 7
40
+
41
+ deprecate_constant :CDTOC
12
42
  end
13
43
  end
14
44
  end
@@ -0,0 +1,55 @@
1
+ module FMOD
2
+ module Core
3
+
4
+ ##
5
+ # List of tag types that could be stored within a sound. These include id3
6
+ # tags, metadata from net-streams and vorbis/asf data.
7
+ # @since 0.9.2
8
+ module TagType
9
+
10
+ ##
11
+ # Unknown
12
+ UNKNOWN = 0
13
+
14
+ ##
15
+ # ID3V1
16
+ ID3V1 = 1
17
+
18
+ ##
19
+ # ID3V2
20
+ ID3V2 = 2
21
+
22
+ ##
23
+ # Vorbis Comment
24
+ VORBIS_COMMENT = 3
25
+
26
+ ##
27
+ # ShoutCast
28
+ SHOUT_CAST = 4
29
+
30
+ ##
31
+ # IceCast
32
+ ICE_CAST = 5
33
+
34
+ ##
35
+ # ASF
36
+ ASF = 6
37
+
38
+ ##
39
+ # MIDI
40
+ MIDI = 7
41
+
42
+ ##
43
+ # Play list
44
+ PLAYLIST = 8
45
+
46
+ ##
47
+ # FMOD
48
+ FMOD = 9
49
+
50
+ ##
51
+ # User
52
+ USER = 10
53
+ end
54
+ end
55
+ end
@@ -1,5 +1,8 @@
1
1
  module FMOD
2
2
  module Core
3
+
4
+ ##
5
+ # Strongly-typed values for indicating various units of time.
3
6
  module TimeUnit
4
7
 
5
8
  ##
@@ -1,18 +1,31 @@
1
1
  module FMOD
2
2
  module Core
3
- # @attr x [Float]
4
- # @attr y [Float]
5
- # @attr z [Float]
3
+
4
+ ##
5
+ # Structure describing a point in 3D space.
6
6
  class Vector < Structure
7
7
 
8
+ ##
9
+ # @return [Vector] a new {Vector} with all values set to 0.0.
8
10
  def self.zero
9
11
  new(0.0, 0.0, 0.0)
10
12
  end
11
13
 
14
+ ##
15
+ # @return [Vector] a new {Vector} with all values set to 1.0.
12
16
  def self.one
13
17
  new(1.0, 1.0, 1.0)
14
18
  end
15
19
 
20
+ ##
21
+ # @overload initialize(address)
22
+ # @param address [Pointer, Integer, String, nil] The address in memory
23
+ # where the structure will be created from. If no address is given,
24
+ # new memory will be allocated.
25
+ # @overload initialize(x, y, z)
26
+ # @param x [Float] The X coordinate in 3D space.
27
+ # @param y [Float] The Y coordinate in 3D space.
28
+ # @param z [Float] The Z coordinate in 3D space.
16
29
  def initialize(*args)
17
30
  address ||= args.size == 1 ? args.first : nil
18
31
  members = [:x, :y, :z]
@@ -21,19 +34,43 @@ module FMOD
21
34
  set(*args) if args.size == 3
22
35
  end
23
36
 
37
+ # @!attribute x
38
+ # @return [Float] the X coordinate in 3D space.
39
+
40
+ # @!attribute y
41
+ # @return [Float] the Y coordinate in 3D space.
42
+
43
+ # @!attribute z
44
+ # @return [Float] the Z coordinate in 3D space.
45
+
24
46
  [:x, :y, :z].each do |symbol|
25
47
  define_method(symbol) { self[symbol] }
26
48
  define_method("#{symbol}=") { |value| self[symbol] = value.to_f }
27
49
  end
28
50
 
51
+ ##
52
+ # Helper function to set the {#x}, {#y}, and {#z} values simultaneously.
53
+ #
54
+ # @param x [Float] The X coordinate in 3D space.
55
+ # @param y [Float] The Y coordinate in 3D space.
56
+ # @param z [Float] The Z coordinate in 3D space.
57
+ #
58
+ # @return [self]
29
59
  def set(x, y, z)
30
60
  self[:x], self[:y], self[:z] = x, y, z
61
+ self
31
62
  end
32
63
 
64
+ ##
65
+ # @return [Array(Float, Float, Float)] the result of interpreting the
66
+ # vector as an Array.
33
67
  def to_a
34
68
  @members.map { |sym| self[sym] }
35
69
  end
36
70
 
71
+ ##
72
+ # @return [Hash<Symbol, Float>] the result of interpreting the vector as a
73
+ # Hash.
37
74
  def to_h
38
75
  { x: self[:x], y: self[:y], z: self[:z] }
39
76
  end