beeps 0.2.1 → 0.3

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.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/.doc/ext/beeps/adsr.cpp +1 -1
  3. data/.doc/ext/beeps/analyser.cpp +1 -1
  4. data/.doc/ext/beeps/file_in.cpp +1 -1
  5. data/.doc/ext/beeps/gain.cpp +1 -1
  6. data/.doc/ext/beeps/mic_in.cpp +1 -1
  7. data/.doc/ext/beeps/oscillator.cpp +1 -1
  8. data/.doc/ext/beeps/pitch_shift.cpp +1 -1
  9. data/.doc/ext/beeps/processor.cpp +1 -1
  10. data/.doc/ext/beeps/sound.cpp +1 -1
  11. data/.doc/ext/beeps/sound_player.cpp +1 -1
  12. data/.doc/ext/beeps/time_stretch.cpp +1 -1
  13. data/.github/workflows/release-gem.yml +1 -1
  14. data/.github/workflows/test.yml +3 -0
  15. data/ChangeLog.md +5 -0
  16. data/Rakefile +3 -1
  17. data/VERSION +1 -1
  18. data/beeps.gemspec +2 -2
  19. data/ext/beeps/adsr.cpp +1 -1
  20. data/ext/beeps/analyser.cpp +1 -1
  21. data/ext/beeps/defs.h +2 -0
  22. data/ext/beeps/extconf.rb +11 -3
  23. data/ext/beeps/file_in.cpp +1 -1
  24. data/ext/beeps/gain.cpp +1 -1
  25. data/ext/beeps/mic_in.cpp +1 -1
  26. data/ext/beeps/oscillator.cpp +1 -1
  27. data/ext/beeps/pitch_shift.cpp +1 -1
  28. data/ext/beeps/processor.cpp +1 -1
  29. data/ext/beeps/sound.cpp +1 -1
  30. data/ext/beeps/sound_player.cpp +1 -1
  31. data/ext/beeps/time_stretch.cpp +1 -1
  32. data/include/beeps/defs.h +7 -0
  33. data/include/beeps/ruby/beeps.h +1 -1
  34. data/include/beeps/ruby/exception.h +2 -2
  35. data/include/beeps/ruby/filter.h +7 -7
  36. data/include/beeps/ruby/generator.h +5 -5
  37. data/include/beeps/ruby/processor.h +2 -2
  38. data/include/beeps/ruby/sound.h +4 -4
  39. data/lib/beeps/extension.rb +4 -0
  40. data/src/beeps.cpp +3 -1
  41. data/src/beeps.h +22 -0
  42. data/src/osx/beeps.mm +19 -0
  43. data/src/win32/beeps.cpp +36 -0
  44. data/src/win32/exception.cpp +40 -0
  45. data/src/win32/exception.h +40 -0
  46. data/src/win32/signals.cpp +186 -0
  47. metadata +11 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fb86426316eb60913fcb725b8ee212785e3fde7f75bfb58a682e7a4a8468c20d
4
- data.tar.gz: 91ed66b1ac199397817a1129432818f809b59e10b1bbf4a3e24ebd1fb2706ff3
3
+ metadata.gz: c4df684684e65c0ee091bb8054a55e57cee8e8d9b932382defa62229027cedb7
4
+ data.tar.gz: 6c59120efd1f32823ef0d1982f243106f38ea4543a568739e9739811ee1e3d4c
5
5
  SHA512:
6
- metadata.gz: e33ed0d5cd549533810d6ed7525f66a9bf0504d4e65c6ee2f90da399d437ecc6016d0844d6d85c049bb4d7cf20ddb06c7d38a3ab2e49fd7668de8e225fe89e6e
7
- data.tar.gz: 805747561bbb762333b571f3b5694cd10fec190085df0bfd81fd2295406f77c8e5fe50eda51a2fd3378014f93c276d1fc37a5a70d0c179a719bd4c2552dd13bd
6
+ metadata.gz: db163aa74ddac2978422aa52b3bef3e157295aa93f46a79e8e32b88c0b0752f337cd6bc1636e53dae751ddaac554c86b4daa72ad57f038ddf3586078253bb669
7
+ data.tar.gz: 9997be8c7be61a021087d05b3e17aa695a07d3a70e9fed9bd61b3b82d66cda81c2e5279a74ef0100771281480d1ada8b9b52d6a936375f1a361fe6aa3d97d5bf
@@ -5,7 +5,7 @@
5
5
  #include "defs.h"
6
6
 
7
7
 
8
- RUCY_DEFINE_WRAPPER_VALUE_FROM_TO(Beeps::ADSR)
8
+ RUCY_DEFINE_WRAPPER_VALUE_FROM_TO(BEEPS_EXPORT, Beeps::ADSR)
9
9
 
10
10
  #define THIS to<Beeps::ADSR*>(self)
