spectrum-analyzer 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/README.md +49 -0
- data/VERSION +1 -1
- data/lib/spectrum-analyzer/clients/generator.rb +20 -19
- data/spectrum-analyzer.gemspec +4 -4
- metadata +3 -3
- data/README.rdoc +0 -19
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NmNhN2RmNGEzMTMwMTgyYjE2NDk4ODY4YWUxMzIwYTkxOTRlNmQ5NQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MjgxMzg5NzA3Mjg1YmIzYjMzMWI1ZTM3ZjdiYWYxODg1ZGRmNTE4Zg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NzU4YmYxOTVjNzg3MTU1ODA3MmQzYjk5ZTA1YzEwNDJjY2I4NjViMzgyMGVm
|
10
|
+
NDYzZjE0MDhmOTQ0MzJlM2FlMGJlYzY2Njg2YzAwNTAxZTlhMTg4ZjQ1YzQy
|
11
|
+
NWNmMjU2NjM2ZTA3M2UzY2Q3YjI4NjI4MWNiMWNiNjVhZTI4ZTQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZDBiYWIyYmYzZmViYjI3MThhMWM5NTE1OGEzYzIwNjI3MjI1NDcyMzFhYzFm
|
14
|
+
NDU2ZThlMjg0MDJkOGUyMDUzZTY4ZjAxMWNkMjkxNTkyYmVlYjViMmExZDE4
|
15
|
+
ZjNjNTU0M2I3Njc0YjY1Zjc1YzEzNWE5ODUxNDZmZjZhNDdjYzA=
|
data/README.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
[![Code Climate](https://codeclimate.com/github/jusroberts/spectrum-analyzer.png)](https://codeclimate.com/github/jusroberts/spectrum-analyzer)
|
2
|
+
# Ruby Sound Spectrum Analyzer
|
3
|
+
|
4
|
+
Have you ever wanted to break apart a sound file and see what frequencies make it up? Well, you're in luck! This program does JUST THAT!!!!
|
5
|
+
|
6
|
+
##How do I do?
|
7
|
+
|
8
|
+
Right now, it's very basic. You need to initiate all the processes by yourself.
|
9
|
+
```ruby
|
10
|
+
require 'spectrum-analyzer'
|
11
|
+
```
|
12
|
+
configure your stuff
|
13
|
+
```ruby
|
14
|
+
c = SpectrumAnalyzer.configuration
|
15
|
+
c.file_name = "whatever"
|
16
|
+
c.window_function = :hanning #or :rectangular. Those are the only two implemented currently
|
17
|
+
c.window_size = 512 #MUST BE A POWER OF 2!!!! 128, 256, 512, 1024, etc. If not, I cannot guarantee your results. In fact, you'll probably break FFTW3. Sorry.
|
18
|
+
c.analysis_array = [] #This does nothing right now. #eventually
|
19
|
+
```
|
20
|
+
|
21
|
+
generate a spectrum
|
22
|
+
```ruby
|
23
|
+
g = SpectrumAnalyzer.generate
|
24
|
+
g.build_spectrum
|
25
|
+
```
|
26
|
+
You now have a bunch of "domains" held in the spectrum (SpectrumAnalyzer.spectrum)
|
27
|
+
```ruby
|
28
|
+
s = SpectrumAnalyzer.spectrum
|
29
|
+
s.domains
|
30
|
+
```
|
31
|
+
These domains are an array of frequencies that occur over the time slice defined by the window_size. The values are currently complex numbers, but they represent decibels of each frequency range in that window.
|
32
|
+
|
33
|
+
More to come.
|
34
|
+
|
35
|
+
##Contributing to spectrum-analyzer
|
36
|
+
|
37
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
38
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
39
|
+
* Fork the project.
|
40
|
+
* Start a feature/bugfix branch.
|
41
|
+
* Commit and push until you are happy with your contribution.
|
42
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
43
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
44
|
+
|
45
|
+
##Copyright
|
46
|
+
|
47
|
+
Copyright (c) 2013 Justin Roberts. See LICENSE.txt for
|
48
|
+
further details.
|
49
|
+
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.2
|
@@ -55,11 +55,12 @@ module SpectrumAnalyzer
|
|
55
55
|
end
|
56
56
|
|
57
57
|
def generate_domain(buffer)
|
58
|
-
wave = Array.new()
|
59
58
|
windowed_array = apply_window(buffer.to_a, windows[@config.window_function])
|
60
|
-
wave.concat(windowed_array)
|
61
59
|
na = NArray.to_na(windowed_array)
|
62
|
-
FFTW3.fft(na).to_a[0, @config.window_size/2]
|
60
|
+
fft_array = FFTW3.fft(na).to_a[0, @config.window_size/2]
|
61
|
+
domain = Array.new()
|
62
|
+
fft_array.each { |x| domain.push(x.magnitude)}
|
63
|
+
domain
|
63
64
|
end
|
64
65
|
|
65
66
|
def analyze_spectrum
|
@@ -115,22 +116,22 @@ module SpectrumAnalyzer
|
|
115
116
|
end
|
116
117
|
|
117
118
|
def analyze_for_hit(fft_array, index)
|
118
|
-
ranges = analysis_array
|
119
|
-
|
120
|
-
j=0
|
121
|
-
hit = Array.new()
|
122
|
-
|
123
|
-
ranges.each do |x|
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
end
|
132
|
-
ping = !hit.include?(false)
|
133
|
-
return ping
|
119
|
+
#ranges = analysis_array
|
120
|
+
#
|
121
|
+
#j=0
|
122
|
+
#hit = Array.new()
|
123
|
+
##p "INDEX: #{index}"
|
124
|
+
#ranges.each do |x|
|
125
|
+
# sum_total = 0
|
126
|
+
# for i in x[:b_index]..x[:t_index]
|
127
|
+
# sum_total += fft_array[i] if !fft_array[i].nil?
|
128
|
+
# end
|
129
|
+
# average = sum_total / (x[:t_index] - x[:b_index])
|
130
|
+
# hit[j] = average > x[:min] and average < x[:max]
|
131
|
+
# j+=1
|
132
|
+
#end
|
133
|
+
#ping = !hit.include?(false)
|
134
|
+
#return ping
|
134
135
|
end
|
135
136
|
|
136
137
|
end
|
data/spectrum-analyzer.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: spectrum-analyzer 0.1.
|
5
|
+
# stub: spectrum-analyzer 0.1.2 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "spectrum-analyzer"
|
9
|
-
s.version = "0.1.
|
9
|
+
s.version = "0.1.2"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.authors = ["Justin Roberts"]
|
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
|
|
15
15
|
s.email = "justin.roberts@careerbuilder.com"
|
16
16
|
s.extra_rdoc_files = [
|
17
17
|
"LICENSE.txt",
|
18
|
-
"README.
|
18
|
+
"README.md"
|
19
19
|
]
|
20
20
|
s.files = [
|
21
21
|
".document",
|
@@ -23,7 +23,7 @@ Gem::Specification.new do |s|
|
|
23
23
|
"Gemfile",
|
24
24
|
"Gemfile.lock",
|
25
25
|
"LICENSE.txt",
|
26
|
-
"README.
|
26
|
+
"README.md",
|
27
27
|
"Rakefile",
|
28
28
|
"VERSION",
|
29
29
|
"lib/spectrum-analyzer.rb",
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spectrum-analyzer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Roberts
|
@@ -114,14 +114,14 @@ executables: []
|
|
114
114
|
extensions: []
|
115
115
|
extra_rdoc_files:
|
116
116
|
- LICENSE.txt
|
117
|
-
- README.
|
117
|
+
- README.md
|
118
118
|
files:
|
119
119
|
- .document
|
120
120
|
- .rspec
|
121
121
|
- Gemfile
|
122
122
|
- Gemfile.lock
|
123
123
|
- LICENSE.txt
|
124
|
-
- README.
|
124
|
+
- README.md
|
125
125
|
- Rakefile
|
126
126
|
- VERSION
|
127
127
|
- lib/spectrum-analyzer.rb
|
data/README.rdoc
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
= spectrum-analyzer
|
2
|
-
|
3
|
-
Description goes here.
|
4
|
-
|
5
|
-
== Contributing to spectrum-analyzer
|
6
|
-
|
7
|
-
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
8
|
-
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
9
|
-
* Fork the project.
|
10
|
-
* Start a feature/bugfix branch.
|
11
|
-
* Commit and push until you are happy with your contribution.
|
12
|
-
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
13
|
-
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
14
|
-
|
15
|
-
== Copyright
|
16
|
-
|
17
|
-
Copyright (c) 2013 Justin Roberts. See LICENSE.txt for
|
18
|
-
further details.
|
19
|
-
|