beeps 0.1.32 → 0.1.33
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/adsr.cpp +139 -0
- data/.doc/ext/beeps/analyser.cpp +128 -0
- data/.doc/ext/beeps/beeps.cpp +9 -1
- data/.doc/ext/beeps/file_in.cpp +55 -9
- data/.doc/ext/beeps/gain.cpp +64 -0
- data/.doc/ext/beeps/mic_in.cpp +83 -0
- data/.doc/ext/beeps/native.cpp +20 -8
- data/.doc/ext/beeps/oscillator.cpp +88 -0
- data/.doc/ext/beeps/pitch_shift.cpp +64 -0
- data/.doc/ext/beeps/processor.cpp +31 -2
- data/.doc/ext/beeps/sound.cpp +90 -7
- data/.doc/ext/beeps/sound_player.cpp +156 -0
- data/.doc/ext/beeps/time_stretch.cpp +64 -0
- data/.github/workflows/release-gem.yml +4 -1
- data/ChangeLog.md +8 -0
- data/Rakefile +26 -4
- data/VERSION +1 -1
- data/beeps.gemspec +2 -2
- data/ext/beeps/adsr.cpp +150 -0
- data/ext/beeps/analyser.cpp +134 -0
- data/ext/beeps/beeps.cpp +10 -1
- data/ext/beeps/extconf.rb +1 -2
- data/ext/beeps/file_in.cpp +60 -9
- data/ext/beeps/gain.cpp +67 -0
- data/ext/beeps/mic_in.cpp +88 -0
- data/ext/beeps/native.cpp +20 -8
- data/ext/beeps/oscillator.cpp +93 -0
- data/ext/beeps/pitch_shift.cpp +67 -0
- data/ext/beeps/processor.cpp +34 -2
- data/ext/beeps/sound.cpp +99 -7
- data/ext/beeps/sound_player.cpp +169 -0
- data/ext/beeps/time_stretch.cpp +67 -0
- data/include/beeps/beeps.h +2 -1
- data/include/beeps/filter.h +179 -0
- data/include/beeps/generator.h +120 -0
- data/include/beeps/processor.h +37 -68
- data/include/beeps/ruby/filter.h +78 -0
- data/include/beeps/ruby/generator.h +60 -0
- data/include/beeps/ruby/processor.h +5 -45
- data/include/beeps/ruby/sound.h +14 -3
- data/include/beeps/signals.h +10 -4
- data/include/beeps/sound.h +67 -2
- data/lib/beeps/beeps.rb +6 -1
- data/lib/beeps/processor.rb +95 -15
- data/lib/beeps/sound.rb +29 -2
- data/src/adsr.cpp +245 -0
- data/src/analyser.cpp +254 -0
- data/src/beeps.cpp +11 -2
- data/src/file_in.cpp +94 -0
- data/src/gain.cpp +55 -0
- data/src/mic_in.cpp +262 -0
- data/src/mic_in.h +20 -0
- data/src/openal.cpp +2 -1
- data/src/oscillator.cpp +145 -0
- data/src/osx/signals.mm +83 -0
- data/src/pitch_shift.cpp +82 -0
- data/src/processor.cpp +202 -88
- data/src/processor.h +98 -0
- data/src/signals.cpp +326 -20
- data/src/signals.h +192 -2
- data/src/sound.cpp +735 -113
- data/src/sound.h +6 -1
- data/src/time_stretch.cpp +91 -0
- data/test/helper.rb +2 -1
- data/test/test_beeps.rb +10 -7
- data/test/test_beeps_init.rb +18 -0
- data/test/test_file_in.rb +15 -0
- data/test/test_processor.rb +50 -0
- data/test/test_sound.rb +87 -11
- data/test/test_sound_player.rb +134 -0
- metadata +54 -16
- data/.doc/ext/beeps/sawtooth_wave.cpp +0 -61
- data/.doc/ext/beeps/sine_wave.cpp +0 -61
- data/.doc/ext/beeps/square_wave.cpp +0 -61
- data/ext/beeps/sawtooth_wave.cpp +0 -64
- data/ext/beeps/sine_wave.cpp +0 -64
- data/ext/beeps/square_wave.cpp +0 -64
data/include/beeps/processor.h
CHANGED
@@ -4,6 +4,7 @@
|
|
4
4
|
#define __BEEPS_PROCESSOR_H__
|
5
5
|
|
6
6
|
|
7
|
+
#include <xot/ref.h>
|
7
8
|
#include <xot/pimpl.h>
|
8
9
|
#include <beeps/defs.h>
|
9
10
|
|
@@ -15,118 +16,86 @@ namespace Beeps
|
|
15
16
|
class Signals;
|
16
17
|
|
17
18
|
|
18
|
-
class Processor
|
19
|
+
class Processor : public Xot::RefCountable<>
|
19
20
|
{
|
20
21
|
|
21
|
-
|
22
|
-
|
23
|
-
virtual ~Processor ();
|
24
|
-
|
25
|
-
virtual void process (Signals* signals);
|
26
|
-
|
27
|
-
virtual operator bool () const;
|
28
|
-
|
29
|
-
virtual bool operator ! () const;
|
30
|
-
|
31
|
-
protected:
|
32
|
-
|
33
|
-
Processor ();
|
34
|
-
|
35
|
-
};// Processor
|
36
|
-
|
37
|
-
|
38
|
-
class SineWave : public Processor
|
39
|
-
{
|
40
|
-
|
41
|
-
typedef Processor Super;
|
22
|
+
typedef Processor This;
|
42
23
|
|
43
24
|
public:
|
44
25
|
|
45
|
-
|
26
|
+
class Context {};
|
46
27
|
|
47
|
-
|
28
|
+
typedef Xot::Ref<This> Ref;
|
48
29
|
|
49
|
-
virtual
|
30
|
+
virtual ~Processor ();
|
50
31
|
|
51
|
-
virtual
|
32
|
+
virtual void reset ();
|
52
33
|
|
53
|
-
virtual void
|
34
|
+
virtual void set_input (Processor* input);
|
54
35
|
|
55
|
-
|
36
|
+
virtual Processor* input ();
|
56
37
|
|
57
|
-
|
58
|
-
|
59
|
-
};// SineWave
|
38
|
+
virtual const Processor* input () const;
|
60
39
|
|
40
|
+
virtual operator bool () const;
|
61
41
|
|
62
|
-
|
63
|
-
{
|
42
|
+
virtual bool operator ! () const;
|
64
43
|
|
65
|
-
|
44
|
+
struct Data;
|
66
45
|
|
67
|
-
|
46
|
+
Xot::PImpl<Data> self;
|
68
47
|
|
69
|
-
|
48
|
+
protected:
|
70
49
|
|
71
|
-
|
50
|
+
Processor (bool generator = false);
|
72
51
|
|
73
|
-
virtual void
|
52
|
+
virtual void process (Context* context, Signals* signals, uint* offset) final;
|
74
53
|
|
75
|
-
virtual
|
54
|
+
virtual void generate (Context* context, Signals* signals, uint* offset);
|
76
55
|
|
77
|
-
virtual void
|
56
|
+
virtual void filter (Context* context, Signals* signals, uint* offset);
|
78
57
|
|
79
|
-
|
58
|
+
virtual void set_updated ();
|
80
59
|
|
81
|
-
|
60
|
+
friend class ProcessorContext;
|
82
61
|
|
83
|
-
};//
|
62
|
+
};// Processor
|
84
63
|
|
85
64
|
|
86
|
-
class
|
65
|
+
class Generator : public Processor
|
87
66
|
{
|
88
67
|
|
89
68
|
typedef Processor Super;
|
90
69
|
|
91
|
-
|
92
|
-
|
93
|
-
SawtoothWave ();
|
94
|
-
|
95
|
-
virtual ~SawtoothWave ();
|
96
|
-
|
97
|
-
virtual void set_frequency (float frequency);
|
70
|
+
protected:
|
98
71
|
|
99
|
-
|
72
|
+
Generator ();
|
100
73
|
|
101
|
-
|
74
|
+
private:
|
102
75
|
|
103
|
-
|
76
|
+
void filter (
|
77
|
+
Context* context, Signals* signals, uint* offset) override final;
|
104
78
|
|
105
|
-
|
79
|
+
};// Generator
|
106
80
|
|
107
|
-
};// SawtoothWave
|
108
81
|
|
109
|
-
|
110
|
-
class FileIn : public Processor
|
82
|
+
class Filter : public Processor
|
111
83
|
{
|
112
84
|
|
113
85
|
typedef Processor Super;
|
114
86
|
|
115
|
-
|
116
|
-
|
117
|
-
FileIn (const char* path = NULL);
|
87
|
+
protected:
|
118
88
|
|
119
|
-
|
89
|
+
Filter (Processor* input = NULL);
|
120
90
|
|
121
|
-
|
91
|
+
void set_buffering_seconds (float seconds);
|
122
92
|
|
123
|
-
|
124
|
-
|
125
|
-
struct Data;
|
93
|
+
private:
|
126
94
|
|
127
|
-
|
95
|
+
void generate (
|
96
|
+
Context* context, Signals* signals, uint* offset) override final;
|
128
97
|
|
129
|
-
};//
|
98
|
+
};// Filter
|
130
99
|
|
131
100
|
|
132
101
|
}// Beeps
|
@@ -0,0 +1,78 @@
|
|
1
|
+
// -*- c++ -*-
|
2
|
+
#pragma once
|
3
|
+
#ifndef __BEEPS_RUBY_FILTER_H__
|
4
|
+
#define __BEEPS_RUBY_FILTER_H__
|
5
|
+
|
6
|
+
|
7
|
+
#include <rucy/class.h>
|
8
|
+
#include <rucy/extension.h>
|
9
|
+
#include <beeps/filter.h>
|
10
|
+
|
11
|
+
|
12
|
+
RUCY_DECLARE_WRAPPER_VALUE_FROM_TO(Beeps::TimeStretch)
|
13
|
+
|
14
|
+
RUCY_DECLARE_WRAPPER_VALUE_FROM_TO(Beeps::PitchShift)
|
15
|
+
|
16
|
+
|
17
|
+
namespace Beeps
|
18
|
+
{
|
19
|
+
|
20
|
+
|
21
|
+
Rucy::Class gain_class ();
|
22
|
+
// class Beeps::Gain
|
23
|
+
|
24
|
+
Rucy::Class adsr_class ();
|
25
|
+
// class Beeps::ADSR
|
26
|
+
|
27
|
+
Rucy::Class time_stretch_class ();
|
28
|
+
// class Beeps::TimeStretch
|
29
|
+
|
30
|
+
Rucy::Class pitch_shift_class ();
|
31
|
+
// class Beeps::PitchShift
|
32
|
+
|
33
|
+
Rucy::Class analyser_class ();
|
34
|
+
// class Beeps::Analyser
|
35
|
+
|
36
|
+
|
37
|
+
}// Beeps
|
38
|
+
|
39
|
+
|
40
|
+
namespace Rucy
|
41
|
+
{
|
42
|
+
|
43
|
+
|
44
|
+
template <> inline Class
|
45
|
+
get_ruby_class<Beeps::Gain> ()
|
46
|
+
{
|
47
|
+
return Beeps::gain_class();
|
48
|
+
}
|
49
|
+
|
50
|
+
template <> inline Class
|
51
|
+
get_ruby_class<Beeps::ADSR> ()
|
52
|
+
{
|
53
|
+
return Beeps::adsr_class();
|
54
|
+
}
|
55
|
+
|
56
|
+
template <> inline Class
|
57
|
+
get_ruby_class<Beeps::TimeStretch> ()
|
58
|
+
{
|
59
|
+
return Beeps::time_stretch_class();
|
60
|
+
}
|
61
|
+
|
62
|
+
template <> inline Class
|
63
|
+
get_ruby_class<Beeps::PitchShift> ()
|
64
|
+
{
|
65
|
+
return Beeps::pitch_shift_class();
|
66
|
+
}
|
67
|
+
|
68
|
+
template <> inline Class
|
69
|
+
get_ruby_class<Beeps::Analyser> ()
|
70
|
+
{
|
71
|
+
return Beeps::analyser_class();
|
72
|
+
}
|
73
|
+
|
74
|
+
|
75
|
+
}// Rucy
|
76
|
+
|
77
|
+
|
78
|
+
#endif//EOH
|
@@ -0,0 +1,60 @@
|
|
1
|
+
// -*- c++ -*-
|
2
|
+
#pragma once
|
3
|
+
#ifndef __BEEPS_RUBY_GENERATOR_H__
|
4
|
+
#define __BEEPS_RUBY_GENERATOR_H__
|
5
|
+
|
6
|
+
|
7
|
+
#include <rucy/class.h>
|
8
|
+
#include <rucy/extension.h>
|
9
|
+
#include <beeps/generator.h>
|
10
|
+
|
11
|
+
|
12
|
+
RUCY_DECLARE_WRAPPER_VALUE_FROM_TO(Beeps::Oscillator)
|
13
|
+
|
14
|
+
RUCY_DECLARE_WRAPPER_VALUE_FROM_TO(Beeps::FileIn)
|
15
|
+
|
16
|
+
|
17
|
+
namespace Beeps
|
18
|
+
{
|
19
|
+
|
20
|
+
|
21
|
+
Rucy::Class oscillator_class ();
|
22
|
+
// class Beeps::Oscillator
|
23
|
+
|
24
|
+
Rucy::Class file_in_class ();
|
25
|
+
// class Beeps::FileIn
|
26
|
+
|
27
|
+
Rucy::Class mic_in_class ();
|
28
|
+
// class Beeps::MicIn
|
29
|
+
|
30
|
+
|
31
|
+
}// Beeps
|
32
|
+
|
33
|
+
|
34
|
+
namespace Rucy
|
35
|
+
{
|
36
|
+
|
37
|
+
|
38
|
+
template <> inline Class
|
39
|
+
get_ruby_class<Beeps::Oscillator> ()
|
40
|
+
{
|
41
|
+
return Beeps::oscillator_class();
|
42
|
+
}
|
43
|
+
|
44
|
+
template <> inline Class
|
45
|
+
get_ruby_class<Beeps::FileIn> ()
|
46
|
+
{
|
47
|
+
return Beeps::file_in_class();
|
48
|
+
}
|
49
|
+
|
50
|
+
template <> inline Class
|
51
|
+
get_ruby_class<Beeps::MicIn> ()
|
52
|
+
{
|
53
|
+
return Beeps::mic_in_class();
|
54
|
+
}
|
55
|
+
|
56
|
+
|
57
|
+
}// Rucy
|
58
|
+
|
59
|
+
|
60
|
+
#endif//EOH
|
@@ -9,6 +9,9 @@
|
|
9
9
|
#include <beeps/processor.h>
|
10
10
|
|
11
11
|
|
12
|
+
RUCY_DECLARE_WRAPPER_VALUE_FROM_TO(Beeps::Processor)
|
13
|
+
|
14
|
+
|
12
15
|
namespace Beeps
|
13
16
|
{
|
14
17
|
|
@@ -16,33 +19,14 @@ namespace Beeps
|
|
16
19
|
Rucy::Class processor_class ();
|
17
20
|
// class Beeps::Processor
|
18
21
|
|
19
|
-
Rucy::Class sine_wave_class ();
|
20
|
-
// class Beeps::SineWave
|
21
|
-
|
22
|
-
Rucy::Class square_wave_class ();
|
23
|
-
// class Beeps::SineWave
|
24
|
-
|
25
|
-
Rucy::Class sawtooth_wave_class ();
|
26
|
-
// class Beeps::SawtoothWave
|
27
22
|
|
28
|
-
|
29
|
-
|
23
|
+
template <typename T>
|
24
|
+
class RubyProcessor : public Rucy::ClassWrapper<T> {};
|
30
25
|
|
31
26
|
|
32
27
|
}// Beeps
|
33
28
|
|
34
29
|
|
35
|
-
RUCY_DECLARE_VALUE_FROM_TO(Beeps::Processor)
|
36
|
-
|
37
|
-
RUCY_DECLARE_VALUE_FROM_TO(Beeps::SineWave)
|
38
|
-
|
39
|
-
RUCY_DECLARE_VALUE_FROM_TO(Beeps::SquareWave)
|
40
|
-
|
41
|
-
RUCY_DECLARE_VALUE_FROM_TO(Beeps::SawtoothWave)
|
42
|
-
|
43
|
-
RUCY_DECLARE_VALUE_FROM_TO(Beeps::FileIn)
|
44
|
-
|
45
|
-
|
46
30
|
namespace Rucy
|
47
31
|
{
|
48
32
|
|
@@ -53,30 +37,6 @@ namespace Rucy
|
|
53
37
|
return Beeps::processor_class();
|
54
38
|
}
|
55
39
|
|
56
|
-
template <> inline Class
|
57
|
-
get_ruby_class<Beeps::SineWave> ()
|
58
|
-
{
|
59
|
-
return Beeps::sine_wave_class();
|
60
|
-
}
|
61
|
-
|
62
|
-
template <> inline Class
|
63
|
-
get_ruby_class<Beeps::SquareWave> ()
|
64
|
-
{
|
65
|
-
return Beeps::square_wave_class();
|
66
|
-
}
|
67
|
-
|
68
|
-
template <> inline Class
|
69
|
-
get_ruby_class<Beeps::SawtoothWave> ()
|
70
|
-
{
|
71
|
-
return Beeps::sawtooth_wave_class();
|
72
|
-
}
|
73
|
-
|
74
|
-
template <> inline Class
|
75
|
-
get_ruby_class<Beeps::FileIn> ()
|
76
|
-
{
|
77
|
-
return Beeps::file_in_class();
|
78
|
-
}
|
79
|
-
|
80
40
|
|
81
41
|
}// Rucy
|
82
42
|
|
data/include/beeps/ruby/sound.h
CHANGED
@@ -9,10 +9,18 @@
|
|
9
9
|
#include <beeps/sound.h>
|
10
10
|
|
11
11
|
|
12
|
+
RUCY_DECLARE_VALUE_FROM_TO(Beeps::SoundPlayer)
|
13
|
+
|
14
|
+
RUCY_DECLARE_VALUE_FROM_TO(Beeps::Sound)
|
15
|
+
|
16
|
+
|
12
17
|
namespace Beeps
|
13
18
|
{
|
14
19
|
|
15
20
|
|
21
|
+
Rucy::Class sound_player_class ();
|
22
|
+
// class Beeps::SoundPlayer
|
23
|
+
|
16
24
|
Rucy::Class sound_class ();
|
17
25
|
// class Beeps::Sound
|
18
26
|
|
@@ -20,13 +28,16 @@ namespace Beeps
|
|
20
28
|
}// Beeps
|
21
29
|
|
22
30
|
|
23
|
-
RUCY_DECLARE_VALUE_FROM_TO(Beeps::Sound)
|
24
|
-
|
25
|
-
|
26
31
|
namespace Rucy
|
27
32
|
{
|
28
33
|
|
29
34
|
|
35
|
+
template <> inline Class
|
36
|
+
get_ruby_class<Beeps::SoundPlayer> ()
|
37
|
+
{
|
38
|
+
return Beeps::sound_player_class();
|
39
|
+
}
|
40
|
+
|
30
41
|
template <> inline Class
|
31
42
|
get_ruby_class<Beeps::Sound> ()
|
32
43
|
{
|
data/include/beeps/signals.h
CHANGED
@@ -17,17 +17,23 @@ namespace Beeps
|
|
17
17
|
|
18
18
|
public:
|
19
19
|
|
20
|
-
Signals (
|
20
|
+
Signals ();
|
21
21
|
|
22
22
|
~Signals ();
|
23
23
|
|
24
24
|
Signals dup () const;
|
25
25
|
|
26
|
-
|
26
|
+
double sample_rate () const;
|
27
27
|
|
28
|
-
uint
|
28
|
+
uint nchannels () const;
|
29
29
|
|
30
|
-
uint
|
30
|
+
uint nsamples () const;
|
31
|
+
|
32
|
+
uint capacity () const;
|
33
|
+
|
34
|
+
bool empty () const;
|
35
|
+
|
36
|
+
const double* samples () const;
|
31
37
|
|
32
38
|
operator bool () const;
|
33
39
|
|
data/include/beeps/sound.h
CHANGED
@@ -15,6 +15,48 @@ namespace Beeps
|
|
15
15
|
class Processor;
|
16
16
|
|
17
17
|
|
18
|
+
class SoundPlayer
|
19
|
+
{
|
20
|
+
|
21
|
+
public:
|
22
|
+
|
23
|
+
SoundPlayer ();
|
24
|
+
|
25
|
+
~SoundPlayer ();
|
26
|
+
|
27
|
+
void play ();
|
28
|
+
|
29
|
+
void pause ();
|
30
|
+
|
31
|
+
void rewind ();
|
32
|
+
|
33
|
+
void stop ();
|
34
|
+
|
35
|
+
bool is_playing () const;
|
36
|
+
|
37
|
+
bool is_paused () const;
|
38
|
+
|
39
|
+
bool is_stopped () const;
|
40
|
+
|
41
|
+
void set_gain (float gain);
|
42
|
+
|
43
|
+
float gain () const;
|
44
|
+
|
45
|
+
void set_loop (bool loop);
|
46
|
+
|
47
|
+
bool loop () const;
|
48
|
+
|
49
|
+
operator bool () const;
|
50
|
+
|
51
|
+
bool operator ! () const;
|
52
|
+
|
53
|
+
struct Data;
|
54
|
+
|
55
|
+
Xot::PSharedImpl<Data> self;
|
56
|
+
|
57
|
+
};// SoundPlayer
|
58
|
+
|
59
|
+
|
18
60
|
class Sound
|
19
61
|
{
|
20
62
|
|
@@ -22,11 +64,29 @@ namespace Beeps
|
|
22
64
|
|
23
65
|
Sound ();
|
24
66
|
|
25
|
-
Sound (
|
67
|
+
Sound (
|
68
|
+
Processor* processor, float seconds,
|
69
|
+
uint nchannels = 1, double sample_rate = 0);
|
26
70
|
|
27
71
|
~Sound ();
|
28
72
|
|
29
|
-
|
73
|
+
SoundPlayer play ();
|
74
|
+
|
75
|
+
void save (const char* path) const;
|
76
|
+
|
77
|
+
double sample_rate () const;
|
78
|
+
|
79
|
+
uint nchannels () const;
|
80
|
+
|
81
|
+
float seconds () const;
|
82
|
+
|
83
|
+
void set_gain (float gain);
|
84
|
+
|
85
|
+
float gain () const;
|
86
|
+
|
87
|
+
void set_loop (bool loop);
|
88
|
+
|
89
|
+
bool loop () const;
|
30
90
|
|
31
91
|
operator bool () const;
|
32
92
|
|
@@ -39,6 +99,11 @@ namespace Beeps
|
|
39
99
|
};// Sound
|
40
100
|
|
41
101
|
|
102
|
+
void stop_all_sound_players ();
|
103
|
+
|
104
|
+
Sound load_sound (const char* path);
|
105
|
+
|
106
|
+
|
42
107
|
}// Beeps
|
43
108
|
|
44
109
|
|
data/lib/beeps/beeps.rb
CHANGED
@@ -35,10 +35,15 @@ module Beeps
|
|
35
35
|
beep_sound(2).play
|
36
36
|
end
|
37
37
|
|
38
|
+
def beep_processor=(processor)
|
39
|
+
@beep_processor = processor
|
40
|
+
end
|
41
|
+
|
38
42
|
private
|
39
43
|
|
40
44
|
def beep_sound(time)
|
41
|
-
|
45
|
+
@beep_processor ||= Oscillator.new(:square)
|
46
|
+
Sound.new @beep_processor, time
|
42
47
|
end
|
43
48
|
|
44
49
|
self
|
data/lib/beeps/processor.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
|
4
4
|
require 'xot/setter'
|
5
|
+
require 'xot/const_symbol_accessor'
|
5
6
|
require 'xot/universal_accessor'
|
6
7
|
require 'xot/block_util'
|
7
8
|
require 'beeps/ext'
|
@@ -14,43 +15,122 @@ module Beeps
|
|
14
15
|
|
15
16
|
include Xot::Setter
|
16
17
|
|
17
|
-
def initialize(options
|
18
|
+
def initialize(**options, &block)
|
18
19
|
super()
|
19
|
-
set options
|
20
|
+
set options unless options.empty?
|
20
21
|
Xot::BlockUtil.instance_eval_or_block_call self, &block if block
|
21
22
|
end
|
22
23
|
|
24
|
+
def >>(o)
|
25
|
+
o.input = self
|
26
|
+
o
|
27
|
+
end
|
28
|
+
|
29
|
+
def <<(o)
|
30
|
+
self.input = o
|
31
|
+
o
|
32
|
+
end
|
33
|
+
|
34
|
+
universal_accessor :input
|
35
|
+
|
23
36
|
end# Processor
|
24
37
|
|
25
38
|
|
26
|
-
class
|
39
|
+
class Oscillator
|
40
|
+
|
41
|
+
const_symbol_accessor :type, **{
|
42
|
+
none: NONE,
|
43
|
+
sine: SINE,
|
44
|
+
triangle: TRIANGLE,
|
45
|
+
square: SQUARE,
|
46
|
+
sawtooth: SAWTOOTH
|
47
|
+
}
|
48
|
+
|
49
|
+
def initialize(type = :sine, *args, **kwargs, &block)
|
50
|
+
super(*args, **kwargs, &block)
|
51
|
+
self.type = type
|
52
|
+
end
|
27
53
|
|
28
54
|
alias freq= frequency=
|
29
55
|
alias freq frequency
|
30
56
|
|
31
|
-
universal_accessor :frequency, :freq
|
57
|
+
universal_accessor :type, :frequency, :freq
|
32
58
|
|
33
|
-
end#
|
59
|
+
end# Oscillator
|
34
60
|
|
35
61
|
|
36
|
-
class
|
62
|
+
class FileIn
|
37
63
|
|
38
|
-
|
39
|
-
|
64
|
+
def initialize(path = nil, *args, **kwargs, &block)
|
65
|
+
super(*args, **kwargs, &block)
|
66
|
+
self.path = path if path
|
67
|
+
end
|
40
68
|
|
41
|
-
universal_accessor :
|
69
|
+
universal_accessor :path
|
42
70
|
|
43
|
-
end#
|
71
|
+
end# FileIn
|
44
72
|
|
45
73
|
|
46
|
-
class
|
74
|
+
class Gain
|
47
75
|
|
48
|
-
|
49
|
-
|
76
|
+
universal_accessor :gain
|
77
|
+
|
78
|
+
end# Gain
|
79
|
+
|
80
|
+
|
81
|
+
class ADSR
|
82
|
+
|
83
|
+
def note_on(delay = 0)
|
84
|
+
note_on! delay
|
85
|
+
end
|
86
|
+
|
87
|
+
def note_off(delay = 0)
|
88
|
+
note_off! delay
|
89
|
+
end
|
90
|
+
|
91
|
+
universal_accessor :attack_time, :decay_time, :sustain_level, :release_time
|
92
|
+
|
93
|
+
alias attack= attack_time=
|
94
|
+
alias attack attack_time
|
95
|
+
alias decay= decay_time=
|
96
|
+
alias decay decay_time
|
97
|
+
alias sustain= sustain_level=
|
98
|
+
alias sustain sustain_level
|
99
|
+
alias release= release_time=
|
100
|
+
alias release release_time
|
101
|
+
|
102
|
+
end# ADSR
|
103
|
+
|
104
|
+
|
105
|
+
class TimeStretch
|
106
|
+
|
107
|
+
universal_accessor :scale
|
108
|
+
|
109
|
+
end# TimeStretch
|
110
|
+
|
111
|
+
|
112
|
+
class PitchShift
|
113
|
+
|
114
|
+
universal_accessor :shift
|
115
|
+
|
116
|
+
end# PitchShift
|
117
|
+
|
118
|
+
|
119
|
+
class Analyser
|
120
|
+
|
121
|
+
def each_signal(nsamples = fft_size, &block)
|
122
|
+
return enum_for(:each_signal, nsamples) unless block
|
123
|
+
each_signal!(nsamples, &block)
|
124
|
+
end
|
125
|
+
|
126
|
+
def each_spectrum(&block)
|
127
|
+
return enum_for(:each_spectrum) unless block
|
128
|
+
each_spectrum!(&block)
|
129
|
+
end
|
50
130
|
|
51
|
-
universal_accessor :
|
131
|
+
universal_accessor :fft_size
|
52
132
|
|
53
|
-
end#
|
133
|
+
end# Analyser
|
54
134
|
|
55
135
|
|
56
136
|
end# Beeps
|