11
11
 
@@ -6,7 +6,7 @@
6
6
  #include "defs.h"
7
7
 
8
8
 
9
- RUCY_DEFINE_WRAPPER_VALUE_FROM_TO(Beeps::Analyser)
9
+ RUCY_DEFINE_WRAPPER_VALUE_FROM_TO(BEEPS_EXPORT, Beeps::Analyser)
10
10
 
11
11
  #define THIS to<Beeps::Analyser*>(self)
12
12
 
@@ -5,7 +5,7 @@
5
5
  #include "defs.h"
6
6
 
7
7
 
8
- RUCY_DEFINE_WRAPPER_VALUE_FROM_TO(Beeps::FileIn)
8
+ RUCY_DEFINE_WRAPPER_VALUE_FROM_TO(BEEPS_EXPORT, Beeps::FileIn)
9
9
 
10
10
  #define THIS to<Beeps::FileIn*>(self)
11
11
 
@@ -5,7 +5,7 @@
5
5
  #include "defs.h"
6
6
 
7
7
 
8
- RUCY_DEFINE_WRAPPER_VALUE_FROM_TO(Beeps::Gain)
8
+ RUCY_DEFINE_WRAPPER_VALUE_FROM_TO(BEEPS_EXPORT, Beeps::Gain)
9
9
 
10
10
  #define THIS to<Beeps::Gain*>(self)
11
11
 
@@ -5,7 +5,7 @@
5
5
  #include "defs.h"
6
6
 
7
7
 
8
- RUCY_DEFINE_WRAPPER_VALUE_FROM_TO(Beeps::MicIn)
8
+ RUCY_DEFINE_WRAPPER_VALUE_FROM_TO(BEEPS_EXPORT, Beeps::MicIn)
9
9
 
10
10
  #define THIS to<Beeps::MicIn*>(self)
11
11
 
@@ -5,7 +5,7 @@
5
5
  #include "defs.h"
6
6
 
7
7
 
8
- RUCY_DEFINE_WRAPPER_VALUE_FROM_TO(Beeps::Oscillator)
8
+ RUCY_DEFINE_WRAPPER_VALUE_FROM_TO(BEEPS_EXPORT, Beeps::Oscillator)
9
9
 
10
10
  #define THIS to<Beeps::Oscillator*>(self)
11
11
 
@@ -5,7 +5,7 @@
5
5
  #include "defs.h"
6
6
 
7
7
 
8
- RUCY_DEFINE_WRAPPER_VALUE_FROM_TO(Beeps::PitchShift)
8
+ RUCY_DEFINE_WRAPPER_VALUE_FROM_TO(BEEPS_EXPORT, Beeps::PitchShift)
9
9
 
10
10
  #define THIS to<Beeps::PitchShift*>(self)
11
11
 
@@ -5,7 +5,7 @@
5
5
  #include "defs.h"
6
6
 
7
7
 
8
- RUCY_DEFINE_WRAPPER_VALUE_FROM_TO(Beeps::Processor)
8
+ RUCY_DEFINE_WRAPPER_VALUE_FROM_TO(BEEPS_EXPORT, Beeps::Processor)
9
9
 
10
10
  #define THIS to<Beeps::Processor*>(self)
11
11
 
@@ -4,7 +4,7 @@
4
4
  #include "defs.h"
5
5
 
6
6
 
7
- RUCY_DEFINE_VALUE_FROM_TO(Beeps::Sound)
7
+ RUCY_DEFINE_VALUE_FROM_TO(BEEPS_EXPORT, Beeps::Sound)
8
8
 
9
9
  #define THIS to<Beeps::Sound*>(self)
10
10
 
@@ -4,7 +4,7 @@
4
4
  #include "defs.h"
5
5
 
6
6
 
7
- RUCY_DEFINE_VALUE_FROM_TO(Beeps::SoundPlayer)
7
+ RUCY_DEFINE_VALUE_FROM_TO(BEEPS_EXPORT, Beeps::SoundPlayer)
8
8
 
9
9
  #define THIS to<Beeps::SoundPlayer*>(self)
10
10
 
@@ -5,7 +5,7 @@
5
5
  #include "defs.h"
6
6
 
7
7
 
8
- RUCY_DEFINE_WRAPPER_VALUE_FROM_TO(Beeps::TimeStretch)
8
+ RUCY_DEFINE_WRAPPER_VALUE_FROM_TO(BEEPS_EXPORT, Beeps::TimeStretch)
9
9
 
10
10
  #define THIS to<Beeps::TimeStretch*>(self)
11
11
 
@@ -24,7 +24,7 @@ jobs:
24
24
  run: "ruby -I.github/workflows -rutils -e 'setup_dependencies'"
25
25
 
26
26
  - name: test
