spcore 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog.rdoc CHANGED
@@ -24,3 +24,7 @@ Add EnvelopeDetector#attack_time= and EnvelopeDetector#release_time=
24
24
  ** Discrete and Polynomial resampling classes, each with an .upsample method.
25
25
  ** Plotter class to make graphing with gnuplot easier. Has #plot_1d and #plot_2d methods.
26
26
  ** Signal class for testing convenience. Contains signal data and has convenience methods for plotting, correlation, energy, etc.
27
+
28
+ === 0.1.4 / 2013-02-19
29
+
30
+ Fixed gemspec to always depend on gnuplot (not just for development).
data/README.rdoc CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  * {Homepage}[https://rubygems.org/gems/spcore]
4
4
  * {Documentation}[http://rubydoc.info/gems/spcore/frames]
5
- * {Email}[mailto:jamestunnell at lavabit.com]
5
+ * {Email}[jamestunnell@lavabit.com]
6
6
 
7
7
  == Description
8
8
 
@@ -10,20 +10,20 @@ A library of signal processing methods and classes.
10
10
 
11
11
  == Features
12
12
 
13
- Resampling (discrete up, down and up/down, polynomial up, and hybrid up/down)
14
- FFT transform (forward and inverse)
15
- DFT transform (forward and inverse)
16
- Windows (Blackman, Hamming, etc.)
17
- Windowed sinc filter for lowpass and highpass.
18
- Dual windowed sinc filter for bandpass and bandstop.
19
- Interpolation (linear and polynomial)
20
- Data plotting via gnuplot (must be installed to use).
21
- Delay line
22
- Biquad filters
23
- Envelope detector
24
- Conversion from dB-linear and linear-dB
25
- Oscillator with selectable wave type (sine, square, triangle, sawtooth)
26
- Signal abstraction class.
13
+ * Resampling (discrete up, down and up/down, polynomial up, and hybrid up/down)
14
+ * FFT transform (forward and inverse)
15
+ * DFT transform (forward and inverse)
16
+ * Windows (Blackman, Hamming, etc.)
17
+ * Windowed sinc filter for lowpass and highpass.
18
+ * Dual windowed sinc filter for bandpass and bandstop.
19
+ * Interpolation (linear and polynomial)
20
+ * Data plotting via gnuplot (must be installed to use).
21
+ * Delay line
22
+ * Biquad filters
23
+ * Envelope detector
24
+ * Conversion from dB-linear and linear-dB
25
+ * Oscillator with selectable wave type (sine, square, triangle, sawtooth)
26
+ * Signal abstraction class
27
27
 
28
28
  == Examples
29
29
 
@@ -16,8 +16,8 @@ class Signal
16
16
 
17
17
  # A new instance of Signal.
18
18
  #
19
- # @param [Hash] args Hashed arguments. Required keys are :data and :sample_rate.
20
- # See ARG_SPECS for more details.
19
+ # @param [Hash] hashed_args Hashed arguments. Required keys are :data and
20
+ # :sample_rate. See ARG_SPECS for more details.
21
21
  def initialize hashed_args
22
22
  hash_make Signal::ARG_SPECS, hashed_args
23
23
  end
@@ -43,9 +43,14 @@ class Signal
43
43
  @data[arg]
44
44
  end
45
45
 
46
- def plot_data
47
- plotter = Plotter.new(:title => "signal data sequence", :xtitle => "sample numbers", :ytitle => "sample values")
48
- plotter.plot_1d "signal data" => @data
46
+ # Plot the signal data, either against sample numbers or fraction of total samples.
47
+ # @param plot_against_fraction If false, plot data against sample number. If true,
48
+ # plot against fraction of total samples.
49
+ def plot_data plot_against_fraction
50
+ xtitle = (plot_against_fraction ? "fraction of total samples" : "sample numbers")
51
+ plotter = Plotter.new(:title => "signal data sequence", :xtitle => xtitle, :ytitle => "sample values")
52
+ titled_sequence = {"signal data" => @data}
53
+ plotter.plot_1d titled_sequence, plot_against_fraction
49
54
  end
50
55
 
51
56
  # Increase the sample rate of signal data by the given factor using
@@ -17,7 +17,7 @@ class Interpolation
17
17
  # Given 2 sample points, interpolates a value anywhere between the two points.
18
18
  #
19
19
  # @param [Numeric] y0 First (left) y-value
20
- # @param [Numeric] y0 Second (right) y-value
20
+ # @param [Numeric] y1 Second (right) y-value
21
21
  # @param [Numeric] x Percent distance (along the x-axis) between the two y-values
22
22
  def self.linear y0, y1, x
23
23
  raise ArgumentError, "x is not between 0.0 and 1.0" unless x.between?(0.0,1.0)
@@ -26,8 +26,10 @@ class Plotter
26
26
 
27
27
  # Plot XY datapoints.
28
28
  # @param [Hash] titled_hashes A hash that maps dataset titles to data. The data itself
29
- # is a hash also, that maps x values to y values. For example,
30
- # plot_2d could be called passing it the hash { "somedata" => {0.0 => 4.0, 1.0 => 2.0}}
29
+ # is a hash also, that maps x values to y values.
30
+ #
31
+ # @example
32
+ # Plotter.plot_2d "somedata" => {0.0 => 4.0, 1.0 => 2.0}
31
33
  def plot_2d titled_hashes
32
34
  datasets = []
33
35
  titled_hashes.each do |title, hash|
@@ -45,10 +47,12 @@ class Plotter
45
47
  # Plot a sequence of values.
46
48
  # @param [Hash] titled_sequences A hash that maps sequence titles to data. The data itself
47
49
  # is an array of values. In the plot, values will be mapped to
48
- # their index in the sequence. For example, plot_1d could be
49
- # called passing it the hash { "somedataseq" => [0,2,3,6,3,-1]}
50
+ # their index in the sequence.
50
51
  # @param plot_against_fraction If true, instead of plotting samples against sample number, plot
51
52
  # them against the fraction (sample_number / total_samples).
53
+ #
54
+ # @example
55
+ # Plotter.plot_1d "somedata" => [0,2,3,6,3,-1]
52
56
  def plot_1d titled_sequences, plot_against_fraction = false
53
57
  datasets = []
54
58
  titled_sequences.each do |title, sequence|
@@ -1,5 +1,5 @@
1
1
  # A library of signal processing methods and classes.
2
2
  module SPCore
3
3
  # spcore version
4
- VERSION = "0.1.3"
4
+ VERSION = "0.1.4"
5
5
  end
data/spcore.gemspec CHANGED
@@ -8,20 +8,20 @@ Gem::Specification.new do |gem|
8
8
  gem.summary = %q{A library of signal processing methods and classes.}
9
9
  gem.description = <<DESCRIPTION
10
10
  Contains core signal processing methods and classes, including:
11
- Resampling (discrete up, down and up/down, polynomial up, and hybrid up/down)
12
- FFT transform (forward and inverse)
13
- DFT transform (forward and inverse)
14
- Windows (Blackman, Hamming, etc.)
15
- Windowed sinc filter for lowpass and highpass.
16
- Dual windowed sinc filter for bandpass and bandstop.
17
- Interpolation (linear and polynomial)
18
- Data plotting via gnuplot (must be installed to use).
19
- Delay line
20
- Biquad filters
21
- Envelope detector
22
- Conversion from dB-linear and linear-dB
23
- Oscillator with selectable wave type (sine, square, triangle, sawtooth)
24
- Signal abstraction class.
11
+ * Resampling (discrete up, down and up/down, polynomial up, and hybrid up/down).
12
+ * FFT transform (forward and inverse).
13
+ * DFT transform (forward and inverse).
14
+ * Windows (Blackman, Hamming, etc.).
15
+ * Windowed sinc filter for lowpass and highpass.
16
+ * Dual windowed sinc filter for bandpass and bandstop.
17
+ * Interpolation (linear and polynomial).
18
+ * Data plotting via gnuplot (must be installed to use).
19
+ * Delay line.
20
+ * Biquad filters.
21
+ * Envelope detector.
22
+ * Conversion from dB-linear and linear-dB.
23
+ * Oscillator with selectable wave type (sine, square, triangle, sawtooth).
24
+ * Signal abstraction class.
25
25
 
26
26
  DESCRIPTION
27
27
  gem.license = "MIT"
@@ -35,11 +35,11 @@ DESCRIPTION
35
35
  gem.require_paths = ['lib']
36
36
 
37
37
  gem.add_dependency 'hashmake'
38
+ gem.add_dependency 'gnuplot'
38
39
 
39
40
  gem.add_development_dependency 'bundler', '~> 1.0'
40
41
  gem.add_development_dependency 'rake', '~> 0.8'
41
42
  gem.add_development_dependency 'rspec', '~> 2.4'
42
43
  gem.add_development_dependency 'yard', '~> 0.8'
43
44
  gem.add_development_dependency 'pry'
44
- gem.add_development_dependency 'gnuplot'
45
45
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spcore
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -27,6 +27,22 @@ dependencies:
27
27
  - - ! '>='
28
28
  - !ruby/object:Gem::Version
29
29
  version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: gnuplot
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
30
46
  - !ruby/object:Gem::Dependency
31
47
  name: bundler
32
48
  requirement: !ruby/object:Gem::Requirement
@@ -107,31 +123,15 @@ dependencies:
107
123
  - - ! '>='
108
124
  - !ruby/object:Gem::Version
109
125
  version: '0'
110
- - !ruby/object:Gem::Dependency
111
- name: gnuplot
112
- requirement: !ruby/object:Gem::Requirement
113
- none: false
114
- requirements:
115
- - - ! '>='
116
- - !ruby/object:Gem::Version
117
- version: '0'
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
- requirements:
123
- - - ! '>='
124
- - !ruby/object:Gem::Version
125
- version: '0'
126
126
  description: ! "Contains core signal processing methods and classes, including:\n
127
- \ Resampling (discrete up, down and up/down, polynomial up, and hybrid up/down)\n
128
- \ FFT transform (forward and inverse)\n DFT transform (forward and inverse)\n Windows
129
- (Blackman, Hamming, etc.)\n Windowed sinc filter for lowpass and highpass.\n Dual
130
- windowed sinc filter for bandpass and bandstop.\n Interpolation (linear and polynomial)\n
131
- \ Data plotting via gnuplot (must be installed to use).\n Delay line\n Biquad
132
- filters\n Envelope detector\n Conversion from dB-linear and linear-dB\n Oscillator
133
- with selectable wave type (sine, square, triangle, sawtooth)\n Signal abstraction
134
- class.\n\n"
127
+ \ * Resampling (discrete up, down and up/down, polynomial up, and hybrid up/down).\n
128
+ \ * FFT transform (forward and inverse).\n * DFT transform (forward and inverse).\n
129
+ \ * Windows (Blackman, Hamming, etc.).\n * Windowed sinc filter for lowpass and
130
+ highpass.\n * Dual windowed sinc filter for bandpass and bandstop.\n * Interpolation
131
+ (linear and polynomial).\n * Data plotting via gnuplot (must be installed to use).\n
132
+ \ * Delay line.\n * Biquad filters.\n * Envelope detector.\n * Conversion from
133
+ dB-linear and linear-dB.\n * Oscillator with selectable wave type (sine, square,
134
+ triangle, sawtooth).\n * Signal abstraction class.\n\n"
135
135
  email: jamestunnell@lavabit.com
136
136
  executables: []
137
137
  extensions: []
@@ -225,7 +225,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
225
225
  version: '0'
226
226
  segments:
227
227
  - 0
228
- hash: 272931151
228
+ hash: -91888305
229
229
  required_rubygems_version: !ruby/object:Gem::Requirement
230
230
  none: false
231
231
  requirements:
@@ -234,7 +234,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
234
234
  version: '0'
235
235
  segments:
236
236
  - 0
237
- hash: 272931151
237
+ hash: -91888305
238
238
  requirements: []
239
239
  rubyforge_project:
240
240
  rubygems_version: 1.8.23