dsprb 1.0.0 → 2.1.0

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.
data/sig/dsprb.rbs CHANGED
@@ -36,13 +36,37 @@ module DSP
36
36
 
37
37
  def self.mfcc: (
38
38
  Waveform,
39
- ?size: ::Integer,
39
+ ?size: ::Integer?,
40
40
  ?coefficients: ::Integer,
41
41
  ?window_seconds: ::Float,
42
42
  ?hop_seconds: ::Float,
43
43
  **untyped
44
44
  ) -> ::Array[::Array[::Float]]
45
45
 
46
+ module Check
47
+ def self.positive!: [T < _Positive] (T, ::String) -> T
48
+ def self.non_negative!: [T < _Negative] (T, ::String) -> T
49
+ def self.at_least!: [T < ::Comparable] (T, T, ::String) -> T
50
+ def self.power_of_two!: (::Integer, ::String) -> ::Integer
51
+ def self.below!: [T < ::Comparable] (T, T, ::String, ::String) -> T
52
+ def self.present!: [T] (T, ::String) -> T
53
+ end
54
+
55
+ interface _Positive
56
+ def positive?: () -> bool
57
+ end
58
+
59
+ interface _Negative
60
+ def negative?: () -> bool
61
+ end
62
+
63
+ module Prepared
64
+ def self.extended: (untyped) -> void
65
+
66
+ def prepared: [T] (untyped) { () -> T } -> T
67
+ def prepared_count: () -> ::Integer
68
+ end
69
+
46
70
  module Resolver
47
71
  def self.call: (untyped, ::Hash[::Symbol, untyped], ::String) -> untyped
48
72
  end
@@ -86,6 +110,8 @@ module DSP
86
110
  end
87
111
 
88
112
  module Window
113
+ extend Prepared
114
+
89
115
  HAMMING: ::Array[::Float]
90
116
  HANN: ::Array[::Float]
91
117
  BLACKMAN: ::Array[::Float]
@@ -97,6 +123,7 @@ module DSP
97
123
  def self.hann: (::Integer) -> ::Array[::Float]
98
124
  def self.blackman: (::Integer) -> ::Array[::Float]
99
125
  def self.cosine_sum: (::Integer, ::Array[::Float]) -> ::Array[::Float]
126
+ def self.build_cosine_sum: (::Integer, ::Array[::Float]) -> ::Array[::Float]
100
127
  def self.apply: (frame, ::Array[::Float]) -> ::Array[::Float]
101
128
  def self.assert_length!: (untyped) -> void
102
129
  def self.resolve: (window) -> _WindowFunction
@@ -117,6 +144,17 @@ module DSP
117
144
  def initialize: (::Integer) -> void
118
145
  def call: (::Array[::Float], ::Array[::Float]) -> [::Array[::Float], ::Array[::Float]]
119
146
  end
147
+
148
+ class Real
149
+ MINIMUM_SIZE: ::Integer
150
+
151
+ attr_reader size: ::Integer
152
+ attr_reader bins: ::Integer
153
+
154
+ def initialize: (::Integer) -> void
155
+ def call: (frame) -> [::Array[::Float], ::Array[::Float]]
156
+ def power: (frame) -> spectrum
157
+ end
120
158
  end
121
159
 
122
160
  class Spectrum
@@ -178,11 +216,23 @@ module DSP
178
216
  end
179
217
 
180
218
  module Dct
219
+ class Two
220
+ extend Prepared
221
+
222
+ attr_reader length: ::Integer
223
+ attr_reader count: ::Integer
224
+
225
+ def self.for: (::Integer, ::Integer) -> Two
226
+ def initialize: (::Integer, ::Integer) -> void
227
+ def call: (::Array[::Numeric]) -> ::Array[::Float]
228
+ end
229
+
181
230
  def self.two: (::Array[::Numeric], ::Integer) -> ::Array[::Float]
182
231
  end
183
232
 
184
233
  class Mfcc
185
234
  DEFAULT_COEFFICIENTS: ::Integer
235
+ %a{deprecated: the default size follows the frame length; see Mfcc.size_for}
186
236
  DEFAULT_SIZE: ::Integer
187
237
  DEFAULT_WINDOW_SECONDS: ::Float
188
238
  DEFAULT_HOP_SECONDS: ::Float
