seal 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. data/README.md +1 -1
  2. data/include/seal/buf.h +13 -8
  3. data/include/seal/core.h +1 -5
  4. data/include/seal/efs.h +22 -22
  5. data/include/seal/err.h +3 -8
  6. data/include/seal/fmt.h +1 -6
  7. data/include/seal/listener.h +7 -6
  8. data/include/seal/raw.h +2 -6
  9. data/include/seal/rvb.h +12 -6
  10. data/include/seal/src.h +27 -10
  11. data/include/seal/stream.h +12 -5
  12. data/mpg123/build/config.guess +0 -0
  13. data/mpg123/build/config.sub +0 -0
  14. data/mpg123/build/depcomp +0 -0
  15. data/mpg123/build/install-sh +0 -0
  16. data/mpg123/build/missing +0 -0
  17. data/mpg123/configure +0 -0
  18. data/mpg123/ports/MSVC++/2010/libmpg123/libmpg123.vcxproj +5 -0
  19. data/mpg123/ports/MSVC++/2010/libmpg123/yasm.exe +0 -0
  20. data/mpg123/scripts/benchmark-cpu.pl +0 -0
  21. data/mpg123/src/win32_net.c +0 -0
  22. data/mpg123/src/win32_support.c +0 -0
  23. data/mpg123/src/win32_support.h +0 -0
  24. data/mpg123/windows-builds.sh +0 -0
  25. data/spec/seal/core_spec.rb +1 -1
  26. data/spec/seal/effect_slot_spec.rb +5 -8
  27. data/spec/seal/reverb_spec.rb +10 -9
  28. data/spec/seal/source_spec.rb +23 -10
  29. data/spec/seal/stream_spec.rb +7 -0
  30. data/spec/spec_helper.rb +2 -1
  31. data/spec/support/boolean_reader_aliases.rb +9 -0
  32. data/src/rubyext.c +115 -67
  33. data/src/seal/buf.c +0 -6
  34. data/src/seal/core.c +1 -7
  35. data/src/seal/efs.c +0 -9
  36. data/src/seal/err.c +0 -6
  37. data/src/seal/fmt.c +0 -6
  38. data/src/seal/listener.c +0 -6
  39. data/src/seal/mpg.c +0 -6
  40. data/src/seal/mpg.h +0 -4
  41. data/src/seal/ov.c +0 -6
  42. data/src/seal/ov.h +1 -5
  43. data/src/seal/raw.c +0 -6
  44. data/src/seal/reader.c +4 -11
  45. data/src/seal/reader.h +1 -5
  46. data/src/seal/src.c +9 -6
  47. data/src/seal/stream.c +0 -6
  48. data/src/seal/threading.c +0 -6
  49. data/src/seal/threading.h +1 -6
  50. data/src/seal/wav.c +1 -8
  51. data/src/seal/wav.h +2 -6
  52. metadata +5 -3
  53. data/src/win32api.rb +0 -29
@@ -9,6 +9,13 @@ describe Stream do
9
9
 
10
10
  it_behaves_like 'an audio object with format'
11
11
 
12
+ specify 'open is equivalent to new' do
13
+ klass = described_class
14
+ class << klass; alias unit_test_open new; end
15
+ klass.method(:open).should eq klass.method(:unit_test_open)
16
+ class << klass; remove_method :unit_test_open; end
17
+ end
18
+
12
19
  context 'that are closed' do
13
20
  subject do
14
21
  Stream.new(WAV_PATH).tap { |stream| stream.close }
@@ -20,7 +20,7 @@ class Symbol
20
20
  end
21
21
  end
22
22
 
23
- Dir["./spec/support/**/*.rb"].each { |f| require f}
23
+ Dir["./spec/support/**/*.rb"].each { |f| require f }
24
24
  require 'seal'
25
25
  include Seal
26
26
 
@@ -32,6 +32,7 @@ OV_PATH = File.join FIXTURE_DIR, 'heal.ogg'
32
32
  RSpec.configure do |config|
33
33
  config.include CustomMatchers
