beeps 0.3.11 → 0.3.12
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/sound_player.cpp +57 -0
- data/.github/workflows/release-gem.yml +3 -0
- data/.github/workflows/utils.rb +88 -17
- data/ChangeLog.md +14 -0
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/beeps.gemspec +3 -4
- data/ext/beeps/extconf.rb +1 -1
- data/ext/beeps/sound_player.cpp +64 -1
- data/include/beeps/defs.h +2 -0
- data/include/beeps/filter.h +6 -0
- data/include/beeps/generator.h +8 -2
- data/include/beeps/processor.h +10 -8
- data/include/beeps/ruby.h +2 -2
- data/include/beeps/signals.h +14 -0
- data/include/beeps/sound.h +12 -0
- data/include/beeps.h +2 -2
- data/lib/beeps/extension.rb +8 -2
- data/lib/beeps/sound.rb +1 -1
- data/src/analyser.cpp +10 -3
- data/src/envelope.cpp +2 -5
- data/src/file_in.cpp +7 -1
- data/src/gain.cpp +7 -0
- data/src/mixer.cpp +16 -3
- data/src/oscillator.cpp +7 -1
- data/src/osx/signals.mm +4 -4
- data/src/osx/text_in.mm +1 -1
- data/src/processor.cpp +51 -38
- data/src/processor.h +1 -5
- data/src/reverb.cpp +2 -3
- data/src/sequencer.cpp +4 -4
- data/src/signals.cpp +178 -161
- data/src/signals.h +2 -15
- data/src/sound.cpp +154 -5
- data/src/time_stretch.cpp +2 -2
- data/src/value.cpp +8 -2
- data/src/win32/signals.cpp +9 -9
- data/src/x_pass.h +2 -3
- data/test/test_sound_player.rb +70 -0
- metadata +6 -6
data/src/win32/signals.cpp
CHANGED
|
@@ -150,19 +150,19 @@ namespace Beeps
|
|
|
150
150
|
if (bytes.empty())
|
|
151
151
|
beeps_error(__FILE__, __LINE__, "failed to read bytes: '%s'", path);
|
|
152
152
|
|
|
153
|
-
uint Bps
|
|
154
|
-
uint nchannels
|
|
155
|
-
uint nsamples
|
|
156
|
-
Signals signals
|
|
153
|
+
uint Bps = format.wBitsPerSample / 8;
|
|
154
|
+
uint nchannels = format.nChannels;
|
|
155
|
+
uint nsamples = bytes.size() / Bps / nchannels;
|
|
156
|
+
Signals signals(nsamples, nchannels, format.nSamplesPerSec);
|
|
157
157
|
|
|
158
|
-
for (uint
|
|
158
|
+
for (uint ch = 0; ch < nchannels; ++ch)
|
|
159
159
|
{
|
|
160
160
|
switch (Bps)
|
|
161
161
|
{
|
|
162
162
|
case 1:
|
|
163
163
|
{
|
|
164
|
-
Sample* to_p = Signals_at(&signals, 0,
|
|
165
|
-
const uchar* from_p = ((uchar*) &bytes[0]) +
|
|
164
|
+
Sample* to_p = Signals_at(&signals, 0, ch);
|
|
165
|
+
const uchar* from_p = ((uchar*) &bytes[0]) + ch;
|
|
166
166
|
for (uint i = 0; i < nsamples; ++i, to_p += nchannels, from_p += nchannels)
|
|
167
167
|
*to_p = (*to_p - 128) / 128.f;
|
|
168
168
|
break;
|
|
@@ -170,8 +170,8 @@ namespace Beeps
|
|
|
170
170
|
|
|
171
171
|
case 2:
|
|
172
172
|
{
|
|
173
|
-
Sample* to_p = Signals_at(&signals, 0,
|
|
174
|
-
const ushort* from_p = ((ushort*) &bytes[0]) +
|
|
173
|
+
Sample* to_p = Signals_at(&signals, 0, ch);
|
|
174
|
+
const ushort* from_p = ((ushort*) &bytes[0]) + ch;
|
|
175
175
|
for (uint i = 0; i < nsamples; ++i, to_p += nchannels, from_p += nchannels)
|
|
176
176
|
*to_p = *from_p / 32768.f;
|
|
177
177
|
break;
|
data/src/x_pass.h
CHANGED
|
@@ -27,9 +27,8 @@ namespace Beeps
|
|
|
27
27
|
|
|
28
28
|
void tick (Signals* signals)
|
|
29
29
|
{
|
|
30
|
-
uint nchannels
|
|
31
|
-
Signals filtered
|
|
32
|
-
signals->nsamples(), nchannels, signals->sample_rate());
|
|
30
|
+
uint nchannels = signals->nchannels();
|
|
31
|
+
Signals filtered(signals->nsamples(), nchannels, signals->sample_rate());
|
|
33
32
|
|
|
34
33
|
Signals_tick(
|
|
35
34
|
&filtered, *signals,
|
data/test/test_sound_player.rb
CHANGED
|
@@ -127,6 +127,76 @@ class TestSoundPlayer < Test::Unit::TestCase
|
|
|
127
127
|
assert_equal [false, false, true], [p.playing?, p.paused?, p.stopped?]
|
|
128
128
|
end
|
|
129
129
|
|
|
130
|
+
def test_position()
|
|
131
|
+
p = sound(1).play
|
|
132
|
+
p.pause
|
|
133
|
+
assert_equal 0, p.position
|
|
134
|
+
|
|
135
|
+
p.position = 100
|
|
136
|
+
sleep 0.05
|
|
137
|
+
assert_equal 100, p.position
|
|
138
|
+
|
|
139
|
+
p.position 200
|
|
140
|
+
sleep 0.05
|
|
141
|
+
assert_equal 200, p.position
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
def test_position_stream()
|
|
145
|
+
p = stream_sound.play
|
|
146
|
+
p.pause
|
|
147
|
+
assert_equal 0, p.position
|
|
148
|
+
|
|
149
|
+
p.position = 100
|
|
150
|
+
sleep 0.05
|
|
151
|
+
assert_equal 100, p.position
|
|
152
|
+
|
|
153
|
+
p.position 200
|
|
154
|
+
sleep 0.05
|
|
155
|
+
assert_equal 200, p.position
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
def test_time()
|
|
159
|
+
p = sound.play
|
|
160
|
+
p.pause
|
|
161
|
+
assert_in_epsilon 0, p.time
|
|
162
|
+
|
|
163
|
+
p.time = 0.05
|
|
164
|
+
sleep 0.05
|
|
165
|
+
assert_in_epsilon 0.05, p.time
|
|
166
|
+
|
|
167
|
+
p.time 0.1
|
|
168
|
+
sleep 0.05
|
|
169
|
+
assert_in_epsilon 0.1, p.time
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
def test_time_stream()
|
|
173
|
+
p = stream_sound.play
|
|
174
|
+
p.pause
|
|
175
|
+
assert_in_epsilon 0, p.time
|
|
176
|
+
|
|
177
|
+
p.time = 0.05
|
|
178
|
+
sleep 0.05
|
|
179
|
+
assert_in_epsilon 0.05, p.time
|
|
180
|
+
|
|
181
|
+
p.time 0.1
|
|
182
|
+
sleep 0.05
|
|
183
|
+
assert_in_epsilon 0.1, p.time
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
def test_time_scale()
|
|
187
|
+
p = sound.play
|
|
188
|
+
assert_in_epsilon 1, p.time_scale
|
|
189
|
+
|
|
190
|
+
p.time_scale = 0.5
|
|
191
|
+
assert_in_epsilon 0.5, p.time_scale
|
|
192
|
+
|
|
193
|
+
p.time_scale 2.0
|
|
194
|
+
assert_in_epsilon 2.0, p.time_scale
|
|
195
|
+
|
|
196
|
+
assert_raise(ArgumentError) {p.time_scale = 0}
|
|
197
|
+
assert_raise(ArgumentError) {p.time_scale = -1}
|
|
198
|
+
end
|
|
199
|
+
|
|
130
200
|
def test_gain()
|
|
131
201
|
p = sound.play
|
|
132
202
|
assert_in_epsilon 1, p.gain
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: beeps
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.3.
|
|
4
|
+
version: 0.3.12
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- xordog
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-05-09 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: xot
|
|
@@ -16,28 +16,28 @@ dependencies:
|
|
|
16
16
|
requirements:
|
|
17
17
|
- - "~>"
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: 0.3.
|
|
19
|
+
version: 0.3.12
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
24
|
- - "~>"
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: 0.3.
|
|
26
|
+
version: 0.3.12
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: rucy
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
30
30
|
requirements:
|
|
31
31
|
- - "~>"
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: 0.3.
|
|
33
|
+
version: 0.3.12
|
|
34
34
|
type: :runtime
|
|
35
35
|
prerelease: false
|
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
37
|
requirements:
|
|
38
38
|
- - "~>"
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: 0.3.
|
|
40
|
+
version: 0.3.12
|
|
41
41
|
description: Synthesize and play beep sounds.
|
|
42
42
|
email: xordog@gmail.com
|
|
43
43
|
executables: []
|