maca-Scruby 0.0.8

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.
Files changed (43) hide show
  1. data/README.rdoc +26 -0
  2. data/Rakefile +10 -0
  3. data/Scruby.gemspec +36 -0
  4. data/bin/live_session.rb +12 -0
  5. data/changes +1 -0
  6. data/lib/live/session.rb +144 -0
  7. data/lib/scruby.rb +60 -0
  8. data/lib/scruby/audio/control_name.rb +29 -0
  9. data/lib/scruby/audio/env.rb +97 -0
  10. data/lib/scruby/audio/node.rb +20 -0
  11. data/lib/scruby/audio/server.rb +112 -0
  12. data/lib/scruby/audio/synth.rb +15 -0
  13. data/lib/scruby/audio/synthdef.rb +114 -0
  14. data/lib/scruby/audio/ugens/env_gen.rb +18 -0
  15. data/lib/scruby/audio/ugens/in_out.rb +43 -0
  16. data/lib/scruby/audio/ugens/multi_out_ugens.rb +48 -0
  17. data/lib/scruby/audio/ugens/operation_indices.yaml +92 -0
  18. data/lib/scruby/audio/ugens/operation_ugens.rb +64 -0
  19. data/lib/scruby/audio/ugens/ugen.rb +154 -0
  20. data/lib/scruby/audio/ugens/ugen_defs.yaml +3421 -0
  21. data/lib/scruby/audio/ugens/ugen_operations.rb +44 -0
  22. data/lib/scruby/audio/ugens/ugens.rb +34 -0
  23. data/lib/scruby/control/metro.rb +6 -0
  24. data/lib/scruby/extensions.rb +109 -0
  25. data/lib/scruby/typed_array.rb +64 -0
  26. data/spec/audio/env_gen_specs.rb +25 -0
  27. data/spec/audio/in_out_spec.rb +107 -0
  28. data/spec/audio/integration_spec.rb +106 -0
  29. data/spec/audio/lib_spec.rb +14 -0
  30. data/spec/audio/multiout_ugen_spec.rb +112 -0
  31. data/spec/audio/node_spec.rb +60 -0
  32. data/spec/audio/operation_ugens_spec.rb +189 -0
  33. data/spec/audio/server_spec.rb +68 -0
  34. data/spec/audio/synth_spec.rb +46 -0
  35. data/spec/audio/synthdef_spec.rb +275 -0
  36. data/spec/audio/ugen_operations_spec.rb +146 -0
  37. data/spec/audio/ugen_spec.rb +333 -0
  38. data/spec/audio/ugens_spec.rb +61 -0
  39. data/spec/env_spec.rb +64 -0
  40. data/spec/extensions_spec.rb +133 -0
  41. data/spec/helper.rb +11 -0
  42. data/spec/typed_array_spec.rb +95 -0
  43. metadata +129 -0