27
- run: bundle exec rake quiet test
27
+ run: bundle exec rake quiet packages test
28
28
 
29
29
  - name: create gem
30
30
  id: gem
@@ -24,6 +24,9 @@ jobs:
24
24
  - name: setup dependencies
25
25
  run: "ruby -I.github/workflows -rutils -e 'setup_dependencies'"
26
26
 
27
+ - name: packages
28
+ run: bundle exec rake packages
29
+
27
30
  - name: lib
28
31
  run: bundle exec rake lib
29
32
 
data/ChangeLog.md CHANGED
@@ -1,6 +1,11 @@
1
1
  # beeps ChangeLog
2
2
 
3
3
 
4
+ ## [v0.3] - 2024-07-06
5
+
6
+ - Support Windows
7
+
8
+
4
9
  ## [v0.2.1] - 2024-07-05
5
10
 
6
11
  - Do not delete OpenAL objects after calling OpenAL_fin()
data/Rakefile CHANGED
@@ -15,6 +15,8 @@ require 'beeps/extension'
15
15
  EXTENSIONS = [Xot, Rucy, Beeps]
16
16
  TESTS_ALONE = ['test/test_beeps_init.rb']
17
17
 
18
+ install_packages win32: %w[MINGW_PACKAGE_PREFIX-openal]
19
+
18
20
  use_external_library 'https://github.com/thestk/stk',
19
21
  tag: '4.6.2',
20
22
  incdirs: 'include',
@@ -47,6 +49,6 @@ default_tasks :ext
47
49
  use_bundler
48
50
  build_native_library
49
51
  build_ruby_extension
50
- test_ruby_extension
52
+ test_ruby_extension unless github_actions? && win32?
51
53
  generate_documents
52
54
  build_ruby_gem
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.1
1
+ 0.3
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.1'
29
- s.add_runtime_dependency 'rucy', '~> 0.2.1'
28
+ s.add_runtime_dependency 'xot', '~> 0.3'
29
+ s.add_runtime_dependency 'rucy', '~> 0.3'
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/adsr.cpp CHANGED
@@ -5,7 +5,7 @@
5
5
  #include "defs.h"
6
6
 
7
7
 
8
- RUCY_DEFINE_WRAPPER_VALUE_FROM_TO(Beeps::ADSR)
8
+ RUCY_DEFINE_WRAPPER_VALUE_FROM_TO(BEEPS_EXPORT, Beeps::ADSR)
9
9
 
10
10
  #define THIS to<Beeps::ADSR*>(self)
11
11
 
@@ -6,7 +6,7 @@
6
6
  #include "defs.h"
7
7
 
8
8
 
9
- RUCY_DEFINE_WRAPPER_VALUE_FROM_TO(Beeps::Analyser)
9
+ RUCY_DEFINE_WRAPPER_VALUE_FROM_TO(BEEPS_EXPORT, Beeps::Analyser)
10
10
 
11
11
  #define THIS to<Beeps::Analyser*>(self)
12
12
 
data/ext/beeps/defs.h CHANGED
@@ -9,6 +9,8 @@
9
9
  #include "beeps/ruby/defs.h"
10
10
 
11
11
 
12
+ using namespace Xot::Types;
13
+
12
14
  using namespace Rucy;
13
15
 
14
16
 
data/ext/beeps/extconf.rb CHANGED
@@ -11,9 +11,17 @@ require 'beeps/extension'
11
11
 
12
12
  Xot::ExtConf.new Xot, Rucy, Beeps do
13
13
  setup do
14
- headers << 'ruby.h' << 'OpenAL/al.h' << 'OpenAL/alc.h'
15
- frameworks << 'OpenAL' << 'AVFoundation' if osx?
16
- $LDFLAGS << ' -Wl,--out-implib=native.dll.a' if cygwin?
14
+ headers << 'ruby.h'
15
+
16
+ if win32?
17
+ headers << 'AL/al.h' << 'AL/alc.h'
18
+ libs << 'openal' << 'ole32' << 'mf' << 'mfplat' << 'mfreadwrite' << 'mfuuid'
19
+ elsif osx?
20
+ headers << 'OpenAL/al.h' << 'OpenAL/alc.h'
21
+ frameworks << 'OpenAL' << 'AVFoundation'
22
+ end
23
+
24
+ $LDFLAGS << ' -Wl,--out-implib=native.dll.a' if mingw? || cygwin?
17
25
  end
18
26
 
19
27
  create_makefile 'beeps/native'
@@ -5,7 +5,7 @@
5
5
  #include "defs.h"
6
6
 
7
7
 
8
- RUCY_DEFINE_WRAPPER_VALUE_FROM_TO(Beeps::FileIn)
8
+ RUCY_DEFINE_WRAPPER_VALUE_FROM_TO(BEEPS_EXPORT, Beeps::FileIn)
9
9
 
