Introduction
Introduction Statistics Contact Development Disclaimer Help
Add a new signature system - warvox - VoIP based wardialing tool, forked from r…
Log
Files
Refs
README
---
commit 21e1c9d19ba3b568ee1c30e534330ae147d8d672
parent c277049cd337d91d4e54afc9a7744bcc17bb988f
Author: HD Moore <[email protected]>
Date: Sun, 27 Mar 2011 05:39:13 +0000
Add a new signature system
Diffstat:
M bin/create_sig.rb | 3 ++-
M lib/warvox/audio/raw.rb | 67 +++++++++++++++++++++++++++++…
M lib/warvox/jobs/analysis.rb | 8 ++++----
3 files changed, 73 insertions(+), 5 deletions(-)
---
diff --git a/bin/create_sig.rb b/bin/create_sig.rb
@@ -34,4 +34,5 @@ if(raw.samples.length == 0)
exit(1)
end
-$stdout.puts raw.to_freq.inspect.gsub(/\s+/,'')
+
+$stdout.puts raw.to_freq_sig_txt
diff --git a/lib/warvox/audio/raw.rb b/lib/warvox/audio/raw.rb
@@ -151,6 +151,72 @@ class Raw
self.class.fft_to_freq_sig(ffts, freq_cnt)
end
+ def to_freq_sig(opts={})
+ fcnt = opts[:frequency_count] || 5
+
+ ffts = []
+
+ # Obtain 20 DFTs for the sample, at 1/20th second offsets into…
+ 0.upto(19) do |i|
+ ffts[i] = KissFFT.fftr(8192, 8000, 1, self.samples[ i …
+ end
+
+ # Create a frequency table at 100hz boundaries
+ f = [ *(0.step(4000, 100)) ]
+
+ # Create a worker method to find the closest frequency
+ barker = Proc.new do |t|
+ t = t.to_i
+ f.sort { |a,b|
+ (a-t).abs <=> (b-t).abs
+ }.first
+ end
+
+ # Map each slice of the audio's FFT with each FFT chunk (8k sa…
+ tops = ffts.map{|x| x.map{|y| y.map{|z|
+
+ frq,pwr = z
+
+ # Toss any signals with a strength under 100
+ if pwr < 100.0
+ frq,pwr = [0,0]
+ # Map the signal to the closest offset of 50hz
+ else
+ frq = barker.call(frq)
+ end
+
+ # Make sure the strength is an integer
+ pwr = pwr.to_i
+
+ # Sort by signal strength and take the top fcnt items
+ [frq, pwr]}.sort{|a,b|
+ b[1] <=> a[1]
+ }[0, fcnt].map{|w|
+ # Grab just the frequency (drop the strength)
+ w[0]
+ # Remove any duplicates due to hz mapping
+ }.uniq
+
+ } }
+
+ # Track the generated 4-second chunk signatures
+ sigs = []
+
+ # Expand the list of top frequencies per sample into a flat li…
+ tops.each do |t|
+ next if t.length < 4
+ 0.upto(t.length - 4) { |i| t[i].each { |a| t[i+1].each…
+ end
+
+ # Dump any duplicate signatures
+ sigs = sigs.uniq
+ end
+
+ def to_freq_sig_txt(opts={})
+ # Convert this to comma delimited frequencies, one sequence pe…
+ to_freq_sig(opts).map{|x| x.join(",") }.sort.join("\n") …
+ end
+
def self.fft_to_freq_sig(ffts, freq_cnt)
sig = []
ffts.each do |s|
@@ -231,6 +297,7 @@ class Raw
final
end
+
end
end
diff --git a/lib/warvox/jobs/analysis.rb b/lib/warvox/jobs/analysis.rb
@@ -138,14 +138,14 @@ class Analysis < Base
#
raw = WarVOX::Audio::Raw.from_file(input)
fft = KissFFT.fftr(8192, 8000, 1, raw.samples)
- freq = WarVOX::Audio::Raw.fft_to_freq_sig(fft, 20)
- flow = freq.inspect.gsub(/\s+/, '')
+
+ freq = raw.to_freq_sig_txt()
fd = File.new("#{bname}.sig", "wb")
- fd.write "#{num} #{flow}\n"
+ fd.write freq
fd.close
# Save the signature data
- res[:sig_data] = flow
+ res[:sig_data] = freq
#
# Create a raw decompressed file
You are viewing proxied material from jay.scot. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.