beeps 0.2 → 0.2.1
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/.github/workflows/release-gem.yml +1 -1
- data/.github/workflows/tag.yml +1 -1
- data/.github/workflows/test.yml +7 -1
- data/ChangeLog.md +10 -0
- data/Gemfile.lock +1 -1
- data/VERSION +1 -1
- data/beeps.gemspec +2 -2
- data/include/beeps/debug.h +0 -1
- data/include/beeps/ruby.h +3 -1
- data/include/beeps.h +2 -0
- data/src/openal.cpp +6 -0
- data/src/openal.h +2 -0
- data/src/signals.cpp +17 -15
- data/src/signals.h +6 -6
- data/src/sound.cpp +41 -18
- data/test/helper.rb +0 -5
- data/test/test_sound_player.rb +4 -0
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fb86426316eb60913fcb725b8ee212785e3fde7f75bfb58a682e7a4a8468c20d
|
4
|
+
data.tar.gz: 91ed66b1ac199397817a1129432818f809b59e10b1bbf4a3e24ebd1fb2706ff3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e33ed0d5cd549533810d6ed7525f66a9bf0504d4e65c6ee2f90da399d437ecc6016d0844d6d85c049bb4d7cf20ddb06c7d38a3ab2e49fd7668de8e225fe89e6e
|
7
|
+
data.tar.gz: 805747561bbb762333b571f3b5694cd10fec190085df0bfd81fd2295406f77c8e5fe50eda51a2fd3378014f93c276d1fc37a5a70d0c179a719bd4c2552dd13bd
|
data/.github/workflows/tag.yml
CHANGED
data/.github/workflows/test.yml
CHANGED
@@ -16,7 +16,7 @@ jobs:
|
|
16
16
|
ruby-version: 3.2
|
17
17
|
|
18
18
|
- name: checkout
|
19
|
-
uses: actions/checkout@
|
19
|
+
uses: actions/checkout@v4
|
20
20
|
|
21
21
|
- name: setup gems
|
22
22
|
run: bundle install
|
@@ -24,5 +24,11 @@ jobs:
|
|
24
24
|
- name: setup dependencies
|
25
25
|
run: "ruby -I.github/workflows -rutils -e 'setup_dependencies'"
|
26
26
|
|
27
|
+
- name: lib
|
28
|
+
run: bundle exec rake lib
|
29
|
+
|
30
|
+
- name: ext
|
31
|
+
run: bundle exec rake ext
|
32
|
+
|
27
33
|
- name: test
|
28
34
|
run: bundle exec rake test
|
data/ChangeLog.md
CHANGED
@@ -1,6 +1,16 @@
|
|
1
1
|
# beeps ChangeLog
|
2
2
|
|
3
3
|
|
4
|
+
## [v0.2.1] - 2024-07-05
|
5
|
+
|
6
|
+
- Do not delete OpenAL objects after calling OpenAL_fin()
|
7
|
+
- Do not redefine fin!() methods, they are no longer needed
|
8
|
+
- Skip 'test_play_end_then_stop' on GitHub Actions
|
9
|
+
- Update workflows for test
|
10
|
+
- Update to actions/checkout@v4
|
11
|
+
- Fix 'github_actions?'
|
12
|
+
|
13
|
+
|
4
14
|
## [v0.2] - 2024-03-14
|
5
15
|
|
6
16
|
- Change the super class for exception class from RuntimeError to StandardError
|
data/Gemfile.lock
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2
|
1
|
+
0.2.1
|
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_runtime_dependency 'xot', '~> 0.2'
|
29
|
-
s.add_runtime_dependency 'rucy', '~> 0.2'
|
28
|
+
s.add_runtime_dependency 'xot', '~> 0.2.1'
|
29
|
+
s.add_runtime_dependency 'rucy', '~> 0.2.1'
|
30
30
|
|
31
31
|
s.files = `git ls-files`.split $/
|
32
32
|
s.executables = s.files.grep(%r{^bin/}) {|f| File.basename f}
|
data/include/beeps/debug.h
CHANGED
data/include/beeps/ruby.h
CHANGED
@@ -4,11 +4,13 @@
|
|
4
4
|
#define __BEEPS_RUBY_H__
|
5
5
|
|
6
6
|
|
7
|
-
#include <beeps/ruby/beeps.h>
|
8
7
|
#include <beeps/ruby/defs.h>
|
8
|
+
#include <beeps/ruby/beeps.h>
|
9
9
|
#include <beeps/ruby/exception.h>
|
10
10
|
|
11
11
|
#include <beeps/ruby/processor.h>
|
12
|
+
#include <beeps/ruby/generator.h>
|
13
|
+
#include <beeps/ruby/filter.h>
|
12
14
|
#include <beeps/ruby/sound.h>
|
13
15
|
|
14
16
|
|
data/include/beeps.h
CHANGED
data/src/openal.cpp
CHANGED
data/src/openal.h
CHANGED
data/src/signals.cpp
CHANGED
@@ -24,21 +24,6 @@ namespace Beeps
|
|
24
24
|
};// Signals::Data
|
25
25
|
|
26
26
|
|
27
|
-
Frames*
|
28
|
-
Signals_get_frames (Signals* signals)
|
29
|
-
{
|
30
|
-
if (!signals)
|
31
|
-
argument_error(__FILE__, __LINE__);
|
32
|
-
|
33
|
-
return signals->self->frames.get();
|
34
|
-
}
|
35
|
-
|
36
|
-
const Frames*
|
37
|
-
Signals_get_frames (const Signals* signals)
|
38
|
-
{
|
39
|
-
return Signals_get_frames(const_cast<Signals*>(signals));
|
40
|
-
}
|
41
|
-
|
42
27
|
Signals
|
43
28
|
Signals_create (uint capacity, uint nchannels, double sample_rate)
|
44
29
|
{
|
@@ -67,8 +52,10 @@ namespace Beeps
|
|
67
52
|
frames->setDataRate(sample_rate);
|
68
53
|
|
69
54
|
for (uint channel = 0; channel < nchannels; ++channel)
|
55
|
+
{
|
70
56
|
for (uint sample = 0; sample < nsamples; ++sample)
|
71
57
|
(*frames)(sample, channel) = channels[channel][sample];
|
58
|
+
}
|
72
59
|
|
73
60
|
Signals s;
|
74
61
|
s.self->frames.reset(frames);
|
@@ -296,6 +283,21 @@ namespace Beeps
|
|
296
283
|
return (float) (signals.nsamples() / signals.sample_rate());
|
297
284
|
}
|
298
285
|
|
286
|
+
Frames*
|
287
|
+
Signals_get_frames (Signals* signals)
|
288
|
+
{
|
289
|
+
if (!signals)
|
290
|
+
argument_error(__FILE__, __LINE__);
|
291
|
+
|
292
|
+
return signals->self->frames.get();
|
293
|
+
}
|
294
|
+
|
295
|
+
const Frames*
|
296
|
+
Signals_get_frames (const Signals* signals)
|
297
|
+
{
|
298
|
+
return Signals_get_frames(const_cast<Signals*>(signals));
|
299
|
+
}
|
300
|
+
|
299
301
|
static void
|
300
302
|
make_audio_buffer (
|
301
303
|
AudioFile<float>::AudioBuffer* buffer, const Signals& signals)
|
data/src/signals.h
CHANGED
@@ -24,10 +24,6 @@ namespace Beeps
|
|
24
24
|
template <typename T> class SignalSamples;
|
25
25
|
|
26
26
|
|
27
|
-
Frames* Signals_get_frames ( Signals* signals);
|
28
|
-
|
29
|
-
const Frames* Signals_get_frames (const Signals* signals);
|
30
|
-
|
31
27
|
Signals Signals_create (
|
32
28
|
uint capacity, uint nchannels = 1, double sample_rate = 0);
|
33
29
|
|
@@ -53,6 +49,10 @@ namespace Beeps
|
|
53
49
|
|
54
50
|
float Signals_get_seconds (const Signals& signals);
|
55
51
|
|
52
|
+
Frames* Signals_get_frames ( Signals* signals);
|
53
|
+
|
54
|
+
const Frames* Signals_get_frames (const Signals* signals);
|
55
|
+
|
56
56
|
void Signals_save (const Signals& signals, const char* path);
|
57
57
|
|
58
58
|
Signals Signals_load (const char* path);
|
@@ -63,8 +63,8 @@ namespace Beeps
|
|
63
63
|
|
64
64
|
public:
|
65
65
|
|
66
|
-
Frames (unsigned int
|
67
|
-
: stk::StkFrames(
|
66
|
+
Frames (unsigned int nframes = 0, unsigned int nchannels = 0)
|
67
|
+
: stk::StkFrames(nframes, nchannels)
|
68
68
|
{
|
69
69
|
}
|
70
70
|
|
data/src/sound.cpp
CHANGED
@@ -67,8 +67,10 @@ namespace Beeps
|
|
67
67
|
std::vector<short> buffer;
|
68
68
|
buffer.reserve(nsamples * nchannels);
|
69
69
|
for (uint sample = 0; sample < nsamples; ++sample)
|
70
|
+
{
|
70
71
|
for (uint channel = 0; channel < nchannels; ++channel)
|
71
72
|
buffer.push_back((*frames)(sample, channel) * SHRT_MAX);
|
73
|
+
}
|
72
74
|
|
73
75
|
alBufferData(
|
74
76
|
self->id,
|
@@ -94,9 +96,11 @@ namespace Beeps
|
|
94
96
|
struct Data
|
95
97
|
{
|
96
98
|
|
97
|
-
|
99
|
+
void* context = NULL;
|
100
|
+
|
101
|
+
ALint id = -1;
|
98
102
|
|
99
|
-
bool owner
|
103
|
+
bool owner = false;
|
100
104
|
|
101
105
|
~Data ()
|
102
106
|
{
|
@@ -111,26 +115,28 @@ namespace Beeps
|
|
111
115
|
alGenBuffers(1, &id_);
|
112
116
|
OpenAL_check_error(__FILE__, __LINE__);
|
113
117
|
|
114
|
-
|
115
|
-
|
118
|
+
context = OpenAL_get_context();
|
119
|
+
id = id_;
|
120
|
+
owner = true;
|
116
121
|
}
|
117
122
|
|
118
123
|
void clear ()
|
119
124
|
{
|
120
|
-
if (owner &&
|
125
|
+
if (owner && is_valid())
|
121
126
|
{
|
122
127
|
ALuint id_ = id;
|
123
128
|
alDeleteBuffers(1, &id_);
|
124
129
|
OpenAL_check_error(__FILE__, __LINE__);
|
125
130
|
}
|
126
131
|
|
127
|
-
|
128
|
-
|
132
|
+
context = NULL;
|
133
|
+
id = -1;
|
134
|
+
owner = false;
|
129
135
|
}
|
130
136
|
|
131
137
|
bool is_valid () const
|
132
138
|
{
|
133
|
-
return id >= 0;
|
139
|
+
return id >= 0 && context == OpenAL_get_context();
|
134
140
|
}
|
135
141
|
|
136
142
|
};// Data
|
@@ -145,9 +151,7 @@ namespace Beeps
|
|
145
151
|
|
146
152
|
void create ()
|
147
153
|
{
|
148
|
-
|
149
|
-
alGenSources(1, &id_);
|
150
|
-
if (OpenAL_no_error()) self->id = id_;
|
154
|
+
self->create();
|
151
155
|
}
|
152
156
|
|
153
157
|
void clear ()
|
@@ -310,7 +314,7 @@ namespace Beeps
|
|
310
314
|
|
311
315
|
operator bool () const
|
312
316
|
{
|
313
|
-
return self->
|
317
|
+
return self->is_valid();
|
314
318
|
}
|
315
319
|
|
316
320
|
bool operator ! () const
|
@@ -321,22 +325,41 @@ namespace Beeps
|
|
321
325
|
struct Data
|
322
326
|
{
|
323
327
|
|
324
|
-
|
328
|
+
void* context = NULL;
|
329
|
+
|
330
|
+
ALint id = -1;
|
325
331
|
|
326
332
|
~Data ()
|
327
333
|
{
|
328
334
|
clear();
|
329
335
|
}
|
330
336
|
|
337
|
+
void create ()
|
338
|
+
{
|
339
|
+
ALuint id_ = 0;
|
340
|
+
alGenSources(1, &id_);
|
341
|
+
if (!OpenAL_no_error()) return;
|
342
|
+
|
343
|
+
context = OpenAL_get_context();
|
344
|
+
id = id_;
|
345
|
+
}
|
346
|
+
|
331
347
|
void clear ()
|
332
348
|
{
|
333
|
-
if (
|
349
|
+
if (is_valid())
|
350
|
+
{
|
351
|
+
ALuint id_ = id;
|
352
|
+
alDeleteSources(1, &id_);
|
353
|
+
OpenAL_check_error(__FILE__, __LINE__);
|
354
|
+
}
|
334
355
|
|
335
|
-
|
336
|
-
|
337
|
-
|
356
|
+
context = NULL;
|
357
|
+
id = -1;
|
358
|
+
}
|
338
359
|
|
339
|
-
|
360
|
+
bool is_valid () const
|
361
|
+
{
|
362
|
+
return id >= 0 && context == OpenAL_get_context();
|
340
363
|
}
|
341
364
|
|
342
365
|
};// Data
|
data/test/helper.rb
CHANGED
data/test/test_sound_player.rb
CHANGED
@@ -54,6 +54,10 @@ class TestSoundPlayer < Test::Unit::TestCase
|
|
54
54
|
end
|
55
55
|
|
56
56
|
def test_play_end_then_stop()
|
57
|
+
# FIXME: not tested because it fails due to GHA's "Null Audio Device".
|
58
|
+
# https://github.com/xord/beeps/actions/runs/9044146493/job/24852497305
|
59
|
+
return if github_actions?
|
60
|
+
|
57
61
|
s = sound
|
58
62
|
sec = s.seconds
|
59
63
|
|
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:
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- xordog
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-07-05 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:
|
19
|
+
version: 0.2.1
|
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:
|
26
|
+
version: 0.2.1
|
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:
|
33
|
+
version: 0.2.1
|
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:
|
40
|
+
version: 0.2.1
|
41
41
|
description: Synthesize and play beep sounds.
|
42
42
|
email: xordog@gmail.com
|
43
43
|
executables: []
|