WaveSwissKnife 0.3.1.20130103 → 0.4.0.20130322

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/AUTHORS CHANGED
@@ -4,3 +4,4 @@
4
4
  * 0.2.0.20120302
5
5
  * 0.3.0.20121227
6
6
  * 0.3.1.20130103
7
+ * 0.4.0.20130322
data/ChangeLog CHANGED
@@ -1,5 +1,11 @@
1
1
  = WaveSwissKnife Release History
2
2
 
3
+ == 0.4.0.20130322 (Beta)
4
+
5
+ * GMP library automatically installs if absent
6
+ * Added support for Travis
7
+ * Bug correction: Rational did not inspect the same as before.
8
+
3
9
  == 0.3.1.20130103 (Beta)
4
10
 
5
11
  * Bug correction: Core dumps using Ruby 1.9 and/or 64 bits environments
data/ReleaseInfo CHANGED
@@ -2,7 +2,7 @@
2
2
  # This file has been generated by RubyPackager during a delivery.
3
3
  # More info about RubyPackager: http://rubypackager.sourceforge.net
4
4
  {
5
- :version => '0.3.1.20130103',
5
+ :version => '0.4.0.20130322',
6
6
  :tags => [ 'Beta' ],
7
7
  :dev_status => 'Beta'
8
8
  }
data/bin/WSK.rb CHANGED
@@ -5,7 +5,7 @@
5
5
  #++
6
6
 
7
7
  # Main file
8
-
8
+ require 'rubygems'
9
9
  require 'rUtilAnts/Logging'
10
10
  RUtilAnts::Logging::install_logger_on_object
11
11
  require 'WSK/Common'
@@ -3,6 +3,11 @@
3
3
  # Licensed under the terms specified in LICENSE file. No warranty is provided.
4
4
  #++
5
5
 
6
+ require 'rubygems'
7
+ require 'mkmf'
8
+
9
+ ROOT_DIR = File.expand_path("#{File.dirname(__FILE__)}/../..")
10
+
6
11
  # Build external libraries.
7
12
  # Set CFLAGS and LDFLAGS accordingly.
8
13
  #
@@ -24,6 +29,83 @@ def build_external_libs(*iLstExternalLibs)
24
29
  end
25
30
  end
26
31
 
27
- require 'mkmf'
32
+ # Execute a command, with nice logging and error handling around
33
+ #
34
+ # Parameters:
35
+ # * *iCmd* (_String_): Command to execute
36
+ def exec_cmd(iCmd)
37
+ puts "[#{Dir.getwd}]> #{iCmd}"
38
+ raise RuntimeError, "Unable to execute \"#{iCmd}\" on your system." if !system(iCmd)
39
+ puts ''
40
+ end
41
+
42
+ # Build a local copy of GMP, downloaded directly from the Internet
43
+ def build_local_gmp
44
+ lGMPBaseName = 'gmp-5.1.1'
45
+ lGMPDir = "#{ROOT_DIR}/gmp"
46
+ lGMPInstallDir = "#{ROOT_DIR}/gmp/#{lGMPBaseName}-install"
47
+
48
+ puts "**** Have to download, compile and install the GMP library in #{lGMPInstallDir}."
49
+ puts ''
50
+
51
+ FileUtils::mkdir_p(lGMPDir)
52
+ lOldDir = Dir.getwd
53
+ Dir.chdir(lGMPDir)
54
+ begin
55
+ puts "** Download #{lGMPBaseName} from ftp://ftp.gmplib.org/pub/gmp/#{lGMPBaseName}.tar.bz2 ..."
56
+ require 'net/ftp'
57
+ ftp = Net::FTP.new('ftp.gmplib.org')
58
+ ftp.login
59
+ ftp.getbinaryfile("pub/gmp/#{lGMPBaseName}.tar.bz2")
60
+ ftp.close
61
+ puts '** Extract archive contents ...'
62
+ exec_cmd "tar xjf #{lGMPBaseName}.tar.bz2"
63
+ Dir.chdir(lGMPBaseName)
64
+ puts '** Configure GMP for compilation ...'
65
+ exec_cmd "./configure --prefix=#{lGMPInstallDir}"
66
+ puts '** Compile GMP ...'
67
+ exec_cmd 'make'
68
+ puts "** Install locally GMP in #{lGMPInstallDir} ..."
69
+ exec_cmd 'make install'
70
+ ensure
71
+ Dir.chdir(lOldDir)
72
+ end
73
+
74
+ puts "**** GMP installed correctly in #{lGMPInstallDir}."
75
+ puts ''
76
+ end
77
+
78
+ # Look for GMP in system and locally
79
+ # If it is found, compilation and link options will include it
80
+ #
81
+ # Return:
82
+ # * _Boolean_: Has GMP been found?
83
+ def find_gmp
84
+ rSuccess = have_library('gmp','mpz_get_str','gmp.h')
85
+
86
+ if (!rSuccess)
87
+ # Find locally installed GMP
88
+ lGMPDir = File.expand_path("#{File.dirname(__FILE__)}/../../gmp")
89
+ if (File.exist?(lGMPDir))
90
+ lLastInstalledGMP = Dir.glob("#{lGMPDir}/*-install").sort[-1]
91
+ if (lLastInstalledGMP != nil)
92
+ puts "Found GMP installed in #{lLastInstalledGMP}."
93
+ find_header('gmp.h',"#{lLastInstalledGMP}/include")
94
+ find_library('gmp',nil,"#{lLastInstalledGMP}/lib")
95
+ rSuccess = true
96
+ else
97
+ puts 'Could not find GMP library installed locally.'
98
+ end
99
+ end
100
+ end
101
+
102
+ return rSuccess
103
+ end
104
+
28
105
  $CFLAGS += ' -Wall '
