beeps 0.1.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +7 -0
  2. data/.doc/ext/beeps/beeps.cpp +46 -0
  3. data/.doc/ext/beeps/file_in.cpp +59 -0
  4. data/.doc/ext/beeps/native.cpp +41 -0
  5. data/.doc/ext/beeps/processor.cpp +49 -0
  6. data/.doc/ext/beeps/sawtooth_wave.cpp +66 -0
  7. data/.doc/ext/beeps/sine_wave.cpp +66 -0
  8. data/.doc/ext/beeps/sound.cpp +69 -0
  9. data/.doc/ext/beeps/square_wave.cpp +66 -0
  10. data/README.md +4 -0
  11. data/Rakefile +27 -0
  12. data/VERSION +1 -0
  13. data/beeps.gemspec +43 -0
  14. data/ext/beeps/beeps.cpp +48 -0
  15. data/ext/beeps/defs.h +13 -0
  16. data/ext/beeps/extconf.rb +25 -0
  17. data/ext/beeps/file_in.cpp +61 -0
  18. data/ext/beeps/native.cpp +41 -0
  19. data/ext/beeps/processor.cpp +50 -0
  20. data/ext/beeps/sawtooth_wave.cpp +69 -0
  21. data/ext/beeps/sine_wave.cpp +69 -0
  22. data/ext/beeps/sound.cpp +72 -0
  23. data/ext/beeps/square_wave.cpp +69 -0
  24. data/include/beeps.h +12 -0
  25. data/include/beeps/beeps.h +25 -0
  26. data/include/beeps/defs.h +23 -0
  27. data/include/beeps/exception.h +47 -0
  28. data/include/beeps/openal.h +34 -0
  29. data/include/beeps/processor.h +132 -0
  30. data/include/beeps/ruby.h +10 -0
  31. data/include/beeps/ruby/beeps.h +21 -0
  32. data/include/beeps/ruby/processor.h +86 -0
  33. data/include/beeps/ruby/sound.h +42 -0
  34. data/include/beeps/signals.h +53 -0
  35. data/include/beeps/sound.h +44 -0
  36. data/lib/beeps.rb +9 -0
  37. data/lib/beeps/autoinit.rb +10 -0
  38. data/lib/beeps/beeps.rb +49 -0
  39. data/lib/beeps/ext.rb +4 -0
  40. data/lib/beeps/module.rb +49 -0
  41. data/lib/beeps/processor.rb +60 -0
  42. data/lib/beeps/sound.rb +19 -0
  43. data/src/beeps.cpp +93 -0
  44. data/src/exception.cpp +43 -0
  45. data/src/openal.cpp +216 -0
  46. data/src/openal.h +25 -0
  47. data/src/processor.cpp +201 -0
  48. data/src/signals.cpp +90 -0
  49. data/src/sound.cpp +125 -0
  50. data/src/stk/include/Blit.h +151 -0
  51. data/src/stk/include/BlitSaw.h +148 -0
  52. data/src/stk/include/BlitSquare.h +170 -0
  53. data/src/stk/include/FileRead.h +141 -0
  54. data/src/stk/include/FileWvIn.h +195 -0
  55. data/src/stk/include/Generator.h +50 -0
  56. data/src/stk/include/SineWave.h +159 -0
  57. data/src/stk/include/Stk.h +589 -0
  58. data/src/stk/include/WvIn.h +46 -0
  59. data/src/stk/src/Blit.cpp +78 -0
  60. data/src/stk/src/BlitSaw.cpp +91 -0
  61. data/src/stk/src/BlitSquare.cpp +95 -0
  62. data/src/stk/src/FileRead.cpp +903 -0
  63. data/src/stk/src/FileWvIn.cpp +260 -0
  64. data/src/stk/src/SineWave.cpp +78 -0
  65. data/src/stk/src/Stk.cpp +395 -0
  66. data/test/helper.rb +17 -0
  67. data/test/test_beeps.rb +18 -0
  68. data/test/test_sound.rb +26 -0
  69. metadata +177 -0