34
34
  config.alias_it_should_behave_like_to :it_validates, 'validates that'
35
+ config.alias_it_should_behave_like_to :it_defines, 'defines'
35
36
 
36
37
  config.instance_eval do
37
38
  before :all do
@@ -0,0 +1,9 @@
1
+ require 'spec_helper'
2
+
3
+ shared_examples 'boolean reader aliases' do |method_names|
4
+ method_names.each do |name|
5
+ specify "#{name}? is an alias of #{name}" do
6
+ subject.method(name).should eq subject.method("#{name}?")
7
+ end
8
+ end
9
+ end
@@ -1,9 +1,3 @@
1
- /*
2
- * ruby_binding.c is part of the Scorched End Audio Library (SEAL) and is
3
- * licensed under the terms of the GNU Lesser General Public License.
4
- * See COPYING attached with the library.
5
- */
6
-
7
1
  #include <stdlib.h>
8
2
  #include <seal.h>
9
3
  #include "ruby.h"
@@ -138,15 +132,8 @@ set_obj_int(VALUE robj, VALUE rnum, void* set)
138
132
  check_seal_err(((seal_err_t (*)(void*, int)) set)(
139
133
  DATA_PTR(robj), NUM2INT(rnum)
140
134
  ));
141
- }
142
135
 
143
- static
144
- VALUE
145
- set_obj_ulong(VALUE robj, VALUE rnum, void* set)
146
- {
147
- check_seal_err(((seal_err_t (*)(void*, int)) set)(
148
- DATA_PTR(robj), NUM2ULONG(rnum)
149
- ));
136
+ return rnum;
150
137
  }
151
138
 
152
139
  static
@@ -205,17 +192,6 @@ get_obj_int(VALUE robj, void* get)
205
192
  return INT2NUM(integer);
206
193
  }
207
194
 
208
- static
209
- VALUE
210
- get_obj_ulong(VALUE robj, void* get)
211
- {
212
- unsigned long long_integer;
213
-
214
- get_obj_attr(robj, &long_integer, get);
215
-
216
- return ULONG2NUM(long_integer);
217
- }
218
-
219
195
  static
220
196
  VALUE
221
197
  get_obj_char(VALUE robj, void* get)
@@ -396,6 +372,9 @@ per_source_effect_limit()
396
372
  * specifies the format of the audio file; automatic recognition of the audio
397
373
  * format will be attempted if _format_ is not specified. See Seal::Format for
398
374
  * possible values. Sets all the attributes appropriately.
375
+ *
376
+ * There is a limit on the number of allocated buffers. This method raises an
377
+ * error if it is exceeding the limit.
399
378
  */
400
379
  static
401
380
  VALUE
@@ -576,6 +555,9 @@ close_stream(VALUE rstream)
576
555
  * Seal::Source.new -> source
577
556
  *
578
557
  * Initializes a new source.
558
+ *
559
+ * There is a limit on the number of allocated sources. This method raises an
560
+ * error if it is exceeding the limit.
579
561
  */
580
562
  static
581
563
  VALUE
@@ -745,6 +727,29 @@ get_src_stream(VALUE rsrc)
745
727
  return rb_iv_get(rsrc, "@stream");
746
728
  }
747
729
 
