Module: Noyes

Includes:
Math
Defined in:
lib/noyes.rb,
lib/noyes_c.rb,
lib/ruby_impl/dct.rb,
lib/ruby_impl/delta.rb,
lib/common/noyes_dsl.rb,
lib/ruby_impl/filter.rb,
lib/ruby_impl/segment.rb,
lib/ruby_impl/live_cmn.rb,
lib/ruby_impl/mel_filter.rb,
lib/ruby_impl/power_spec.rb,
lib/ruby_impl/preemphasis.rb,
lib/ruby_impl/compression.rb,
lib/ruby_impl/log_compress.rb,
lib/ruby_impl/hamming_window.rb,
lib/ruby_impl/speech_trimmer.rb,
lib/ruby_impl/bent_cent_marker.rb,
lib/ruby_impl/discrete_fourier_transform.rb

Overview

The NoyesC module encapsulates the C implementation of the Noyes library. Functionally, it is identical to the Noyes and NoyesJava modules. The NoyesC implementation is composed of Ruby bindings, which are written in C and the core C routines. The core C routines are not dependent on the Ruby wrappers or any Ruby libraries. They can be compiled into pure C implementations without modification. The underlying pure C implementation files can be identified by the 'c_' prefix.

The underlying C implementation closely parallels the Noyes API. For example, the following Ruby and C code are identical.

pre = NoyesC::Preemphasizer.new 0.97
preemphasized_data = pre << data


Preemphasizer *pre = preemphasizer_new(0.97);
Carr * preemphasized_data = preemphasizer_apply(data);

Defined Under Namespace

Classes: BentCentMarker, BitArray, Compression, Compressor, DCT, DeltaDecoder, DeltaEncoder, DoubleDeltaFilter, Filter, FloatAssembler, FloatSplitter, GolombRiceDecoder, GolombRiceEncoder, HammingWindow, LiveCMN, LogCompressor, MelFilter, NullCompressor, NullDecompressor, PowerSpectrumFilter, Preemphasizer, Segmenter, SpeechTrimmer, ULaw

Instance Method Summary collapse

Methods included from Math

#dot_product, log2, max, min

Instance Method Details

#dft(data, size) ⇒ Object

Takes the discrete Fourier transform.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/ruby_impl/discrete_fourier_transform.rb', line 6

def dft data,size
  vals = Array.new(size) do |i| 
    i < data.size ? Complex(data[i],0) : Complex(0,0)
  end
  j=0
  size.times do |i|
    vals[j],vals[i] = vals[i],vals[j] if i<j
    m = size/2
    while j>=m && m>1
      j-=m 
      m/=2
    end
    j+=m
  end
  k=1
  while k<size
    incr = 2*k
    mul = Complex.polar 1, Math::PI/k
    w = Complex(1, 0)
    k.times do |i|
      i.step(size-1,incr) do |j|
        tmp =  w * vals[j+k]
        vals[j+k],vals[j]=vals[j]-tmp,vals[j]+tmp
      end
      w *= mul;
    end
    k=incr
  end
  vals
end