beeps 0.3.6 → 0.3.7
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/beeps.cpp +7 -0
- data/.doc/ext/beeps/high_pass.cpp +63 -0
- data/.doc/ext/beeps/low_pass.cpp +63 -0
- data/.doc/ext/beeps/native.cpp +8 -0
- data/.doc/ext/beeps/oscillator.cpp +87 -10
- data/.doc/ext/beeps/processor.cpp +14 -1
- data/.doc/ext/beeps/reverb.cpp +99 -0
- data/.doc/ext/beeps/signals.cpp +128 -0
- data/ChangeLog.md +24 -0
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/beeps.gemspec +2 -2
- data/ext/beeps/beeps.cpp +8 -0
- data/ext/beeps/high_pass.cpp +66 -0
- data/ext/beeps/low_pass.cpp +66 -0
- data/ext/beeps/native.cpp +8 -0
- data/ext/beeps/oscillator.cpp +95 -12
- data/ext/beeps/processor.cpp +15 -1
- data/ext/beeps/reverb.cpp +106 -0
- data/ext/beeps/signals.cpp +136 -0
- data/include/beeps/beeps.h +2 -2
- data/include/beeps/defs.h +3 -0
- data/include/beeps/filter.h +118 -17
- data/include/beeps/generator.h +50 -17
- data/include/beeps/processor.h +23 -6
- data/include/beeps/ruby/filter.h +33 -0
- data/include/beeps/ruby/signals.h +40 -0
- data/include/beeps/signals.h +1 -1
- data/lib/beeps/processor.rb +46 -1
- data/lib/beeps/signals.rb +19 -0
- data/lib/beeps.rb +1 -0
- data/src/analyser.cpp +34 -37
- data/src/beeps.cpp +7 -6
- data/src/envelope.cpp +60 -46
- data/src/file_in.cpp +6 -6
- data/src/gain.cpp +5 -5
- data/src/high_pass.cpp +57 -0
- data/src/low_pass.cpp +57 -0
- data/src/mic_in.cpp +16 -14
- data/src/mixer.cpp +38 -20
- data/src/oscillator.cpp +260 -168
- data/src/pitch_shift.cpp +6 -6
- data/src/processor.cpp +118 -11
- data/src/processor.h +8 -0
- data/src/reverb.cpp +124 -0
- data/src/sequencer.cpp +18 -14
- data/src/signals.cpp +264 -106
- data/src/signals.h +28 -89
- data/src/sound.cpp +28 -20
- data/src/time_stretch.cpp +6 -6
- data/src/win32/signals.cpp +8 -7
- data/src/x_pass.h +51 -0
- data/test/helper.rb +14 -0
- data/test/test_analyser.rb +26 -0
- data/test/test_envelope.rb +55 -0
- data/test/test_file_in.rb +22 -1
- data/test/test_gain.rb +28 -0
- data/test/test_high_pass.rb +41 -0
- data/test/test_low_pass.rb +41 -0
- data/test/test_mixer.rb +63 -0
- data/test/test_oscillator.rb +58 -0
- data/test/test_pitch_shift.rb +32 -0
- data/test/test_processor.rb +7 -0
- data/test/test_signals.rb +60 -0
- data/test/test_time_stretch.rb +36 -0
- metadata +48 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da80687e0b8f8943386ad2b822947ce6b25982ebe35c7eaaced3447baed524f5
|
4
|
+
data.tar.gz: bbc943dc74223cea8f78182fa01c6ae4f99f8f084aa168b1b5e6544e1d57f668
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e01e5556af238432d614c3c22166f0854d3564b9c4f6dbb954df89e25b277654b9146aaec68f7a7fa89beebf744bdcf3c254152df19e342746210b48ec085c1
|
7
|
+
data.tar.gz: 59273b85ece4e4031a7a4b8667e4efc5bb281ca7208de7c8335ecdfbec8631f8bd6d9f08900781d39ddc0766c6643c5e64d9feeecf27ae3e4d0f85d16345b7da
|
data/.doc/ext/beeps/beeps.cpp
CHANGED
@@ -19,6 +19,12 @@ VALUE fin(VALUE self)
|
|
19
19
|
return self;
|
20
20
|
}
|
21
21
|
|
22
|
+
static
|
23
|
+
VALUE get_sample_rate(VALUE self)
|
24
|
+
{
|
25
|
+
return value(Beeps::sample_rate());
|
26
|
+
}
|
27
|
+
|
22
28
|
static
|
23
29
|
VALUE process_streams(VALUE self)
|
24
30
|
{
|
@@ -35,6 +41,7 @@ Init_beeps ()
|
|
35
41
|
mBeeps = rb_define_module("Beeps");
|
36
42
|
mBeeps.define_singleton_method("init!", init);
|
37
43
|
mBeeps.define_singleton_method("fin!", fin);
|
44
|
+
rb_define_singleton_method(mBeeps, "sample_rate", RUBY_METHOD_FUNC(get_sample_rate), 0);
|
38
45
|
mBeeps.define_singleton_method("process_streams!", process_streams);
|
39
46
|
}
|
40
47
|
|
@@ -0,0 +1,63 @@
|
|
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_EXPORT, Beeps::HighPass)
|
9
|
+
|
10
|
+
#define THIS to<Beeps::HighPass*>(self)
|
11
|
+
|
12
|
+
#define CHECK RUCY_CHECK_OBJ(Beeps::HighPass, self)
|
13
|
+
|
14
|
+
|
15
|
+
static
|
16
|
+
VALUE alloc(VALUE klass)
|
17
|
+
{
|
18
|
+
return value(new Beeps::RubyProcessor<Beeps::HighPass>, klass);
|
19
|
+
}
|
20
|
+
|
21
|
+
static
|
22
|
+
VALUE set_cutoff_frequency(VALUE self, VALUE frequency)
|
23
|
+
{
|
24
|
+
CHECK;
|
25
|
+
|
26
|
+
THIS->set_cutoff_frequency(to<float>(frequency));
|
27
|
+
}
|
28
|
+
|
29
|
+
static
|
30
|
+
VALUE get_cutoff_frequency(VALUE self)
|
31
|
+
{
|
32
|
+
CHECK;
|
33
|
+
|
34
|
+
return value(THIS->cutoff_frequency());
|
35
|
+
}
|
36
|
+
|
37
|
+
|
38
|
+
static Class cHighPass;
|
39
|
+
|
40
|
+
void
|
41
|
+
Init_beeps_high_pass ()
|
42
|
+
{
|
43
|
+
Module mBeeps = rb_define_module("Beeps");
|
44
|
+
|
45
|
+
cHighPass = mBeeps.define_class("HighPass", Beeps::processor_class());
|
46
|
+
rb_define_alloc_func(cHighPass, alloc);
|
47
|
+
rb_define_method(cHighPass, "cutoff_frequency=", RUBY_METHOD_FUNC(set_cutoff_frequency), 1);
|
48
|
+
rb_define_method(cHighPass, "cutoff_frequency", RUBY_METHOD_FUNC(get_cutoff_frequency), 0);
|
49
|
+
}
|
50
|
+
|
51
|
+
|
52
|
+
namespace Beeps
|
53
|
+
{
|
54
|
+
|
55
|
+
|
56
|
+
Class
|
57
|
+
high_pass_class ()
|
58
|
+
{
|
59
|
+
return cHighPass;
|
60
|
+
}
|
61
|
+
|
62
|
+
|
63
|
+
}// Beeps
|
@@ -0,0 +1,63 @@
|
|
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_EXPORT, Beeps::LowPass)
|
9
|
+
|
10
|
+
#define THIS to<Beeps::LowPass*>(self)
|
11
|
+
|
12
|
+
#define CHECK RUCY_CHECK_OBJ(Beeps::LowPass, self)
|
13
|
+
|
14
|
+
|
15
|
+
static
|
16
|
+
VALUE alloc(VALUE klass)
|
17
|
+
{
|
18
|
+
return value(new Beeps::RubyProcessor<Beeps::LowPass>, klass);
|
19
|
+
}
|
20
|
+
|
21
|
+
static
|
22
|
+
VALUE set_cutoff_frequency(VALUE self, VALUE frequency)
|
23
|
+
{
|
24
|
+
CHECK;
|
25
|
+
|
26
|
+
THIS->set_cutoff_frequency(to<float>(frequency));
|
27
|
+
}
|
28
|
+
|
29
|
+
static
|
30
|
+
VALUE get_cutoff_frequency(VALUE self)
|
31
|
+
{
|
32
|
+
CHECK;
|
33
|
+
|
34
|
+
return value(THIS->cutoff_frequency());
|
35
|
+
}
|
36
|
+
|
37
|
+
|
38
|
+
static Class cLowPass;
|
39
|
+
|
40
|
+
void
|
41
|
+
Init_beeps_low_pass ()
|
42
|
+
{
|
43
|
+
Module mBeeps = rb_define_module("Beeps");
|
44
|
+
|
45
|
+
cLowPass = mBeeps.define_class("LowPass", Beeps::processor_class());
|
46
|
+
rb_define_alloc_func(cLowPass, alloc);
|
47
|
+
rb_define_method(cLowPass, "cutoff_frequency=", RUBY_METHOD_FUNC(set_cutoff_frequency), 1);
|
48
|
+
rb_define_method(cLowPass, "cutoff_frequency", RUBY_METHOD_FUNC(get_cutoff_frequency), 0);
|
49
|
+
}
|
50
|
+
|
51
|
+
|
52
|
+
namespace Beeps
|
53
|
+
{
|
54
|
+
|
55
|
+
|
56
|
+
Class
|
57
|
+
low_pass_class ()
|
58
|
+
{
|
59
|
+
return cLowPass;
|
60
|
+
}
|
61
|
+
|
62
|
+
|
63
|
+
}// Beeps
|
data/.doc/ext/beeps/native.cpp
CHANGED
@@ -4,6 +4,7 @@
|
|
4
4
|
void Init_beeps ();
|
5
5
|
void Init_beeps_exception ();
|
6
6
|
|
7
|
+
void Init_beeps_signals ();
|
7
8
|
void Init_beeps_sound ();
|
8
9
|
void Init_beeps_sound_player ();
|
9
10
|
void Init_beeps_processor ();
|
@@ -16,6 +17,9 @@ void Init_beeps_mic_in ();
|
|
16
17
|
void Init_beeps_gain ();
|
17
18
|
void Init_beeps_mixer ();
|
18
19
|
void Init_beeps_envelope ();
|
20
|
+
void Init_beeps_low_pass ();
|
21
|
+
void Init_beeps_high_pass ();
|
22
|
+
void Init_beeps_reverb ();
|
19
23
|
void Init_beeps_time_stretch ();
|
20
24
|
void Init_beeps_pitch_shift ();
|
21
25
|
void Init_beeps_analyser ();
|
@@ -35,6 +39,7 @@ extern "C" void
|
|
35
39
|
Init_beeps();
|
36
40
|
Init_beeps_exception();
|
37
41
|
|
42
|
+
Init_beeps_signals();
|
38
43
|
Init_beeps_sound();
|
39
44
|
Init_beeps_sound_player();
|
40
45
|
Init_beeps_processor();
|
@@ -47,6 +52,9 @@ extern "C" void
|
|
47
52
|
Init_beeps_gain();
|
48
53
|
Init_beeps_mixer();
|
49
54
|
Init_beeps_envelope();
|
55
|
+
Init_beeps_low_pass();
|
56
|
+
Init_beeps_high_pass();
|
57
|
+
Init_beeps_reverb();
|
50
58
|
Init_beeps_time_stretch();
|
51
59
|
Init_beeps_pitch_shift();
|
52
60
|
Init_beeps_analyser();
|
@@ -43,12 +43,12 @@ VALUE set_samples(VALUE self, VALUE samples)
|
|
43
43
|
Value* array = samples.as_array();
|
44
44
|
size_t size = samples.size();
|
45
45
|
|
46
|
-
std::vector<
|
47
|
-
|
46
|
+
std::vector<Beeps::Sample> data;
|
47
|
+
data.reserve(size);
|
48
48
|
for (size_t i = 0; i < size; ++i)
|
49
|
-
|
49
|
+
data.push_back(to<Beeps::Sample>(array[i]));
|
50
50
|
|
51
|
-
THIS->set_samples(&
|
51
|
+
THIS->set_samples(&data[0], data.size());
|
52
52
|
}
|
53
53
|
|
54
54
|
static
|
@@ -56,13 +56,13 @@ VALUE each_sample(VALUE self)
|
|
56
56
|
{
|
57
57
|
CHECK;
|
58
58
|
|
59
|
-
const
|
60
|
-
size_t size
|
61
|
-
if (!
|
59
|
+
const Beeps::Sample* samples = THIS->samples();
|
60
|
+
size_t size = THIS->nsamples();
|
61
|
+
if (!samples || size == 0) return Qnil;
|
62
62
|
|
63
63
|
Value ret;
|
64
64
|
for (size_t i = 0; i < size; ++i)
|
65
|
-
ret = rb_yield(value(
|
65
|
+
ret = rb_yield(value((float) samples[i]));
|
66
66
|
return ret;
|
67
67
|
}
|
68
68
|
|
@@ -71,7 +71,11 @@ VALUE set_frequency(VALUE self, VALUE frequency)
|
|
71
71
|
{
|
72
72
|
CHECK;
|
73
73
|
|
74
|
-
|
74
|
+
if (frequency.is_a(Beeps::processor_class()))
|
75
|
+
THIS->set_frequency(to<Beeps::Processor*>(frequency));
|
76
|
+
else
|
77
|
+
THIS->set_frequency(to<float>(frequency));
|
78
|
+
|
75
79
|
return frequency;
|
76
80
|
}
|
77
81
|
|
@@ -88,7 +92,11 @@ VALUE set_phase(VALUE self, VALUE phase)
|
|
88
92
|
{
|
89
93
|
CHECK;
|
90
94
|
|
91
|
-
|
95
|
+
if (phase.is_a(Beeps::processor_class()))
|
96
|
+
THIS->set_phase(to<Beeps::Processor*>(phase));
|
97
|
+
else
|
98
|
+
THIS->set_phase(to<float>(phase));
|
99
|
+
|
92
100
|
return phase;
|
93
101
|
}
|
94
102
|
|
@@ -100,6 +108,69 @@ VALUE get_phase(VALUE self)
|
|
100
108
|
return value(THIS->phase());
|
101
109
|
}
|
102
110
|
|
111
|
+
static
|
112
|
+
VALUE set_gain(VALUE self, VALUE gain)
|
113
|
+
{
|
114
|
+
CHECK;
|
115
|
+
|
116
|
+
if (gain.is_a(Beeps::processor_class()))
|
117
|
+
THIS->set_gain(to<Beeps::Processor*>(gain));
|
118
|
+
else
|
119
|
+
THIS->set_gain(to<float>(gain));
|
120
|
+
|
121
|
+
return gain;
|
122
|
+
}
|
123
|
+
|
124
|
+
static
|
125
|
+
VALUE get_gain(VALUE self)
|
126
|
+
{
|
127
|
+
CHECK;
|
128
|
+
|
129
|
+
return value(THIS->gain());
|
130
|
+
}
|
131
|
+
|
132
|
+
static
|
133
|
+
VALUE set_offset(VALUE self, VALUE offset)
|
134
|
+
{
|
135
|
+
CHECK;
|
136
|
+
|
137
|
+
if (offset.is_a(Beeps::processor_class()))
|
138
|
+
THIS->set_offset(to<Beeps::Processor*>(offset));
|
139
|
+
else
|
140
|
+
THIS->set_offset(to<float>(offset));
|
141
|
+
|
142
|
+
return offset;
|
143
|
+
}
|
144
|
+
|
145
|
+
static
|
146
|
+
VALUE get_offset(VALUE self)
|
147
|
+
{
|
148
|
+
CHECK;
|
149
|
+
|
150
|
+
return value(THIS->offset());
|
151
|
+
}
|
152
|
+
|
153
|
+
static
|
154
|
+
VALUE set_duty(VALUE self, VALUE duty)
|
155
|
+
{
|
156
|
+
CHECK;
|
157
|
+
|
158
|
+
if (duty.is_a(Beeps::processor_class()))
|
159
|
+
THIS->set_duty(to<Beeps::Processor*>(duty));
|
160
|
+
else
|
161
|
+
THIS->set_duty(to<float>(duty));
|
162
|
+
|
163
|
+
return duty;
|
164
|
+
}
|
165
|
+
|
166
|
+
static
|
167
|
+
VALUE get_duty(VALUE self)
|
168
|
+
{
|
169
|
+
CHECK;
|
170
|
+
|
171
|
+
return value(THIS->duty());
|
172
|
+
}
|
173
|
+
|
103
174
|
|
104
175
|
static Class cOscillator;
|
105
176
|
|
@@ -118,6 +189,12 @@ Init_beeps_oscillator ()
|
|
118
189
|
rb_define_method(cOscillator, "frequency", RUBY_METHOD_FUNC(get_frequency), 0);
|
119
190
|
rb_define_method(cOscillator, "phase=", RUBY_METHOD_FUNC(set_phase), 1);
|
120
191
|
rb_define_method(cOscillator, "phase", RUBY_METHOD_FUNC(get_phase), 0);
|
192
|
+
rb_define_method(cOscillator, "gain=", RUBY_METHOD_FUNC(set_gain), 1);
|
193
|
+
rb_define_method(cOscillator, "gain", RUBY_METHOD_FUNC(get_gain), 0);
|
194
|
+
rb_define_method(cOscillator, "offset=", RUBY_METHOD_FUNC(set_offset), 1);
|
195
|
+
rb_define_method(cOscillator, "offset", RUBY_METHOD_FUNC(get_offset), 0);
|
196
|
+
rb_define_method(cOscillator, "duty=", RUBY_METHOD_FUNC(set_duty), 1);
|
197
|
+
rb_define_method(cOscillator, "duty", RUBY_METHOD_FUNC(get_duty), 0);
|
121
198
|
|
122
199
|
cOscillator.define_const("TYPE_NONE", Beeps::Oscillator::TYPE_NONE);
|
123
200
|
cOscillator.define_const("SINE", Beeps::Oscillator::SINE);
|
@@ -1,6 +1,7 @@
|
|
1
1
|
#include "beeps/ruby/processor.h"
|
2
2
|
|
3
3
|
|
4
|
+
#include "beeps/ruby/signals.h"
|
4
5
|
#include "beeps/exception.h"
|
5
6
|
#include "defs.h"
|
6
7
|
|
@@ -17,7 +18,7 @@ RUCY_DEFINE_WRAPPER_VALUE_FROM_TO(BEEPS_EXPORT, Beeps::Processor)
|
|
17
18
|
static
|
18
19
|
VALUE alloc(VALUE klass)
|
19
20
|
{
|
20
|
-
Beeps::beeps_error(__FILE__, __LINE__);
|
21
|
+
Beeps::beeps_error(__FILE__, __LINE__, "can not instantiate Processor class.");
|
21
22
|
}
|
22
23
|
|
23
24
|
static
|
@@ -53,6 +54,16 @@ VALUE on_start(VALUE self)
|
|
53
54
|
CALL(on_start());
|
54
55
|
}
|
55
56
|
|
57
|
+
static
|
58
|
+
VALUE get_signals(VALUE self, VALUE processor, VALUE seconds, VALUE nchannels, VALUE sample_rate)
|
59
|
+
{
|
60
|
+
return value(Beeps::get_signals(
|
61
|
+
to<Beeps::Processor*>(processor),
|
62
|
+
to<float> (seconds),
|
63
|
+
to<uint> (nchannels),
|
64
|
+
to<double> (sample_rate)));
|
65
|
+
}
|
66
|
+
|
56
67
|
|
57
68
|
static Class cProcessor;
|
58
69
|
|
@@ -67,6 +78,8 @@ Init_beeps_processor ()
|
|
67
78
|
rb_define_method(cProcessor, "input=", RUBY_METHOD_FUNC(set_input), 1);
|
68
79
|
rb_define_method(cProcessor, "input", RUBY_METHOD_FUNC(get_input), 0);
|
69
80
|
rb_define_method(cProcessor, "on_start", RUBY_METHOD_FUNC(on_start), 0);
|
81
|
+
|
82
|
+
cProcessor.define_singleton_method("get_signals!", get_signals);
|
70
83
|
}
|
71
84
|
|
72
85
|
|
@@ -0,0 +1,99 @@
|
|
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_EXPORT, Beeps::Reverb)
|
9
|
+
|
10
|
+
#define THIS to<Beeps::Reverb*>(self)
|
11
|
+
|
12
|
+
#define CHECK RUCY_CHECK_OBJ(Beeps::Reverb, self)
|
13
|
+
|
14
|
+
|
15
|
+
static
|
16
|
+
VALUE alloc(VALUE klass)
|
17
|
+
{
|
18
|
+
return value(new Beeps::RubyProcessor<Beeps::Reverb>, klass);
|
19
|
+
}
|
20
|
+
|
21
|
+
static
|
22
|
+
VALUE set_mix(VALUE self, VALUE mix)
|
23
|
+
{
|
24
|
+
CHECK;
|
25
|
+
|
26
|
+
THIS->set_mix(to<float>(mix));
|
27
|
+
}
|
28
|
+
|
29
|
+
static
|
30
|
+
VALUE get_mix(VALUE self)
|
31
|
+
{
|
32
|
+
CHECK;
|
33
|
+
|
34
|
+
return value(THIS->mix());
|
35
|
+
}
|
36
|
+
|
37
|
+
static
|
38
|
+
VALUE set_room_size(VALUE self, VALUE size)
|
39
|
+
{
|
40
|
+
CHECK;
|
41
|
+
|
42
|
+
THIS->set_room_size(to<float>(size));
|
43
|
+
}
|
44
|
+
|
45
|
+
static
|
46
|
+
VALUE get_room_size(VALUE self)
|
47
|
+
{
|
48
|
+
CHECK;
|
49
|
+
|
50
|
+
return value(THIS->room_size());
|
51
|
+
}
|
52
|
+
|
53
|
+
static
|
54
|
+
VALUE set_damping(VALUE self, VALUE damping)
|
55
|
+
{
|
56
|
+
CHECK;
|
57
|
+
|
58
|
+
THIS->set_damping(to<float>(damping));
|
59
|
+
}
|
60
|
+
|
61
|
+
static
|
62
|
+
VALUE get_damping(VALUE self)
|
63
|
+
{
|
64
|
+
CHECK;
|
65
|
+
|
66
|
+
return value(THIS->damping());
|
67
|
+
}
|
68
|
+
|
69
|
+
|
70
|
+
static Class cReverb;
|
71
|
+
|
72
|
+
void
|
73
|
+
Init_beeps_reverb ()
|
74
|
+
{
|
75
|
+
Module mBeeps = rb_define_module("Beeps");
|
76
|
+
|
77
|
+
cReverb = mBeeps.define_class("Reverb", Beeps::processor_class());
|
78
|
+
rb_define_alloc_func(cReverb, alloc);
|
79
|
+
rb_define_method(cReverb, "mix=", RUBY_METHOD_FUNC(set_mix), 1);
|
80
|
+
rb_define_method(cReverb, "mix", RUBY_METHOD_FUNC(get_mix), 0);
|
81
|
+
rb_define_method(cReverb, "room_size=", RUBY_METHOD_FUNC(set_room_size), 1);
|
82
|
+
rb_define_method(cReverb, "room_size", RUBY_METHOD_FUNC(get_room_size), 0);
|
83
|
+
rb_define_method(cReverb, "damping=", RUBY_METHOD_FUNC(set_damping), 1);
|
84
|
+
rb_define_method(cReverb, "damping", RUBY_METHOD_FUNC(get_damping), 0);
|
85
|
+
}
|
86
|
+
|
87
|
+
|
88
|
+
namespace Beeps
|
89
|
+
{
|
90
|
+
|
91
|
+
|
92
|
+
Class
|
93
|
+
reverb_class ()
|
94
|
+
{
|
95
|
+
return cReverb;
|
96
|
+
}
|
97
|
+
|
98
|
+
|
99
|
+
}// Beeps
|
@@ -0,0 +1,128 @@
|
|
1
|
+
#include "beeps/ruby/signals.h"
|
2
|
+
|
3
|
+
|
4
|
+
#include "defs.h"
|
5
|
+
|
6
|
+
|
7
|
+
RUCY_DEFINE_VALUE_FROM_TO(BEEPS_EXPORT, Beeps::Signals)
|
8
|
+
|
9
|
+
#define THIS to<Beeps::Signals*>(self)
|
10
|
+
|
11
|
+
#define CHECK RUCY_CHECK_OBJ(Beeps::Signals, self)
|
12
|
+
|
13
|
+
|
14
|
+
static
|
15
|
+
VALUE alloc(VALUE klass)
|
16
|
+
{
|
17
|
+
return new_type<Beeps::Signals>(klass);
|
18
|
+
}
|
19
|
+
|
20
|
+
static
|
21
|
+
VALUE initialize_copy(VALUE self, VALUE obj)
|
22
|
+
{
|
23
|
+
CHECK;
|
24
|
+
*THIS = to<Beeps::Signals*>(obj)->dup();
|
25
|
+
return self;
|
26
|
+
}
|
27
|
+
|
28
|
+
static
|
29
|
+
VALUE get_sample_rate(VALUE self)
|
30
|
+
{
|
31
|
+
CHECK;
|
32
|
+
|
33
|
+
return value(THIS->sample_rate());
|
34
|
+
}
|
35
|
+
|
36
|
+
static
|
37
|
+
VALUE get_nchannels(VALUE self)
|
38
|
+
{
|
39
|
+
CHECK;
|
40
|
+
|
41
|
+
return value(THIS->nchannels());
|
42
|
+
}
|
43
|
+
|
44
|
+
static
|
45
|
+
VALUE get_nsamples(VALUE self)
|
46
|
+
{
|
47
|
+
CHECK;
|
48
|
+
|
49
|
+
return value(THIS->nsamples());
|
50
|
+
}
|
51
|
+
|
52
|
+
static
|
53
|
+
VALUE get_capacity(VALUE self)
|
54
|
+
{
|
55
|
+
CHECK;
|
56
|
+
|
57
|
+
return value(THIS->capacity());
|
58
|
+
}
|
59
|
+
|
60
|
+
static
|
61
|
+
VALUE is_empty(VALUE self)
|
62
|
+
{
|
63
|
+
CHECK;
|
64
|
+
|
65
|
+
return value(THIS->empty());
|
66
|
+
}
|
67
|
+
|
68
|
+
static
|
69
|
+
VALUE each(VALUE self, VALUE channel_)
|
70
|
+
{
|
71
|
+
CHECK;
|
72
|
+
|
73
|
+
uint nchannels = THIS->nchannels();
|
74
|
+
uint nsamples = THIS->nsamples();
|
75
|
+
const auto* samples = THIS->samples();
|
76
|
+
|
77
|
+
if (channel_)
|
78
|
+
{
|
79
|
+
int channel = to<int>(channel_);
|
80
|
+
if (channel < 0)
|
81
|
+
argument_error(__FILE__, __LINE__);
|
82
|
+
if (channel >= nchannels)
|
83
|
+
argument_error(__FILE__, __LINE__);
|
84
|
+
|
85
|
+
const auto* p = samples + channel;
|
86
|
+
for (uint i = 0; i < nsamples; ++i, p += nchannels)
|
87
|
+
rb_yield(value(*p));
|
88
|
+
}
|
89
|
+
else
|
90
|
+
{
|
91
|
+
uint size = nsamples * nchannels;
|
92
|
+
for (uint i = 0; i < size; ++i)
|
93
|
+
rb_yield(value(samples[i]));
|
94
|
+
}
|
95
|
+
}
|
96
|
+
|
97
|
+
|
98
|
+
static Class cSignals;
|
99
|
+
|
100
|
+
void
|
101
|
+
Init_beeps_signals ()
|
102
|
+
{
|
103
|
+
Module mBeeps = rb_define_module("Beeps");
|
104
|
+
|
105
|
+
cSignals = rb_define_class_under(mBeeps, "Signals", rb_cObject);
|
106
|
+
rb_define_alloc_func(cSignals, alloc);
|
107
|
+
rb_define_private_method(cSignals, "initialize_copy", RUBY_METHOD_FUNC(initialize_copy), 1);
|
108
|
+
rb_define_method(cSignals, "sample_rate", RUBY_METHOD_FUNC(get_sample_rate), 0);
|
109
|
+
rb_define_method(cSignals, "nchannels", RUBY_METHOD_FUNC(get_nchannels), 0);
|
110
|
+
rb_define_method(cSignals, "nsamples", RUBY_METHOD_FUNC(get_nsamples), 0);
|
111
|
+
rb_define_method(cSignals, "capacity", RUBY_METHOD_FUNC(get_capacity), 0);
|
112
|
+
cSignals.define_method("empty?", is_empty);
|
113
|
+
cSignals.define_method("each!", each);
|
114
|
+
}
|
115
|
+
|
116
|
+
|
117
|
+
namespace Beeps
|
118
|
+
{
|
119
|
+
|
120
|
+
|
121
|
+
Class
|
122
|
+
signals_class ()
|
123
|
+
{
|
124
|
+
return cSignals;
|
125
|
+
}
|
126
|
+
|
127
|
+
|
128
|
+
}// Beeps
|
data/ChangeLog.md
CHANGED
@@ -1,6 +1,30 @@
|
|
1
1
|
# beeps ChangeLog
|
2
2
|
|
3
3
|
|
4
|
+
## [v0.3.7] - 2025-05-11
|
5
|
+
|
6
|
+
- Add LowPass and HighPass classes
|
7
|
+
- Add Reverb class
|
8
|
+
- Add Signals class for ruby extension
|
9
|
+
- Add Beeps.sample_rate()
|
10
|
+
- Add Processor.get_signals!() method
|
11
|
+
- Add Oscillator#gain, Oscillator#offset, and Oscillator#duty
|
12
|
+
- Add more tests for processors
|
13
|
+
|
14
|
+
- Update STK
|
15
|
+
- Processor has sub inputs
|
16
|
+
- Reimplement oscillators without STK wave generators
|
17
|
+
- Oscillator#frequency= can take another processor like low frequency oscillator for frequency modulation
|
18
|
+
- Oscillator: phase, gain, offset, and duty can also accept a processor as input
|
19
|
+
- Make process segment size variable based on the frequency of the sub-input
|
20
|
+
- Sequencer: Call set_updated()
|
21
|
+
|
22
|
+
- Refactor: hide Beeps::Frames class
|
23
|
+
|
24
|
+
- Fix the issue where the sound player with a streaming source does not stop when the envelope's note_off is called
|
25
|
+
- Fix crashes
|
26
|
+
|
27
|
+
|
4
28
|
## [v0.3.6] - 2025-04-08
|
5
29
|
|
6
30
|
- Update dependencies: xot, rucy
|
data/Rakefile
CHANGED
@@ -17,7 +17,7 @@ TESTS_ALONE = ['test/test_beeps_init.rb']
|
|
17
17
|
install_packages win32: %w[MINGW_PACKAGE_PREFIX-openal]
|
18
18
|
|
19
19
|
use_external_library 'https://github.com/thestk/stk',
|
20
|
-
tag: '
|
20
|
+
tag: '5.0.1',
|
21
21
|
incdirs: 'include',
|
22
22
|
srcdirs: 'src',
|
23
23
|
excludes: %w[stk/src/include Tcp Udp Socket Thread Mutex InetWv /Rt]
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.7
|
data/beeps.gemspec
CHANGED
@@ -25,8 +25,8 @@ Gem::Specification.new do |s|
|
|
25
25
|
s.platform = Gem::Platform::RUBY
|
26
26
|
s.required_ruby_version = '>= 3.0.0'
|
27
27
|
|
28
|
-
s.add_dependency 'xot', '~> 0.3.
|
29
|
-
s.add_dependency 'rucy', '~> 0.3.
|
28
|
+
s.add_dependency 'xot', '~> 0.3.7', '>= 0.3.7'
|
29
|
+
s.add_dependency 'rucy', '~> 0.3.7', '>= 0.3.7'
|
30
30
|
|
31
31
|
s.files = `git ls-files`.split $/
|
32
32
|
s.executables = s.files.grep(%r{^bin/}) {|f| File.basename f}
|
data/ext/beeps/beeps.cpp
CHANGED
@@ -21,6 +21,13 @@ RUCY_DEF0(fin)
|
|
21
21
|
}
|
22
22
|
RUCY_END
|
23
23
|
|
24
|
+
static
|
25
|
+
RUCY_DEF0(get_sample_rate)
|
26
|
+
{
|
27
|
+
return value(Beeps::sample_rate());
|
28
|
+
}
|
29
|
+
RUCY_END
|
30
|
+
|
24
31
|
static
|
25
32
|
RUCY_DEF0(process_streams)
|
26
33
|
{
|
@@ -38,6 +45,7 @@ Init_beeps ()
|
|
38
45
|
mBeeps = define_module("Beeps");
|
39
46
|
mBeeps.define_singleton_method("init!", init);
|
40
47
|
mBeeps.define_singleton_method("fin!", fin);
|
48
|
+
mBeeps.define_singleton_method("sample_rate", get_sample_rate);
|
41
49
|
mBeeps.define_singleton_method("process_streams!", process_streams);
|
42
50
|
}
|
43
51
|
|