106
+ if (!find_gmp)
107
+ build_local_gmp
108
+ raise RuntimeError, 'Unable to install GMP library automatically. Please do it manually from http://gmplib.org before attempting to install WaveSwissKnife.' unless find_gmp
109
+ end
110
+
29
111
  build_external_libs('CommonUtils')
@@ -23,7 +23,7 @@ module WSK
23
23
  def get_nbr_samples(iInputData)
24
24
  @Function = WSK::Functions::Function.new
25
25
  @Function.read_from_file(@FctFileName)
26
- lMinX, lMinY, lMaxX, lMaxY = @Function.get_bounds
26
+ lMinX, _, lMaxX, _ = @Function.get_bounds
27
27
  @NbrSamplesOut = lMaxX.to_i-lMinX.to_i+1
28
28
 
29
29
  return @NbrSamplesOut
@@ -46,7 +46,7 @@ module WSK
46
46
  lFunction.read_from_input_volume(iInputData, lIdxBegin, lIdxEnd, lInterval, @RMSRatio)
47
47
  # Normalize the volume function on a [-1..1] scale
48
48
  lFunction.divide_by(Rational(2)**(iInputData.Header.NbrBitsPerSample-1))
49
- lMinX, lMinY, lMaxX, lMaxY = lFunction.get_bounds
49
+ _, lMinY, _, lMaxY = lFunction.get_bounds
50
50
  lDBMinY = lFunction.value_val_2_db(lMinY, Rational(1))
51
51
  lDBMaxY = lFunction.value_val_2_db(lMaxY, Rational(1))
52
52
  log_info "Dynamic range: [#{sprintf('%.2f',lMinY)} - #{sprintf('%.2f',lMaxY)}] ([#{sprintf('%.2f',lDBMinY)}db - #{sprintf('%.2f',lDBMaxY)}db] = #{sprintf('%.2f',lDBMaxY-lDBMinY)}db)"
data/lib/WSK/Functions.rb CHANGED
@@ -5,6 +5,15 @@
5
5
 
6
6
  require 'rational'
7
7
 
8
+ # Make sure pretty_inspect uses Rational constructor
9
+ class Rational
10
+
11
+ def inspect
12
+ "Rational(#{self.numerator}, #{self.denominator})"
13
+ end
14
+
15
+ end
16
+
8
17
  # Convert a float to a Rational
9
18
  class Float
10
19
 
@@ -227,7 +236,7 @@ module WSK
227
236
  log_err "Unknown function type: #{@Function[:FunctionType]}"
228
237
  end
229
238
  end
230
-
239
+
231
240
  # Round values to a given precision
232
241
  #
233
242
  # Parameters::
@@ -244,7 +253,7 @@ module WSK
244
253
  end
245
254
  optimize
246
255
  end
247
-
256
+
248
257
  # Apply damping.
249
258
  #
250
259
  # Parameters::
@@ -607,7 +616,7 @@ module WSK
607
616
  def value_log(iValue)
608
617
  return Math::log(iValue).to_r
609
618
  end
610
-
619
+
611
620
  # Compute a DB value out of a ratio using function values
612
621
  #
613
622
  # Parameters::
@@ -618,7 +627,7 @@ module WSK
618
627
  def value_val_2_db(iValue, iMaxValue)
619
628
  @Log2 = Math::log(2).to_r
620
629
  @LogMax = value_log(iMaxValue)
621
-
630
+
622
631
  return value_val_2_db_Internal(iValue)
623
632
  end
624
633
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: WaveSwissKnife
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1.20130103
4
+ version: 0.4.0.20130322
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-03 00:00:00.000000000 Z
12
+ date: 2013-03-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rUtilAnts