@@ -0,0 +1,133 @@
1
+ require File.join( File.expand_path(File.dirname(__FILE__)),"helper")
2
+
3
+ require "#{SCRUBY_DIR}/audio/ugens/ugen_operations"
4
+ require "#{SCRUBY_DIR}/extensions"
5
+ require "ruby2ruby"
6
+
7
+ describe Numeric do
8
+
9
+ before :all do
10
+ @bin_op = mock('binop')
11
+ BinaryOpUGen = mock( 'BinaryOpUGen', :new => @bin_on )
12
+ @ugen = mock( 'ugen' )
13
+ Ugen = mock( 'Ugen', :new => @ugen)
14
+ end
15
+
16
+ it "shoud have an scalar rate" do
17
+ 1.rate.should eql(:scalar)
18
+ end
19
+
20
+ it "should have an scalar rate" do
21
+ 100.0.rate.should == :scalar
22
+ end
23
+
24
+ it "sum as usual" do
25
+ (100 + 100).should == 200
26
+ end
27
+
28
+ it "should #collect_constants" do
29
+ 1.send( :collect_constants ).should == 1
30
+ 1.5.send( :collect_constants ).should == 1.5
31
+ end
32
+
33
+ it "should spec #input_specs" do
34
+ synthdef = mock('synthdef', :constants => [200.0,1,3, 400.0] )
35
+ 200.0.send( :input_specs, synthdef ).should == [-1,0]
36
+ 3.send( :input_specs, synthdef ).should == [-1,2]
37
+ 400.0.send( :input_specs, synthdef ).should == [-1,3]
38
+ end
39
+
40
+ it "should spec encode"
41
+
42
+
43
+ end
44
+
45
+ describe Array, "monkey patches" do
46
+ describe "#collect_with_index" do
47
+ it do
48
+ [].should respond_to( :collect_with_index )
49
+ end
50
+
51
+ it "should return an array the same size as the original" do
52
+ [1,2,3,4].collect_with_index{ nil }.should have( 4 ).items
53
+ end
54
+
55
+ it "should collect_with_index" do
56
+ array = %w(a, b, c, d)
57
+ array.collect_with_index{ |element, index| [index, element] }.should eql( [0,1,2,3].zip( array ) )
58
+ end
59
+
60
+ it "should wrap and zip" do
61
+ [:a,:b,:c].wrap_and_zip([1]).flatten.should == [:a,1,:b,1,:c,1]
62
+
63
+ [0.5, 0.5].wrap_and_zip([3],[5]).flatten.should == [0.5,3,5,0.5,3,5]
64
+ [0.01, 1.0].wrap_and_zip([-4.0],[5]).flatten.should == [0.01, -4.0, 5, 1.0, -4.0, 5]
65
+ end
66
+
67
+ it "should sum with Ugen"
68
+ it "should collect constants"
69
+
70
+
71
+ end
72
+ end
73
+
74
+ describe Proc do
75
+ describe "#argument_names" do
76
+
77
+ it do
78
+ Proc.new{}.should respond_to( :argument_names )
79
+ end
80
+
81
+ it "should get empty array if proc has no args" do
82
+ Proc.new{}.argument_names.should eql( [] )
83
+ end
84
+
85
+ it "should get one argument name" do
86
+ Proc.new{ |arg| }.argument_names.should eql( [ :arg ] )
87
+ end
88
+
89
+ it "should get arg names with several args" do
90
+ Proc.new{ |arg, arg2, arg3| }.argument_names.should eql( [ :arg, :arg2, :arg3 ] )
91
+ end
92
+ end
93
+ end
94
+
95
+ describe Array do
96
+ describe "#wrap_to" do
97
+
98
+ it do
99
+ Array.new.should respond_to( :wrap_to )
100
+ end
101
+
102
+ it "should wrap_to!" do
103
+ [1,2].wrap_to!(4).should == [1,2,1,2]
104
+ end
105
+
106
+ it do
107
+ Array.new.should respond_to( :wrap_to )
108
+ end
109
+
110
+ it "should return self if the passed size is the same as self.size" do
111
+ a = [1,2,3,4]
112
+ a.wrap_to( 4 ).should == a
113
+ end
114
+
115
+ it "should etc..."
116
+
117
+ end
118
+ end
119
+
120
+ describe String do
121
+
122
+ it "should encode" do
123
+ "SinOsc".encode.should == [6, 83, 105, 110, 79, 115, 99].pack('C*')
124
+ end
125
+
126
+ it "should encode large strings" do
127
+ 'set arguments cn.argNum << this is the size of controlNames when controlName was added'.encode.should ==
128
+ [86, 115, 101, 116, 32, 97, 114, 103, 117, 109, 101, 110, 116, 115, 32, 99, 110, 46, 97, 114, 103, 78, 117, 109, 32, 60, 60, 32, 116, 104, 105, 115, 32, 105, 115, 32, 116, 104, 101, 32, 115, 105, 122, 101, 32, 111, 102, 32, 99, 111, 110, 116, 114, 111, 108, 78, 97, 109, 101, 115, 32, 119, 104, 101, 110, 32, 99, 111, 110, 116, 114, 111, 108, 78, 97, 109, 101, 32, 119, 97, 115, 32, 97, 100, 100, 101, 100].pack('C*')
129
+ end
130
+
131
+ end
132
+
133
+
data/spec/helper.rb ADDED
@@ -0,0 +1,11 @@
1
+ require "rubygems"
2
+ require "spec"
3
+ require 'yaml'
4
+
5
+ SCRUBY_DIR = File.join( File.expand_path(File.dirname(__FILE__) ), '..', 'lib', 'scruby')
6
+
7
+
8
+
9
+
10
+
11
+
@@ -0,0 +1,95 @@
1
+ require File.join( File.expand_path(File.dirname(__FILE__)), "helper")
2
+ require "#{SCRUBY_DIR}/typed_array"
3
+
4
+ class Type
5
+ end
6
+
7
+ describe TypedArray do
8
+
9
+ before do
10
+ @t1 = Type.new
11
+ @t2 = Type.new
12
+ end
13
+
14
+ it "should initialize with attributes" do
15
+ objs = (0..3).map{ Type.new }
16
+ ta = TypedArray.new( Type, objs )
17
+ ta.type.should == Type
18
+ ta.should == objs
19
+ end
20
+
21
+ it "should instantiate with an array" do
22
+ objs = (0..3).map{ Type.new }
23
+ ta = TypedArray.new( Type, objs )
24
+ ta.should == objs
25
+ end
26
+
27
+ it "set type by instance" do
28
+ ta = TypedArray.new( Type.new )
29
+ ta.type.should == Type
30
+ end
31
+
32
+ it "should raise error if wrong type" do
33
+ lambda{ TypedArray.new(Type, 1) }.should raise_error(TypeError)
34
+ end
35
+
36
+ it "+ success" do
37
+ ta = TypedArray.new( Type )
38
+ o = Type.new
39
+ sum = ta + [o]
40
+ sum.should be_instance_of(TypedArray)
41
+ sum.should == [o]
42
+ end
43
+
44
+ it "+ failure" do
45
+ lambda{ TypedArray.new(Type, Type.new) + [1] }.should raise_error(TypeError)
46
+ end
47
+
48
+ it "concat success" do
49
+ ta = TypedArray.new( Type, [@t1] )
50
+ ta.concat( [@t2] ).should == ta
51
+ ta.should == [@t1,@t2]
52
+ end
53
+
54
+ it "concat failure" do
55
+ lambda{ TypedArray.new(Type, Type.new).concat( 1 ) }.should raise_error(TypeError)
56
+ lambda{ TypedArray.new(Type, Type.new).concat( [1] ) }.should raise_error(TypeError)
57
+ end
58
+
59
+ it "<< success" do
60
+ ta = TypedArray.new(Type) << @t1
61
+ ta.should == [@t1]
62
+ end
63
+
64
+ it "<< failure" do
65
+ lambda{ TypedArray.new(Type, Type.new) << [1] }.should raise_error(TypeError)
66
+ end
67
+
68
+ it "[]= success" do
69
+ ta = TypedArray.new(Type)
70
+ ta[0]= @t1
71
+ ta[0].should == @t1
72
+ end
73
+
74
+ it "[]= failure" do
75
+ lambda{ TypedArray.new(Type, Type.new)[0]= 1 }.should raise_error(TypeError)
76
+ end
77
+
78
+ it "push success" do
79
+ ta = TypedArray.new(Type)
80
+ ta.push( @t1 )
81
+ ta.should == [@t1]
82
+ end
83
+
84
+ it "push failure" do
85
+ lambda{ TypedArray.new(Type, Type.new).push(1) }.should raise_error(TypeError)
86
+ end
87
+
88
+ it "should convert to array" do
89
+ ta = TypedArray.new(Type)
90
+ ta.to_a.should be_instance_of(Array)
91
+ end
92
+
93
+ end
94
+
95
+
metadata ADDED
@@ -0,0 +1,129 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: maca-Scruby
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.8
5
+ platform: ruby
6
+ authors:
7
+ - Macario Ortega
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-02-05 00:00:00 -08:00
13
+ default_executable: live_session.rb
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: echoe
17
+ version_requirement:
18
+ version_requirements: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: "0"
23
+ version:
24
+ description: Small client for doing sound synthesis from ruby using the SuperCollider synth, usage is quite similar from SuperCollider.
25
+ email: macarui@gmail.com
26
+ executables:
27
+ - live_session.rb
28
+ extensions: []
29
+
30
+ extra_rdoc_files:
31
+ - bin/live_session.rb
32
+ - lib/live/session.rb
33
+ - lib/scruby/audio/control_name.rb
34
+ - lib/scruby/audio/env.rb
35
+ - lib/scruby/audio/node.rb
36
+ - lib/scruby/audio/server.rb
37
+ - lib/scruby/audio/synth.rb
38
+ - lib/scruby/audio/synthdef.rb
39
+ - lib/scruby/audio/ugens/env_gen.rb
40
+ - lib/scruby/audio/ugens/in_out.rb
41
+ - lib/scruby/audio/ugens/multi_out_ugens.rb
42
+ - lib/scruby/audio/ugens/operation_indices.yaml
43
+ - lib/scruby/audio/ugens/operation_ugens.rb
44
+ - lib/scruby/audio/ugens/ugen.rb
45
+ - lib/scruby/audio/ugens/ugen_defs.yaml
46
+ - lib/scruby/audio/ugens/ugen_operations.rb
47
+ - lib/scruby/audio/ugens/ugens.rb
48
+ - lib/scruby/control/metro.rb
49
+ - lib/scruby/extensions.rb
50
+ - lib/scruby/typed_array.rb
51
+ - lib/scruby.rb
52
+ - README.rdoc
53
+ files:
54
+ - bin/live_session.rb
55
+ - changes
56
+ - lib/live/session.rb
57
+ - lib/scruby/audio/control_name.rb
58
+ - lib/scruby/audio/env.rb
59
+ - lib/scruby/audio/node.rb
60
+ - lib/scruby/audio/server.rb
61
+ - lib/scruby/audio/synth.rb
62
+ - lib/scruby/audio/synthdef.rb
63
+ - lib/scruby/audio/ugens/env_gen.rb
64
+ - lib/scruby/audio/ugens/in_out.rb
65
+ - lib/scruby/audio/ugens/multi_out_ugens.rb
66
+ - lib/scruby/audio/ugens/operation_indices.yaml
67
+ - lib/scruby/audio/ugens/operation_ugens.rb
68
+ - lib/scruby/audio/ugens/ugen.rb
69
+ - lib/scruby/audio/ugens/ugen_defs.yaml
70
+ - lib/scruby/audio/ugens/ugen_operations.rb
71
+ - lib/scruby/audio/ugens/ugens.rb
72
+ - lib/scruby/control/metro.rb
73
+ - lib/scruby/extensions.rb
74
+ - lib/scruby/typed_array.rb
75
+ - lib/scruby.rb
76
+ - Rakefile
77
+ - README.rdoc
78
+ - spec/audio/env_gen_specs.rb
79
+ - spec/audio/in_out_spec.rb
80
+ - spec/audio/integration_spec.rb
81
+ - spec/audio/lib_spec.rb
82
+ - spec/audio/multiout_ugen_spec.rb
83
+ - spec/audio/node_spec.rb
84
+ - spec/audio/operation_ugens_spec.rb
85
+ - spec/audio/server_spec.rb
86
+ - spec/audio/synth_spec.rb
87
+ - spec/audio/synthdef_spec.rb
88
+ - spec/audio/ugen_operations_spec.rb
89
+ - spec/audio/ugen_spec.rb
90
+ - spec/audio/ugens_spec.rb
91
+ - spec/env_spec.rb
92
+ - spec/extensions_spec.rb
93
+ - spec/helper.rb
94
+ - spec/typed_array_spec.rb
95
+ - Manifest
96
+ - Scruby.gemspec
97
+ has_rdoc: true
98
+ homepage: http://github.com/maca/scruby
99
+ post_install_message:
100
+ rdoc_options:
101
+ - --line-numbers
102
+ - --inline-source
103
+ - --title
104
+ - Scruby
105
+ - --main
106
+ - README.rdoc
107
+ require_paths:
108
+ - lib
109
+ required_ruby_version: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - ">="
112
+ - !ruby/object:Gem::Version
113
+ version: "0"
114
+ version:
115
+ required_rubygems_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ version: "1.2"
120
+ version:
121
+ requirements: []
122
+
123
+ rubyforge_project: scruby
124
+ rubygems_version: 1.2.0
125
+ signing_key:
126
+ specification_version: 2
127
+ summary: Small client for doing sound synthesis from ruby using the SuperCollider synth, usage is quite similar from SuperCollider.
128
+ test_files: []
129
+