beeps 0.2.1 → 0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.doc/ext/beeps/adsr.cpp +1 -1
- data/.doc/ext/beeps/analyser.cpp +1 -1
- data/.doc/ext/beeps/file_in.cpp +1 -1
- data/.doc/ext/beeps/gain.cpp +1 -1
- data/.doc/ext/beeps/mic_in.cpp +1 -1
- data/.doc/ext/beeps/oscillator.cpp +1 -1
- data/.doc/ext/beeps/pitch_shift.cpp +1 -1
- data/.doc/ext/beeps/processor.cpp +1 -1
- data/.doc/ext/beeps/sound.cpp +1 -1
- data/.doc/ext/beeps/sound_player.cpp +1 -1
- data/.doc/ext/beeps/time_stretch.cpp +1 -1
- data/.github/workflows/release-gem.yml +1 -1
- data/.github/workflows/test.yml +3 -0
- data/ChangeLog.md +5 -0
- data/Rakefile +3 -1
- data/VERSION +1 -1
- data/beeps.gemspec +2 -2
- data/ext/beeps/adsr.cpp +1 -1
- data/ext/beeps/analyser.cpp +1 -1
- data/ext/beeps/defs.h +2 -0
- data/ext/beeps/extconf.rb +11 -3
- data/ext/beeps/file_in.cpp +1 -1
- data/ext/beeps/gain.cpp +1 -1
- data/ext/beeps/mic_in.cpp +1 -1
- data/ext/beeps/oscillator.cpp +1 -1
- data/ext/beeps/pitch_shift.cpp +1 -1
- data/ext/beeps/processor.cpp +1 -1
- data/ext/beeps/sound.cpp +1 -1
- data/ext/beeps/sound_player.cpp +1 -1
- data/ext/beeps/time_stretch.cpp +1 -1
- data/include/beeps/defs.h +7 -0
- data/include/beeps/ruby/beeps.h +1 -1
- data/include/beeps/ruby/exception.h +2 -2
- data/include/beeps/ruby/filter.h +7 -7
- data/include/beeps/ruby/generator.h +5 -5
- data/include/beeps/ruby/processor.h +2 -2
- data/include/beeps/ruby/sound.h +4 -4
- data/lib/beeps/extension.rb +4 -0
- data/src/beeps.cpp +3 -1
- data/src/beeps.h +22 -0
- data/src/osx/beeps.mm +19 -0
- data/src/win32/beeps.cpp +36 -0
- data/src/win32/exception.cpp +40 -0
- data/src/win32/exception.h +40 -0
- data/src/win32/signals.cpp +186 -0
- metadata +11 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c4df684684e65c0ee091bb8054a55e57cee8e8d9b932382defa62229027cedb7
|
4
|
+
data.tar.gz: 6c59120efd1f32823ef0d1982f243106f38ea4543a568739e9739811ee1e3d4c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db163aa74ddac2978422aa52b3bef3e157295aa93f46a79e8e32b88c0b0752f337cd6bc1636e53dae751ddaac554c86b4daa72ad57f038ddf3586078253bb669
|
7
|
+
data.tar.gz: 9997be8c7be61a021087d05b3e17aa695a07d3a70e9fed9bd61b3b82d66cda81c2e5279a74ef0100771281480d1ada8b9b52d6a936375f1a361fe6aa3d97d5bf
|
data/.doc/ext/beeps/adsr.cpp
CHANGED
data/.doc/ext/beeps/analyser.cpp
CHANGED
data/.doc/ext/beeps/file_in.cpp
CHANGED
data/.doc/ext/beeps/gain.cpp
CHANGED
data/.doc/ext/beeps/mic_in.cpp
CHANGED
data/.doc/ext/beeps/sound.cpp
CHANGED
data/.github/workflows/test.yml
CHANGED
data/ChangeLog.md
CHANGED
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.
|
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.
|
29
|
-
s.add_runtime_dependency 'rucy', '~> 0.
|
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
data/ext/beeps/analyser.cpp
CHANGED
data/ext/beeps/defs.h
CHANGED
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
|
15
|
-
|
16
|
-
|
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'
|
data/ext/beeps/file_in.cpp
CHANGED
data/ext/beeps/gain.cpp
CHANGED
data/ext/beeps/mic_in.cpp
CHANGED
data/ext/beeps/oscillator.cpp
CHANGED
data/ext/beeps/pitch_shift.cpp
CHANGED
data/ext/beeps/processor.cpp
CHANGED
data/ext/beeps/sound.cpp
CHANGED
data/ext/beeps/sound_player.cpp
CHANGED
data/ext/beeps/time_stretch.cpp
CHANGED
data/include/beeps/defs.h
CHANGED
data/include/beeps/ruby/beeps.h
CHANGED
@@ -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
|
|
data/include/beeps/ruby/filter.h
CHANGED
@@ -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
|
|
data/include/beeps/ruby/sound.h
CHANGED
@@ -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
|
|
data/lib/beeps/extension.rb
CHANGED
data/src/beeps.cpp
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
// -*- objc -*-
|
2
|
-
#include "beeps
|
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
data/src/win32/beeps.cpp
ADDED
@@ -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.
|
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.
|
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.
|
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.
|
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.
|
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
|