10
10
  #define THIS to<Beeps::FileIn*>(self)
11
11
 
data/ext/beeps/gain.cpp CHANGED
@@ -5,7 +5,7 @@
5
5
  #include "defs.h"
6
6
 
7
7
 
8
- RUCY_DEFINE_WRAPPER_VALUE_FROM_TO(Beeps::Gain)
8
+ RUCY_DEFINE_WRAPPER_VALUE_FROM_TO(BEEPS_EXPORT, Beeps::Gain)
9
9
 
10
10
  #define THIS to<Beeps::Gain*>(self)
11
11
 
data/ext/beeps/mic_in.cpp CHANGED
@@ -5,7 +5,7 @@
5
5
  #include "defs.h"
6
6
 
7
7
 
8
- RUCY_DEFINE_WRAPPER_VALUE_FROM_TO(Beeps::MicIn)
8
+ RUCY_DEFINE_WRAPPER_VALUE_FROM_TO(BEEPS_EXPORT, Beeps::MicIn)
9
9
 
10
10
  #define THIS to<Beeps::MicIn*>(self)
11
11
 
@@ -5,7 +5,7 @@
5
5
  #include "defs.h"
6
6
 
7
7
 
8
- RUCY_DEFINE_WRAPPER_VALUE_FROM_TO(Beeps::Oscillator)
8
+ RUCY_DEFINE_WRAPPER_VALUE_FROM_TO(BEEPS_EXPORT, Beeps::Oscillator)
9
9
 
10
10
  #define THIS to<Beeps::Oscillator*>(self)
11
11
 
@@ -5,7 +5,7 @@
5
5
  #include "defs.h"
6
6
 
7
7
 
8
- RUCY_DEFINE_WRAPPER_VALUE_FROM_TO(Beeps::PitchShift)
8
+ RUCY_DEFINE_WRAPPER_VALUE_FROM_TO(BEEPS_EXPORT, Beeps::PitchShift)
9
9
 
10
10
  #define THIS to<Beeps::PitchShift*>(self)
11
11
 
@@ -5,7 +5,7 @@
5
5
  #include "defs.h"
6
6
 
7
7
 
8
- RUCY_DEFINE_WRAPPER_VALUE_FROM_TO(Beeps::Processor)
8
+ RUCY_DEFINE_WRAPPER_VALUE_FROM_TO(BEEPS_EXPORT, Beeps::Processor)
9
9
 
10
10
  #define THIS to<Beeps::Processor*>(self)
11
11
 
data/ext/beeps/sound.cpp CHANGED
@@ -4,7 +4,7 @@
4
4
  #include "defs.h"
5
5
 
6
6
 
7
- RUCY_DEFINE_VALUE_FROM_TO(Beeps::Sound)
7
+ RUCY_DEFINE_VALUE_FROM_TO(BEEPS_EXPORT, Beeps::Sound)
8
8
 
9
9
  #define THIS to<Beeps::Sound*>(self)
10
10
 
@@ -4,7 +4,7 @@
4
4
  #include "defs.h"
5
5
 
6
6
 
7
- RUCY_DEFINE_VALUE_FROM_TO(Beeps::SoundPlayer)
7
+ RUCY_DEFINE_VALUE_FROM_TO(BEEPS_EXPORT, Beeps::SoundPlayer)
8
8
 
9
9
  #define THIS to<Beeps::SoundPlayer*>(self)
10
10
 
@@ -5,7 +5,7 @@
5
5
  #include "defs.h"
6
6
 
7
7
 
8
- RUCY_DEFINE_WRAPPER_VALUE_FROM_TO(Beeps::TimeStretch)
8
+ RUCY_DEFINE_WRAPPER_VALUE_FROM_TO(BEEPS_EXPORT, Beeps::TimeStretch)
9
9
 
10
10
  #define THIS to<Beeps::TimeStretch*>(self)
11
11
 
data/include/beeps/defs.h CHANGED
@@ -8,6 +8,13 @@
8
8
  #include <xot/string.h>
9
9
 
10
10
 
11
+ #if defined(WIN32) && defined(GCC) && defined(BEEPS)
12
+ #define BEEPS_EXPORT __declspec(dllexport)
13
+ #else
14
+ #define BEEPS_EXPORT
15
+ #endif
16
+
17
+
11
18
  namespace Beeps
