aud 0.0.1

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/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2013 Josh Dzielak
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
File without changes
data/bin/aud ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'aud'
4
+ require 'aud/cli'
5
+
6
+ Aud::CLI.start
data/lib/aud/cli.rb ADDED
@@ -0,0 +1,75 @@
1
+ require 'thor'
2
+
3
+ module Aud
4
+ class CLI < Thor
5
+
6
+ default_task :listen
7
+
8
+ desc 'listen', 'Listens to STDIN or a file'
9
+
10
+ method_option :octave,
11
+ default: 3,
12
+ aliases: '-o',
13
+ banner: 'Set an octave [1-5]'
14
+
15
+ method_option :file,
16
+ aliases: '-f',
17
+ banner: 'A file to listen to'
18
+
19
+ method_option :channel,
20
+ default: 1,
21
+ aliases: '-c',
22
+ type: :numeric,
23
+ banner: 'Set a MIDI channel [1-16]'
24
+
25
+ method_option :delay,
26
+ default: 50,
27
+ aliases: '-d',
28
+ type: :numeric,
29
+ banner: 'Minimum delay in milliseconds between sounds'
30
+
31
+ method_option :strategy,
32
+ default: 'tick',
33
+ aliases: '-s',
34
+ banner: 'A strategy for making sounds, currently only tick'
35
+
36
+ method_option :notext,
37
+ type: :boolean,
38
+ default: false,
39
+ aliases: '-n',
40
+ banner: 'Suppress text output'
41
+
42
+ def listen
43
+ output = UniMIDI::Output.first
44
+
45
+ if options[:strategy] == 'tick'
46
+ aud = Aud::Tick.new(output, options)
47
+ else
48
+ raise 'Only tick strategy is supported, but feel free to contribute another!'
49
+ end
50
+
51
+ _exit = false
52
+ Signal.trap(:INT) do _exit = true end
53
+ Signal.trap(:TERM) do _exit = true end
54
+
55
+ process_line = lambda { |line|
56
+ line = line.strip
57
+ aud.process(line)
58
+ puts line unless options[:notext]
59
+ sleep(options[:delay] / 1000.0)
60
+ }
61
+
62
+ if options[:file]
63
+ File.open(options[:file]).each do |line|
64
+ process_line.call(line) unless _exit
65
+ end
66
+ else
67
+ # fixup ARGF
68
+ ARGV.clear
69
+ ARGF.each_line do |line|
70
+ process_line.call(line) unless _exit
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
data/lib/aud/tick.rb ADDED
@@ -0,0 +1,27 @@
1
+ require 'midi'
2
+
3
+ module Aud
4
+ class Tick
5
+
6
+ attr_accessor :midi
7
+ attr_accessor :output
8
+ attr_accessor :properties
9
+
10
+ def initialize(output, properties)
11
+ self.midi = MIDI::IO.new(output)
12
+ self.properties = properties
13
+ end
14
+
15
+ def process(line)
16
+ self.midi.octave properties[:octave] || 3
17
+ self.midi.note(to_note(line), :channel => properties[:channel])
18
+ self.midi.off
19
+ end
20
+
21
+ private
22
+
23
+ def to_note(line)
24
+ "C"
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,3 @@
1
+ module Aud
2
+ VERSION = "0.0.1"
3
+ end
data/lib/aud.rb ADDED
@@ -0,0 +1,5 @@
1
+ require 'aud/tick'
2
+
3
+ module Aud
4
+
5
+ end
metadata ADDED
@@ -0,0 +1,100 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: aud
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Josh Dzielak
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-12-04 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: thor
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '0.18'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '0.18'
30
+ - !ruby/object:Gem::Dependency
31
+ name: midi
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: 0.0.9
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 0.0.9
46
+ - !ruby/object:Gem::Dependency
47
+ name: debugger
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ description: A command line utility for playing sounds in response to log lines.
63
+ email: jdzielak@gmail.com
64
+ executables:
65
+ - aud
66
+ extensions: []
67
+ extra_rdoc_files: []
68
+ files:
69
+ - bin/aud
70
+ - lib/aud/cli.rb
71
+ - lib/aud/tick.rb
72
+ - lib/aud/version.rb
73
+ - lib/aud.rb
74
+ - LICENSE
75
+ - README.md
76
+ homepage: https://github.com/dzello/aud
77
+ licenses: []
78
+ post_install_message:
79
+ rdoc_options: []
80
+ require_paths:
81
+ - lib
82
+ required_ruby_version: !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ required_rubygems_version: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ requirements: []
95
+ rubyforge_project:
96
+ rubygems_version: 1.8.23
97
+ signing_key:
98
+ specification_version: 3
99
+ summary: Audibilize text files
100
+ test_files: []