feep 0.0.6 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f430501b6debcb58be0850a447ee61b16d4852c0
4
- data.tar.gz: 5825fb85483442fc7139ba75d4ccc9eb3d08ed53
3
+ metadata.gz: 3fbfa4b1a2f1ad90c662578b40edd7bbf4b7730a
4
+ data.tar.gz: 618b77c63ea478dbb25da2d7f434bb6756ff8c0a
5
5
  SHA512:
6
- metadata.gz: 676926fc0c7627b599b358a338d4c6a745fc60bb2f126c0cb08ba4c13ef32619cc5aa4faa7624d083635cfb29db99ed120801e1d0fb44c4f103aa3fd63918dba
7
- data.tar.gz: 4dff04f0fdb00e2a93f9f7e8798802bd3d8d729d3cc2c14e1f0c0315cce7c728b8234d778d33218af83b35f2c55303d962c753fa1da8c6eb9692c93e00339c15
6
+ metadata.gz: f6bf0d4aef97bc23668c7ba56de50be3bab94bee3e848ebe3ab124b25e395010e5bccd06570ed154003292ada9881f8b0457854043c35df3c0c3335e619f74f9
7
+ data.tar.gz: 9a12ac8131c8957682042f3af6ff30ff0ccd6a1568accf43d3cfc3ce1f387330217e2bb60008e7b82d4cb18b3f44343491e21c03c48eefc53e65f12dd4f1f946
data/README.md CHANGED
@@ -14,17 +14,17 @@ Besides a quick way to make some kind of noise for fun or testing your speakers,
14
14
 
15
15
  * `gem install feep`
16
16
 
17
- Feep doesn't require any parameters, as it will play a 440Hz/A4 sine wave at 50% full volume for 200 milliseconds unless you supply one of the below options. Feep will only save the resulting WAV file it creates if you specify the `-save` parameter.
17
+ Feep doesn't require any parameters, as it will play a 440Hz/A4 sine wave at 50% full volume for 100 milliseconds unless you supply one of the below options. Feep will only save the resulting WAV file(s) it creates if you specify the `--save` parameter.
18
18
 
19
19
  The full usage looks like this:
20
20
 
21
- `feep [-f, -n, --freq-or-note FREQUENCY|NOTE_NAME] [-s, --scale SCALE_ID] [-d, --degrees NUMBER_OF_SCALE_DEGREES] [-w, --waveform WAVEFORM] [-a, --amplitude MAX_AMPLITUDE] [-d, --duration DURATION] [-save] [-loud]`
21
+ `feep [-f, -n, --freq-or-note FREQUENCY|NOTE_NAME] [-s, --scale SCALE_ID] [-sd, --degrees SCALE_DEGREES] [-w, --waveform WAVEFORM_ID] [-a, --amplitude MAX_AMPLITUDE] [-d, --duration DURATION] [--save] [--loud]`
22
22
 
23
23
  `-f, -n, --freq-or-note`: a number from 0 to 20000, or a valid note name from C0 to B9 (including sharps and flats). You can try a frequency outside of this range, but you may get odd results. You may also enter some combination of these with commas between them and it'll play all of them together in a chord.
24
24
 
25
- `-s, -scale`: a scale ID that is part of the list that the gem understands (currently). If you put in an invalid one, it will list the valid ones.
25
+ `-s, -scale`: a scale ID that is part of the list that the gem understands. If you put in an invalid one, it will list the valid ones.
26
26
 
27
- `-d, --degrees`: the number of degrees of a scale you want to play. By default, the scale will play one octave.
27
+ `-sd, --degrees`: the number of degrees of a scale you want to play. By default, the scale will play one octave.
28
28
 
29
29
  `-w, --waveform`: a string equal to "sine", "square", "saw", "triangle", or "noise".
30
30
 
@@ -32,14 +32,15 @@ The full usage looks like this:
32
32
 
33
33
  `-d, --duration`: number of milliseconds for the sound to last.
34
34
 
35
- `-save`: switch to save the resulting WAV file in the current directory. Will create it in the format of `waveform_frequency-in-Hz_volume_duration.wav`.
35
+ `--save`: switch to save the resulting WAV file in the current directory. Will create it in the format of `waveform_frequency-in-Hz_volume_duration.wav`.
36
36
 