@@ -191,7 +241,8 @@ module DSP
191
241
  attr_reader spectrum: Spectrum
192
242
  attr_reader coefficients: ::Integer
193
243
 
194
- def self.for: (sample_rate: ::Numeric, ?size: ::Integer, ?coefficients: ::Integer, **untyped) -> Mfcc
244
+ def self.size_for: (::Integer) -> ::Integer
245
+ def self.for: (sample_rate: ::Numeric, ?size: ::Integer?, ?coefficients: ::Integer, **untyped) -> Mfcc
195
246
  def initialize: (filterbank: MelFilterbank, ?coefficients: ::Integer, ?spectrum: Spectrum?) -> void
196
247
  def call: (spectrum) -> ::Array[::Float]
197
248
 
@@ -205,6 +256,8 @@ module DSP
205
256
  end
206
257
 
207
258
  class Decimator
259
+ extend Prepared
260
+
208
261
  DEFAULT_TAPS: ::Integer
209
262
  CUTOFF_RATIO: ::Float
210
263
 
@@ -213,6 +266,8 @@ module DSP
213
266
  attr_reader kernel: ::Array[::Float]
214
267
 
215
268
  def self.factor_for: (::Numeric, ::Numeric) -> ::Integer
269
+ def self.for: (::Integer, ?taps: ::Integer) -> Decimator
270
+ def self.to: (Waveform, ::Numeric, ?taps: ::Integer) -> Waveform
216
271
  def initialize: (::Integer, ?taps: ::Integer) -> void
217
272
  def call: (Waveform) -> Waveform
218
273
  end
@@ -225,6 +280,17 @@ module DSP
225
280
  DENOMINATOR_FLOOR: ::Float
226
281
  UNBOUNDED_MAGNITUDE: ::Float
227
282
 
283
+ class Envelope
284
+ extend Prepared
285
+
286
+ attr_reader points: ::Integer
287
+ attr_reader order: ::Integer
288
+
289
+ def self.for: (points: ::Integer, order: ::Integer) -> Envelope
290
+ def initialize: (points: ::Integer, order: ::Integer) -> void
291
+ def call: (::Array[::Float]) -> ::Array[::Float]
292
+ end
293
+
228
294
  class Model
229
295
  attr_reader coefficients: ::Array[::Float]
230
296
  attr_reader error: ::Float
@@ -239,28 +305,43 @@ module DSP
239
305
  def self.advance: (::Array[::Float], ::Integer, ::Float) -> ::Array[::Float]
240
306
  end
241
307
 
308
+ module Polynomial
309
+ MAXIMUM_ITERATIONS: ::Integer
310
+ TOLERANCE: ::Float
311
+ STARTING_ANGLE: ::Float
312
+
313
+ def self.roots: (::Array[::Numeric]) -> ::Array[::Complex]
314
+ end
315
+
242
316
  class Formants
243
317
  class Peak
244
318
  attr_reader frequency: ::Float
245
319
  attr_reader amplitude: ::Float
320
+ attr_reader bandwidth: ::Float?
246
321
 
247
- def self.new: (frequency: ::Float, amplitude: ::Float) -> Peak
322
+ def self.new: (frequency: ::Float, amplitude: ::Float, ?bandwidth: ::Float?) -> Peak
248
323
  end
249
324
 
250
325
  DEFAULT_MAXIMUM_HZ: ::Float
251
326
  DEFAULT_COUNT: ::Integer
327
+ %a{deprecated: ignored since 2.1.0}
252
328
  DEFAULT_RESOLUTION: ::Integer
329
+ %a{deprecated: ignored since 2.1.0}
253
330
  DEFAULT_SEPARATION_HZ: ::Float
254
331
  DEFAULT_EDGE_MARGIN_HZ: ::Float
332
+ MAXIMUM_BANDWIDTH_HZ: ::Float
255
333
  MINIMUM_SAMPLES: ::Integer
256
334
  ENERGY_FLOOR: ::Float
257
335
  LOG_FLOOR: ::Float
258
336
 
259
337
  attr_reader maximum_frequency: ::Float
260
338
  attr_reader count: ::Integer
339
+ %a{deprecated: ignored since 2.1.0}
261
340
  attr_reader resolution: ::Integer
341
+ %a{deprecated: ignored since 2.1.0}
262
342
  attr_reader separation: ::Float