730
+ /*
731
+ * call-seq:
732
+ * source.feed(effect_slot, index) -> source
733
+ *
734
+ * Feeds an _effect_slot_ with the output of _source_ so the output is filtered
735
+ * based on the effect attached to _effect_slot_. Later calls to this method
736
+ * with a different effect slot and the same source and index will override the
737
+ * old association. _index_ is the zero-based index for the effect. Each
738
+ * different effect slot that _source_ is feeding must have a unique
739
+ * corresponding index. The max is <em>Seal.per_src_effect_limit - 1</em>.
740
+ */
741
+ static
742
+ VALUE
743
+ feed_efs(VALUE rsrc, VALUE rslot, VALUE rindex)
744
+ {
745
+ seal_src_t* src;
746
+
747
+ Data_Get_Struct(rsrc, seal_src_t, src);
748
+ check_seal_err(seal_feed_efs(src, DATA_PTR(rslot), NUM2INT(rindex)));
749
+
750
+ return rsrc;
751
+ }
752
+
748
753
  /*
749
754
  * call-seq:
750
755
  * source.update -> source
@@ -1081,7 +1086,7 @@ load_rvb(VALUE rrvb, VALUE rpreset)
1081
1086
  seal_rvb_t* rvb;
1082
1087
 
1083
1088
  Data_Get_Struct(rrvb, seal_rvb_t, rvb);
1084
- check_seal_err(seal_load_rvb(DATA_PTR(rrvb), NUM2INT(rpreset)));
1089
+ check_seal_err(seal_load_rvb(rvb, NUM2INT(rpreset)));
1085
1090
 
1086
1091
  return rrvb;
1087
1092
  }
@@ -1093,6 +1098,9 @@ load_rvb(VALUE rrvb, VALUE rpreset)
1093
1098
  *
1094
1099
  * Initializes a new reverb effect. If a preset is specified, initializes
1095
1100
  * the reverb object to load the preset.
1101
+ *
1102
+ * There is a limit on the number of allocated reverbs. This method raises an
1103
+ * error if it is exceeding the limit.
1096
1104
  */
1097
1105
  static
1098
1106
  VALUE
@@ -1544,7 +1552,11 @@ is_rvb_hfdecay_limited(VALUE rrvb)
1544
1552
  * effect_slot.effect = effect -> effect
1545
1553
  *
1546
1554
  * Fills _effect_slot_ with _effect_, then _effect_slot_ will become ready to
1547
- * feed sources. Pass nil to unfill the slot.
1555
+ * be fed by sources. Pass nil to unfill the slot.
1556
+ *
1557
+ * Changing the parameters of _effect_ after it is attached to _effect_slot_
1558
+ * will not change the sound effect provided by _effect_slot_. To update the
1559
+ * sound effect, the updated _effect_ must be re-attached to _effect_slot_.
1548
1560
  */
1549
1561
  static
1550
1562
  VALUE
@@ -1570,8 +1582,11 @@ set_efs_effect(VALUE rslot, VALUE reffect)
1570
1582
  * EffectSlot.new -> effect_slot
1571
1583
  * EffectSlot.new(effect) -> effect_slot
1572
1584
  *
1573
- * Initializes a new effect slot. If an effect object is specified,
1574
- * initializes the effect slot to have that effect object associated.
1585
+ * Initializes a new effect slot. If an effect object is specified, initializes
1586
+ * the effect slot to have that effect object associated.
1587
+ *
1588
+ * There is a limit on the number of allocated effect slots. This method raises
1589
+ * an error if it is exceeding the limit.
1575
1590
  */
1576
1591
  static
1577
1592
  VALUE
@@ -1600,26 +1615,6 @@ get_efs_effect(VALUE rslot)
1600
1615
  return rb_iv_get(rslot, "@effect");
1601
1616
  }
1602
1617
 
1603
- /*
1604
- * call-seq:
1605
- * slot.feed(index, source) -> slot
1606
- *
1607
- * Mixes a sound effect loaded into _effect_slot_ with _source_'s output.
1608
- * Later calls to this function with a different effect slot and the same
1609
- * index will override the old effect slot association.
1610
- */
1611
- static
1612
- VALUE
1613
- feed_efs(VALUE rslot, VALUE rindex, VALUE rsrc)
1614
- {
1615
- seal_src_t* src;
1616
-
1617
- Data_Get_Struct(rsrc, seal_src_t, src);
1618
- check_seal_err(seal_feed_efs(DATA_PTR(rslot), NUM2INT(rindex), src));
1619
-
1620
- return rslot;
1621
- }
1622
-
1623
1618
  /*
1624
1619
  * call-seq:
1625
1620
  * effect_slot.gain = flt -> flt
@@ -1638,8 +1633,7 @@ set_efs_gain(VALUE refs, VALUE value)
1638
1633
  * call-seq:
1639
1634
  * effect_slot.gain -> flt
1640
1635
  *
1641
- * Gets the output level of _effect_slot_ in the interval. The default is
1642
- * 1.0.
1636
+ * Gets the output level of _effect_slot_. The default is 1.0.
1643
1637
  */
