beeps 0.3.8 → 0.3.10
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/analyser.cpp +2 -2
- data/.doc/ext/beeps/native.cpp +5 -5
- data/.doc/ext/beeps/oscillator.cpp +2 -2
- data/.doc/ext/beeps/sequencer.cpp +17 -0
- data/.doc/ext/beeps/sound.cpp +1 -1
- data/.doc/ext/beeps/text_in.cpp +63 -0
- data/.doc/ext/beeps/value.cpp +107 -0
- data/CLAUDE.md +24 -0
- data/ChangeLog.md +18 -0
- data/README.md +1 -0
- data/Rakefile +3 -1
- data/VERSION +1 -1
- data/beeps.gemspec +2 -2
- data/ext/beeps/analyser.cpp +2 -2
- data/ext/beeps/extconf.rb +10 -6
- data/ext/beeps/native.cpp +5 -5
- data/ext/beeps/oscillator.cpp +2 -2
- data/ext/beeps/sequencer.cpp +18 -0
- data/ext/beeps/sound.cpp +1 -1
- data/ext/beeps/text_in.cpp +66 -0
- data/ext/beeps/value.cpp +114 -0
- data/include/beeps/generator.h +121 -0
- data/include/beeps/ruby/generator.h +22 -0
- data/include/beeps/signals.h +2 -0
- data/lib/beeps/ext.rb +1 -1
- data/lib/beeps/processor.rb +56 -1
- data/src/osx/signals.h +23 -0
- data/src/osx/signals.mm +66 -15
- data/src/osx/text_in.mm +133 -0
- data/src/sdl/beeps.cpp +19 -0
- data/src/sdl/signals.cpp +18 -0
- data/src/sdl/text_in.cpp +61 -0
- data/src/sequencer.cpp +31 -16
- data/src/signals.cpp +104 -30
- data/src/signals.h +10 -4
- data/src/value.cpp +181 -0
- data/src/win32/text_in.cpp +62 -0
- data/test/test_oscillator.rb +2 -2
- data/test/test_sequencer.rb +25 -0
- data/test/test_value.rb +47 -0
- metadata +24 -18
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 83c3fb3d71043da5eaa1f4f6c9832442f68d9fb9ee765c1d19891306df2ca3da
|
|
4
|
+
data.tar.gz: 6f80df9fa3ada9ecf150708c9efaf090800044b38c3e694108bfcb2b766ef577
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a94142e5430d65b5d9539b2f9b9d5d92bf13b893cf77c9aa00a3bbe52ec5e3cdca78db410fe4400ee465f3c9d6124201046414059fbc32635540a024c10c0e8d
|
|
7
|
+
data.tar.gz: 9b1a87a0c216b7cee8afe2bfd2decabb7035c5723449c3f02876336e33cf5c2c36dff5c0f2e0c4e757e4278c3b89f93d51e8489b571893460b665a34dd37b792
|
data/.doc/ext/beeps/analyser.cpp
CHANGED
|
@@ -72,8 +72,8 @@ VALUE each_signal(VALUE self, VALUE nsamples_)
|
|
|
72
72
|
Value args(2, values);
|
|
73
73
|
for (uint i = start; i < nsamples; i += 2)
|
|
74
74
|
{
|
|
75
|
-
args
|
|
76
|
-
args
|
|
75
|
+
args.set(0, value(samples[i + 0]));
|
|
76
|
+
args.set(1, value(samples[i + 1]));
|
|
77
77
|
rb_yield(args);
|
|
78
78
|
}
|
|
79
79
|
break;
|
data/.doc/ext/beeps/native.cpp
CHANGED
|
@@ -9,10 +9,12 @@ void Init_beeps_sound ();
|
|
|
9
9
|
void Init_beeps_sound_player ();
|
|
10
10
|
void Init_beeps_processor ();
|
|
11
11
|
|
|
12
|
+
void Init_beeps_value ();
|
|
12
13
|
void Init_beeps_oscillator ();
|
|
13
14
|
void Init_beeps_sequencer ();
|
|
14
15
|
void Init_beeps_file_in ();
|
|
15
16
|
void Init_beeps_mic_in ();
|
|
17
|
+
void Init_beeps_text_in ();
|
|
16
18
|
|
|
17
19
|
void Init_beeps_gain ();
|
|
18
20
|
void Init_beeps_mixer ();
|
|
@@ -26,11 +28,7 @@ void Init_beeps_analyser ();
|
|
|
26
28
|
|
|
27
29
|
|
|
28
30
|
extern "C" void
|
|
29
|
-
|
|
30
|
-
Init_beeps_native ()
|
|
31
|
-
#else
|
|
32
|
-
Init_native ()
|
|
33
|
-
#endif
|
|
31
|
+
Init_beeps_ext ()
|
|
34
32
|
{
|
|
35
33
|
RUCY_TRY
|
|
36
34
|
|
|
@@ -44,10 +42,12 @@ extern "C" void
|
|
|
44
42
|
Init_beeps_sound_player();
|
|
45
43
|
Init_beeps_processor();
|
|
46
44
|
|
|
45
|
+
Init_beeps_value();
|
|
47
46
|
Init_beeps_oscillator();
|
|
48
47
|
Init_beeps_sequencer();
|
|
49
48
|
Init_beeps_file_in();
|
|
50
49
|
Init_beeps_mic_in();
|
|
50
|
+
Init_beeps_text_in();
|
|
51
51
|
|
|
52
52
|
Init_beeps_gain();
|
|
53
53
|
Init_beeps_mixer();
|
|
@@ -40,8 +40,8 @@ VALUE set_samples(VALUE self, VALUE samples)
|
|
|
40
40
|
{
|
|
41
41
|
CHECK;
|
|
42
42
|
|
|
43
|
-
Value* array = samples.as_array();
|
|
44
|
-
size_t size
|
|
43
|
+
const Value* array = samples.as_array();
|
|
44
|
+
size_t size = samples.size();
|
|
45
45
|
|
|
46
46
|
std::vector<Beeps::Sample> data;
|
|
47
47
|
data.reserve(size);
|
|
@@ -56,6 +56,22 @@ VALUE get_time_scale(VALUE self)
|
|
|
56
56
|
return value(THIS->time_scale());
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
+
static
|
|
60
|
+
VALUE each_note(VALUE self)
|
|
61
|
+
{
|
|
62
|
+
CHECK;
|
|
63
|
+
|
|
64
|
+
Value ret;
|
|
65
|
+
for (auto it = THIS->begin(), end = THIS->end(); it != end; ++it)
|
|
66
|
+
{
|
|
67
|
+
ret = rb_yield_values(3,
|
|
68
|
+
value(it->processor.get()),
|
|
69
|
+
value(it->offset),
|
|
70
|
+
value(it->duration));
|
|
71
|
+
}
|
|
72
|
+
return ret;
|
|
73
|
+
}
|
|
74
|
+
|
|
59
75
|
|
|
60
76
|
static Class cSequencer;
|
|
61
77
|
|
|
@@ -70,6 +86,7 @@ Init_beeps_sequencer ()
|
|
|
70
86
|
rb_define_method(cSequencer, "remove", RUBY_METHOD_FUNC(remove), 2);
|
|
71
87
|
//rb_define_method(cSequencer, "time_scale=", RUBY_METHOD_FUNC(set_time_scale), 1);
|
|
72
88
|
//rb_define_method(cSequencer, "time_scale", RUBY_METHOD_FUNC(get_time_scale), 0);
|
|
89
|
+
cSequencer.define_method("each_note!", each_note);
|
|
73
90
|
}
|
|
74
91
|
|
|
75
92
|
|
data/.doc/ext/beeps/sound.cpp
CHANGED
|
@@ -0,0 +1,63 @@
|
|
|
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_EXPORT, Beeps::TextIn)
|
|
9
|
+
|
|
10
|
+
#define THIS to<Beeps::TextIn*>(self)
|
|
11
|
+
|
|
12
|
+
#define CHECK RUCY_CHECK_OBJ(Beeps::TextIn, self)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
static
|
|
16
|
+
VALUE alloc(VALUE klass)
|
|
17
|
+
{
|
|
18
|
+
return value(new Beeps::RubyProcessor<Beeps::TextIn>, klass);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
static
|
|
22
|
+
VALUE synthesize(VALUE self, VALUE text)
|
|
23
|
+
{
|
|
24
|
+
CHECK;
|
|
25
|
+
|
|
26
|
+
THIS->synthesize(text.c_str());
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
static
|
|
30
|
+
VALUE get_sample_rate(VALUE self)
|
|
31
|
+
{
|
|
32
|
+
CHECK;
|
|
33
|
+
|
|
34
|
+
return value(THIS->sample_rate());
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
static Class cTextIn;
|
|
39
|
+
|
|
40
|
+
void
|
|
41
|
+
Init_beeps_text_in ()
|
|
42
|
+
{
|
|
43
|
+
Module mBeeps = rb_define_module("Beeps");
|
|
44
|
+
|
|
45
|
+
cTextIn = mBeeps.define_class("TextIn", Beeps::processor_class());
|
|
46
|
+
rb_define_alloc_func(cTextIn, alloc);
|
|
47
|
+
rb_define_method(cTextIn, "synthesize", RUBY_METHOD_FUNC(synthesize), 1);
|
|
48
|
+
rb_define_method(cTextIn, "sample_rate", RUBY_METHOD_FUNC(get_sample_rate), 0);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
namespace Beeps
|
|
53
|
+
{
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
Class
|
|
57
|
+
text_in_class ()
|
|
58
|
+
{
|
|
59
|
+
return cTextIn;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
}// Beeps
|
|
@@ -0,0 +1,107 @@
|
|
|
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_EXPORT, Beeps::Value)
|
|
9
|
+
|
|
10
|
+
#define THIS to<Beeps::Value*>(self)
|
|
11
|
+
|
|
12
|
+
#define CHECK RUCY_CHECK_OBJ(Beeps::Value, self)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
static
|
|
16
|
+
VALUE alloc(VALUE klass)
|
|
17
|
+
{
|
|
18
|
+
return value(new Beeps::RubyProcessor<Beeps::Value>, klass);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
static
|
|
22
|
+
VALUE set_type(VALUE self, VALUE type)
|
|
23
|
+
{
|
|
24
|
+
CHECK;
|
|
25
|
+
|
|
26
|
+
THIS->set_type((Beeps::Value::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_value(VALUE self, VALUE value)
|
|
40
|
+
{
|
|
41
|
+
CHECK;
|
|
42
|
+
|
|
43
|
+
THIS->set_value(to<float>(value));
|
|
44
|
+
return value;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
static
|
|
48
|
+
VALUE insert(VALUE self, VALUE value, VALUE time)
|
|
49
|
+
{
|
|
50
|
+
CHECK;
|
|
51
|
+
|
|
52
|
+
THIS->insert(to<float>(value), to<float>(time));
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
static
|
|
56
|
+
VALUE clear(VALUE self)
|
|
57
|
+
{
|
|
58
|
+
CHECK;
|
|
59
|
+
|
|
60
|
+
THIS->clear();
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
static
|
|
64
|
+
VALUE each_value(VALUE self)
|
|
65
|
+
{
|
|
66
|
+
CHECK;
|
|
67
|
+
|
|
68
|
+
Value ret;
|
|
69
|
+
for (auto it = THIS->begin(), end = THIS->end(); it != end; ++it)
|
|
70
|
+
ret = rb_yield_values(2, value(it->value), value(it->time));
|
|
71
|
+
return ret;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
static Class cValue;
|
|
76
|
+
|
|
77
|
+
void
|
|
78
|
+
Init_beeps_value ()
|
|
79
|
+
{
|
|
80
|
+
Module mBeeps = rb_define_module("Beeps");
|
|
81
|
+
|
|
82
|
+
cValue = mBeeps.define_class("Value", Beeps::processor_class());
|
|
83
|
+
rb_define_alloc_func(cValue, alloc);
|
|
84
|
+
rb_define_method(cValue, "type=", RUBY_METHOD_FUNC(set_type), 1);
|
|
85
|
+
rb_define_method(cValue, "type", RUBY_METHOD_FUNC(get_type), 0);
|
|
86
|
+
rb_define_method(cValue, "value=", RUBY_METHOD_FUNC(set_value), 1);
|
|
87
|
+
rb_define_method(cValue, "insert", RUBY_METHOD_FUNC(insert), 2);
|
|
88
|
+
rb_define_method(cValue, "clear", RUBY_METHOD_FUNC(clear), 0);
|
|
89
|
+
cValue.define_method("each_value!", each_value);
|
|
90
|
+
|
|
91
|
+
cValue.define_const("TYPE_NONE", Beeps::Value::TYPE_NONE);
|
|
92
|
+
cValue.define_const("LINEAR", Beeps::Value::LINEAR);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
namespace Beeps
|
|
97
|
+
{
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
Class
|
|
101
|
+
value_class ()
|
|
102
|
+
{
|
|
103
|
+
return cValue;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
}// Beeps
|
data/CLAUDE.md
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Beeps
|
|
2
|
+
|
|
3
|
+
Audio synthesis and playback library. Provides an audio processing chain with oscillators, filters, envelopes, and effects.
|
|
4
|
+
|
|
5
|
+
## Processor Chain
|
|
6
|
+
|
|
7
|
+
Connect processors with the `>>` operator:
|
|
8
|
+
```ruby
|
|
9
|
+
Beeps::Oscillator.new >> Beeps::Gain.new(gain: 0.5)
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## External Libraries
|
|
13
|
+
|
|
14
|
+
Automatically fetched and statically linked at build time:
|
|
15
|
+
- STK 5.0.1 — DSP toolkit
|
|
16
|
+
- AudioFile 1.1.1 — Audio file I/O
|
|
17
|
+
- r8brain-free-src 6.2 — Sample rate conversion
|
|
18
|
+
- signalsmith-stretch — Time stretching
|
|
19
|
+
|
|
20
|
+
## Platform Dependencies
|
|
21
|
+
|
|
22
|
+
- macOS: OpenAL, AVFoundation
|
|
23
|
+
- Windows: OpenAL, Media Foundation
|
|
24
|
+
- Linux: libopenal-dev
|
data/ChangeLog.md
CHANGED
|
@@ -1,6 +1,24 @@
|
|
|
1
1
|
# beeps ChangeLog
|
|
2
2
|
|
|
3
3
|
|
|
4
|
+
## [v0.3.10] - 2026-04-09
|
|
5
|
+
|
|
6
|
+
- Add Sequencer#each_note
|
|
7
|
+
- Add 'apt' for install_packages()
|
|
8
|
+
- Add Value processor for time-varying value generation
|
|
9
|
+
- Change C-Extension name from 'native.so' to 'beeps_ext.so'
|
|
10
|
+
- Update dependencies
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
## [v0.3.9] - 2025-07-06
|
|
14
|
+
|
|
15
|
+
- Add TextIn class
|
|
16
|
+
- Add Signals::full()
|
|
17
|
+
- Add Siangls_shift() and Signals_set_capacity()
|
|
18
|
+
- Add Signals_create() and Signals_append() for AVAudioPCMBuffer
|
|
19
|
+
- Add deepwiki badge
|
|
20
|
+
|
|
21
|
+
|
|
4
22
|
## [v0.3.8] - 2025-05-22
|
|
5
23
|
|
|
6
24
|
- The oscillator resets the frequency to 0.001 if it is set to 0
|
data/README.md
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
# Beeps - Plays beep sound
|
|
2
2
|
|
|
3
|
+
[](https://deepwiki.com/xord/beeps)
|
|
3
4
|

|
|
4
5
|

|
|
5
6
|

|
data/Rakefile
CHANGED
|
@@ -14,7 +14,9 @@ require 'beeps/extension'
|
|
|
14
14
|
EXTENSIONS = [Xot, Rucy, Beeps]
|
|
15
15
|
TESTS_ALONE = ['test/test_beeps_init.rb']
|
|
16
16
|
|
|
17
|
-
install_packages
|
|
17
|
+
install_packages(
|
|
18
|
+
mingw: %w[MINGW_PACKAGE_PREFIX-openal],
|
|
19
|
+
apt: %w[libopenal-dev])
|
|
18
20
|
|
|
19
21
|
use_external_library 'https://github.com/thestk/stk',
|
|
20
22
|
tag: '5.0.1',
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.3.
|
|
1
|
+
0.3.10
|
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.10'
|
|
29
|
+
s.add_dependency 'rucy', '~> 0.3.10'
|
|
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/analyser.cpp
CHANGED
|
@@ -76,8 +76,8 @@ RUCY_DEF1(each_signal, nsamples_)
|
|
|
76
76
|
Value args(2, values);
|
|
77
77
|
for (uint i = start; i < nsamples; i += 2)
|
|
78
78
|
{
|
|
79
|
-
args
|
|
80
|
-
args
|
|
79
|
+
args.set(0, value(samples[i + 0]));
|
|
80
|
+
args.set(1, value(samples[i + 1]));
|
|
81
81
|
rb_yield(args);
|
|
82
82
|
}
|
|
83
83
|
break;
|
data/ext/beeps/extconf.rb
CHANGED
|
@@ -13,16 +13,20 @@ Xot::ExtConf.new Xot, Rucy, Beeps do
|
|
|
13
13
|
setup do
|
|
14
14
|
headers << 'ruby.h'
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
libs << 'openal' << 'ole32' << 'mf' << 'mfplat' << 'mfreadwrite' << 'mfuuid'
|
|
19
|
-
elsif osx?
|
|
16
|
+
case
|
|
17
|
+
when osx?
|
|
20
18
|
headers << 'OpenAL/al.h' << 'OpenAL/alc.h'
|
|
21
19
|
frameworks << 'OpenAL' << 'AVFoundation'
|
|
20
|
+
when win32?
|
|
21
|
+
headers << 'AL/al.h' << 'AL/alc.h'
|
|
22
|
+
libs << 'openal' << 'ole32' << 'mf' << 'mfplat' << 'mfreadwrite' << 'mfuuid'
|
|
23
|
+
when linux?
|
|
24
|
+
headers << 'AL/al.h' << 'AL/alc.h'
|
|
25
|
+
libs << 'openal'
|
|
22
26
|
end
|
|
23
27
|
|
|
24
|
-
$LDFLAGS << ' -Wl,--out-implib=
|
|
28
|
+
$LDFLAGS << ' -Wl,--out-implib=beeps_ext.dll.a' if mingw? || cygwin?
|
|
25
29
|
end
|
|
26
30
|
|
|
27
|
-
create_makefile '
|
|
31
|
+
create_makefile 'beeps_ext'
|
|
28
32
|
end
|
data/ext/beeps/native.cpp
CHANGED
|
@@ -9,10 +9,12 @@ void Init_beeps_sound ();
|
|
|
9
9
|
void Init_beeps_sound_player ();
|
|
10
10
|
void Init_beeps_processor ();
|
|
11
11
|
|
|
12
|
+
void Init_beeps_value ();
|
|
12
13
|
void Init_beeps_oscillator ();
|
|
13
14
|
void Init_beeps_sequencer ();
|
|
14
15
|
void Init_beeps_file_in ();
|
|
15
16
|
void Init_beeps_mic_in ();
|
|
17
|
+
void Init_beeps_text_in ();
|
|
16
18
|
|
|
17
19
|
void Init_beeps_gain ();
|
|
18
20
|
void Init_beeps_mixer ();
|
|
@@ -26,11 +28,7 @@ void Init_beeps_analyser ();
|
|
|
26
28
|
|
|
27
29
|
|
|
28
30
|
extern "C" void
|
|
29
|
-
|
|
30
|
-
Init_beeps_native ()
|
|
31
|
-
#else
|
|
32
|
-
Init_native ()
|
|
33
|
-
#endif
|
|
31
|
+
Init_beeps_ext ()
|
|
34
32
|
{
|
|
35
33
|
RUCY_TRY
|
|
36
34
|
|
|
@@ -44,10 +42,12 @@ extern "C" void
|
|
|
44
42
|
Init_beeps_sound_player();
|
|
45
43
|
Init_beeps_processor();
|
|
46
44
|
|
|
45
|
+
Init_beeps_value();
|
|
47
46
|
Init_beeps_oscillator();
|
|
48
47
|
Init_beeps_sequencer();
|
|
49
48
|
Init_beeps_file_in();
|
|
50
49
|
Init_beeps_mic_in();
|
|
50
|
+
Init_beeps_text_in();
|
|
51
51
|
|
|
52
52
|
Init_beeps_gain();
|
|
53
53
|
Init_beeps_mixer();
|
data/ext/beeps/oscillator.cpp
CHANGED
|
@@ -43,8 +43,8 @@ RUCY_DEF1(set_samples, samples)
|
|
|
43
43
|
{
|
|
44
44
|
CHECK;
|
|
45
45
|
|
|
46
|
-
Value* array = samples.as_array();
|
|
47
|
-
size_t size
|
|
46
|
+
const Value* array = samples.as_array();
|
|
47
|
+
size_t size = samples.size();
|
|
48
48
|
|
|
49
49
|
std::vector<Beeps::Sample> data;
|
|
50
50
|
data.reserve(size);
|
data/ext/beeps/sequencer.cpp
CHANGED
|
@@ -61,6 +61,23 @@ RUCY_DEF0(get_time_scale)
|
|
|
61
61
|
}
|
|
62
62
|
RUCY_END
|
|
63
63
|
|
|
64
|
+
static
|
|
65
|
+
RUCY_DEF0(each_note)
|
|
66
|
+
{
|
|
67
|
+
CHECK;
|
|
68
|
+
|
|
69
|
+
Value ret;
|
|
70
|
+
for (auto it = THIS->begin(), end = THIS->end(); it != end; ++it)
|
|
71
|
+
{
|
|
72
|
+
ret = rb_yield_values(3,
|
|
73
|
+
value(it->processor.get()),
|
|
74
|
+
value(it->offset),
|
|
75
|
+
value(it->duration));
|
|
76
|
+
}
|
|
77
|
+
return ret;
|
|
78
|
+
}
|
|
79
|
+
RUCY_END
|
|
80
|
+
|
|
64
81
|
|
|
65
82
|
static Class cSequencer;
|
|
66
83
|
|
|
@@ -75,6 +92,7 @@ Init_beeps_sequencer ()
|
|
|
75
92
|
cSequencer.define_method("remove", remove);
|
|
76
93
|
//cSequencer.define_method("time_scale=", set_time_scale);
|
|
77
94
|
//cSequencer.define_method("time_scale", get_time_scale);
|
|
95
|
+
cSequencer.define_method("each_note!", each_note);
|
|
78
96
|
}
|
|
79
97
|
|
|
80
98
|
|
data/ext/beeps/sound.cpp
CHANGED
|
@@ -0,0 +1,66 @@
|
|
|
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_EXPORT, Beeps::TextIn)
|
|
9
|
+
|
|
10
|
+
#define THIS to<Beeps::TextIn*>(self)
|
|
11
|
+
|
|
12
|
+
#define CHECK RUCY_CHECK_OBJ(Beeps::TextIn, self)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
static
|
|
16
|
+
RUCY_DEF_ALLOC(alloc, klass)
|
|
17
|
+
{
|
|
18
|
+
return value(new Beeps::RubyProcessor<Beeps::TextIn>, klass);
|
|
19
|
+
}
|
|
20
|
+
RUCY_END
|
|
21
|
+
|
|
22
|
+
static
|
|
23
|
+
RUCY_DEF1(synthesize, text)
|
|
24
|
+
{
|
|
25
|
+
CHECK;
|
|
26
|
+
|
|
27
|
+
THIS->synthesize(text.c_str());
|
|
28
|
+
}
|
|
29
|
+
RUCY_END
|
|
30
|
+
|
|
31
|
+
static
|
|
32
|
+
RUCY_DEF0(get_sample_rate)
|
|
33
|
+
{
|
|
34
|
+
CHECK;
|
|
35
|
+
|
|
36
|
+
return value(THIS->sample_rate());
|
|
37
|
+
}
|
|
38
|
+
RUCY_END
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
static Class cTextIn;
|
|
42
|
+
|
|
43
|
+
void
|
|
44
|
+
Init_beeps_text_in ()
|
|
45
|
+
{
|
|
46
|
+
Module mBeeps = define_module("Beeps");
|
|
47
|
+
|
|
48
|
+
cTextIn = mBeeps.define_class("TextIn", Beeps::processor_class());
|
|
49
|
+
cTextIn.define_alloc_func(alloc);
|
|
50
|
+
cTextIn.define_method("synthesize", synthesize);
|
|
51
|
+
cTextIn.define_method("sample_rate", get_sample_rate);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
namespace Beeps
|
|
56
|
+
{
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
Class
|
|
60
|
+
text_in_class ()
|
|
61
|
+
{
|
|
62
|
+
return cTextIn;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
}// Beeps
|
data/ext/beeps/value.cpp
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
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_EXPORT, Beeps::Value)
|
|
9
|
+
|
|
10
|
+
#define THIS to<Beeps::Value*>(self)
|
|
11
|
+
|
|
12
|
+
#define CHECK RUCY_CHECK_OBJ(Beeps::Value, self)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
static
|
|
16
|
+
RUCY_DEF_ALLOC(alloc, klass)
|
|
17
|
+
{
|
|
18
|
+
return value(new Beeps::RubyProcessor<Beeps::Value>, klass);
|
|
19
|
+
}
|
|
20
|
+
RUCY_END
|
|
21
|
+
|
|
22
|
+
static
|
|
23
|
+
RUCY_DEF1(set_type, type)
|
|
24
|
+
{
|
|
25
|
+
CHECK;
|
|
26
|
+
|
|
27
|
+
THIS->set_type((Beeps::Value::Type) to<uint>(type));
|
|
28
|
+
return type;
|
|
29
|
+
}
|
|
30
|
+
RUCY_END
|
|
31
|
+
|
|
32
|
+
static
|
|
33
|
+
RUCY_DEF0(get_type)
|
|
34
|
+
{
|
|
35
|
+
CHECK;
|
|
36
|
+
|
|
37
|
+
return value(THIS->type());
|
|
38
|
+
}
|
|
39
|
+
RUCY_END
|
|
40
|
+
|
|
41
|
+
static
|
|
42
|
+
RUCY_DEF1(set_value, value)
|
|
43
|
+
{
|
|
44
|
+
CHECK;
|
|
45
|
+
|
|
46
|
+
THIS->set_value(to<float>(value));
|
|
47
|
+
return value;
|
|
48
|
+
}
|
|
49
|
+
RUCY_END
|
|
50
|
+
|
|
51
|
+
static
|
|
52
|
+
RUCY_DEF2(insert, value, time)
|
|
53
|
+
{
|
|
54
|
+
CHECK;
|
|
55
|
+
|
|
56
|
+
THIS->insert(to<float>(value), to<float>(time));
|
|
57
|
+
}
|
|
58
|
+
RUCY_END
|
|
59
|
+
|
|
60
|
+
static
|
|
61
|
+
RUCY_DEF0(clear)
|
|
62
|
+
{
|
|
63
|
+
CHECK;
|
|
64
|
+
|
|
65
|
+
THIS->clear();
|
|
66
|
+
}
|
|
67
|
+
RUCY_END
|
|
68
|
+
|
|
69
|
+
static
|
|
70
|
+
RUCY_DEF0(each_value)
|
|
71
|
+
{
|
|
72
|
+
CHECK;
|
|
73
|
+
|
|
74
|
+
Value ret;
|
|
75
|
+
for (auto it = THIS->begin(), end = THIS->end(); it != end; ++it)
|
|
76
|
+
ret = rb_yield_values(2, value(it->value), value(it->time));
|
|
77
|
+
return ret;
|
|
78
|
+
}
|
|
79
|
+
RUCY_END
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
static Class cValue;
|
|
83
|
+
|
|
84
|
+
void
|
|
85
|
+
Init_beeps_value ()
|
|
86
|
+
{
|
|
87
|
+
Module mBeeps = define_module("Beeps");
|
|
88
|
+
|
|
89
|
+
cValue = mBeeps.define_class("Value", Beeps::processor_class());
|
|
90
|
+
cValue.define_alloc_func(alloc);
|
|
91
|
+
cValue.define_method("type=", set_type);
|
|
92
|
+
cValue.define_method("type", get_type);
|
|
93
|
+
cValue.define_method("value=", set_value);
|
|
94
|
+
cValue.define_method("insert", insert);
|
|
95
|
+
cValue.define_method("clear", clear);
|
|
96
|
+
cValue.define_method("each_value!", each_value);
|
|
97
|
+
|
|
98
|
+
cValue.define_const("TYPE_NONE", Beeps::Value::TYPE_NONE);
|
|
99
|
+
cValue.define_const("LINEAR", Beeps::Value::LINEAR);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
namespace Beeps
|
|
104
|
+
{
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
Class
|
|
108
|
+
value_class ()
|
|
109
|
+
{
|
|
110
|
+
return cValue;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
}// Beeps
|