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
@@ -0,0 +1,72 @@
1
+ #include "beeps/ruby/sound.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::Sound)
13
+
14
+ #define THIS to<Beeps::Sound*>(self)
15
+
16
+ #define CHECK RUCY_CHECK_OBJECT(Beeps::Sound, self)
17
+
18
+
19
+ static
20
+ RUCY_DEF_ALLOC(alloc, klass)
21
+ {
22
+ return new_type<Beeps::Sound>(klass);
23
+ }
24
+ RUCY_END
25
+
26
+ static
27
+ RUCY_DEF2(initialize, processor, seconds)
28
+ {
29
+ RUCY_CHECK_OBJ(Beeps::Sound, self);
30
+
31
+ *THIS = Beeps::Sound(to<Beeps::Processor*>(processor), to<float>(seconds));
32
+ return self;
33
+ }
34
+ RUCY_END
35
+
36
+ static
37
+ RUCY_DEF0(play)
38
+ {
39
+ CHECK;
40
+
41
+ THIS->play();
42
+ return self;
43
+ }
44
+ RUCY_END
45
+
46
+
47
+ static Class cSound;
48
+
49
+ void
50
+ Init_sound ()
51
+ {
52
+ Module mBeeps = define_module("Beeps");
53
+
54
+ cSound = mBeeps.define_class("Sound");
55
+ cSound.define_alloc_func(alloc);
56
+ cSound.define_private_method("initialize", initialize);
57
+ cSound.define_method("play", play);
58
+ }
59
+
60
+
61
+ namespace Beeps
62
+ {
63
+
64
+
65
+ Class
66
+ sound_class ()
67
+ {
68
+ return cSound;
69
+ }
70
+
71
+
72
+ }// 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::SquareWave)
13
+
14
+ #define THIS to<Beeps::SquareWave*>(self)
15
+
16
+ #define CHECK RUCY_CHECK_OBJECT(Beeps::SquareWave, self)
17
+
18
+
19
+ static
20
+ RUCY_DEF_ALLOC(alloc, klass)
21
+ {
22
+ return new_type<Beeps::SquareWave>(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 cSquareWave;
45
+
46
+ void
47
+ Init_square_wave ()
48
+ {
49
+ Module mBeeps = define_module("Beeps");
50
+
51
+ cSquareWave = mBeeps.define_class("SquareWave", Beeps::processor_class());
52
+ cSquareWave.define_alloc_func(alloc);
53
+ cSquareWave.define_method("frequency=", set_frequency);
54
+ cSquareWave.define_method("frequency", frequency);
55
+ }
56
+
57
+
58
+ namespace Beeps
59
+ {
60
+
61
+
62
+ Class
63
+ square_wave_class ()
64
+ {
65
+ return cSquareWave;
66
+ }
67
+
68
+
69
+ }// Beeps
data/include/beeps.h ADDED
@@ -0,0 +1,12 @@
1
+ // -*- c++ -*-
2
+ #pragma once
3
+ #ifndef __BEEPS_H__
4
+ #define __BEEPS_H__
5
+
6
+
7
+ #include <beeps/defs.h>
8
+ #include <beeps/beeps.h>
9
+ #include <beeps/exception.h>
10
+
11
+
12
+ #endif//EOH
@@ -0,0 +1,25 @@
1
+ // -*- c++ -*-
2
+ #pragma once
3
+ #ifndef __BEEPS_BEEPS_H__
4
+ #define __BEEPS_BEEPS_H__
5
+
6
+
7
+ #include <beeps/defs.h>
8
+
9
+
10
+ namespace Beeps
11
+ {
12
+
13
+
14
+ void init ();
15
+
16
+ void fin ();
17
+
18
+
19
+ uint sampling_rate ();
20
+
21
+
22
+ }// Beeps
23
+
24
+
25
+ #endif//EOH
@@ -0,0 +1,23 @@
1
+ // -*- c++ -*-
2
+ #pragma once
3
+ #ifndef __BEEPS_DEFS_H__
4
+ #define __BEEPS_DEFS_H__
5
+
6
+
7
+ #include <xot/defs.h>
8
+ #include <xot/string.h>
9
+
10
+
11
+ namespace Beeps
12
+ {
13
+
14
+
15
+ using namespace Xot::Types;
16
+
17
+ using Xot::String;
18
+
19
+
20
+ }// Beeps
21
+
22
+
23
+ #endif//EOH
@@ -0,0 +1,47 @@
1
+ // -*- c++ -*-
2
+ #pragma once
3
+ #ifndef __BEEPS_EXCEPTION_H__
4
+ #define __BEEPS_EXCEPTION_H__
5
+
6
+
7
+ #include <xot/exception.h>
8
+ #include <beeps/defs.h>
9
+
10
+
11
+ namespace Beeps
12
+ {
13
+
14
+
15
+ class BeepsError : public Xot::XotError
16
+ {
17
+ typedef Xot::XotError Super;
18
+ public: BeepsError (const char* str = NULL);
19
+ };
20
+
21
+
22
+ class OpenALError : public BeepsError
23
+ {
24
+ typedef BeepsError Super;
25
+ public: OpenALError (const char* str = NULL);
26
+ };
27
+
28
+
29
+ namespace ErrorFunctions
30
+ {
31
+
32
+ using namespace Xot::ErrorFunctions;
33
+
34
+ void beeps_error (const char* file, int line, const char* format = NULL, ...);
35
+
36
+ void openal_error (const char* file, int line, const char* format = NULL, ...);
37
+
38
+ }// ErrorFunctions
39
+
40
+
41
+ using namespace ErrorFunctions;
42
+
43
+
44
+ }// Beeps
45
+
46
+
47
+ #endif//EOH
@@ -0,0 +1,34 @@
1
+ // -*- c++ -*-
2
+ #pragma once
3
+ #ifndef __BEEPS_OPENAL_H__
4
+ #define __BEEPS_OPENAL_H__
5
+
6
+
7
+ #if defined(OSX) || defined(IOS)
8
+ #include <OpenAL/al.h>
9
+ #include <OpenAL/alc.h>
10
+ #else
11
+ #include <AL/al.h>
12
+ #include <AL/alc.h>
13
+ #endif
14
+
15
+
16
+ namespace Beeps
17
+ {
18
+
19
+
20
+ ALCenum get_error ();
21
+
22
+ bool no_error ();
23
+
24
+ bool is_error (ALCenum err);
25
+
26
+ void check_error(const char* file, int line);
27
+
28
+ void clear_error ();
29
+
30
+
31
+ }// Beeps
32
+
33
+
34
+ #endif//EOH
@@ -0,0 +1,132 @@
1
+ // -*- c++ -*-
2
+ #pragma once
3
+ #ifndef __BEEPS_PROCESSOR_H__
4
+ #define __BEEPS_PROCESSOR_H__
5
+
6
+
7
+ #include <xot/pimpl.h>
8
+
9
+
10
+ namespace Beeps
11
+ {
12
+
13
+
14
+ class Signals;
15
+
16
+
17
+ class Processor
18
+ {
19
+
20
+ public:
21
+
22
+ Processor ();
23
+
24
+ virtual ~Processor ();
25
+
26
+ virtual void process (Signals* signals);
27
+
28
+ virtual operator bool () const;
29
+
30
+ virtual bool operator ! () const;
31
+
32
+ };// Processor
33
+
34
+
35
+ class SineWave : public Processor
36
+ {
37
+
38
+ typedef Processor Super;
39
+
40
+ public:
41
+
42
+ SineWave ();
43
+
44
+ virtual ~SineWave ();
45
+
46
+ virtual void set_frequency (float frequency);
47
+
48
+ virtual float frequency () const;
49
+
50
+ virtual void process (Signals* signals);
51
+
52
+ struct Data;
53
+
54
+ Xot::PImpl<Data, true> self;
55
+
56
+ };// SineWave
57
+
58
+
59
+ class SquareWave : public Processor
60
+ {
61
+
62
+ typedef Processor Super;
63
+
64
+ public:
65
+
66
+ SquareWave ();
67
+
68
+ virtual ~SquareWave ();
69
+
70
+ virtual void set_frequency (float frequency);
71
+
72
+ virtual float frequency () const;
73
+
74
+ virtual void process (Signals* signals);
75
+
76
+ struct Data;
77
+
78
+ Xot::PImpl<Data, true> self;
79
+
80
+ };// SquareWave
81
+
82
+
83
+ class SawtoothWave : public Processor
84
+ {
85
+
86
+ typedef Processor Super;
87
+
88
+ public:
89
+
90
+ SawtoothWave ();
91
+
92
+ virtual ~SawtoothWave ();
93
+
94
+ virtual void set_frequency (float frequency);
95
+
96
+ virtual float frequency () const;
97
+
98
+ virtual void process (Signals* signals);
99
+
100
+ struct Data;
101
+
102
+ Xot::PImpl<Data, true> self;
103
+
104
+ };// SawtoothWave
105
+
106
+
107
+ class FileIn : public Processor
108
+ {
109
+
110
+ typedef Processor Super;
111
+
112
+ public:
113
+
114
+ FileIn (const char* path = NULL);
115
+
116
+ virtual ~FileIn ();
117
+
118
+ virtual void process (Signals* signals);
119
+
120
+ virtual operator bool () const;
121
+
122
+ struct Data;
123
+
124
+ Xot::PImpl<Data, true> self;
125
+
126
+ };// FileIn
127
+
128
+
129
+ }// Beeps
130
+
131
+
132
+ #endif//EOH
@@ -0,0 +1,10 @@
1
+ // -*- c++ -*-
2
+ #pragma once
3
+ #ifndef __BEEPS_RUBY_H__
4
+ #define __BEEPS_RUBY_H__
5
+
6
+
7
+ #include <beeps/ruby/beeps.h>
8
+
9
+
10
+ #endif//EOH
@@ -0,0 +1,21 @@
1
+ // -*- c++ -*-
2
+ #pragma once
3
+ #ifndef __BEEPS_RUBY_BEEPS_H__
4
+ #define __BEEPS_RUBY_BEEPS_H__
5
+
6
+
7
+ #include <rucy/module.h>
8
+
9
+
10
+ namespace Beeps
11
+ {
12
+
13
+
14
+ Rucy::Module beeps_module ();
15
+ // module Beeps
16
+
17
+
18
+ }// Beeps
19
+
20
+
21
+ #endif//EOH