data/README.md ADDED
@@ -0,0 +1,4 @@
1
+
2
+ # Beeps - Plays beep sound.
3
+
4
+ by snori@xord.org
data/Rakefile ADDED
@@ -0,0 +1,27 @@
1
+ # -*- mode: ruby; coding: utf-8 -*-
2
+
3
+
4
+ %w[../xot ../rucy .]
5
+ .map {|s| File.expand_path "../#{s}/lib", __FILE__}
6
+ .each {|s| $:.unshift s if !$:.include?(s) && File.directory?(s)}
7
+
8
+ require 'xot/rake'
9
+ require 'xot/module'
10
+ require 'rucy/module'
11
+ require 'beeps/module'
12
+
13
+ include Xot::Rake
14
+
15
+
16
+ MODULES = [Xot, Rucy, Beeps].map {|m| m.const_get :Module}
17
+ MODULE = MODULES.last
18
+ INCDIRS = ['src/stk/include']
19
+ TESTS_ALONE = ['test/test_beeps.rb']
20
+
21
+
22
+ task :default => :build
23
+
24
+ task :build => :ext
25
+
26
+
27
+ MODULES.each {|m| m.load_tasks :lib, :ext, :test, :doc, :gem}
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.10
data/beeps.gemspec ADDED
@@ -0,0 +1,43 @@
1
+ # -*- mode: ruby; coding: utf-8 -*-
2
+
3
+
4
+ File.expand_path('../lib', __FILE__)
5
+ .tap {|s| $:.unshift s if !$:.include?(s) && File.directory?(s)}
6
+
7
+ require 'beeps/module'
8
+
9
+
10
+ Gem::Specification.new do |s|
11
+ glob = -> *patterns do
12
+ patterns.map {|pat| Dir.glob(pat).to_a}.flatten
13
+ end
14
+
15
+ mod = Beeps::Module
16
+ name = mod.name.downcase
17
+ rdocs = glob.call *%w[README .doc/ext/**/*.cpp]
18
+
19
+ s.name = name
20
+ s.summary = 'Plays beep sound.'
21
+ s.description = 'Synthesize and play beep sounds.'
22
+ s.version = mod.version
23
+
24
+ s.authors = %w[snori]
25
+ s.email = 'snori@xord.org'
26
+ s.homepage = "https://github.com/xord/beeps"
27
+
28
+ s.platform = Gem::Platform::RUBY
29
+ s.required_ruby_version = '>=1.9.0'
30
+
31
+ s.add_runtime_dependency 'rake'
32
+ s.add_runtime_dependency 'xot'
33
+ s.add_runtime_dependency 'rucy'
34
+ s.add_development_dependency 'gemcutter'
35
+
36
+ s.files = `git ls-files`.split $/
37
+ s.executables = s.files.grep(%r{^bin/}) {|f| File.basename f}
38
+ s.test_files = s.files.grep %r{^(test|spec|features)/}
39
+ s.extra_rdoc_files = rdocs.to_a
40
+ s.has_rdoc = true
41
+
42
+ s.extensions << 'Rakefile'
43
+ end
@@ -0,0 +1,48 @@
1
+ #include <rucy.h>
2
+ #include "beeps/beeps.h"
3
+ #include "defs.h"
4
+
5
+
6
+ using namespace Rucy;
7
+
8
+
9
+ static
10
+ RUCY_DEF0(init)
11
+ {
12
+ Beeps::init();
13
+ return self;
14
+ }
15
+ RUCY_END
16
+
17
+ static
18
+ RUCY_DEF0(fin)
19
+ {
20
+ Beeps::fin();
21
+ return self;
22
+ }
23
+ RUCY_END
24
+
25
+
26
+ static Module mBeeps;
27
+
28
+ void
29
+ Init_beeps ()
30
+ {
31
+ mBeeps = define_module("Beeps");
32
+ mBeeps.define_singleton_method("init!", init);
33
+ mBeeps.define_singleton_method("fin!", fin);
34
+ }
35
+
36
+
37
+ namespace Beeps
38
+ {
39
+
40
+
41
+ Module
42
+ beeps_module ()
43
+ {
44
+ return mBeeps;
45
+ }
46
+
47
+
48
+ }// Beeps
data/ext/beeps/defs.h ADDED
@@ -0,0 +1,13 @@
1
+ // -*- c++ -*-
2
+ #pragma once
3
+ #ifndef __BEEPS_EXT_DEFS_H__
4
+ #define __BEEPS_EXT_DEFS_H__
5
+
6
+
7
+ #include <beeps/exception.h>
8
+
9
+
10
+ using Beeps::beeps_error;
11
+
12
+
13
+ #endif//EOH
@@ -0,0 +1,25 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+
4
+ %w[../xot ../rucy .]
5
+ .map {|s| File.expand_path "../../../#{s}/lib", __FILE__}
6
+ .each {|s| $:.unshift s if !$:.include?(s) && File.directory?(s)}
7
+
8
+ require 'mkmf'
9
+ require 'xot/extconf'
10
+ require 'xot/module'
11
+ require 'rucy/module'
12
+ require 'beeps/module'
13
+
14
+
15
+ Xot::ExtConf.new Xot, Rucy, Beeps do
16
+ setup do
17
+ headers << 'OpenAL/al.h' << 'OpenAL/alc.h'
18
+ local_libs << 'rucy'
19
+ frameworks << 'OpenAL' if osx?
20
+ $LDFLAGS << ' -Wl,--out-implib=native.dll.a' if cygwin?
21
+ end
22
+
23
+ dir_config 'boost'
24
+ create_makefile 'beeps/native'
25
+ end
@@ -0,0 +1,61 @@
1
+ #include "beeps/ruby/processor.h"
2
+
3
+
4
+ #include <rucy.h>
5
+ #include "beeps/exception.h"
6
+ #include "defs.h"
7
+
8
+
9
+ using namespace Rucy;
10
+
11
+
12
+ RUCY_DEFINE_VALUE_FROM_TO(Beeps::FileIn)
13
+
14
+ #define THIS to<Beeps::FileIn*>(self)
15
+
16
+ #define CHECK RUCY_CHECK_OBJECT(Beeps::FileIn, self)
17
+
18
+
19
+ static
20
+ RUCY_DEF_ALLOC(alloc, klass)
21
+ {
22
+ return new_type<Beeps::FileIn>(klass);
23
+ }
24
+ RUCY_END
25
+
26
+ static
27
+ RUCY_DEF1(initialize, path)
28
+ {
29
+ RUCY_CHECK_OBJ(Beeps::FileIn, self);
30
+
31
+ *THIS = Beeps::FileIn(to<const char*>(path));
32
+ return self;
33
+ }
34
+ RUCY_END
35
+
36
+
37
+ static Class cFileIn;
38
+
39
+ void
40
+ Init_file_in ()
41
+ {
42
+ Module mBeeps = define_module("Beeps");
43
+
44
+ cFileIn = mBeeps.define_class("FileIn", Beeps::processor_class());
45
+ cFileIn.define_alloc_func(alloc);
46
+ cFileIn.define_private_method("initialize", initialize);
47
+ }
48
+
49
+
50
+ namespace Beeps
51
+ {
52
+
53
+
54
+ Class
55
+ file_in_class ()
56
+ {
57
+ return cFileIn;
58
+ }
59
+
60
+
61
+ }// Beeps
@@ -0,0 +1,41 @@
1
+ #include <rucy.h>
2
+ #include "defs.h"
3
+
4
+
5
+ using namespace Rucy;
6
+
7
+
8
+ void Init_beeps ();
9
+
10
+ void Init_processor ();
11
+ void Init_sine_wave ();
12
+ void Init_square_wave ();
13
+ void Init_sawtooth_wave ();
14
+ void Init_file_in ();
15
+
16
+ void Init_sound ();
17
+
18
+
19
+ extern "C" void
20
+ #ifdef COCOAPODS
21
+ Init_beeps_native ()
22
+ #else
23
+ Init_native ()
24
+ #endif
25
+ {
26
+ RUCY_TRY
27
+
28
+ Rucy::init();
29
+
30
+ Init_beeps();
31
+
32
+ Init_processor();
33
+ Init_sine_wave();
34
+ Init_square_wave();
35
+ Init_sawtooth_wave();
36
+ Init_file_in();
37
+
38
+ Init_sound();
39
+
40
+ RUCY_CATCH
41
+ }
@@ -0,0 +1,50 @@
1
+ #include "beeps/ruby/processor.h"
2
+
3
+
4
+ #include <rucy.h>
5
+ #include "beeps/exception.h"
6
+ #include "defs.h"
7
+
8
+
9
+ using namespace Rucy;
10
+
11
+
12
+ RUCY_DEFINE_VALUE_FROM_TO(Beeps::Processor)
13
+
14
+ #define THIS to<Beeps::Processor*>(self)
15
+
16
+ #define CHECK RUCY_CHECK_OBJECT(Beeps::Processor, self)
17
+
18
+
19
+ static
20
+ RUCY_DEF_ALLOC(alloc, klass)
21
+ {
22
+ beeps_error(__FILE__, __LINE__);
23
+ }
24
+ RUCY_END
25
+
26
+
27
+ static Class cProcessor;
28
+
29
+ void
30
+ Init_processor ()
31
+ {
32
+ Module mBeeps = define_module("Beeps");
33
+
34
+ cProcessor = mBeeps.define_class("Processor");
35
+ cProcessor.define_alloc_func(alloc);
36
+ }
37
+
38
+
39
+ namespace Beeps
40
+ {
41
+
42
+
43
+ Class
44
+ processor_class ()
45
+ {
46
+ return cProcessor;
47
+ }
48
+
49
+
50
+ }// Beeps
@@ -0,0 +1,69 @@
1
+ #include "beeps/ruby/processor.h"
2
+
3
+
4
+ #include <rucy.h>
5
+ #include "beeps/exception.h"
6
+ #include "defs.h"
7
+
8
+
9
+ using namespace Rucy;
10
+
11
+
12
+ RUCY_DEFINE_VALUE_FROM_TO(Beeps::SawtoothWave)
13
+
14
+ #define THIS to<Beeps::SawtoothWave*>(self)
15
+
16
+ #define CHECK RUCY_CHECK_OBJECT(Beeps::SawtoothWave, self)
17
+
18
+
19
+ static
20
+ RUCY_DEF_ALLOC(alloc, klass)
21
+ {
22
+ return new_type<Beeps::SawtoothWave>(klass);
23
+ }
24
+ RUCY_END
25
+
26
+ static
27
+ RUCY_DEF1(set_frequency, frequency)
28
+ {
29
+ CHECK;
30
+ THIS->set_frequency(frequency.as_f(true));
31
+ return self;
32
+ }
33
+ RUCY_END
34
+
35
+ static
36
+ RUCY_DEF0(frequency)
37
+ {
38
+ CHECK;
39
+ return to<float>(THIS->frequency());
40
+ }
41
+ RUCY_END
42
+
43
+
44
+ static Class cSawtoothWave;
45
+
46
+ void
47
+ Init_sawtooth_wave ()
48
+ {
49
+ Module mBeeps = define_module("Beeps");
50
+
51
+ cSawtoothWave = mBeeps.define_class("SawtoothWave", Beeps::processor_class());
52
+ cSawtoothWave.define_alloc_func(alloc);
53
+ cSawtoothWave.define_method("frequency=", set_frequency);
54
+ cSawtoothWave.define_method("frequency", frequency);
55
+ }
56
+
57
+
58
+ namespace Beeps
59
+ {
60
+
61
+
62
+ Class
63
+ sawtooth_wave_class ()
64
+ {
65
+ return cSawtoothWave;
66
+ }
67
+
68
+
69
+ }// Beeps
@@ -0,0 +1,69 @@
1
+ #include "beeps/ruby/processor.h"
2
+
3
+
4
+ #include <rucy.h>
5
+ #include "beeps/exception.h"
6
+ #include "defs.h"
7
+
8
+
9
+ using namespace Rucy;
10
+
11
+
12
+ RUCY_DEFINE_VALUE_FROM_TO(Beeps::SineWave)
13
+
14
+ #define THIS to<Beeps::SineWave*>(self)
15
+
16
+ #define CHECK RUCY_CHECK_OBJECT(Beeps::SineWave, self)
17
+
18
+
19
+ static
20
+ RUCY_DEF_ALLOC(alloc, klass)
21
+ {
22
+ return new_type<Beeps::SineWave>(klass);
23
+ }
24
+ RUCY_END
25
+
26
+ static
27
+ RUCY_DEF1(set_frequency, frequency)
28
+ {
29
+ CHECK;
30
+ THIS->set_frequency(frequency.as_f(true));
31
+ return self;
32
+ }
33
+ RUCY_END
34
+
35
+ static
36
+ RUCY_DEF0(frequency)
37
+ {
38
+ CHECK;
39
+ return to<float>(THIS->frequency());
40
+ }
41
+ RUCY_END
42
+
43
+
44
+ static Class cSineWave;
45
+
46
+ void
47
+ Init_sine_wave ()
48
+ {
49
+ Module mBeeps = define_module("Beeps");
50
+
51
+ cSineWave = mBeeps.define_class("SineWave", Beeps::processor_class());
52
+ cSineWave.define_alloc_func(alloc);
53
+ cSineWave.define_method("frequency=", set_frequency);
54
+ cSineWave.define_method("frequency", frequency);
55
+ }
56
+
57
+
58
+ namespace Beeps
59
+ {
60
+
61
+
62
+ Class
63
+ sine_wave_class ()
64
+ {
65
+ return cSineWave;
66
+ }
67
+
68
+
69
+ }// Beeps