1644
1638
  static
1645
1639
  VALUE
@@ -1878,10 +1872,17 @@ bind_core(void)
1878
1872
  /*
1879
1873
  * Document-class: Seal::Buffer
1880
1874
  *
1881
- * Buffers are essentially abstract representations of the (raw) audio data
1882
- * and are used by sources. Buffers are most suitable for small-sized sound
1883
- * effect which can be efficiently loaded to memory at once. Streams, on the
1884
- * other hand, are more suitable for long audio such as background music.
1875
+ * Interfaces for manipulating buffers. Buffers are essentially abstract
1876
+ * representations of (raw) audio data and are used by sources. Buffers are
1877
+ * most suitable for small-sized sound effect which can be efficiently loaded
1878
+ * to memory at once. Streams, on the other hand, are more suitable for massive
1879
+ * audio such as background music.
1880
+ *
1881
+ * In order to have 3D sound effect on the buffer, the audio file needs to have
1882
+ * mono-channel. If the audio file has multi-channel, the sound will not be
1883
+ * positioned in a 3D space. Multi-channel audio (a.k.a. stereo) is already
1884
+ * designed to have illusion of directionality and audible perspective. Most
1885
+ * sound effect should be monophonic.
1885
1886
  */
1886
1887
  static
1887
1888
  void
@@ -1901,8 +1902,19 @@ bind_buf(void)
1901
1902
  /*
1902
1903
  * Document-class: Seal::Stream
1903
1904
  *
1904
- * Streams are used by streaming sources to avoid loading big audio into
1905
- * memory. It is the front end for various decoders.
1905
+ * Interfaces for manipulating streams used by streaming sources. Streams are
1906
+ * usually necessary when the audio data is too massive to fit into main
1907
+ * memory as a whole (such as a background music, which can eat up to dozens of
1908
+ * megabytes of memory after decoding), in which case buffers are not suitable.
1909
+ *
1910
+ * Streams often contain multi-channel audio (since most of the time they are
1911
+ * used to play background music, and background music files are often
1912
+ * multi-channel already), which means that they often contain sound that are
1913
+ * not positioned, i.e., not processed by the 3D sound rendering pipeline. That
1914
+ * fact is totally fine for background music since they are usually not
1915
+ * associated to any object in the application. If positioned streams are
1916
+ * needed and the audio file has multi-channel, the audio file need to be
1917
+ * converted to mono-channel.
1906
1918
  */
1907
1919
  static
1908
1920
  void
@@ -1923,20 +1935,31 @@ bind_stream(void)
1923
1935
  /*
1924
1936
  * Document-class: Seal::Source
1925
1937
  *
1926
- * Sources are abstract representations of sound sources which emit sound in
1927
- * Euclidean space.
1938
+ * Interfaces for manipulating sources. Sources are abstract representations of
1939
+ * sound sources which emit sound in a Euclidean space. The sound comes from
1940
+ * its attached buffer or stream. Its properties combined with those of the
1941
+ * listener singleton object determine how the sound should be rendered.
1928
1942
  */
1929
1943
 
1930
1944
  /*
1931
1945
  * Document-module: Seal::Source::State
1932
1946
  *
1933
1947
  * A collection of Source states.
1948
+ *
1949
+ * A just-initialized source is in the _INITIAL_ state. After a call to
1950
+ * _play_, the source will enter the _PLAYING_ state. After a call to _pause_,
1951
+ * the source will enter the _PAUSED_ state. After a call to _stop_, the source
1952
+ * will enter the _STOPPED_ state.
1934
1953
  */
1935
1954
 
