beeps 0.1.32 → 0.1.33
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.
- checksums.yaml +4 -4
- data/.doc/ext/beeps/adsr.cpp +139 -0
- data/.doc/ext/beeps/analyser.cpp +128 -0
- data/.doc/ext/beeps/beeps.cpp +9 -1
- data/.doc/ext/beeps/file_in.cpp +55 -9
- data/.doc/ext/beeps/gain.cpp +64 -0
- data/.doc/ext/beeps/mic_in.cpp +83 -0
- data/.doc/ext/beeps/native.cpp +20 -8
- data/.doc/ext/beeps/oscillator.cpp +88 -0
- data/.doc/ext/beeps/pitch_shift.cpp +64 -0
- data/.doc/ext/beeps/processor.cpp +31 -2
- data/.doc/ext/beeps/sound.cpp +90 -7
- data/.doc/ext/beeps/sound_player.cpp +156 -0
- data/.doc/ext/beeps/time_stretch.cpp +64 -0
- data/.github/workflows/release-gem.yml +4 -1
- data/ChangeLog.md +8 -0
- data/Rakefile +26 -4
- data/VERSION +1 -1
- data/beeps.gemspec +2 -2
- data/ext/beeps/adsr.cpp +150 -0
- data/ext/beeps/analyser.cpp +134 -0
- data/ext/beeps/beeps.cpp +10 -1
- data/ext/beeps/extconf.rb +1 -2
- data/ext/beeps/file_in.cpp +60 -9
- data/ext/beeps/gain.cpp +67 -0
- data/ext/beeps/mic_in.cpp +88 -0
- data/ext/beeps/native.cpp +20 -8
- data/ext/beeps/oscillator.cpp +93 -0
- data/ext/beeps/pitch_shift.cpp +67 -0
- data/ext/beeps/processor.cpp +34 -2
- data/ext/beeps/sound.cpp +99 -7
- data/ext/beeps/sound_player.cpp +169 -0
- data/ext/beeps/time_stretch.cpp +67 -0
- data/include/beeps/beeps.h +2 -1
- data/include/beeps/filter.h +179 -0
- data/include/beeps/generator.h +120 -0
- data/include/beeps/processor.h +37 -68
- data/include/beeps/ruby/filter.h +78 -0
- data/include/beeps/ruby/generator.h +60 -0
- data/include/beeps/ruby/processor.h +5 -45
- data/include/beeps/ruby/sound.h +14 -3
- data/include/beeps/signals.h +10 -4
- data/include/beeps/sound.h +67 -2
- data/lib/beeps/beeps.rb +6 -1
- data/lib/beeps/processor.rb +95 -15
- data/lib/beeps/sound.rb +29 -2
- data/src/adsr.cpp +245 -0
- data/src/analyser.cpp +254 -0
- data/src/beeps.cpp +11 -2
- data/src/file_in.cpp +94 -0
- data/src/gain.cpp +55 -0
- data/src/mic_in.cpp +262 -0
- data/src/mic_in.h +20 -0
- data/src/openal.cpp +2 -1
- data/src/oscillator.cpp +145 -0
- data/src/osx/signals.mm +83 -0
- data/src/pitch_shift.cpp +82 -0
- data/src/processor.cpp +202 -88
- data/src/processor.h +98 -0
- data/src/signals.cpp +326 -20
- data/src/signals.h +192 -2
- data/src/sound.cpp +735 -113
- data/src/sound.h +6 -1
- data/src/time_stretch.cpp +91 -0
- data/test/helper.rb +2 -1
- data/test/test_beeps.rb +10 -7
- data/test/test_beeps_init.rb +18 -0
- data/test/test_file_in.rb +15 -0
- data/test/test_processor.rb +50 -0
- data/test/test_sound.rb +87 -11
- data/test/test_sound_player.rb +134 -0
- metadata +54 -16
- data/.doc/ext/beeps/sawtooth_wave.cpp +0 -61
- data/.doc/ext/beeps/sine_wave.cpp +0 -61
- data/.doc/ext/beeps/square_wave.cpp +0 -61
- data/ext/beeps/sawtooth_wave.cpp +0 -64
- data/ext/beeps/sine_wave.cpp +0 -64
- data/ext/beeps/square_wave.cpp +0 -64
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0b9915b433d5e54ae45f1a6cc1fc0a922f558ed0133908c3d1bf30554fc348c3
|
4
|
+
data.tar.gz: 53f4a30891273bfcdd969ca408a963b6aa5c847055c3868701dc356e46a45b6e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 90ed2a73165ea3106af0512fd0133bc587762944c0da07d70d5d1bb1a3815df7173417e528a5e9979677c5d8ccb0a60207ca855ea3eceff5f675010cd87bb13a
|
7
|
+
data.tar.gz: e8e6f3e6a1fb38ba2a45bae0aaa2a549097d726a6ae0f5ea2ba768351a354144f9d67a1f9f84ac2b3ff17451cbdb3e9a9209dfcd1f986b31ee850aae5b693b2e
|
@@ -0,0 +1,139 @@
|
|
1
|
+
#include "beeps/ruby/filter.h"
|
2
|
+
|
3
|
+
|
4
|
+
#include "beeps/ruby/processor.h"
|
5
|
+
#include "defs.h"
|
6
|
+
|
7
|
+
|
8
|
+
RUCY_DEFINE_WRAPPER_VALUE_FROM_TO(Beeps::ADSR)
|
9
|
+
|
10
|
+
#define THIS to<Beeps::ADSR*>(self)
|
11
|
+
|
12
|
+
#define CHECK RUCY_CHECK_OBJ(Beeps::ADSR, self)
|
13
|
+
|
14
|
+
|
15
|
+
static
|
16
|
+
VALUE alloc(VALUE klass)
|
17
|
+
{
|
18
|
+
return value(new Beeps::RubyProcessor<Beeps::ADSR>, klass);
|
19
|
+
}
|
20
|
+
|
21
|
+
static
|
22
|
+
VALUE note_on(VALUE self, VALUE delay)
|
23
|
+
{
|
24
|
+
CHECK;
|
25
|
+
|
26
|
+
THIS->note_on(to<float>(delay));
|
27
|
+
}
|
28
|
+
|
29
|
+
static
|
30
|
+
VALUE note_off(VALUE self, VALUE delay)
|
31
|
+
{
|
32
|
+
CHECK;
|
33
|
+
|
34
|
+
THIS->note_off(to<float>(delay));
|
35
|
+
}
|
36
|
+
|
37
|
+
static
|
38
|
+
VALUE set_attack_time(VALUE self, VALUE time)
|
39
|
+
{
|
40
|
+
CHECK;
|
41
|
+
|
42
|
+
THIS->set_attack_time(to<float>(time));
|
43
|
+
return time;
|
44
|
+
}
|
45
|
+
|
46
|
+
static
|
47
|
+
VALUE get_attack_time(VALUE self)
|
48
|
+
{
|
49
|
+
CHECK;
|
50
|
+
|
51
|
+
return value(THIS->attack_time());
|
52
|
+
}
|
53
|
+
|
54
|
+
static
|
55
|
+
VALUE set_decay_time(VALUE self, VALUE time)
|
56
|
+
{
|
57
|
+
CHECK;
|
58
|
+
|
59
|
+
THIS->set_decay_time(to<float>(time));
|
60
|
+
return time;
|
61
|
+
}
|
62
|
+
|
63
|
+
static
|
64
|
+
VALUE get_decay_time(VALUE self)
|
65
|
+
{
|
66
|
+
CHECK;
|
67
|
+
|
68
|
+
return value(THIS->decay_time());
|
69
|
+
}
|
70
|
+
|
71
|
+
static
|
72
|
+
VALUE set_sustain_level(VALUE self, VALUE level)
|
73
|
+
{
|
74
|
+
CHECK;
|
75
|
+
|
76
|
+
THIS->set_sustain_level(to<float>(level));
|
77
|
+
return level;
|
78
|
+
}
|
79
|
+
|
80
|
+
static
|
81
|
+
VALUE get_sustain_level(VALUE self)
|
82
|
+
{
|
83
|
+
CHECK;
|
84
|
+
|
85
|
+
return value(THIS->sustain_level());
|
86
|
+
}
|
87
|
+
|
88
|
+
static
|
89
|
+
VALUE set_release_time(VALUE self, VALUE time)
|
90
|
+
{
|
91
|
+
CHECK;
|
92
|
+
|
93
|
+
THIS->set_release_time(to<float>(time));
|
94
|
+
return time;
|
95
|
+
}
|
96
|
+
|
97
|
+
static
|
98
|
+
VALUE get_release_time(VALUE self)
|
99
|
+
{
|
100
|
+
CHECK;
|
101
|
+
|
102
|
+
return value(THIS->release_time());
|
103
|
+
}
|
104
|
+
|
105
|
+
|
106
|
+
static Class cADSR;
|
107
|
+
|
108
|
+
void
|
109
|
+
Init_beeps_adsr ()
|
110
|
+
{
|
111
|
+
Module mBeeps = rb_define_module("Beeps");
|
112
|
+
|
113
|
+
cADSR = mBeeps.define_class("ADSR", Beeps::processor_class());
|
114
|
+
rb_define_alloc_func(cADSR, alloc);
|
115
|
+
cADSR.define_private_method("note_on!", note_on);
|
116
|
+
cADSR.define_private_method("note_off!", note_off);
|
117
|
+
rb_define_method(cADSR, "attack_time=", RUBY_METHOD_FUNC(set_attack_time), 1);
|
118
|
+
rb_define_method(cADSR, "attack_time", RUBY_METHOD_FUNC(get_attack_time), 0);
|
119
|
+
rb_define_method(cADSR, "decay_time=", RUBY_METHOD_FUNC(set_decay_time), 1);
|
120
|
+
rb_define_method(cADSR, "decay_time", RUBY_METHOD_FUNC(get_decay_time), 0);
|
121
|
+
rb_define_method(cADSR, "sustain_level=", RUBY_METHOD_FUNC(set_sustain_level), 1);
|
122
|
+
rb_define_method(cADSR, "sustain_level", RUBY_METHOD_FUNC(get_sustain_level), 0);
|
123
|
+
rb_define_method(cADSR, "release_time=", RUBY_METHOD_FUNC(set_release_time), 1);
|
124
|
+
rb_define_method(cADSR, "release_time", RUBY_METHOD_FUNC(get_release_time), 0);
|
125
|
+
}
|
126
|
+
|
127
|
+
|
128
|
+
namespace Beeps
|
129
|
+
{
|
130
|
+
|
131
|
+
|
132
|
+
Class
|
133
|
+
adsr_class ()
|
134
|
+
{
|
135
|
+
return cADSR;
|
136
|
+
}
|
137
|
+
|
138
|
+
|
139
|
+
}// Beeps
|
@@ -0,0 +1,128 @@
|
|
1
|
+
#include "beeps/ruby/filter.h"
|
2
|
+
|
3
|
+
|
4
|
+
#include "beeps/ruby/processor.h"
|
5
|
+
#include "beeps/signals.h"
|
6
|
+
#include "defs.h"
|
7
|
+
|
8
|
+
|
9
|
+
RUCY_DEFINE_WRAPPER_VALUE_FROM_TO(Beeps::Analyser)
|
10
|
+
|
11
|
+
#define THIS to<Beeps::Analyser*>(self)
|
12
|
+
|
13
|
+
#define CHECK RUCY_CHECK_OBJ(Beeps::Analyser, self)
|
14
|
+
|
15
|
+
|
16
|
+
static
|
17
|
+
VALUE alloc(VALUE klass)
|
18
|
+
{
|
19
|
+
return value(new Beeps::RubyProcessor<Beeps::Analyser>, klass);
|
20
|
+
}
|
21
|
+
|
22
|
+
static
|
23
|
+
VALUE set_fft_size(VALUE self, VALUE size)
|
24
|
+
{
|
25
|
+
CHECK;
|
26
|
+
|
27
|
+
THIS->set_fft_size(to<uint>(size));
|
28
|
+
return size;
|
29
|
+
}
|
30
|
+
|
31
|
+
static
|
32
|
+
VALUE get_fft_size(VALUE self)
|
33
|
+
{
|
34
|
+
CHECK;
|
35
|
+
|
36
|
+
return value(THIS->fft_size());
|
37
|
+
}
|
38
|
+
|
39
|
+
static
|
40
|
+
VALUE get_resolution(VALUE self)
|
41
|
+
{
|
42
|
+
CHECK;
|
43
|
+
|
44
|
+
return value(THIS->resolution());
|
45
|
+
}
|
46
|
+
|
47
|
+
static
|
48
|
+
VALUE each_signal(VALUE self, VALUE nsamples_)
|
49
|
+
{
|
50
|
+
CHECK;
|
51
|
+
|
52
|
+
if (!*THIS)
|
53
|
+
invalid_object_error(__FILE__, __LINE__);
|
54
|
+
|
55
|
+
const Beeps::Signals& sig = THIS->signals();
|
56
|
+
|
57
|
+
uint nsamples = to<uint>(nsamples_);
|
58
|
+
if (nsamples > sig.nsamples()) nsamples = sig.nsamples();
|
59
|
+
|
60
|
+
const double* samples = sig.samples();
|
61
|
+
uint nchannels = sig.nchannels();
|
62
|
+
uint start = (sig.nsamples() - nsamples) * nchannels;
|
63
|
+
switch (nchannels)
|
64
|
+
{
|
65
|
+
case 1:
|
66
|
+
for (uint i = start; i < nsamples; ++i)
|
67
|
+
rb_yield(value(samples[i]));
|
68
|
+
break;
|
69
|
+
|
70
|
+
case 2:
|
71
|
+
Value values[2];
|
72
|
+
Value args(2, values);
|
73
|
+
for (uint i = start; i < nsamples; i += 2)
|
74
|
+
{
|
75
|
+
args[0] = value(samples[i + 0]);
|
76
|
+
args[1] = value(samples[i + 1]);
|
77
|
+
rb_yield(args);
|
78
|
+
}
|
79
|
+
break;
|
80
|
+
}
|
81
|
+
|
82
|
+
return nil();
|
83
|
+
}
|
84
|
+
|
85
|
+
static
|
86
|
+
VALUE each_spectrum(VALUE self)
|
87
|
+
{
|
88
|
+
CHECK;
|
89
|
+
|
90
|
+
if (!*THIS)
|
91
|
+
invalid_object_error(__FILE__, __LINE__);
|
92
|
+
|
93
|
+
for (auto val : THIS->spectrum())
|
94
|
+
rb_yield(value(val));
|
95
|
+
|
96
|
+
return nil();
|
97
|
+
}
|
98
|
+
|
99
|
+
|
100
|
+
static Class cAnalyser;
|
101
|
+
|
102
|
+
void
|
103
|
+
Init_beeps_analyser ()
|
104
|
+
{
|
105
|
+
Module mBeeps = rb_define_module("Beeps");
|
106
|
+
|
107
|
+
cAnalyser = mBeeps.define_class("Analyser", Beeps::processor_class());
|
108
|
+
rb_define_alloc_func(cAnalyser, alloc);
|
109
|
+
rb_define_method(cAnalyser, "fft_size=", RUBY_METHOD_FUNC(set_fft_size), 1);
|
110
|
+
rb_define_method(cAnalyser, "fft_size", RUBY_METHOD_FUNC(get_fft_size), 0);
|
111
|
+
rb_define_method(cAnalyser, "resolution", RUBY_METHOD_FUNC(get_resolution), 0);
|
112
|
+
cAnalyser.define_private_method("each_signal!", each_signal);
|
113
|
+
cAnalyser.define_private_method("each_spectrum!", each_spectrum);
|
114
|
+
}
|
115
|
+
|
116
|
+
|
117
|
+
namespace Beeps
|
118
|
+
{
|
119
|
+
|
120
|
+
|
121
|
+
Class
|
122
|
+
analyser_class ()
|
123
|
+
{
|
124
|
+
return cAnalyser;
|
125
|
+
}
|
126
|
+
|
127
|
+
|
128
|
+
}// Beeps
|
data/.doc/ext/beeps/beeps.cpp
CHANGED
@@ -19,6 +19,13 @@ VALUE fin(VALUE self)
|
|
19
19
|
return self;
|
20
20
|
}
|
21
21
|
|
22
|
+
static
|
23
|
+
VALUE process_streams(VALUE self)
|
24
|
+
{
|
25
|
+
Beeps::process_streams();
|
26
|
+
return self;
|
27
|
+
}
|
28
|
+
|
22
29
|
|
23
30
|
static Module mBeeps;
|
24
31
|
|
@@ -27,7 +34,8 @@ Init_beeps ()
|
|
27
34
|
{
|
28
35
|
mBeeps = rb_define_module("Beeps");
|
29
36
|
mBeeps.define_singleton_method("init!", init);
|
30
|
-
mBeeps.define_singleton_method("fin!",
|
37
|
+
mBeeps.define_singleton_method("fin!", fin);
|
38
|
+
mBeeps.define_singleton_method("process_streams!", process_streams);
|
31
39
|
}
|
32
40
|
|
33
41
|
|
data/.doc/ext/beeps/file_in.cpp
CHANGED
@@ -1,29 +1,70 @@
|
|
1
|
-
#include "beeps/ruby/
|
1
|
+
#include "beeps/ruby/generator.h"
|
2
2
|
|
3
3
|
|
4
|
+
#include "beeps/ruby/processor.h"
|
4
5
|
#include "defs.h"
|
5
6
|
|
6
7
|
|
7
|
-
|
8
|
+
RUCY_DEFINE_WRAPPER_VALUE_FROM_TO(Beeps::FileIn)
|
8
9
|
|
9
10
|
#define THIS to<Beeps::FileIn*>(self)
|
10
11
|
|
11
|
-
#define CHECK
|
12
|
+
#define CHECK RUCY_CHECK_OBJ(Beeps::FileIn, self)
|
12
13
|
|
13
14
|
|
14
15
|
static
|
15
16
|
VALUE alloc(VALUE klass)
|
16
17
|
{
|
17
|
-
return
|
18
|
+
return value(new Beeps::RubyProcessor<Beeps::FileIn>, klass);
|
19
|
+
}
|
20
|
+
|
21
|
+
static
|
22
|
+
VALUE set_path(VALUE self, VALUE path)
|
23
|
+
{
|
24
|
+
CHECK;
|
25
|
+
|
26
|
+
THIS->set_path(path.c_str());
|
27
|
+
return path;
|
28
|
+
}
|
29
|
+
|
30
|
+
static
|
31
|
+
VALUE get_path(VALUE self)
|
32
|
+
{
|
33
|
+
CHECK;
|
34
|
+
|
35
|
+
return value(THIS->path());
|
36
|
+
}
|
37
|
+
|
38
|
+
static
|
39
|
+
VALUE get_sample_rate(VALUE self)
|
40
|
+
{
|
41
|
+
CHECK;
|
42
|
+
|
43
|
+
return value(THIS->sample_rate());
|
44
|
+
}
|
45
|
+
|
46
|
+
static
|
47
|
+
VALUE get_nchannels(VALUE self)
|
48
|
+
{
|
49
|
+
CHECK;
|
50
|
+
|
51
|
+
return value(THIS->nchannels());
|
52
|
+
}
|
53
|
+
|
54
|
+
static
|
55
|
+
VALUE get_nsamples(VALUE self)
|
56
|
+
{
|
57
|
+
CHECK;
|
58
|
+
|
59
|
+
return value(THIS->nsamples());
|
18
60
|
}
|
19
61
|
|
20
62
|
static
|
21
|
-
VALUE
|
63
|
+
VALUE get_seconds(VALUE self)
|
22
64
|
{
|
23
|
-
|
65
|
+
CHECK;
|
24
66
|
|
25
|
-
|
26
|
-
return self;
|
67
|
+
return value(THIS->seconds());
|
27
68
|
}
|
28
69
|
|
29
70
|
|
@@ -36,7 +77,12 @@ Init_beeps_file_in ()
|
|
36
77
|
|
37
78
|
cFileIn = mBeeps.define_class("FileIn", Beeps::processor_class());
|
38
79
|
rb_define_alloc_func(cFileIn, alloc);
|
39
|
-
|
80
|
+
rb_define_method(cFileIn, "path=", RUBY_METHOD_FUNC(set_path), 1);
|
81
|
+
rb_define_method(cFileIn, "path", RUBY_METHOD_FUNC(get_path), 0);
|
82
|
+
rb_define_method(cFileIn, "sample_rate", RUBY_METHOD_FUNC(get_sample_rate), 0);
|
83
|
+
rb_define_method(cFileIn, "nchannels", RUBY_METHOD_FUNC(get_nchannels), 0);
|
84
|
+
rb_define_method(cFileIn, "nsamples", RUBY_METHOD_FUNC(get_nsamples), 0);
|
85
|
+
rb_define_method(cFileIn, "seconds", RUBY_METHOD_FUNC(get_seconds), 0);
|
40
86
|
}
|
41
87
|
|
42
88
|
|
@@ -0,0 +1,64 @@
|
|
1
|
+
#include "beeps/ruby/filter.h"
|
2
|
+
|
3
|
+
|
4
|
+
#include "beeps/ruby/processor.h"
|
5
|
+
#include "defs.h"
|
6
|
+
|
7
|
+
|
8
|
+
RUCY_DEFINE_WRAPPER_VALUE_FROM_TO(Beeps::Gain)
|
9
|
+
|
10
|
+
#define THIS to<Beeps::Gain*>(self)
|
11
|
+
|
12
|
+
#define CHECK RUCY_CHECK_OBJ(Beeps::Gain, self)
|
13
|
+
|
14
|
+
|
15
|
+
static
|
16
|
+
VALUE alloc(VALUE klass)
|
17
|
+
{
|
18
|
+
return value(new Beeps::RubyProcessor<Beeps::Gain>, klass);
|
19
|
+
}
|
20
|
+
|
21
|
+
static
|
22
|
+
VALUE set_gain(VALUE self, VALUE gain)
|
23
|
+
{
|
24
|
+
CHECK;
|
25
|
+
|
26
|
+
THIS->set_gain(to<float>(gain));
|
27
|
+
return gain;
|
28
|
+
}
|
29
|
+
|
30
|
+
static
|
31
|
+
VALUE get_gain(VALUE self)
|
32
|
+
{
|
33
|
+
CHECK;
|
34
|
+
|
35
|
+
return value(THIS->gain());
|
36
|
+
}
|
37
|
+
|
38
|
+
|
39
|
+
static Class cGain;
|
40
|
+
|
41
|
+
void
|
42
|
+
Init_beeps_gain ()
|
43
|
+
{
|
44
|
+
Module mBeeps = rb_define_module("Beeps");
|
45
|
+
|
46
|
+
cGain = mBeeps.define_class("Gain", Beeps::processor_class());
|
47
|
+
rb_define_alloc_func(cGain, alloc);
|
48
|
+
rb_define_method(cGain, "gain=", RUBY_METHOD_FUNC(set_gain), 1);
|
49
|
+
rb_define_method(cGain, "gain", RUBY_METHOD_FUNC(get_gain), 0);
|
50
|
+
}
|
51
|
+
|
52
|
+
|
53
|
+
namespace Beeps
|
54
|
+
{
|
55
|
+
|
56
|
+
|
57
|
+
Class
|
58
|
+
gain_class ()
|
59
|
+
{
|
60
|
+
return cGain;
|
61
|
+
}
|
62
|
+
|
63
|
+
|
64
|
+
}// Beeps
|
@@ -0,0 +1,83 @@
|
|
1
|
+
#include "beeps/ruby/generator.h"
|
2
|
+
|
3
|
+
|
4
|
+
#include "beeps/ruby/processor.h"
|
5
|
+
#include "defs.h"
|
6
|
+
|
7
|
+
|
8
|
+
RUCY_DEFINE_WRAPPER_VALUE_FROM_TO(Beeps::MicIn)
|
9
|
+
|
10
|
+
#define THIS to<Beeps::MicIn*>(self)
|
11
|
+
|
12
|
+
#define CHECK RUCY_CHECK_OBJ(Beeps::MicIn, self)
|
13
|
+
|
14
|
+
|
15
|
+
static
|
16
|
+
VALUE alloc(VALUE klass)
|
17
|
+
{
|
18
|
+
return value(new Beeps::RubyProcessor<Beeps::MicIn>, klass);
|
19
|
+
}
|
20
|
+
|
21
|
+
static
|
22
|
+
VALUE start(VALUE self)
|
23
|
+
{
|
24
|
+
CHECK;
|
25
|
+
|
26
|
+
THIS->start();
|
27
|
+
return self;
|
28
|
+
}
|
29
|
+
|
30
|
+
static
|
31
|
+
VALUE stop(VALUE self)
|
32
|
+
{
|
33
|
+
CHECK;
|
34
|
+
|
35
|
+
THIS->stop();
|
36
|
+
return self;
|
37
|
+
}
|
38
|
+
|
39
|
+
static
|
40
|
+
VALUE get_sample_rate(VALUE self)
|
41
|
+
{
|
42
|
+
CHECK;
|
43
|
+
|
44
|
+
return value(THIS->sample_rate());
|
45
|
+
}
|
46
|
+
|
47
|
+
static
|
48
|
+
VALUE get_nchannels(VALUE self)
|
49
|
+
{
|
50
|
+
CHECK;
|
51
|
+
|
52
|
+
return value(THIS->nchannels());
|
53
|
+
}
|
54
|
+
|
55
|
+
|
56
|
+
static Class cMicIn;
|
57
|
+
|
58
|
+
void
|
59
|
+
Init_beeps_mic_in ()
|
60
|
+
{
|
61
|
+
Module mBeeps = rb_define_module("Beeps");
|
62
|
+
|
63
|
+
cMicIn = mBeeps.define_class("MicIn", Beeps::processor_class());
|
64
|
+
rb_define_alloc_func(cMicIn, alloc);
|
65
|
+
rb_define_method(cMicIn, "start", RUBY_METHOD_FUNC(start), 0);
|
66
|
+
rb_define_method(cMicIn, "stop", RUBY_METHOD_FUNC(stop), 0);
|
67
|
+
rb_define_method(cMicIn, "sample_rate", RUBY_METHOD_FUNC(get_sample_rate), 0);
|
68
|
+
rb_define_method(cMicIn, "nchannels", RUBY_METHOD_FUNC(get_nchannels), 0);
|
69
|
+
}
|
70
|
+
|
71
|
+
|
72
|
+
namespace Beeps
|
73
|
+
{
|
74
|
+
|
75
|
+
|
76
|
+
Class
|
77
|
+
mic_in_class ()
|
78
|
+
{
|
79
|
+
return cMicIn;
|
80
|
+
}
|
81
|
+
|
82
|
+
|
83
|
+
}// Beeps
|
data/.doc/ext/beeps/native.cpp
CHANGED
@@ -4,13 +4,19 @@
|
|
4
4
|
void Init_beeps ();
|
5
5
|
void Init_beeps_exception ();
|
6
6
|
|
7
|
+
void Init_beeps_sound ();
|
8
|
+
void Init_beeps_sound_player ();
|
7
9
|
void Init_beeps_processor ();
|
8
|
-
|
9
|
-
void
|
10
|
-
void Init_beeps_sawtooth_wave ();
|
10
|
+
|
11
|
+
void Init_beeps_oscillator ();
|
11
12
|
void Init_beeps_file_in ();
|
13
|
+
void Init_beeps_mic_in ();
|
12
14
|
|
13
|
-
void
|
15
|
+
void Init_beeps_gain ();
|
16
|
+
void Init_beeps_adsr ();
|
17
|
+
void Init_beeps_time_stretch ();
|
18
|
+
void Init_beeps_pitch_shift ();
|
19
|
+
void Init_beeps_analyser ();
|
14
20
|
|
15
21
|
|
16
22
|
extern "C" void
|
@@ -27,13 +33,19 @@ extern "C" void
|
|
27
33
|
Init_beeps();
|
28
34
|
Init_beeps_exception();
|
29
35
|
|
36
|
+
Init_beeps_sound();
|
37
|
+
Init_beeps_sound_player();
|
30
38
|
Init_beeps_processor();
|
31
|
-
|
32
|
-
|
33
|
-
Init_beeps_sawtooth_wave();
|
39
|
+
|
40
|
+
Init_beeps_oscillator();
|
34
41
|
Init_beeps_file_in();
|
42
|
+
Init_beeps_mic_in();
|
35
43
|
|
36
|
-
|
44
|
+
Init_beeps_gain();
|
45
|
+
Init_beeps_adsr();
|
46
|
+
Init_beeps_time_stretch();
|
47
|
+
Init_beeps_pitch_shift();
|
48
|
+
Init_beeps_analyser();
|
37
49
|
|
38
50
|
RUCY_CATCH
|
39
51
|
}
|
@@ -0,0 +1,88 @@
|
|
1
|
+
#include "beeps/ruby/generator.h"
|
2
|
+
|
3
|
+
|
4
|
+
#include "beeps/ruby/processor.h"
|
5
|
+
#include "defs.h"
|
6
|
+
|
7
|
+
|
8
|
+
RUCY_DEFINE_WRAPPER_VALUE_FROM_TO(Beeps::Oscillator)
|
9
|
+
|
10
|
+
#define THIS to<Beeps::Oscillator*>(self)
|
11
|
+
|
12
|
+
#define CHECK RUCY_CHECK_OBJ(Beeps::Oscillator, self)
|
13
|
+
|
14
|
+
|
15
|
+
static
|
16
|
+
VALUE alloc(VALUE klass)
|
17
|
+
{
|
18
|
+
return value(new Beeps::RubyProcessor<Beeps::Oscillator>, klass);
|
19
|
+
}
|
20
|
+
|
21
|
+
static
|
22
|
+
VALUE set_type(VALUE self, VALUE type)
|
23
|
+
{
|
24
|
+
CHECK;
|
25
|
+
|
26
|
+
THIS->set_type((Beeps::Oscillator::Type) to<uint>(type));
|
27
|
+
return type;
|
28
|
+
}
|
29
|
+
|
30
|
+
static
|
31
|
+
VALUE get_type(VALUE self)
|
32
|
+
{
|
33
|
+
CHECK;
|
34
|
+
|
35
|
+
return value(THIS->type());
|
36
|
+
}
|
37
|
+
|
38
|
+
static
|
39
|
+
VALUE set_frequency(VALUE self, VALUE frequency)
|
40
|
+
{
|
41
|
+
CHECK;
|
42
|
+
|
43
|
+
THIS->set_frequency(to<float>(frequency));
|
44
|
+
return frequency;
|
45
|
+
}
|
46
|
+
|
47
|
+
static
|
48
|
+
VALUE get_frequency(VALUE self)
|
49
|
+
{
|
50
|
+
CHECK;
|
51
|
+
|
52
|
+
return value(THIS->frequency());
|
53
|
+
}
|
54
|
+
|
55
|
+
|
56
|
+
static Class cOscillator;
|
57
|
+
|
58
|
+
void
|
59
|
+
Init_beeps_oscillator ()
|
60
|
+
{
|
61
|
+
Module mBeeps = rb_define_module("Beeps");
|
62
|
+
|
63
|
+
cOscillator = mBeeps.define_class("Oscillator", Beeps::processor_class());
|
64
|
+
rb_define_alloc_func(cOscillator, alloc);
|
65
|
+
rb_define_method(cOscillator, "type=", RUBY_METHOD_FUNC(set_type), 1);
|
66
|
+
rb_define_method(cOscillator, "type", RUBY_METHOD_FUNC(get_type), 0);
|
67
|
+
rb_define_method(cOscillator, "frequency=", RUBY_METHOD_FUNC(set_frequency), 1);
|
68
|
+
rb_define_method(cOscillator, "frequency", RUBY_METHOD_FUNC(get_frequency), 0);
|
69
|
+
cOscillator.define_const("NONE", Beeps::Oscillator::NONE);
|
70
|
+
cOscillator.define_const("SINE", Beeps::Oscillator::SINE);
|
71
|
+
cOscillator.define_const("TRIANGLE", Beeps::Oscillator::TRIANGLE);
|
72
|
+
cOscillator.define_const("SQUARE", Beeps::Oscillator::SQUARE);
|
73
|
+
cOscillator.define_const("SAWTOOTH", Beeps::Oscillator::SAWTOOTH);
|
74
|
+
}
|
75
|
+
|
76
|
+
|
77
|
+
namespace Beeps
|
78
|
+
{
|
79
|
+
|
80
|
+
|
81
|
+
Class
|
82
|
+
oscillator_class ()
|
83
|
+
{
|
84
|
+
return cOscillator;
|
85
|
+
}
|
86
|
+
|
87
|
+
|
88
|
+
}// Beeps
|