37
- `-loud`: switch that displays note and file-making information.
37
+ `--loud`: switch that displays note and file-making information.
38
38
 
39
39
  ## Examples
40
40
 
41
- * `feep` - play a C4 sine wave note at 50% full volume for 200 ms
41
+ * `feep` - play a C4 sine wave note at 50% full volume for 100 ms
42
42
  * `feep -n Ab6 -w saw` - play a Ab6 sawtooth wave note at 50% full volume for 200 ms
43
43
  * `feep -n C#5 -w square -a 0.4 -d 500` - play a C#5 square wave note at 40% full volume for 500 ms
44
44
  * `feep -n 2000 -w triangle -a 0.8 -d 2000` - play a 2000Hz triangle wave note at 80% full volume for 2000 ms
45
45
  * `feep -n C3 -s major` - play a major scale with C3 as the root note
46
+ * `feep -n D#5 -s whole_note -d 20` - play 20 degrees of a whole note scale with D#5 as the root note
data/bin/feep CHANGED
@@ -1,78 +1,79 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'optparse'
4
- require_relative '../lib/feep'
5
-
6
- def parse_options
7
- options = {:freq_or_note => '440.000', :scale => nil, :waveform => 'sine', :volume => 0.5, :duration => 100, :save => false, :loud => false, :usage => nil}
8
-
9
- optparse = OptionParser.new do |opts|
10
- opts.banner = 'usage: feep [-f, -n, --freq-or-note FREQUENCY|NOTE_NAME] [-s, --scale SCALE_ID] [-d, --degrees NUMBER_OF_SCALE_DEGREES] [-w, --waveform WAVEFORM] [-a, --amplitude MAX_AMPLITUDE] [-d, --duration DURATION] [-save] [-loud]'
11
-
12
- opts.on('-f', '-n', '--freq-or-note FREQUENCY|NOTE_NAME', 'One or more frequencies or note names to play at once, e.g. 440 or A4 or 220,440,880') do |f_or_n|
13
- options[:freq_or_note] = f_or_n
14
- end
15
-
16
- opts.on('-s', '--scale SCALE_ID', 'Name of a scale to play') do |s|
17
- options[:scale] = s
18
- end
19
-
20
- opts.on('-d', '--degrees NUMBER_OF_DEGREES', 'Number of degrees of the scale to play') do |d|
21
- options[:degrees] = d
22
- end
23
-
24
- opts.on('-w', '--wave WAVEFORM', 'Waveform type to use for the sound') do |w|
25
- options[:waveform] = w
26
- end
27
-
28
- opts.on('-a', '--amplitude MAX_AMPLITUDE', 'Amplitude/volume (0.0 - 1.0) to play the sound(s) at') do |a|
29
- options[:volume] = a.to_f
30
- end
31
-
32
- opts.on('-d', '--duration DURATION', 'Duration in ms to play the sound(s)') do |d|
33
- options[:duration] = d.to_i
34
- end
35
-
36
- opts.on('--save', 'Save the resulting WAV file in the current directory') do
37
- options[:save] = true
38
- end
39
-
40
- opts.on('--loud', 'Displays information about note(s) being played') do
41
- options[:loud] = true
42
- end
43
-
44
- opts.on('-v', '--version', 'Display version number and exit') do
45
- puts "#{$PROGRAM_NAME} #{Feep::VERSION}"
46
- exit
47
- end
48
-
49
- opts.on('-h', '--help', 'Display this screen and exit') do
50
- puts opts
51
- exit
52
- end
53
- end
54
-
55
- options[:usage] = optparse.to_s
56
- optparse.parse!()
57
-
58
- return options
59
- end
60
-
61
- def print_error(error)
62
- case error
63
- when OptionParser::InvalidOption
64
- puts "#{$PROGRAM_NAME}: illegal option #{error.args.join(' ')}"
65
- else
66
- puts "An unexpected error occurred while running #{$PROGRAM_NAME}:"
67
- puts " #{error}\n"
68
- end
69
- end
70
-
71
- begin
72
- options = parse_options
73
-
74
- Feep::Base.new(options)
75
- rescue => error
76
- print_error(error)
77
- exit(false)
78
- end
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'optparse'
4
+ require_relative '../lib/feep'
5
+ require_relative '../lib/feep/version'
6
+
7
+ def parse_options
8
+ options = {:freq_or_note => '440.000', :scale => nil, :waveform => 'sine', :volume => 0.5, :duration => 100, :save => false, :loud => false, :usage => nil}
9
+
10
+ optparse = OptionParser.new do |opts|
11
+ opts.banner = 'usage: feep [-f, -n, --freq-or-note FREQUENCY|NOTE_NAME] [-s, --scale SCALE_ID] [-sd, --degrees NUMBER_OF_SCALE_DEGREES] [-w, --waveform WAVEFORM_ID] [-a, --amplitude MAX_AMPLITUDE] [-d, --duration DURATION] [--save] [--loud]'
12
+
13
+ opts.on('-f', '-n', '--freq-or-note FREQUENCY|NOTE_NAME', 'One or more frequencies or note names to play at once, e.g. 440 or A4 or 220,440,880') do |f_or_n|
14
+ options[:freq_or_note] = f_or_n
15
+ end
16
+
17
+ opts.on('-s', '--scale SCALE_ID', 'Name of a scale to play') do |s|
18
+ options[:scale] = s
19
+ end
20
+
21
+ opts.on('-sd', '--degrees SCALE_DEGREES', 'Number of degrees of the scale to play') do |sd|
22
+ options[:degrees] = sd
23
+ end
24
+
25
+ opts.on('-w', '--waveform WAVEFORM', 'Waveform type to use for the sound') do |w|
26
+ options[:waveform] = w
27
+ end
28
+
29
+ opts.on('-a', '--amplitude MAX_AMPLITUDE', 'Amplitude/volume (0.0 - 1.0) to play the sound(s) at') do |a|
30
+ options[:volume] = a.to_f
31
+ end
32
+
33
+ opts.on('-d', '--duration DURATION', 'Duration in ms to play the sound(s)') do |d|
34
+ options[:duration] = d.to_i
35
+ end
36
+
37
+ opts.on('--save', 'Save the resulting WAV file in the current directory') do
38
+ options[:save] = true
39
+ end
40
+
41
+ opts.on('--loud', 'Displays information about note(s) being played') do
42
+ options[:loud] = true
43
+ end
44
+
45
+ opts.on('-v', '--version', 'Display version number and exit') do
46
+ puts "feep #{Feep::VERSION}"
47
+ exit
48
+ end
49
+
50
+ opts.on('-h', '--help', 'Display this screen and exit') do
51
+ puts opts
52
+ exit
53
+ end
54
+ end
55
+
56
+ options[:usage] = optparse.to_s
57
+ optparse.parse!()
58
+
59
+ return options
60
+ end
61
+
62
+ def print_error(error)
63
+ case error
64
+ when OptionParser::InvalidOption
65
+ puts "#{$PROGRAM_NAME}: illegal option #{error.args.join(' ')}"
66
+ else
67
+ puts "An unexpected error occurred while running #{$PROGRAM_NAME}:"
68
+ puts " #{error}\n"
69
+ end
70
+ end
71
+
72
+ begin
73
+ options = parse_options
74
+
75
+ Feep::Base.new(options)
76
+ rescue => error
77
+ print_error(error)
78
+ exit(false)
79
+ end
@@ -250,7 +250,7 @@ module Feep
250
250
  ERROR_MSG = Hash[
251
251
  :invalid_note => 'Note name argument is invalid.',
252
252
  :invalid_scale => "Scale ID is invalid. Valid IDs are: #{SCALES.keys}",
253
- :invalid_waveform => 'Wave form type is invalid.',
253
+ :invalid_waveform => "Waveform type is invalid. Valid waveform types are: #{WAVE_TYPES}",
254
254
  :scale_needs_note => 'You need to enter a valid note (-n) if you want to play a scale.'
255
255
  ]
256
256
  end
@@ -1,3 +1,3 @@
1
- class Feep
2
- VERSION = '0.0.6'
1
+ module Feep
2
+ VERSION = '0.0.8'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: feep
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Chadwick
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-18 00:00:00.000000000 Z
11
+ date: 2015-03-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: wavefile
@@ -163,4 +163,7 @@ rubygems_version: 2.4.6
163
163
  signing_key:
164
164
  specification_version: 4
165
165
  summary: Make your computer feep with Ruby
166
- test_files: []
166
+ test_files:
167
+ - spec/feep_spec.rb
168
+ - spec/spec_helper.rb
169
+ has_rdoc: