beeps 0.2 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 99cc2d38469ff5c4a36bbca67ab0501a47e0aacac212f0f76771e961bb7a6ac7
4
- data.tar.gz: 406ecb1ebe19efdb536de07efd3723f34eeba93cb89a82767501e94ef08320e1
3
+ metadata.gz: fb86426316eb60913fcb725b8ee212785e3fde7f75bfb58a682e7a4a8468c20d
4
+ data.tar.gz: 91ed66b1ac199397817a1129432818f809b59e10b1bbf4a3e24ebd1fb2706ff3
5
5
  SHA512:
6
- metadata.gz: b3de02786df9756536f43cb41fe595e812394f6b0ecd8e2843489e394f53ed9892048138d3a9804fd1c1f44f19e15801af7180644915dfde6b7677f9c4dadc40
7
- data.tar.gz: 65a636d6922a1dea98e2ea4f26139fe47a696343bb81b561c38d81f3680cefff8597c9d29e791c82026cf786e738ecf6dcf54340cb30812f6e2ed845c1be33f3
6
+ metadata.gz: e33ed0d5cd549533810d6ed7525f66a9bf0504d4e65c6ee2f90da399d437ecc6016d0844d6d85c049bb4d7cf20ddb06c7d38a3ab2e49fd7668de8e225fe89e6e
7
+ data.tar.gz: 805747561bbb762333b571f3b5694cd10fec190085df0bfd81fd2295406f77c8e5fe50eda51a2fd3378014f93c276d1fc37a5a70d0c179a719bd4c2552dd13bd
@@ -15,7 +15,7 @@ jobs:
15
15
  ruby-version: 3.2
16
16
 
17
17
  - name: checkout
18
- uses: actions/checkout@v2
18
+ uses: actions/checkout@v4
19
19
 
20
20
  - name: setup gems
21
21
  run: bundle install
@@ -15,7 +15,7 @@ jobs:
15
15
  ruby-version: 3.2
16
16
 
17
17
  - name: checkout
18
- uses: actions/checkout@v2
18
+ uses: actions/checkout@v4
19
19
  with:
20
20
  fetch-depth: 0
21
21
  token: ${{ secrets.PAT }}
@@ -16,7 +16,7 @@ jobs:
16
16
  ruby-version: 3.2
17
17
 
18
18
  - name: checkout
19
- uses: actions/checkout@v2
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
@@ -9,7 +9,7 @@ GEM
9
9
 
10
10
  PLATFORMS
11
11
  arm64-darwin-21
12
- x86_64-darwin-20
12
+ arm64-darwin-22
13
13
 
14
14
  DEPENDENCIES
15
15
  rake
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}
@@ -5,7 +5,6 @@
5
5
 
6
6
 
7
7
  #include <xot/debug.h>
8
- #include <beeps/defs.h>
9
8
 
10
9
 
11
10
  namespace Beeps
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
@@ -11,6 +11,8 @@
11
11
 
12
12
  #include <beeps/signals.h>
13
13
  #include <beeps/processor.h>
14
+ #include <beeps/generator.h>
15
+ #include <beeps/filter.h>
14
16
  #include <beeps/sound.h>
15
17
 
16
18
 
data/src/openal.cpp CHANGED
@@ -70,6 +70,12 @@ namespace Beeps
70
70
  cleanup();
71
71
  }
72
72
 
73
+ void*
74
+ OpenAL_get_context ()
75
+ {
76
+ return global::context;
77
+ }
78
+
73
79
  ALCenum
74
80
  OpenAL_get_error ()
75
81
  {
data/src/openal.h CHANGED
@@ -23,6 +23,8 @@ namespace Beeps
23
23
 
24
24
  void OpenAL_fin ();
25
25
 
26
+ void* OpenAL_get_context ();
27
+
26
28
  ALCenum OpenAL_get_error();
27
29
 
28
30
  bool OpenAL_no_error();
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 nFrames = 0, unsigned int nChannels = 0)
67
- : stk::StkFrames(nFrames, nChannels)
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
- ALint id = -1;
99
+ void* context = NULL;
100
+
101
+ ALint id = -1;
98
102
 
99
- bool owner = false;
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
- id = id_;
115
- owner = true;
118
+ context = OpenAL_get_context();
119
+ id = id_;
120
+ owner = true;
116
121
  }
117
122
 
118
123
  void clear ()
119
124
  {
120
- if (owner && id >= 0)
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
- id = -1;
128
- owner = false;
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
- ALuint id_ = 0;
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->id >= 0;
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
- ALint id = -1;
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 (id < 0) return;
349
+ if (is_valid())
350
+ {
351
+ ALuint id_ = id;
352
+ alDeleteSources(1, &id_);
353
+ OpenAL_check_error(__FILE__, __LINE__);
354
+ }
334
355
 
335
- ALuint id_ = id;
336
- alDeleteSources(1, &id_);
337
- OpenAL_check_error(__FILE__, __LINE__);
356
+ context = NULL;
357
+ id = -1;
358
+ }
338
359
 
339
- id = -1;
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
@@ -8,8 +8,3 @@ require 'beeps'
8
8
  require 'test/unit'
9
9
 
10
10
  include Xot::Test
11
-
12
-
13
- unless defined?($BEEPS_NOAUTOINIT) && $BEEPS_NOAUTOINIT
14
- def Beeps.fin!() end
15
- end
@@ -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: '0.2'
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-03-13 00:00:00.000000000 Z
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: '0.2'
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: '0.2'
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: '0.2'
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: '0.2'
40
+ version: 0.2.1
41
41
  description: Synthesize and play beep sounds.
42
42
  email: xordog@gmail.com
43
43
  executables: []