263
343
  attr_reader edge_margin: ::Float
344
+ attr_reader order: ::Integer
264
345
 
265
346
  def initialize: (
266
347
  ?maximum_frequency: ::Numeric,
@@ -311,6 +392,7 @@ module DSP
311
392
  attr_reader threshold: ::Float
312
393
  attr_reader voiced_threshold: ::Float
313
394
  attr_reader working_rate: ::Float
395
+ attr_reader minimum_rms: ::Float
314
396
 
315
397
  def initialize: (
316
398
  ?minimum_frequency: ::Numeric,
@@ -318,6 +400,7 @@ module DSP
318
400
  ?hop_seconds: ::Numeric,
319
401
  ?threshold: ::Numeric,
320
402
  ?voiced_threshold: ::Numeric,
403
+ ?minimum_rms: ::Numeric,
321
404
  ?working_rate: ::Numeric
322
405
  ) -> void
323
406
 
metadata CHANGED
@@ -1,10 +1,10 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dsprb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
- - Den Patin
7
+ - Den Patin 丁丹旭
8
8
  bindir: bin
9
9
  cert_chain: []
10
10
  date: 1980-01-02 00:00:00.000000000 Z
@@ -54,20 +54,23 @@ dependencies:
54
54
  description: 'Acoustic analysis of speech in pure Ruby: WAV decoding, radix-2 FFT
55
55
  and power spectra, generalized cosine windows, mel filterbanks and MFCC, the YIN
56
56
  fundamental frequency estimator, linear predictive coding by the Levinson-Durbin
57
- recursion with formant extraction from the all-pole envelope, spectral moments,
58
- Butterworth biquads, windowed-sinc decimation and short-term energy measures. No
59
- dependencies, no native extensions, deterministic output.'
57
+ recursion with formant frequencies and bandwidths from the roots of the predictor
58
+ polynomial, spectral moments, Butterworth biquads, windowed-sinc decimation and
59
+ short-term energy measures. No dependencies, no native extensions, deterministic
60
+ output.'
60
61
  email: hi@dpat.in
61
62
  executables: []
62
63
  extensions: []
63
64
  extra_rdoc_files: []
64
65
  files:
65
66
  - CHANGELOG.md
67
+ - CITATION.cff
66
68
  - LICENSE
67
69
  - README.md
68
70
  - lib/dsprb.rb
69
71
  - lib/dsprb/autocorrelation.rb
70
72
  - lib/dsprb/biquad.rb
73
+ - lib/dsprb/check.rb
71
74
  - lib/dsprb/curve.rb
72
75
  - lib/dsprb/dct.rb
73
76
  - lib/dsprb/decimator.rb
@@ -81,6 +84,8 @@ files:
81
84
  - lib/dsprb/mfcc.rb
82
85
  - lib/dsprb/parabolic.rb
83
86
  - lib/dsprb/pitch_track.rb
87
+ - lib/dsprb/polynomial.rb
88
+ - lib/dsprb/prepared.rb
84
89
  - lib/dsprb/resolver.rb
85
90
  - lib/dsprb/scales.rb
86
91
  - lib/dsprb/spectral_moments.rb
@@ -93,7 +98,7 @@ files:
93
98
  - sig/dsprb.rbs
94
99
  homepage: https://github.com/taiwancards/dsprb
95
100
  licenses:
96
- - WTFPL
101
+ - MIT
97
102
  metadata:
98
103
  source_code_uri: https://github.com/taiwancards/dsprb
99
104
  changelog_uri: https://github.com/taiwancards/dsprb/blob/main/CHANGELOG.md
@@ -106,14 +111,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
106
111
  requirements:
107
112
  - - ">="
108
113
  - !ruby/object:Gem::Version
109
- version: '3.2'
114
+ version: '3.4'
110
115
  required_rubygems_version: !ruby/object:Gem::Requirement
111
116
  requirements:
112
117
  - - ">="
113
118
  - !ruby/object:Gem::Version
114
119
  version: '0'
115
120
  requirements: []
116
- rubygems_version: 4.0.16
121
+ rubygems_version: 4.0.20
117
122
  specification_version: 4
118
123
  summary: Speech signal processing and acoustic feature extraction for numeric signals
119
124
  test_files: []