gentone 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.rspec +2 -0
- data/.travis.yml +3 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +12 -0
- data/bin/gentone +29 -0
- data/gentone.gemspec +27 -0
- data/lib/gentone.rb +17 -0
- data/lib/gentone/generate.rb +33 -0
- data/lib/gentone/version.rb +3 -0
- data/spec/gentone_spec.rb +11 -0
- data/spec/spec_helper.rb +2 -0
- metadata +118 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b10555e53c0f38668a4d78a59ed7f17c0ee920d6
|
4
|
+
data.tar.gz: 37f610b2418d50ab6fb61e8f4c2002ca4757b575
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: eda66890fa6e8a1bbc4c467ab6495dd02f1f7f51844ffbfd1847eed1e1f9ce9d88ed3b5dc4597c6b936c0813da024954919c41f3ad7bb2bacc08e7a14a8aa756
|
7
|
+
data.tar.gz: 8e89f126222fd68b0575bfe00eae9ff06caa970e36e81a8dbb0ee740046d184f31f041742ee13ad3ec5e84d874418378fa1102a23927dca2a7d3a29179d55144
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Robie Lutsey
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Gentone
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'gentone'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install gentone
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/bin/gentone
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require_relative '../lib/gentone'
|
4
|
+
require "optparse"
|
5
|
+
|
6
|
+
args = {:duration => 500, :freq => 600}
|
7
|
+
|
8
|
+
option_parser = OptionParser.new do |opts|
|
9
|
+
opts.banner = "Usage: gentone [args]"
|
10
|
+
|
11
|
+
opts.on('-f FREQUENCY', '--frequency', 'Tone frequency in Hz [600]', Integer) do |freq|
|
12
|
+
unless freq > 1 && freq.integer?
|
13
|
+
raise ArgumentError, "frequency must be a positive integer"
|
14
|
+
end
|
15
|
+
args[:freq] = freq
|
16
|
+
end
|
17
|
+
|
18
|
+
opts.on('-d DURATION', '--duration', 'Tone duration in millis [500]', Integer) do |duration|
|
19
|
+
unless duration > 1 && duration.integer?
|
20
|
+
raise ArgumentError, "duration must be a positive integer"
|
21
|
+
end
|
22
|
+
args[:duration] = duration
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
option_parser.parse!
|
28
|
+
|
29
|
+
Gentone::Runner.new.run(args[:duration], args[:freq])
|
data/gentone.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'gentone/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "gentone"
|
8
|
+
spec.version = Gentone::VERSION
|
9
|
+
spec.authors = ["Robie Lutsey"]
|
10
|
+
spec.email = ["robie1373@gmail.com"]
|
11
|
+
spec.description = %q{play dits and dahs for CW aka morse code. Feed it a string and it plays sounds. os x only.}
|
12
|
+
spec.summary = %q{play dits and dahs for CW aka morse code}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.1.1"
|
23
|
+
spec.add_development_dependency "rspec"
|
24
|
+
|
25
|
+
spec.add_dependency "coreaudio"
|
26
|
+
# spec.add_dependency "highline", "~> 1.6.20"
|
27
|
+
end
|
data/lib/gentone.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require_relative "gentone/version"
|
2
|
+
require "coreaudio"
|
3
|
+
require "querinator"
|
4
|
+
require_relative "gentone/generate"
|
5
|
+
|
6
|
+
module Gentone
|
7
|
+
class Runner
|
8
|
+
def initialize
|
9
|
+
@generator = Generator.new
|
10
|
+
end
|
11
|
+
|
12
|
+
def run(duration, freq)
|
13
|
+
@generator.generate(duration, freq)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require "coreaudio"
|
2
|
+
|
3
|
+
module Gentone
|
4
|
+
class Generator
|
5
|
+
|
6
|
+
def generate(duration, freq = 600.0)
|
7
|
+
sec_duration = duration / 1_000.0
|
8
|
+
frequency = freq * 1.0
|
9
|
+
|
10
|
+
dev = CoreAudio.default_output_device
|
11
|
+
buf = dev.output_buffer(1024)
|
12
|
+
|
13
|
+
phase = Math::PI * 2.0 * frequency / dev.nominal_rate
|
14
|
+
th = Thread.start do
|
15
|
+
i = 0
|
16
|
+
wav = NArray.sint(1024)
|
17
|
+
loop do
|
18
|
+
1024.times {|j| wav[j] = (0.4 * Math.sin(phase*(i+j)) * 0x7FFF).round }
|
19
|
+
i += 1024
|
20
|
+
buf << wav
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
buf.start
|
25
|
+
sleep sec_duration
|
26
|
+
buf.stop
|
27
|
+
|
28
|
+
th.kill.join
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,118 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gentone
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Robie Lutsey
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-01-25 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 10.1.1
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 10.1.1
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: coreaudio
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: play dits and dahs for CW aka morse code. Feed it a string and it plays
|
70
|
+
sounds. os x only.
|
71
|
+
email:
|
72
|
+
- robie1373@gmail.com
|
73
|
+
executables:
|
74
|
+
- gentone
|
75
|
+
extensions: []
|
76
|
+
extra_rdoc_files: []
|
77
|
+
files:
|
78
|
+
- ".gitignore"
|
79
|
+
- ".rspec"
|
80
|
+
- ".travis.yml"
|
81
|
+
- Gemfile
|
82
|
+
- LICENSE.txt
|
83
|
+
- README.md
|
84
|
+
- Rakefile
|
85
|
+
- bin/gentone
|
86
|
+
- gentone.gemspec
|
87
|
+
- lib/gentone.rb
|
88
|
+
- lib/gentone/generate.rb
|
89
|
+
- lib/gentone/version.rb
|
90
|
+
- spec/gentone_spec.rb
|
91
|
+
- spec/spec_helper.rb
|
92
|
+
homepage: ''
|
93
|
+
licenses:
|
94
|
+
- MIT
|
95
|
+
metadata: {}
|
96
|
+
post_install_message:
|
97
|
+
rdoc_options: []
|
98
|
+
require_paths:
|
99
|
+
- lib
|
100
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
requirements: []
|
111
|
+
rubyforge_project:
|
112
|
+
rubygems_version: 2.0.3
|
113
|
+
signing_key:
|
114
|
+
specification_version: 4
|
115
|
+
summary: play dits and dahs for CW aka morse code
|
116
|
+
test_files:
|
117
|
+
- spec/gentone_spec.rb
|
118
|
+
- spec/spec_helper.rb
|