Permalink
Browse files

arguments, ugens

  • Loading branch information...
1 parent fea3df3 commit 54811701187c296361d1199564138666ce3d2895 Macario committed Jul 5, 2009
Showing with 1,020 additions and 398 deletions.
  1. +4 −0 History.txt
  2. +126 −0 Manifest.txt
  3. +7 −0 PostInstall.txt
  4. +13 −3 README.rdoc
  5. +28 −10 Rakefile
  6. +0 −36 Scruby.gemspec
  7. 0 bin/{live_session.rb → livecode.rb}
  8. +0 −1 changes
  9. +0 −2 example.rb.live
  10. +50 −14 examples/example.live.rb
  11. +0 −8 examples/test.rb
  12. +26 −0 extras/Ruby Live.tmbundle/Commands/Run selection:line in session.tmCommand
  13. +26 −0 extras/Ruby Live.tmbundle/Commands/Run selection:scope in session.tmCommand
  14. +24 −0 extras/Ruby Live.tmbundle/Commands/Run update blocks in session.tmCommand
  15. +20 −0 extras/Ruby Live.tmbundle/Commands/Start Session.tmCommand
  16. +22 −0 extras/Ruby Live.tmbundle/Commands/Stop server.tmCommand
  17. +73 −0 extras/Ruby Live.tmbundle/Support/lib/live_session.rb
  18. +164 −0 extras/Ruby Live.tmbundle/Syntaxes/Ruby Live.tmLanguage
  19. +18 −0 extras/Ruby Live.tmbundle/info.plist
  20. +27 −21 lib/scruby.rb
  21. +4 −5 lib/scruby/audio/control_name.rb
  22. +32 −34 lib/scruby/audio/env.rb
  23. +1 −1 lib/scruby/audio/node.rb
  24. +18 −18 lib/scruby/audio/server.rb
  25. +3 −3 lib/scruby/audio/synth.rb
  26. +11 −11 lib/scruby/audio/synthdef.rb
  27. +11 −6 lib/scruby/audio/ugens/env_gen.rb
  28. +33 −20 lib/scruby/audio/ugens/in_out.rb
  29. +9 −9 lib/scruby/audio/ugens/multi_out_ugens.rb
  30. +13 −12 lib/scruby/audio/ugens/operation_ugens.rb
  31. +19 −22 lib/scruby/audio/ugens/ugen.rb
  32. +12 −2 lib/scruby/audio/ugens/ugen_operations.rb
  33. +69 −22 lib/scruby/audio/ugens/ugens.rb
  34. +18 −16 lib/scruby/extensions.rb
  35. +29 −39 lib/scruby/typed_array.rb
  36. +10 −0 script/console
  37. +14 −0 script/destroy
  38. +14 −0 script/generate
  39. +8 −6 spec/audio/{env_gen_specs.rb → env_gen_spec.rb}
  40. +17 −5 spec/audio/in_out_spec.rb
  41. +1 −1 spec/audio/integration_spec.rb
  42. +1 −2 spec/audio/lib_spec.rb
  43. +2 −5 spec/audio/node_spec.rb
  44. +1 −1 spec/audio/operation_ugens_spec.rb
  45. +1 −3 spec/audio/server_spec.rb
  46. +1 −4 spec/audio/synth_spec.rb
  47. +4 −4 spec/audio/synthdef_spec.rb
  48. +1 −4 spec/audio/ugen_operations_spec.rb
  49. +15 −15 spec/audio/ugen_spec.rb
  50. +17 −26 spec/audio/ugens_spec.rb
  51. +0 −3 spec/audio/untitled 11.sh
  52. +1 −0 spec/control/timer_spec.rb
  53. +0 −1 spec/env_spec.rb
  54. +0 −1 spec/extensions_spec.rb
  55. +1 −1 spec/helper.rb
  56. +1 −1 spec/typed_array_spec.rb