12
19
  {
13
20
 
@@ -12,7 +12,7 @@ namespace Beeps
12
12
  {
13
13
 
14
14
 
15
- Rucy::Module beeps_module ();
15
+ BEEPS_EXPORT Rucy::Module beeps_module ();
16
16
  // module Beeps
17
17
 
18
18
 
@@ -12,10 +12,10 @@ namespace Beeps
12
12
  {
13
13
 
14
14
 
15
- Rucy::Class beeps_error_class ();
15
+ BEEPS_EXPORT Rucy::Class beeps_error_class ();
16
16
  // class Beeps::BeepsError
17
17
 
18
- Rucy::Class openal_error_class ();
18
+ BEEPS_EXPORT Rucy::Class openal_error_class ();
19
19
  // class Beeps::OpenALError
20
20
 
21
21
 
@@ -9,28 +9,28 @@
9
9
  #include <beeps/filter.h>
10
10
 
11
11
 
12
- RUCY_DECLARE_WRAPPER_VALUE_FROM_TO(Beeps::TimeStretch)
12
+ RUCY_DECLARE_WRAPPER_VALUE_FROM_TO(BEEPS_EXPORT, Beeps::TimeStretch)
13
13
 
14
- RUCY_DECLARE_WRAPPER_VALUE_FROM_TO(Beeps::PitchShift)
14
+ RUCY_DECLARE_WRAPPER_VALUE_FROM_TO(BEEPS_EXPORT, Beeps::PitchShift)
15
15
 
16
16
 
17
17
  namespace Beeps
18
18
  {
19
19
 
20
20
 
21
- Rucy::Class gain_class ();
21
+ BEEPS_EXPORT Rucy::Class gain_class ();
22
22
  // class Beeps::Gain
23
23
 
24
- Rucy::Class adsr_class ();
24
+ BEEPS_EXPORT Rucy::Class adsr_class ();
25
25
  // class Beeps::ADSR
26
26
 
27
- Rucy::Class time_stretch_class ();
27
+ BEEPS_EXPORT Rucy::Class time_stretch_class ();
28
28
  // class Beeps::TimeStretch
29
29
 
30
- Rucy::Class pitch_shift_class ();
30
+ BEEPS_EXPORT Rucy::Class pitch_shift_class ();
31
31
  // class Beeps::PitchShift
32
32
 
33
- Rucy::Class analyser_class ();
33
+ BEEPS_EXPORT Rucy::Class analyser_class ();
34
34
  // class Beeps::Analyser
35
35
 
36
36
 
@@ -9,22 +9,22 @@
9
9
  #include <beeps/generator.h>
10
10
 
11
11
 
12
- RUCY_DECLARE_WRAPPER_VALUE_FROM_TO(Beeps::Oscillator)
12
+ RUCY_DECLARE_WRAPPER_VALUE_FROM_TO(BEEPS_EXPORT, Beeps::Oscillator)
13
13
 
14
- RUCY_DECLARE_WRAPPER_VALUE_FROM_TO(Beeps::FileIn)
14
+ RUCY_DECLARE_WRAPPER_VALUE_FROM_TO(BEEPS_EXPORT, Beeps::FileIn)
15
15
 
16
16
 
17
17
  namespace Beeps
18
18
  {
19
19
 
20
20
 
21
- Rucy::Class oscillator_class ();
21
+ BEEPS_EXPORT Rucy::Class oscillator_class ();
22
22
  // class Beeps::Oscillator
23
23
 
24
- Rucy::Class file_in_class ();
24
+ BEEPS_EXPORT Rucy::Class file_in_class ();
25
25
  // class Beeps::FileIn
26
26
 
27
- Rucy::Class mic_in_class ();
27
+ BEEPS_EXPORT Rucy::Class mic_in_class ();
28
28
  // class Beeps::MicIn
29
29
 
30
30
 
@@ -9,14 +9,14 @@
9
9
  #include <beeps/processor.h>
10
10
 
11
11
 
12
- RUCY_DECLARE_WRAPPER_VALUE_FROM_TO(Beeps::Processor)
12
+ RUCY_DECLARE_WRAPPER_VALUE_FROM_TO(BEEPS_EXPORT, Beeps::Processor)
13
13
 
14
14
 
15
15
  namespace Beeps
16
16
  {
17
17
 
18
18
 
19
- Rucy::Class processor_class ();
19
+ BEEPS_EXPORT Rucy::Class processor_class ();
20
20
  // class Beeps::Processor
21
21
 
22
22
 
@@ -9,19 +9,19 @@
9
9
  #include <beeps/sound.h>
10
10
 
11
11
 
12
- RUCY_DECLARE_VALUE_FROM_TO(Beeps::SoundPlayer)
12
+ RUCY_DECLARE_VALUE_FROM_TO(BEEPS_EXPORT, Beeps::SoundPlayer)
13
13
 
14
- RUCY_DECLARE_VALUE_FROM_TO(Beeps::Sound)
14
+ RUCY_DECLARE_VALUE_FROM_TO(BEEPS_EXPORT, Beeps::Sound)
15
15
 
16
16
 
17
17
  namespace Beeps
18
18
  {
19
19
 
20
20
 
21
- Rucy::Class sound_player_class ();
21
+ BEEPS_EXPORT Rucy::Class sound_player_class ();
22
22
  // class Beeps::SoundPlayer
23
23
 
24
- Rucy::Class sound_class ();
24
+ BEEPS_EXPORT Rucy::Class sound_class ();
25
25
  // class Beeps::Sound
26
26
 
27
27
 
@@ -25,6 +25,10 @@ module Beeps
25
25
  root_dir 'lib'
26
26
  end
27
27
 
28
+ def ext_dir()
29
+ root_dir 'ext'
30
+ end
31
+
28
32
  end# Extension
29
33
 
30
34
 
data/src/beeps.cpp CHANGED
@@ -1,5 +1,5 @@
1
1
  // -*- objc -*-
2
- #include "beeps/beeps.h"
2
+ #include "beeps.h"
3
3
 
4
4
 
5
5
  #include "Stk.h"
@@ -16,6 +16,7 @@ namespace Beeps
16
16
  void
17
17
  init ()
18
18
  {
19
+ Beeps_init();
19
20
  OpenAL_init();
20
21
 
21
22
  stk::Stk::setSampleRate(44100);
@@ -28,6 +29,7 @@ namespace Beeps
28
29
  SoundPlayer_clear_streams();
29
30
 
30
31
  OpenAL_fin();
32
+ Beeps_fin();
31
33
  }
32
34
 
33
35
  void
data/src/beeps.h ADDED
@@ -0,0 +1,22 @@
1
+ // -*- c++ -*-
2
+ #pragma once
3
+ #ifndef __BEEPS_SRC_BEEPS_H__
4
+ #define __BEEPS_SRC_BEEPS_H__
5
+
6
+
7
+ #include "beeps/beeps.h"
8
+
9
+
10
+ namespace Beeps
11
+ {
12
+
13
+
14
+ void Beeps_init ();
15
+
16
+ void Beeps_fin ();
17
+
18
+
19
+ }// Beeps
20
+
21
+
22
+ #endif//EOH
data/src/osx/beeps.mm ADDED
@@ -0,0 +1,19 @@
1
+ #include "../beeps.h"
2
+
3
+
4
+ namespace Beeps
5
+ {
6
+
7
+
8
+ void
9
+ Beeps_init ()
10
+ {
11
+ }
12
+
13
+ void
14
+ Beeps_fin ()
15
+ {
16
+ }
17
+
18
+
19
+ }// Beeps
@@ -0,0 +1,36 @@
1
+ #include "../beeps.h"
2
+
3
+
4
+ #include <mfapi.h>
5
+ #include <xot/windows.h>
6
+ #include "exception.h"
7
+
8
+
9
+ namespace Beeps
10
+ {
11
+
12
+
13
+ void
14
+ Beeps_init ()
15
+ {
16
+ check_media_foundation_error(
17
+ CoInitializeEx(NULL, COINIT_MULTITHREADED),
18
+ __FILE__, __LINE__);
19
+
20
+ check_media_foundation_error(
21
+ MFStartup(MF_VERSION, MFSTARTUP_NOSOCKET),
22
+ __FILE__, __LINE__);
23
+ }
24
+
25
+ void
26
+ Beeps_fin ()
27
+ {
28
+ check_media_foundation_error(
29
+ MFShutdown(),
30
+ __FILE__, __LINE__);
31
+
32
+ CoUninitialize();
33
+ }
34
+
35
+
36
+ }// Beeps
@@ -0,0 +1,40 @@
1
+ #include "exception.h"
2
+
3
+
4
+ #include <xot/string.h>
5
+
6
+
7
+ namespace Beeps
8
+ {
9
+
10
+
11
+ MediaFoundationError::MediaFoundationError (const char* str)
12
+ : Super(str)
13
+ {
14
+ }
15
+
16
+
17
+ namespace ErrorFunctions
18
+ {
19
+
20
+ void
21
+ media_foundation_error (
22
+ const char* file, int line, HRESULT hresult, const char* format, ...)
23
+ {
24
+ XOT_STRINGF(format, s);
25
+ throw MediaFoundationError(
26
+ Xot::error_text(file, line, s + Xot::stringf(" (0x%p)", hresult)));
27
+ }
28
+
29
+ }// ErrorFunctions
30
+
31
+
32
+ void
33
+ check_media_foundation_error (HRESULT hresult, const char* file, int line)
34
+ {
35
+ if (FAILED(hresult))
36
+ media_foundation_error(file, line, hresult);
37
+ }
38
+
39
+
40
+ }// Beeps
@@ -0,0 +1,40 @@
1
+ // -*- c++ -*-
2
+ #pragma once
3
+ #ifndef __BEEPS_SRC_WIN32_EXCEPTION_H__
4
+ #define __BEEPS_SRC_WIN32_EXCEPTION_H__
5
+
6
+
7
+ #include <xot/windows.h>
8
+ #include "beeps/exception.h"
9
+
10
+
11
+ namespace Beeps
12
+ {
13
+
14
+
15
+ class MediaFoundationError : public BeepsError
16
+ {
17
+ typedef BeepsError Super;
18
+ public: MediaFoundationError (const char* str = NULL);
19
+ };
20
+
21
+
22
+ namespace ErrorFunctions
23
+ {
24
+
25
+ [[noreturn]]
26
+ void media_foundation_error (
27
+ const char* file, int line,
28
+ HRESULT hresult, const char* format = NULL, ...);
29
+
30
+ }// ErrorFunctions
31
+
32
+
33
+ void check_media_foundation_error (
34
+ HRESULT hresult, const char* file, int line);
35
+
36
+
37
+ }// Beeps
38
+
39
+
40
+ #endif//EOH
@@ -0,0 +1,186 @@
1
+ #include "../signals.h"
2
+
3
+
4
+ #include <mfapi.h>
5
+ #include <mfidl.h>
6
+ #include <mfreadwrite.h>
7
+ #include <xot/noncopyable.h>
8
+ #include <xot/string.h>
9
+ #include <xot/windows.h>
10
+ #include "exception.h"
11
+
12
+
13
+ namespace Beeps
14
+ {
15
+
16
+
17
+ template <typename T, void (*Delete) (T*)>
18
+ struct Ptr : public Xot::NonCopyable
19
+ {
20
+
21
+ T* ptr;
22
+
23
+ Ptr () : ptr(NULL) {}
24
+
25
+ ~Ptr () {Delete(ptr);}
26
+
27
+ T* operator -> () {return ptr;}
28
+
29
+ operator bool () const {return ptr;}
30
+
31
+ bool operator ! () const {return !operator bool();}
32
+
33
+ };// Ptr
34
+
35
+ template <typename T>
36
+ static void
37
+ release (T* object)
38
+ {
39
+ if (object) object->Release();
40
+ }
41
+
42
+ template <typename T>
43
+ static void
44
+ mem_free (T* object)
45
+ {
46
+ if (object) CoTaskMemFree(object);
47
+ }
48
+
49
+ template <typename T>
50
+ using ReleasePtr = Ptr<T, release<T>>;
51
+
52
+ template <typename T>
53
+ using MemFreePtr = Ptr<T, mem_free<T>>;
54
+
55
+
56
+ static bool is_file_exist (const char* path)
57
+ {
58
+ DWORD attribs = GetFileAttributes(path);
59
+ return
60
+ attribs != INVALID_FILE_ATTRIBUTES &&
61
+ !(attribs & FILE_ATTRIBUTE_DIRECTORY);
62
+ }
63
+
64
+ static std::wstring
65
+ to_wcs (const char* mbs)
66
+ {
67
+ size_t len = strlen(mbs);
68
+ std::wstring wcs(len, L'#');
69
+ mbstowcs(&wcs[0], mbs, len);
70
+ return wcs;
71
+ }
72
+
73
+ static void
74
+ load_bytes (WAVEFORMATEX* format, std::vector<BYTE>* bytes, const char* path)
75
+ {
76
+ std::wstring wpath = to_wcs(path);
77
+
78
+ ReleasePtr<IMFMediaType> pcm_media_type;
79
+ check_media_foundation_error(
80
+ MFCreateMediaType(&pcm_media_type.ptr),
81
+ __FILE__, __LINE__);
82
+ pcm_media_type->SetGUID(MF_MT_MAJOR_TYPE, MFMediaType_Audio);
83
+ pcm_media_type->SetGUID(MF_MT_SUBTYPE, MFAudioFormat_PCM);
84
+
85
+ ReleasePtr<IMFSourceReader> source_reader;
86
+ check_media_foundation_error(
87
+ MFCreateSourceReaderFromURL(wpath.c_str(), NULL, &source_reader.ptr),
88
+ __FILE__, __LINE__);
89
+
90
+ check_media_foundation_error(
91
+ source_reader->SetCurrentMediaType(
92
+ MF_SOURCE_READER_FIRST_AUDIO_STREAM, NULL, pcm_media_type.ptr),
93
+ __FILE__, __LINE__);
94
+
95
+ ReleasePtr<IMFMediaType> media_type;
96
+ check_media_foundation_error(
97
+ source_reader->GetCurrentMediaType(
98
+ MF_SOURCE_READER_FIRST_AUDIO_STREAM, &media_type.ptr),
99
+ __FILE__, __LINE__);
100
+
101
+ MemFreePtr<WAVEFORMATEX> format_;
102
+ check_media_foundation_error(
103
+ MFCreateWaveFormatExFromMFMediaType(media_type.ptr, &format_.ptr, NULL),
104
+ __FILE__, __LINE__);
105
+
106
+ *format = *format_.ptr;
107
+ if (format->wFormatTag != WAVE_FORMAT_PCM)
108
+ beeps_error(__FILE__, __LINE__, "'%s' is not a PCM file.", path);
109
+
110
+ while (true)
111
+ {
112
+ ReleasePtr<IMFSample> sample;
113
+ DWORD flags = 0;
114
+ check_media_foundation_error(
115
+ source_reader->ReadSample(
116
+ MF_SOURCE_READER_FIRST_AUDIO_STREAM, 0, NULL, &flags, NULL, &sample.ptr),
117
+ __FILE__, __LINE__);
118
+ if (flags & MF_SOURCE_READERF_ENDOFSTREAM)
119
+ break;
120
+
121
+ ReleasePtr<IMFMediaBuffer> buffer;
122
+ check_media_foundation_error(
123
+ sample->ConvertToContiguousBuffer(&buffer.ptr),
124
+ __FILE__, __LINE__);
125
+
126
+ BYTE* data = NULL;
127
+ DWORD size = 0;
128
+ check_media_foundation_error(
129
+ buffer->Lock(&data, NULL, &size),
130
+ __FILE__, __LINE__);
131
+
132
+ bytes->resize(bytes->size() + size);
133
+ memcpy(&(*bytes)[0] + bytes->size() - size, data, size);
134
+
135
+ check_media_foundation_error(
136
+ buffer->Unlock(),
137
+ __FILE__, __LINE__);
138
+ }
139
+ }
140
+
141
+ Signals
142
+ Signals_load (const char* path)
143
+ {
144
+ if (!is_file_exist(path))
145
+ beeps_error(__FILE__, __LINE__, "'%s' not found.", path);
146
+
147
+ WAVEFORMATEX format = {0};
148
+ std::vector<BYTE> bytes;
149
+ load_bytes(&format, &bytes, path);
150
+ if (bytes.empty())
151
+ beeps_error(__FILE__, __LINE__, "failed to read bytes: '%s'", path);
152
+
153
+ uint Bps = format.wBitsPerSample / 8;
154
+ uint nchannels = format.nChannels;
155
+ uint nsamples = bytes.size() / Bps / nchannels;
156
+ Signals signals = Signals_create(nsamples, nchannels, format.nSamplesPerSec);
157
+ Frames* frames = Signals_get_frames(&signals);
158
+
159
+ for (uint channel = 0; channel < nchannels; ++channel)
160
+ {
161
+ switch (Bps)
162
+ {
163
+ case 1:
164
+ {
165
+ const uchar* p = ((uchar*) &bytes[0]) + channel;
166
+ for (uint sample = 0; sample < nsamples; ++sample, p += nchannels)
167
+ (*frames)(sample, channel) = (*p - 128) / 128.f;
168
+ break;
169
+ }
170
+
171
+ case 2:
172
+ {
173
+ const ushort* p = ((ushort*) &bytes[0]) + channel;
174
+ for (uint sample = 0; sample < nsamples; ++sample, p += nchannels)
175
+ (*frames)(sample, channel) = *p / 32768.f;
176
+ break;
177
+ }
178
+ }
179
+ }
180
+
181
+ Signals_set_nsamples(&signals, nsamples);
182
+ return signals;
183
+ }
184
+
185
+
186
+ }// Beeps
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: beeps
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: '0.3'
5
5
  platform: ruby
6
6
  authors:
7
7
  - xordog
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.2.1
19
+ version: '0.3'
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.1
26
+ version: '0.3'
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.1
33
+ version: '0.3'
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.1
40
+ version: '0.3'
41
41
  description: Synthesize and play beep sounds.
42
42
  email: xordog@gmail.com
43
43
  executables: []
@@ -128,6 +128,7 @@ files:
128
128
  - src/adsr.cpp
129
129
  - src/analyser.cpp
130
130
  - src/beeps.cpp
131
+ - src/beeps.h
131
132
  - src/exception.cpp
132
133
  - src/file_in.cpp
133
134
  - src/gain.cpp
@@ -136,6 +137,7 @@ files:
136
137
  - src/openal.cpp
137
138
  - src/openal.h
138
139
  - src/oscillator.cpp
140
+ - src/osx/beeps.mm
139
141
  - src/osx/signals.mm
140
142
  - src/pitch_shift.cpp
141
143
  - src/processor.cpp
@@ -145,6 +147,10 @@ files:
145
147
  - src/sound.cpp
146
148
  - src/sound.h
147
149
  - src/time_stretch.cpp
150
+ - src/win32/beeps.cpp
151
+ - src/win32/exception.cpp
152
+ - src/win32/exception.h
153
+ - src/win32/signals.cpp
148
154
  - test/helper.rb
149
155
  - test/test_beeps.rb
150
156
  - test/test_beeps_init.rb