rubySC 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.
Files changed (5) hide show
  1. checksums.yaml +7 -0
  2. data/lib/init.sc +14 -0
  3. data/lib/rubySC.rb +86 -0
  4. data/lib/voix.rb +23 -0
  5. metadata +45 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 60afeecfcdf89e3419921997db1919b79df4184d
4
+ data.tar.gz: 23a60a985aa742e511d5d79439362e7c533ffbef
5
+ SHA512:
6
+ metadata.gz: bc238b5f02c08e56136d0934d7b09a11da7828110b176c04b0b0af891a2a96733c5a68173c5f2d9396eeb93f8b0e0af175547581d504a9092915b1ce6620a6e6
7
+ data.tar.gz: e88bc0405eff33ab48bc06c6f7a0544271c2317556e32e80b05e8dc707e8775a37ece1479976bfdbc215bdff590d90f244b559894573cb0973e9e0c5e323bf2c
@@ -0,0 +1,14 @@
1
+ // =====================================================================
2
+ // SuperCollider Workspace
3
+ // =====================================================================
4
+
5
+ s.boot;
6
+ NetAddr.langPort.postln;
7
+
8
+ OSCresponder(
9
+ nil, "SC",
10
+ { |time, responder, message, address|
11
+ message[1].asString.interpret
12
+ }
13
+ ).add
14
+
@@ -0,0 +1,86 @@
1
+ #! /usr/bin/ruby
2
+
3
+ require 'osc-ruby'
4
+ require 'singleton'
5
+ include ObjectSpace
6
+ require_relative './voix.rb'
7
+
8
+
9
+ class Musique
10
+
11
+ include Singleton
12
+
13
+ attr_accessor :listeVoix
14
+
15
+ def initialize
16
+ unless p `ps -ef | grep "sclang" | grep -v "grep" | wc -l`.to_i > 0
17
+ system "sclang -u 57119 #{File.dirname(__FILE__)}/init.sc &"
18
+ end
19
+ @postMan= OSC::Client.new "localhost", 57119
20
+ @listeVoix=Hash.new
21
+ define_finalizer(self, Proc.new {self.quit})
22
+ end
23
+
24
+ def send message
25
+ @postMan.send OSC::Message.new "SC", message.to_s
26
+ end
27
+
28
+ def creer voix, options={}
29
+ @listeVoix[voix]=Voix.new options
30
+ self.play voix
31
+ end
32
+
33
+ def play voix
34
+ self.send "Pdef(\\#{voix}).play"
35
+ end
36
+
37
+ def stop voix
38
+ self.send "Pdef(\\#{voix}).stop"
39
+ end
40
+
41
+ def stopAll
42
+ @listeVoix.each_key do |voix|
43
+ puts voix
44
+ self.stop voix
45
+ end
46
+ end
47
+
48
+ def set voix, options
49
+ # @listeVoix[voix.to_s].instance_variable_set "@#{var.to_s}", value
50
+ @listeVoix[voix.to_s].set options
51
+ end
52
+
53
+ def echelle echelle
54
+ @listeVoix.each_key do |voix|
55
+ self.set voix, {:scale => echelle}
56
+ end
57
+ end
58
+
59
+ def updateScore
60
+ @listeVoix.each do |key, value|
61
+ value.instance_variables.each do |variable|
62
+ self.updater key, variable[1..-1], value.instance_variable_get(variable)
63
+ end
64
+ end
65
+ end
66
+
67
+ def updater voix, arg, value
68
+ if voix.is_a? String then
69
+ if arg == "dur" then
70
+ self.send "Pbindef (\\#{voix}, \\#{arg}, Pseq(#{value}.convertRhythm, inf))"
71
+ elsif arg == "degree" then
72
+ self.send "Pbindef(\\#{voix}, \\#{arg}, Pseq(#{value}, inf))"
73
+ else
74
+ self.send "Pbindef(\\#{voix}, \\#{arg}, #{value})"
75
+ end
76
+ end
77
+ end
78
+
79
+ def quit
80
+ `killall sclang scsynth`
81
+ end
82
+
83
+ end
84
+
85
+
86
+
@@ -0,0 +1,23 @@
1
+ class Voix
2
+
3
+ attr_accessor :scale, :dur, :degree, :amp, :root
4
+
5
+ def initialize options={}
6
+
7
+ @scale=options[:scale]
8
+ @dur=options[:dur]
9
+ @degree=options[:degree]
10
+ @root=options[:root]
11
+ @amp=options[:amp]
12
+ @instrument=options[:instrument]
13
+
14
+ end
15
+
16
+ def set options
17
+ options.each_key do |key, value|
18
+ p "caca"
19
+ self.instance_variable_set "@#{key.to_s}", value
20
+ end
21
+ end
22
+
23
+ end
metadata ADDED
@@ -0,0 +1,45 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rubySC
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - moi
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-01-05 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description:
14
+ email:
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/init.sc
20
+ - lib/rubySC.rb
21
+ - lib/voix.rb
22
+ homepage:
23
+ licenses: []
24
+ metadata: {}
25
+ post_install_message:
26
+ rdoc_options: []
27
+ require_paths:
28
+ - lib
29
+ required_ruby_version: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ required_rubygems_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ requirements: []
40
+ rubyforge_project:
41
+ rubygems_version: 2.2.0
42
+ signing_key:
43
+ specification_version: 4
44
+ summary: permet une communication avec SC et JITlib
45
+ test_files: []