JOCLoudness 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -0
- data/lib/JOCLoudness.rb +12 -1
- data/lib/Loudness/IIRFilter/IIRFilter.rb +9 -4
- data/lib/Loudness/JOCLoud.rb +4 -2
- data/lib/Loudness/Mean/MeanFast.rb +14 -3
- data/lib/Loudness/PreFilter/PREFilter.rb +13 -6
- data/lib/Loudness/RlbFilter/RLBFilter.rb +13 -7
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3df471c2ebdf1e1e25de968b5ab074a267a79a05
|
4
|
+
data.tar.gz: 9d13fc517b4901bde3e184692a62aefa2e2e3d99
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cdb7f39ba81828c04f7bef651ee9bd7b733a2c353e745d0a05be8cb71b53d73cbca896f6fc8e2b04e25f3a9edc8bbb9df02cfc720aa3162694d389d654013330
|
7
|
+
data.tar.gz: 27e15a6d9dd5bd67a4f5eb5d680f9659fa393e83fb811de19693d74bdecec1de2048f75339c21996a5158592936e0c8b90d4b5915c52aa0da49e0b5cc58f603d
|
data/README.md
ADDED
data/lib/JOCLoudness.rb
CHANGED
@@ -1,4 +1,15 @@
|
|
1
|
-
#
|
1
|
+
# JOCLoudness -- Wav loudness computation
|
2
|
+
# Copyright (c) 2014 Jordi Cenzano.
|
3
|
+
|
4
|
+
if RUBY_VERSION <= "1.9"
|
5
|
+
fail "JOCLoudness requires ruby >= 1.9.3."
|
6
|
+
end
|
7
|
+
|
2
8
|
require 'logger'
|
3
9
|
require_relative './WavReader/wavfile'
|
4
10
|
require_relative './Loudness/jocLoud.rb'
|
11
|
+
|
12
|
+
# = JOCLoudness
|
13
|
+
#
|
14
|
+
# This ruby native gem is able to load a wav file and calculate its LKFS following the ITU-R BS.1770
|
15
|
+
#
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#file: IIRFilter.rb
|
2
2
|
|
3
|
-
#IIR filter
|
3
|
+
#IIR filter implementation
|
4
4
|
class IIRFilter
|
5
5
|
|
6
6
|
def initialize(order)
|
@@ -15,7 +15,9 @@ class IIRFilter
|
|
15
15
|
|
16
16
|
end
|
17
17
|
|
18
|
-
#Set
|
18
|
+
#Set IIR filter coeficients
|
19
|
+
# @param b [Array] sets the B coeficients of IIR filter example: [1.02, 0.99]
|
20
|
+
# @param a [Array] sets the A coeficients of IIR filter example: [1.02, 0.99]
|
19
21
|
def SetCoefs (b, a)
|
20
22
|
if ((a.kind_of?(Array) == false) or (b.kind_of?(Array) == false))
|
21
23
|
raise 'Filter coeficinets must be an array'
|
@@ -29,7 +31,9 @@ class IIRFilter
|
|
29
31
|
|
30
32
|
end
|
31
33
|
|
32
|
-
#
|
34
|
+
#Set IIR filter coeficients
|
35
|
+
# @param bsampleIn [Float] enters a new sample to filter
|
36
|
+
# @return [Float] the output filtered sample
|
33
37
|
def FilterSample (sampleIn)
|
34
38
|
|
35
39
|
nFilterCoefs = @Order + 1;
|
@@ -76,7 +80,8 @@ class IIRFilter
|
|
76
80
|
return ox
|
77
81
|
end
|
78
82
|
|
79
|
-
#
|
83
|
+
#Gets filter information
|
84
|
+
# @return [String] filter information
|
80
85
|
def Info
|
81
86
|
return "IIR Filter Order #{@Order}\nACoefs #{@ACoefs}\nBCoefs #{@BCoefs}\n"
|
82
87
|
end
|
data/lib/Loudness/JOCLoud.rb
CHANGED
@@ -6,7 +6,6 @@ require_relative './Mean/MeanFast.rb'
|
|
6
6
|
#Loudness computation class (Based on ITU-R BS.1770)
|
7
7
|
class JOCLoud
|
8
8
|
|
9
|
-
# Constructor
|
10
9
|
def initialize
|
11
10
|
@logger = nil
|
12
11
|
|
@@ -26,6 +25,7 @@ class JOCLoud
|
|
26
25
|
end
|
27
26
|
|
28
27
|
# Set logger (optional)
|
28
|
+
# @param logger [Logger] a referce to Logger class
|
29
29
|
def Setlogger(logger)
|
30
30
|
@logger = logger
|
31
31
|
end
|
@@ -71,7 +71,7 @@ class JOCLoud
|
|
71
71
|
Log(Logger::DEBUG,"Endini")
|
72
72
|
end
|
73
73
|
|
74
|
-
# Set audio channels weights (optional). The default channel weights for loudness computation are [1.0, 1.0, 1.0, 1.41, 1.41, 0, 0, 0] (
|
74
|
+
# Set audio channels weights (optional). The default channel weights for loudness computation are [1.0, 1.0, 1.0, 1.41, 1.41, 0, 0, 0] (linear). The channel order is [Left, Right, Centre, Left surround, Right Surround]
|
75
75
|
# @param channelweights [Array]
|
76
76
|
def SetChannelWeigths(channelweights)
|
77
77
|
|
@@ -91,6 +91,8 @@ class JOCLoud
|
|
91
91
|
Log(Logger::INFO,"Set new channel wheights: #{@channelweights}")
|
92
92
|
end
|
93
93
|
|
94
|
+
# Adds a new audio sample array
|
95
|
+
# @param dsample [Array]. The dsample Array must contain 1 Float sample (0...1) per audio channel. Example [0.987655, 0.983344]
|
94
96
|
def Addsample (dsample)
|
95
97
|
@iscomputingLKFS = true
|
96
98
|
|
@@ -1,14 +1,16 @@
|
|
1
1
|
#file: MeanFast.rb
|
2
2
|
|
3
|
-
#
|
3
|
+
#Conputes mean
|
4
4
|
class MeanFast
|
5
5
|
|
6
|
+
#Specifies the type of mean to compute
|
7
|
+
#MEAN_TOTAL = regular mean
|
8
|
+
#MEAN_OVERLAPPED = not implemented yet
|
6
9
|
module MEAN_MODE
|
7
10
|
MEAN_OVERLAPPED = 1
|
8
11
|
MEAN_TOTAL = 2
|
9
12
|
end
|
10
13
|
|
11
|
-
# Ini obj
|
12
14
|
def initialize
|
13
15
|
@bIni = false
|
14
16
|
@mode = MEAN_MODE::MEAN_TOTAL
|
@@ -31,7 +33,12 @@ class MeanFast
|
|
31
33
|
Ini(@mode, 48000, 400, 0.75)
|
32
34
|
end
|
33
35
|
|
34
|
-
|
36
|
+
#Initializes the mean computation, and it sets the mean mode
|
37
|
+
# @param mode Must be = MEAN_TOTAL
|
38
|
+
# @param fs [int] not used in this version
|
39
|
+
# @param lMeanIntervalms [int] not used in this version
|
40
|
+
# @param dOverlappingFactor [Float] not used in this version
|
41
|
+
def Ini(mode, fs = 0, lMeanIntervalms = 0, dOverlappingFactor = 0)
|
35
42
|
|
36
43
|
if (@bIni == true)
|
37
44
|
raise 'ERROR bad state'
|
@@ -65,6 +72,8 @@ class MeanFast
|
|
65
72
|
@bIni = true;
|
66
73
|
end
|
67
74
|
|
75
|
+
#Adds a new sample to mean computation
|
76
|
+
# @param dSample [Float] new sample
|
68
77
|
def AddSample (dSample)
|
69
78
|
rc = false
|
70
79
|
|
@@ -112,6 +121,8 @@ class MeanFast
|
|
112
121
|
return rc
|
113
122
|
end
|
114
123
|
|
124
|
+
#Adds a new sample to mean computation
|
125
|
+
# @return [Float] the resulting mean value
|
115
126
|
def GetMeanVal
|
116
127
|
if (@mode == MEAN_MODE::MEAN_OVERLAPPED)
|
117
128
|
raise 'ERROR function not valid in overlapped mean mode'
|
@@ -2,16 +2,19 @@
|
|
2
2
|
|
3
3
|
require_relative '../IIRFilter/IIRFilter.rb'
|
4
4
|
|
5
|
-
#
|
5
|
+
#PRE filter implementation
|
6
6
|
class PREFilter < IIRFilter
|
7
7
|
|
8
|
-
#
|
8
|
+
#Initialize PRE Filter implementation
|
9
|
+
# @param fs [int] sets the sampleing frecuency. It is used to compute the filter coeficients according to the PRE Filter definition in ITU-R BS.1770
|
9
10
|
def initialize(fs)
|
10
11
|
super 2
|
11
12
|
|
12
13
|
SetFreqSampling(fs)
|
13
14
|
end
|
14
15
|
|
16
|
+
#Sets PRE Filter sampleing frecuency
|
17
|
+
# @param fs [int] sets the sampleing frecuency. It is used to compute the filter coeficients according to the PRE Filter definition in ITU-R BS.1770
|
15
18
|
def SetFreqSampling (fs)
|
16
19
|
@fs = fs
|
17
20
|
|
@@ -30,6 +33,14 @@ class PREFilter < IIRFilter
|
|
30
33
|
|
31
34
|
SetCoefs mBCoefs,mACoefs
|
32
35
|
end
|
36
|
+
|
37
|
+
#Gets filter information
|
38
|
+
# @return [String] filter information
|
39
|
+
def Info
|
40
|
+
return "PRE Filter--------\nFs = #{@fs} Hz\n#{super}\n------------------\n"
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
33
44
|
|
34
45
|
def CalcCoefs (fs, nGdb, dFc)
|
35
46
|
|
@@ -51,8 +62,4 @@ class PREFilter < IIRFilter
|
|
51
62
|
return mBCoefs, mACoefs
|
52
63
|
end
|
53
64
|
|
54
|
-
#Show info
|
55
|
-
def Info
|
56
|
-
return "PRE Filter--------\nFs = #{@fs} Hz\n#{super}\n------------------\n"
|
57
|
-
end
|
58
65
|
end
|
@@ -2,16 +2,19 @@
|
|
2
2
|
|
3
3
|
require_relative '../IIRFilter/IIRFilter.rb'
|
4
4
|
|
5
|
-
#
|
5
|
+
#RLB filter implementation
|
6
6
|
class RLBFilter < IIRFilter
|
7
7
|
|
8
|
-
#
|
8
|
+
#Initialize RLB Filter implementation
|
9
|
+
# @param fs [int] sets the sampleing frecuency. It is used to compute the filter coeficients according to the RLB Filter definition in ITU-R BS.1770
|
9
10
|
def initialize(fs)
|
10
11
|
super 2
|
11
12
|
|
12
13
|
SetFreqSampling(fs)
|
13
14
|
end
|
14
15
|
|
16
|
+
#Sets RLB Filter sampleing frecuency
|
17
|
+
# @param fs [int] sets the sampleing frecuency. It is used to compute the filter coeficients according to the RLB Filter definition in ITU-R BS.1770
|
15
18
|
def SetFreqSampling (fs)
|
16
19
|
@fs = fs
|
17
20
|
|
@@ -29,6 +32,14 @@ class RLBFilter < IIRFilter
|
|
29
32
|
|
30
33
|
SetCoefs mBCoefs,mACoefs
|
31
34
|
end
|
35
|
+
|
36
|
+
#Gets filter information
|
37
|
+
# @return [String] filter information
|
38
|
+
def Info
|
39
|
+
return "RLB Filter--------\nFs = #{@fs} Hz\n#{super}\n------------------\n"
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
32
43
|
|
33
44
|
def CalcCoefs (fs, dFc)
|
34
45
|
dK = Math.tan( (Math::PI * dFc.to_f) / fs.to_f )
|
@@ -48,9 +59,4 @@ class RLBFilter < IIRFilter
|
|
48
59
|
|
49
60
|
return mBCoefs, mACoefs
|
50
61
|
end
|
51
|
-
|
52
|
-
#Show info
|
53
|
-
def Info
|
54
|
-
return "RLB Filter--------\nFs = #{@fs} Hz\n#{super}\n------------------\n"
|
55
|
-
end
|
56
62
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: JOCLoudness
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jordi Cenzano
|
@@ -37,6 +37,7 @@ executables: []
|
|
37
37
|
extensions: []
|
38
38
|
extra_rdoc_files: []
|
39
39
|
files:
|
40
|
+
- README.md
|
40
41
|
- lib/JOCLoudness.rb
|
41
42
|
- lib/Loudness/IIRFilter/IIRFilter.rb
|
42
43
|
- lib/Loudness/JOCLoud.rb
|