View
@@ -0,0 +1,4 @@
+== 0.0.1 2009-06-30
+
+* 1 major enhancement:
+ * Initial release
View
@@ -0,0 +1,126 @@
+History.txt
+Manifest.txt
+PostInstall.txt
+README.rdoc
+Rakefile
+bin/livecode.rb
+doc/classes/Array.html
+doc/classes/Fixnum.html
+doc/classes/Float.html
+doc/classes/Kernel.html
+doc/classes/Live.html
+doc/classes/Live/Pipe.html
+doc/classes/Live/Session.html
+doc/classes/Notice.html
+doc/classes/Numeric.html
+doc/classes/Object.html
+doc/classes/Proc.html
+doc/classes/Scruby.html
+doc/classes/Scruby/Audio.html
+doc/classes/Scruby/Audio/ControlName.html
+doc/classes/Scruby/Audio/SCError.html
+doc/classes/Scruby/Audio/Server.html
+doc/classes/Scruby/Audio/SynthDef.html
+doc/classes/Scruby/Audio/Ugens.html
+doc/classes/Scruby/Audio/Ugens/EnvGen.html
+doc/classes/Scruby/Audio/Ugens/In.html
+doc/classes/Scruby/Audio/Ugens/MultiOutUgen.html
+doc/classes/Scruby/Audio/Ugens/OperationUgens.html
+doc/classes/Scruby/Audio/Ugens/OperationUgens/BasicOpUgen.html
+doc/classes/Scruby/Audio/Ugens/OperationUgens/BinaryOpUGen.html
+doc/classes/Scruby/Audio/Ugens/OperationUgens/MulAdd.html
+doc/classes/Scruby/Audio/Ugens/OperationUgens/UnaryOpUgen.html
+doc/classes/Scruby/Audio/Ugens/Out.html
+doc/classes/Scruby/Audio/Ugens/OutputProxy.html
+doc/classes/Scruby/Audio/Ugens/Ugen.html
+doc/classes/Scruby/Audio/Ugens/UgenOperations.html
+doc/classes/Scruby/Audio/Ugens/UgenOperations/BinaryOperations.html
+doc/classes/Scruby/Audio/Ugens/UgenOperations/UnaryOperators.html
+doc/classes/Scruby/Control.html
+doc/classes/Scruby/Control/Metro.html
+doc/classes/Scruby/Env.html
+doc/classes/Scruby/Node.html
+doc/classes/Scruby/Synth.html
+doc/classes/Special.html
+doc/classes/String.html
+doc/classes/TypedArray.html
+doc/classes/Warning.html
+doc/created.rid
+doc/files/README_rdoc.html
+doc/files/bin/live_session_rb.html
+doc/files/lib/live/session_rb.html
+doc/files/lib/scruby/audio/control_name_rb.html
+doc/files/lib/scruby/audio/env_rb.html
+doc/files/lib/scruby/audio/node_rb.html
+doc/files/lib/scruby/audio/server_rb.html
+doc/files/lib/scruby/audio/synth_rb.html
+doc/files/lib/scruby/audio/synthdef_rb.html
+doc/files/lib/scruby/audio/ugens/env_gen_rb.html
+doc/files/lib/scruby/audio/ugens/in_out_rb.html
+doc/files/lib/scruby/audio/ugens/multi_out_ugens_rb.html
+doc/files/lib/scruby/audio/ugens/operation_indices_yaml.html
+doc/files/lib/scruby/audio/ugens/operation_ugens_rb.html
+doc/files/lib/scruby/audio/ugens/ugen_defs_yaml.html
+doc/files/lib/scruby/audio/ugens/ugen_operations_rb.html
+doc/files/lib/scruby/audio/ugens/ugen_rb.html
+doc/files/lib/scruby/audio/ugens/ugens_rb.html
+doc/files/lib/scruby/control/metro_rb.html
+doc/files/lib/scruby/extensions_rb.html
+doc/files/lib/scruby/typed_array_rb.html
+doc/files/lib/scruby_rb.html
+doc/fr_class_index.html
+doc/fr_file_index.html
+doc/fr_method_index.html
+doc/index.html
+doc/rdoc-style.css
+examples/example.live.rb
+extras/Ruby Live.tmbundle/Commands/Run selection:line in session.tmCommand
+extras/Ruby Live.tmbundle/Commands/Run selection:scope in session.tmCommand
+extras/Ruby Live.tmbundle/Commands/Run update blocks in session.tmCommand
+extras/Ruby Live.tmbundle/Commands/Start Session.tmCommand
+extras/Ruby Live.tmbundle/Commands/Stop server.tmCommand
+extras/Ruby Live.tmbundle/Support/lib/live_session.rb
+extras/Ruby Live.tmbundle/Syntaxes/Ruby Live.tmLanguage
+extras/Ruby Live.tmbundle/info.plist
+lib/live/session.rb
+lib/scruby.rb
+lib/scruby/audio/control_name.rb
+lib/scruby/audio/env.rb
+lib/scruby/audio/node.rb
+lib/scruby/audio/server.rb
+lib/scruby/audio/synth.rb
+lib/scruby/audio/synthdef.rb
+lib/scruby/audio/ugens/env_gen.rb
+lib/scruby/audio/ugens/in_out.rb
+lib/scruby/audio/ugens/multi_out_ugens.rb
+lib/scruby/audio/ugens/operation_indices.yaml
+lib/scruby/audio/ugens/operation_ugens.rb
+lib/scruby/audio/ugens/ugen.rb
+lib/scruby/audio/ugens/ugen_defs.yaml
+lib/scruby/audio/ugens/ugen_operations.rb
+lib/scruby/audio/ugens/ugens.rb
+lib/scruby/extensions.rb
+lib/scruby/typed_array.rb
+script/console
+script/destroy
+script/generate
+spec/audio/env_gen_specs.rb
+spec/audio/in_out_spec.rb
+spec/audio/integration_spec.rb
+spec/audio/lib_spec.rb
+spec/audio/multiout_ugen_spec.rb
+spec/audio/node_spec.rb
+spec/audio/operation_ugens_spec.rb
+spec/audio/server_spec.rb
+spec/audio/synth_spec.rb
+spec/audio/synthdef_spec.rb
+spec/audio/ugen_operations_spec.rb
+spec/audio/ugen_spec.rb
+spec/audio/ugens_spec.rb
+spec/control/timer_spec.rb
+spec/env_spec.rb
+spec/extensions_spec.rb
+spec/helper.rb
+spec/typed_array_spec.rb
+test/test_Scruby.rb
+test/test_helper.rb
View
@@ -0,0 +1,7 @@
+
+For more information on Scruby, see http://Scruby.rubyforge.org
+
+NOTE: Change this information in PostInstall.txt
+You can also delete it if you don't want it.
+
+
View
@@ -1,5 +1,18 @@
+== Scruby
+
+Is a bare-bones SuperCollider livecoding library for Ruby, it provides comunication with a remote or local scsynth server and SynthDef creation with a
+very similar syntax as Sclang.
+
+SynthDef creation and sending is robust but some features are not implemented such as SynthDef variations and others I may not be aware of.
+
+livecode.rb executable is located in the bin directory and a TextMate bundle included in extras permits livecoding from TextMate, comunication is
+thrugh *nix pipes. Similar functionality shouldn't be too dificult to implement from Emacs or Vim.
+
+== TODO
+
+Receive OSC messages from SuperCollider
== LICENSE:
@@ -18,9 +31,6 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-== NOTES
-
-Ruby has operation precendence
View
@@ -1,10 +1,28 @@
-require 'rubygems'
-require 'rake'
-require 'echoe'
-
-Echoe.new('Scruby', '0.0.8') do |p|
- p.description = "Small client for doing sound synthesis from ruby using the SuperCollider synth, usage is quite similar from SuperCollider."
- p.url = 'http://github.com/maca/scruby'
- p.author = "Macario Ortega"
- p.email = "macarui@gmail.com"
-end
+require 'rubygems' unless ENV['NO_RUBYGEMS']
+%w[rake rake/clean fileutils newgem rubigen].each { |f| require f }
+require File.dirname(__FILE__) + '/lib/Scruby'
+
+# Generate all the Rake tasks
+# Run 'rake -T' to see list of generated tasks (from gem root directory)
+$hoe = Hoe.new('Scruby', Scruby::VERSION) do |p|
+ p.developer('FIXME full name', 'FIXME email')
+ p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
+ p.post_install_message = 'PostInstall.txt' # TODO remove if post-install message not required
+ p.rubyforge_name = p.name # TODO this is default value
+ # p.extra_deps = [
+ # ['activesupport','>= 2.0.2'],
+ # ]
+ p.extra_dev_deps = [
+ ['newgem', ">= #{::Newgem::VERSION}"]
+ ]
+ p.clean_globs |= %w[**/.DS_Store tmp *.log]
+ path = (p.rubyforge_name == p.name) ? p.rubyforge_name : "\#{p.rubyforge_name}/\#{p.name}"
+ p.remote_rdoc_dir = File.join(path.gsub(/^#{p.rubyforge_name}\/?/,''), 'rdoc')
+ p.rsync_args = '-av --delete --ignore-errors'
+end
+
+require 'newgem/tasks' # load /tasks/*.rake
+Dir['tasks/**/*.rake'].each { |t| load t }
+
+# TODO - want other tests/tasks run by default? Add them to the list
+task :default => :spec
View
@@ -1,36 +0,0 @@
-# -*- encoding: utf-8 -*-
-
-Gem::Specification.new do |s|
- s.name = %q{Scruby}
- s.version = "0.0.8"
-
- s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
- s.authors = ["Macario Ortega"]
- s.date = %q{2009-02-05}
- s.default_executable = %q{live_session.rb}
- s.description = %q{Small client for doing sound synthesis from ruby using the SuperCollider synth, usage is quite similar from SuperCollider.}
- s.email = %q{macarui@gmail.com}
- s.executables = ["live_session.rb"]
- s.extra_rdoc_files = ["bin/live_session.rb", "lib/live/session.rb", "lib/scruby/audio/control_name.rb", "lib/scruby/audio/env.rb", "lib/scruby/audio/node.rb", "lib/scruby/audio/server.rb", "lib/scruby/audio/synth.rb", "lib/scruby/audio/synthdef.rb", "lib/scruby/audio/ugens/env_gen.rb", "lib/scruby/audio/ugens/in_out.rb", "lib/scruby/audio/ugens/multi_out_ugens.rb", "lib/scruby/audio/ugens/operation_indices.yaml", "lib/scruby/audio/ugens/operation_ugens.rb", "lib/scruby/audio/ugens/ugen.rb", "lib/scruby/audio/ugens/ugen_defs.yaml", "lib/scruby/audio/ugens/ugen_operations.rb", "lib/scruby/audio/ugens/ugens.rb", "lib/scruby/control/metro.rb", "lib/scruby/extensions.rb", "lib/scruby/typed_array.rb", "lib/scruby.rb", "README.rdoc"]
- s.files = ["bin/live_session.rb", "changes", "lib/live/session.rb", "lib/scruby/audio/control_name.rb", "lib/scruby/audio/env.rb", "lib/scruby/audio/node.rb", "lib/scruby/audio/server.rb", "lib/scruby/audio/synth.rb", "lib/scruby/audio/synthdef.rb", "lib/scruby/audio/ugens/env_gen.rb", "lib/scruby/audio/ugens/in_out.rb", "lib/scruby/audio/ugens/multi_out_ugens.rb", "lib/scruby/audio/ugens/operation_indices.yaml", "lib/scruby/audio/ugens/operation_ugens.rb", "lib/scruby/audio/ugens/ugen.rb", "lib/scruby/audio/ugens/ugen_defs.yaml", "lib/scruby/audio/ugens/ugen_operations.rb", "lib/scruby/audio/ugens/ugens.rb", "lib/scruby/control/metro.rb", "lib/scruby/extensions.rb", "lib/scruby/typed_array.rb", "lib/scruby.rb", "Rakefile", "README.rdoc", "spec/audio/env_gen_specs.rb", "spec/audio/in_out_spec.rb", "spec/audio/integration_spec.rb", "spec/audio/lib_spec.rb", "spec/audio/multiout_ugen_spec.rb", "spec/audio/node_spec.rb", "spec/audio/operation_ugens_spec.rb", "spec/audio/server_spec.rb", "spec/audio/synth_spec.rb", "spec/audio/synthdef_spec.rb", "spec/audio/ugen_operations_spec.rb", "spec/audio/ugen_spec.rb", "spec/audio/ugens_spec.rb", "spec/env_spec.rb", "spec/extensions_spec.rb", "spec/helper.rb", "spec/typed_array_spec.rb", "Manifest", "Scruby.gemspec"]
- s.has_rdoc = true
- s.homepage = %q{http://github.com/maca/scruby}
- s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Scruby", "--main", "README.rdoc"]
- s.require_paths = ["lib"]
- s.rubyforge_project = %q{scruby}
- s.rubygems_version = %q{1.3.1}
- s.summary = %q{Small client for doing sound synthesis from ruby using the SuperCollider synth, usage is quite similar from SuperCollider.}
-
- if s.respond_to? :specification_version then
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
- s.specification_version = 2
-
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
- s.add_development_dependency(%q<echoe>, [">= 0"])
- else
- s.add_dependency(%q<echoe>, [">= 0"])
- end
- else
- s.add_dependency(%q<echoe>, [">= 0"])
- end
-end
View
File renamed without changes.
View
@@ -1 +0,0 @@
-
View
@@ -1,2 +0,0 @@
-
-
View
@@ -2,36 +2,72 @@
require scruby
s = Server.new('localhost', 57140)
s.boot
-
require File.expand_path( File.join( File.dirname(__FILE__),'..','..', '..', 'Sequentiable', 'lib', 'metro' ) )
require File.expand_path( File.join( File.dirname(__FILE__),'..','..', '..', 'HumanGenome', 'lib', 'human_genome' ) )
-
-
-sdef = SynthDef.new :test, :values => [456, 0.34, 0.45] do |freq, ancho, amp|
+sdef = SynthDef.new :melo, :values => [456, 0.34, 0.45] do |freq, amp, a, b, c|
gate = EnvGen.kr( Env.perc(0, 0.2) )
- sig = SinOsc.ar( [freq, freq * 1.01], :mul => SinOsc.kr(40) * amp * 0.7 ) * EnvGen.kr( Env.asr(2, 1, 3), gate, :doneAction => 2 )
- sig = SinOsc.ar( [freq, freq * 1.01], :mul => SinOsc.kr(8) * amp * 0.3 ) * EnvGen.kr( Env.asr(2, 1, 2), gate ) + sig
- sig = SinOsc.ar( [freq * 0.25, freq * 0.251], :mul => SinOsc.kr(30) * amp * 0.3 ) * EnvGen.kr( Env.asr(2, 1, 2.5), gate ) + sig
- sig = SinOsc.ar( freq * 2, :mul => SinOsc.kr(500, :mul => 0.1) * amp * 0.2 ) * EnvGen.kr( Env.asr(0, 1, 2), gate ) + sig
+ sig = SinOsc.ar( [freq, freq * 1.01], :mul => SinOsc.kr(40) * amp * 0.7, :add => SinOsc.kr(0.5, :mul => 2.5) ) * EnvGen.kr( Env.asr(2, 1, 3), gate, :doneAction => 2 )
+ sig = SinOsc.ar( [freq, freq * 1.01], :mul => SinOsc.kr(8) * amp * 0.3, :add => SinOsc.kr(0.5, :mul => 2.5) ) * EnvGen.kr( Env.asr(2, 1, 2), gate ) + sig
+ sig = SinOsc.ar( [freq * 0.25, freq * 0.251], :mul => SinOsc.kr(30) * amp * 0.3 ) * EnvGen.kr( Env.asr(2, 1, 3), gate ) + sig
+ sig = SinOsc.ar( freq * 2, :mul => SinOsc.kr(500, :mul => 0.1) * amp * 0.1 ) * EnvGen.kr( Env.asr(0, 1, 2), gate ) + sig
sig = SinOsc.ar( freq * 0.25, :mul => amp * 0.2 ) * EnvGen.kr( Env.asr(0, 1, 0.4), gate ) + sig
- Out.ar( 0, sig)
+ res = Resonz.ar( sig, EnvGen.kr( Env.asr(0.5, 3,c*2) )* a * 10000 )
+ Out.ar( 0, [res[0] * 6 + sig[1] * 0.8]*2 )
end
sdef.send
sleep 0.05
-test = Synth.new :test, :freq => 2000, :amp => 1
-sleep 0.2
+test = Synth.new :melo, :freq => 220, :amp => 0.5
+# [1] * 2 = [1,1]
+s.stop
-bass.set( :gate => 0)
+sdef = SynthDef.new :perc, :values => [456, 0.34, 0.45] do |freq, amp, a, b|
+ dur = a
+ amp = amp * 0.25
+ freq = freq * 0.05
+ sig = SinOsc.ar( Line.kr( freq * 1.5, freq * 1.1, dur ), Math::PI/2, amp * 0.2 * SinOsc.kr(10) )
+ # sig = Resonz.ar( sig, EnvGen.kr( Env.asr(0.5, 3, 2) ) * 120, 0.5 )
+ # sig = LPF.ar( sig, 120 )
+ sig = HPF.ar( WhiteNoise.ar( amp * 0.1 ), freq * 10 ) * b * 0.8 + sig
+ # sig = Pan2.ar( sig, 0)
+ env = EnvGen.kr Env.perc( 0, dur ), :doneAction => 2
+ Out.ar 0, [sig*env]*2
+end
+sdef.send
+sleep 0.05
+test = Synth.new :perc, :freq => 1000, :amp => 0.5, :dur => rand
+sdef = SynthDef.new :perc, :values => [456, 0.34, 0.45] do |freq, amp, a, b|
+ dur = a
+ amp = amp
+ freq = freq * 0.1
+ sig = SinOsc.ar( Line.kr( freq * 1.5, freq * 1.1, dur ), Math::PI/2, amp * 0.2 * SinOsc.kr(10) )
+ sig = HPF.ar( WhiteNoise.ar( amp * 0.1 ), freq * 10 ) * 0.8 + sig
+ env = EnvGen.kr Env.perc( 0, dur ), :doneAction => 2
+ Out.ar 0, [sig*env]*2
+end
+sdef.send
+sleep 0.05
+test = Synth.new :perc, :freq => 1000, :amp => 0.5, :dur => rand
+
+sdef = SynthDef.new :perc, :values => [456, 0.34, 0.45] do |freq, amp, a, b|
+ gate = EnvGen.kr Env.perc(0,0.1)
+ env = EnvGen.kr Env.asr( 0.1, 4, 1 ), gate, :doneAction => 2
+ sig = DelayC.ar( SinOsc.ar(freq), 4, SinOsc.ar( SinOsc.ar( SinOsc.ar( 2 ) ) ) )
+ Out.ar( 0, [sig * env]*2 )
+end
+sdef.send
+sleep 0.05
+test = Synth.new :perc, :freq => 1000, :amp => 0.5, :dur => rand
+# sleep 0.8
s.stop
-test.free
-bass.free
+sleep 0.05
+test = Synth.new :test, :freq => 20, :amp => 1
View
@@ -1,8 +0,0 @@
-
-
-[69,70,71].map( &:freq )
-
-
-
-
-
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>beforeRunningCommand</key>
+ <string>nop</string>
+ <key>command</key>
+ <string>
+cat | tr '\n' '∂' &gt; `ruby -e "require 'tempfile'; puts Dir.tmpdir"`/ruby_live.pipe
+</string>
+ <key>fallbackInput</key>
+ <string>line</string>
+ <key>input</key>
+ <string>selection</string>
+ <key>keyEquivalent</key>
+ <string>$</string>
+ <key>name</key>
+ <string>Run selection/line in session</string>
+ <key>output</key>
+ <string>discard</string>
+ <key>scope</key>
+ <string>source.ruby.live</string>
+ <key>uuid</key>
+ <string>E6569DD2-3A1F-408F-8172-272E77EF8D96</string>
+</dict>
+</plist>
Oops, something went wrong.

0 comments on commit 5481170

Please sign in to comment.