feepogram 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Aanand Prasad
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.rdoc ADDED
@@ -0,0 +1,64 @@
1
+ = feepogram
2
+
3
+ A tiny DSL for non-trivial bloopsaphone projects.
4
+
5
+ == Briefly
6
+
7
+ require 'bloops'
8
+ require 'feepogram'
9
+
10
+ bloops = Bloops.new
11
+ bloops.tempo = 320
12
+
13
+ song = Feepogram.new(bloops) do
14
+ sound :crunch, Bloops::NOISE do |s|
15
+ s.punch = 0.5
16
+ end
17
+
18
+ sound :oooo, Bloops::SINE do |s|
19
+ s.sustain = 2.0
20
+ end
21
+
22
+ sound :plink, Bloops::SQUARE do |s|
23
+ s.punch = 1.0
24
+ end
25
+
26
+ def and_one
27
+ phrase do
28
+ oooo " 1:c2 " * 8
29
+ plink " c d e f g a b + c - " * 4
30
+ end
31
+ end
32
+
33
+ def and_two
34
+ phrase do
35
+ crunch " c2 4 c5 4 " * 8
36
+ oooo " 1:g2 " * 8
37
+ plink " c d e f g a b + c - " * 4
38
+ end
39
+ end
40
+
41
+ 2.times do
42
+ and_one
43
+ and_two
44
+ end
45
+ end
46
+
47
+ song.play
48
+
49
+
50
+ == Right, So
51
+
52
+ +sound+ initialises a bloopsaphone sound and defines a handy method for you. That's not the interesting part.
53
+
54
+ === The Interesting Part
55
+
56
+ +phrase+ defines a 32-beat phrase. Any instruments to which you don't assign a tune in the block are told to rest for 32 beats.
57
+
58
+ This makes it easy to decompose sections of your song into methods and repeat or comment out calls to them, which is something you'll definitely want to be doing if your song is more than 10 seconds long.
59
+
60
+ Yeah, that's it. There's definitely potential for more though! Like, well, I don't know. Potential, though.
61
+
62
+ == Copyright
63
+
64
+ Copyright (c) 2009 Aanand Prasad. See LICENSE for details.
data/lib/feepogram.rb ADDED
@@ -0,0 +1,67 @@
1
+ class Feepogram
2
+ attr_reader :bloops, :length
3
+
4
+ def initialize(bloops, &block)
5
+ @bloops = bloops
6
+ @length = 0
7
+
8
+ @sounds = {}
9
+ @tracks = {}
10
+ @track_lengths = {}
11
+
12
+ instance_eval(&block)
13
+ end
14
+
15
+ def metaclass
16
+ class << self; self; end
17
+ end
18
+
19
+ def metaclass_eval(&block)
20
+ metaclass.class_eval(&block)
21
+ end
22
+
23
+ def sound(name, base, &block)
24
+ name = name.to_sym
25
+
26
+ sound = bloops.sound(base)
27
+
28
+ @sounds[name] = sound
29
+ @tracks[name] = ""
30
+ @track_lengths[name] = 0
31
+
32
+ block.call(sound)
33
+
34
+ instance_variable_set("@#{name}", sound)
35
+
36
+ metaclass_eval do
37
+ define_method(name) do |notes|
38
+ dub(name, notes)
39
+ end
40
+ end
41
+ end
42
+
43
+ def phrase(&block)
44
+ instance_eval(&block)
45
+ @length += 32
46
+ end
47
+
48
+ def dub sound_name, notes
49
+ catchup = @length - @track_lengths[sound_name]
50
+
51
+ @tracks[sound_name] << ("4 " * catchup)
52
+ @tracks[sound_name] << notes
53
+ @track_lengths[sound_name] = length+32
54
+ end
55
+
56
+ def play
57
+ @tracks.each do |sound_name, notes|
58
+ bloops.tune @sounds[sound_name], notes
59
+
60
+ #puts "#{sound_name}: #{notes.gsub(/\s+/, ' ')}"
61
+ end
62
+
63
+ bloops.play
64
+ sleep 1 while !bloops.stopped?
65
+ end
66
+ end
67
+
@@ -0,0 +1,4 @@
1
+ class Feepogram
2
+ VERSION = "0.0.1"
3
+ end
4
+
metadata ADDED
@@ -0,0 +1,93 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: feepogram
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 1
9
+ version: 0.0.1
10
+ platform: ruby
11
+ authors:
12
+ - Aanand Prasad
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-08-17 00:00:00 -04:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: bloopsaphone
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ segments:
29
+ - 0
30
+ version: "0"
31
+ type: :runtime
32
+ version_requirements: *id001
33
+ - !ruby/object:Gem::Dependency
34
+ name: shoulda
35
+ prerelease: false
36
+ requirement: &id002 !ruby/object:Gem::Requirement
37
+ none: false
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ segments:
42
+ - 0
43
+ version: "0"
44
+ type: :development
45
+ version_requirements: *id002
46
+ description:
47
+ email:
48
+ - aanand.prasad@gmail.com
49
+ executables: []
50
+
51
+ extensions: []
52
+
53
+ extra_rdoc_files: []
54
+
55
+ files:
56
+ - lib/feepogram/version.rb
57
+ - lib/feepogram.rb
58
+ - LICENSE
59
+ - README.rdoc
60
+ has_rdoc: true
61
+ homepage: http://github.com/aanand/feepogram
62
+ licenses: []
63
+
64
+ post_install_message:
65
+ rdoc_options: []
66
+
67
+ require_paths:
68
+ - lib
69
+ required_ruby_version: !ruby/object:Gem::Requirement
70
+ none: false
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ segments:
75
+ - 0
76
+ version: "0"
77
+ required_rubygems_version: !ruby/object:Gem::Requirement
78
+ none: false
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ segments:
83
+ - 0
84
+ version: "0"
85
+ requirements: []
86
+
87
+ rubyforge_project:
88
+ rubygems_version: 1.3.7
89
+ signing_key:
90
+ specification_version: 3
91
+ summary: A tiny DSL for non-trivial bloopsaphone projects
92
+ test_files: []
93
+