1936
1955
  /*
1937
1956
  * Document-module: Seal::Source::Type
1938
1957
  *
1939
1958
  * A collection of Source types.
1959
+ *
1960
+ * A source not attached to anything is of the _UNDETERMINED_ type. A source
1961
+ * that is attached to a buffer will become the _STATIC_ type. A source that is
1962
+ * attached to a stream will become the _STREAMING_ type.
1940
1963
  */
1941
1964
  static
1942
1965
  void
@@ -1956,6 +1979,7 @@ bind_src(void)
1956
1979
  rb_define_method(cSource, "buffer", get_src_buf, 0);
1957
1980
  rb_define_method(cSource, "stream=", set_src_stream, 1);
1958
1981
  rb_define_method(cSource, "stream", get_src_stream, 0);
1982
+ rb_define_method(cSource, "feed", feed_efs, 2);
1959
1983
  rb_define_method(cSource, "update", update_src, 0);
1960
1984
  rb_define_method(cSource, "position=", set_src_pos, 1);
1961
1985
  rb_define_method(cSource, "position", get_src_pos, 0);
@@ -2001,8 +2025,15 @@ bind_src(void)
2001
2025
  /*
2002
2026
  * Document-class: Seal::Reverb
2003
2027
  *
2004
- * A Reverb object is a set of parameters that define a reverberation effect.
2005
- * Effect objects can be put into an effect slot for sources to use.
2028
+ * Interfaces for manipulating reverberation effect objects which can be loaded
2029
+ * into effect slots. The reverberation parameters can be customized to
2030
+ * emulate reverberations in different environment or can be loaded from
2031
+ * presets. The preset constants suggest the reverberation environment, for
2032
+ * example, <em>Reverb::Preset::IcePalace::LONGPASSAGE</em> emulates the
2033
+ * reverberation in a long passage of an ice palace.
2034
+ *
2035
+ * For more infomation about reverberations, check out the OpenAL effect
2036
+ * extension guide at: http://zhang.su/seal/EffectsExtensionGuide.pdf
2006
2037
  */
2007
2038
  static
2008
2039
  void
@@ -2263,8 +2294,20 @@ bind_rvb(void)
2263
2294
  /*
2264
2295
  * Document-class: Seal::EffectSlot
2265
2296
  *
2266
- * EffectSlot is the container type for effects. A source can mix an effect in
2267
- * an effect slot to filter the output sound.
2297
+ * Interfaces for manipulating effect slots, which are containers for effect
2298
+ * objects. Effect slots can attach effect objects (such as reverb objects) and
2299
+ * then be fed with a mix of audio from different sources, essentially
2300
+ * filtering the rendering of the sound sources and output to the mixer based
2301
+ * on the attached effect object. For example, if a reverb object is attached
2302
+ * to an effect slot and one source is feeding the slot, the sound of that
2303
+ * source will have the reverberation effect defined by the reverb object.
2304
+
2305
+ * Multiple sources can feed the same effect slot, but conversely there is a
2306
+ * limit on the number of effect slots a source can feed concurrently. See the
2307
+ * documentation for EffectSlot#feed for more details.
2308
+ *
2309
+ * For more infomation about effect slots, check out the OpenAL effect
2310
+ * extension guide at: http://zhang.su/seal/EffectsExtensionGuide.pdf
2268
2311
  */
2269
2312
  static
2270
2313
  void
@@ -2276,7 +2319,6 @@ bind_efs(void)
2276
2319
  rb_define_method(cEffectSlot, "initialize", init_efs, -1);
2277
2320
  rb_define_method(cEffectSlot, "effect=", set_efs_effect, 1);
2278
2321
  rb_define_method(cEffectSlot, "effect", get_efs_effect, 0);
2279
- rb_define_method(cEffectSlot, "feed", feed_efs, 2);
2280
2322
  rb_define_method(cEffectSlot, "gain=", set_efs_gain, 1);
2281
2323
  rb_define_method(cEffectSlot, "gain", get_efs_gain, 0);
2282
2324
  rb_define_method(cEffectSlot, "auto=", set_efs_auto, 1);
@@ -2287,8 +2329,13 @@ bind_efs(void)
2287
2329
  /*
2288
2330
  * Document-class: Seal::Listener
2289
2331
  *
2290
- * Listener has a singleton instance representing the sole listener who hears
2291
- * the sound.
2332
+ * Interfaces for manipulating the listener singleton object. The listener
2333
+ * object abstractly represents the main object in a sound application which
2334
+ * "hears" all the sound. For example, the listener object can be used to
2335
+ * represent the main character moving around on the map in a role-playing
2336
+ * game. The properties of the listener (position, velocity, etc.) combined
2337
+ * with those of the existing sources determine how the sound should be
2338
+ * rendered.
2292
2339
  */
2293
2340
  static
2294
2341
  void
@@ -2314,7 +2361,8 @@ bind_listener(void)
2314
2361
  /*
2315
2362
  * Document-module: Seal
2316
2363
  *
2317
- * The top-level namespace of Seal.
2364
+ * The top-level namespace of Seal. This module contains interfaces for global
2365
+ * Seal operations.
2318
2366
  */
2319
2367
  void
2320
2368
  Init_seal(void)
@@ -1,9 +1,3 @@
1
- /*
2
- * buf.c is part of the Scorched End Audio Library (SEAL) and is licensed
3
- * under the terms of the GNU Lesser General Public License. See COPYING
4
- * attached with the library.
5
- */
6
-
7
1
  #include <stdlib.h>
8
2
  #include <al/al.h>
9
3
  #include <seal/buf.h>
@@ -1,9 +1,3 @@
1
- /*
2
- * core.c is part of the Scorched End Audio Library (SEAL) and is licensed
3
- * under the terms of the GNU Lesser General Public License. See COPYING
4
- * attached with the library.
5
- */
6
-
7
1
  #include <stdlib.h>
8
2
  #include <stddef.h>
9
3
  #include <al/al.h>
@@ -137,7 +131,7 @@ seal_startup(const char* device_name)
137
131
  /* Reset OpenAL's error state. */
138
132
  alGetError();
139
133
 
140
- alcGetIntegerv(device, ALC_MAX_AUXILIARY_SENDS, 1,&per_src_effect_limit);
134
+ alcGetIntegerv(device, ALC_MAX_AUXILIARY_SENDS, 1, &per_src_effect_limit);
141
135
 
142
136
  return SEAL_OK;
143
137
 
@@ -31,15 +31,6 @@ seal_set_efs_effect(seal_efs_t* slot, void* effect)
31
31
  return err;
32
32
  }
33
33
 
34
- seal_err_t
35
- seal_feed_efs(seal_efs_t* slot, int index, seal_src_t* src)
36
- {
37
- alSource3i(src->id, AL_AUXILIARY_SEND_FILTER, slot->id, index,
38
- AL_FILTER_NULL);
39
-
40
- return _seal_get_openal_err();
41
- }
42
-
43
34
  seal_err_t
44
35
  seal_set_efs_gain(seal_efs_t* slot, float gain)
45
36
  {
@@ -1,9 +1,3 @@
1
- /*
2
- * err.c is part of the Scorched End Audio Library (SEAL) and is licensed
3
- * under the terms of the GNU Lesser General Public License. See COPYING
4
- * attached with the library.
5
- */
6
-
7
1
  #include <al/al.h>
8
2
  #include <seal/err.h>
9
3
 
@@ -1,9 +1,3 @@
1
- /*
2
- * fmt.c is part of the Scorched End Audio Library (SEAL) and is licensed
3
- * under the terms of the GNU Lesser General Public License. See COPYING
4
- * attached with the library.
5
- */
6
-
7
1
  #include <stdio.h>
8
2
  #include <stdint.h>
9
3
  #include <seal/fmt.h>
@@ -1,9 +1,3 @@
1
- /*
2
- * listener.c is part of the Scorched End Audio Library (SEAL) and is licensed
3
- * under the terms of the GNU Lesser General Public License. See COPYING
4
- * attached with the library.
5
- */
6
-
7
1
  #include <al/al.h>
8
2
  #include <seal/listener.h>
9
3
  #include <seal/err.h>