rubySC 0.0.2 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE.txt +20 -0
- data/README.rdoc +42 -0
- data/lib/init.sc +23 -9
- data/lib/rubySC.rb +92 -56
- data/lib/voix.rb +17 -7
- metadata +136 -16
- checksums.yaml +0 -7
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2014 simdax
|
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,42 @@
|
|
1
|
+
= rubySC
|
2
|
+
|
3
|
+
1. Créez une instance de Musique :
|
4
|
+
|
5
|
+
` mu=Musique.instance `
|
6
|
+
|
7
|
+
1. ajouter une nouvelle voix :
|
8
|
+
|
9
|
+
` mu.set :nomVoix (ou "nomVoix"), :param => valeur `
|
10
|
+
|
11
|
+
1. il y a 6 paramètres pouvant être réglés :
|
12
|
+
|
13
|
+
* instrument : pour l'instant, seulement deux ("sax" ou "default") !!
|
14
|
+
* dur : les rythmes de votre mélodie
|
15
|
+
* degree : les notes de votre mélodie
|
16
|
+
* amp : le volume de la mélodie
|
17
|
+
* octave : le registre dans lequel se situe votre voix
|
18
|
+
* scale : l'echelle utilisé pour votre mélodie
|
19
|
+
|
20
|
+
1. arrêter ou reprenez vos voix :
|
21
|
+
|
22
|
+
` mu.stop :voixUn, :voixDeux ## arrête deux voix
|
23
|
+
` mu.play :voixUn ## reprend voixUn
|
24
|
+
` mu.stop :all ## arrête tout
|
25
|
+
|
26
|
+
1. Des bêtes de méta-fonctions sont à prévoir.
|
27
|
+
|
28
|
+
== Contributing to rubySC
|
29
|
+
|
30
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
31
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
32
|
+
* Fork the project.
|
33
|
+
* Start a feature/bugfix branch.
|
34
|
+
* Commit and push until you are happy with your contribution.
|
35
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
36
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
37
|
+
|
38
|
+
== Copyright
|
39
|
+
|
40
|
+
Copyright (c) 2014 simdax. See LICENSE.txt for
|
41
|
+
further details.
|
42
|
+
|
data/lib/init.sc
CHANGED
@@ -1,14 +1,28 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
//////////dictionnaire d'instruments
|
2
|
+
|
3
|
+
SynthDef(\sax, { |out, freq=440, amp=0.1, gate=1|
|
4
|
+
var num = 16;
|
5
|
+
var harms = Array.series(num, 1, 1) * Array.exprand(num, 0.995, 1.001);
|
6
|
+
var snd = SinOsc.ar(freq * SinOsc.kr(Rand(2.0,5.0),0,Rand(0.001, 0.01),1) * harms, mul:Array.geom(num, 1, 0.63));
|
7
|
+
snd = Splay.ar(snd);
|
8
|
+
snd = BBandPass.ar(snd, freq * XLine.kr(0.1,4,0.01), 2);
|
9
|
+
snd = snd * amp * EnvGen.ar(Env.adsr(0.001, 0.2, 0.7, 0.2), gate, doneAction:2);
|
10
|
+
Out.ar(out, snd!2);
|
11
|
+
}).add;
|
12
|
+
|
13
|
+
|
14
|
+
///////// Ligne de fin pour mettre le bouzin en route
|
4
15
|
|
5
16
|
s.boot;
|
6
17
|
NetAddr.langPort.postln;
|
7
18
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
}
|
13
|
-
)
|
19
|
+
OSCFunc.newMatching(
|
20
|
+
{ |message, time, addr, responder|
|
21
|
+
//"caca".post;
|
22
|
+
message[1].asString.interpret
|
23
|
+
}, "/SC", n
|
24
|
+
);
|
25
|
+
|
14
26
|
|
27
|
+
m=NetAddr("127.0.0.1", NetAddr.langPort);
|
28
|
+
m.sendMsg("SC", "iop")
|
data/lib/rubySC.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
# -*- coding: utf-8 -*-
|
3
3
|
|
4
4
|
require 'osc-ruby'
|
5
|
+
#require 'osc-ruby/em_server'
|
5
6
|
require 'singleton'
|
6
7
|
include ObjectSpace
|
7
8
|
load "#{File.join(File.dirname(__FILE__), "voix.rb")}"
|
@@ -18,76 +19,49 @@ class Musique
|
|
18
19
|
|
19
20
|
include Singleton
|
20
21
|
|
21
|
-
# ouvre le contact avec SuperCollider
|
22
|
+
# ouvre le contact avec SuperCollider
|
22
23
|
|
23
24
|
def initialize
|
25
|
+
|
26
|
+
## démarre SuperCollider
|
27
|
+
|
24
28
|
unless p `ps -ef | grep "sclang" | grep -v "grep" | wc -l`.to_i > 0
|
25
|
-
system "sclang -u
|
29
|
+
system "sclang -u 57320 #{File.join(File.dirname(__FILE__), "init.sc")} &"
|
26
30
|
end
|
27
|
-
@postMan= OSC::Client.new "localhost", 57119
|
28
|
-
@listeVoix=Hash.new
|
29
|
-
define_finalizer(self, Proc.new {self.quit})
|
30
|
-
end
|
31
31
|
|
32
|
-
|
33
|
-
|
34
|
-
#
|
32
|
+
## récupère l'adresse du port, mais la lib ne marche pas ??
|
33
|
+
|
34
|
+
# @server= OSC::EMServer.new 3333
|
35
|
+
# @server.add_method '/portSuperCollider' do |message|
|
36
|
+
# @portSuperCollider=message.message
|
37
|
+
# end
|
38
|
+
@postMan= OSC::Client.new "localhost", 57320 ## @portSuperCollider
|
35
39
|
|
36
|
-
|
37
|
-
|
40
|
+
# variables et méthodes d'utilisation
|
41
|
+
|
42
|
+
@listeVoix=Hash.new
|
43
|
+
define_finalizer(self, Proc.new {self.quit})
|
44
|
+
|
38
45
|
end
|
39
46
|
|
40
|
-
|
41
|
-
|
42
|
-
def creer voix
|
43
|
-
@listeVoix[voix]=Voix.new
|
44
|
-
self.play voix
|
45
|
-
end
|
46
|
-
|
47
|
-
def multi methode, *args
|
48
|
-
if args[0]=="All" then
|
49
|
-
args=@listeVoix.keys
|
50
|
-
end
|
51
|
-
args.each do |voix|
|
52
|
-
if @listeVoix.has_key?(voix) then
|
53
|
-
self.method(methode).call voix
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
def play voix
|
59
|
-
self.send "Pdef(\\#{voix}).play"
|
60
|
-
end
|
61
|
-
|
62
|
-
def stop voix
|
63
|
-
self.send "Pdef(\\#{voix}).stop"
|
47
|
+
def quit
|
48
|
+
`killall scsynth sclang`
|
64
49
|
end
|
65
|
-
|
66
|
-
##
|
67
50
|
|
68
|
-
def stopAll
|
69
|
-
@listeVoix.each_key do |voix|
|
70
|
-
puts voix
|
71
|
-
self.stop voix
|
72
|
-
end
|
73
|
-
end
|
74
51
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
@listeVoix[voix.to_s].set options
|
79
|
-
end
|
52
|
+
# fonction permettant de communiquer directement avec SuperCollider,
|
53
|
+
# ce qui permet pour qui connaît la syntaxe sclang de faire des
|
54
|
+
# ajustages directs
|
80
55
|
|
81
|
-
def
|
82
|
-
@
|
83
|
-
self.set voix, {:scale => echelle}
|
84
|
-
end
|
56
|
+
def send message
|
57
|
+
@postMan.send OSC::Message.new "/SC", message.to_s
|
85
58
|
end
|
86
59
|
|
60
|
+
|
87
61
|
def updateScore
|
88
62
|
@listeVoix.each do |key, value|
|
89
63
|
value.instance_variables.each do |variable|
|
90
|
-
self.updater key, variable[1..-1], value.instance_variable_get(variable)
|
64
|
+
self.updater key, variable[1..-1], value.instance_variable_get(variable) unless value.instance_variable_get(variable).nil?
|
91
65
|
end
|
92
66
|
end
|
93
67
|
end
|
@@ -101,17 +75,79 @@ class Musique
|
|
101
75
|
self.send "Pbindef(\\#{voix}, \\#{arg}, Pseq(#{value}, inf))"
|
102
76
|
when "scale"
|
103
77
|
self.send "Pbindef(\\#{voix}, \\#{arg}, Scale.#{value})"
|
78
|
+
when "instrument"
|
79
|
+
self.send "Pbindef(\\#{voix}, \\#{arg}, \\#{value})"
|
104
80
|
else
|
105
81
|
self.send "Pbindef(\\#{voix}, \\#{arg}, #{value})"
|
106
82
|
end
|
107
83
|
end
|
108
84
|
end
|
85
|
+
|
86
|
+
# fonctions principales
|
109
87
|
|
110
|
-
def
|
111
|
-
|
88
|
+
def set voix, options={}
|
89
|
+
if voix==:all then
|
90
|
+
begin
|
91
|
+
raise 'ArgumentError : vous ne pouvez appeler une voix "all", renommez-la'
|
92
|
+
rescue
|
93
|
+
gets voix
|
94
|
+
end
|
95
|
+
elsif @listeVoix[voix.to_s].nil? then
|
96
|
+
@listeVoix[voix.to_s]=Voix.new options
|
97
|
+
else
|
98
|
+
@listeVoix[voix.to_s].set options
|
99
|
+
end
|
100
|
+
self.updateScore
|
101
|
+
self.play voix.to_s
|
102
|
+
end
|
103
|
+
|
104
|
+
def remove *args
|
105
|
+
if args[0]==:all then
|
106
|
+
args=@listeVoix.keys
|
107
|
+
end
|
108
|
+
args.each do |voix|
|
109
|
+
@listeVoix.delete args
|
110
|
+
end
|
112
111
|
end
|
113
112
|
|
114
|
-
|
113
|
+
def play *args
|
114
|
+
if args[0]==:all then
|
115
|
+
args=@listeVoix.keys
|
116
|
+
end
|
117
|
+
args.each do |voix|
|
118
|
+
self.send "Pdef(\\#{voix.to_s}).play"
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
def stop *args
|
123
|
+
if args[0]==:all then
|
124
|
+
args=@listeVoix.keys
|
125
|
+
end
|
126
|
+
args.each do |voix|
|
127
|
+
self.send "Pdef(\\#{voix}).stop"
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
### fonction Live Coding
|
132
|
+
|
133
|
+
def list
|
134
|
+
@listeVoix.each do |k, v|
|
135
|
+
puts "#{k} : #{v.inspect}"
|
136
|
+
end
|
137
|
+
end
|
115
138
|
|
116
139
|
|
140
|
+
# fonctions de très haut niveau
|
141
|
+
|
142
|
+
def echelle echelle
|
143
|
+
@listeVoix.each_key do |voix|
|
144
|
+
self.set voix, {:scale => echelle}
|
145
|
+
end
|
146
|
+
self.updateScore
|
147
|
+
end
|
117
148
|
|
149
|
+
def grilleAccords
|
150
|
+
|
151
|
+
end
|
152
|
+
|
153
|
+
end
|
data/lib/voix.rb
CHANGED
@@ -4,21 +4,31 @@
|
|
4
4
|
|
5
5
|
class Voix
|
6
6
|
|
7
|
-
# pour initialiser directement TODO=marche pas... :'(
|
8
7
|
def initialize options={}
|
9
|
-
|
8
|
+
|
9
|
+
if options[:scale].nil?
|
10
|
+
then @scale = "major"
|
11
|
+
else @scale=options[:scale]
|
12
|
+
end
|
10
13
|
@dur=options[:dur]
|
11
14
|
@degree=options[:degree]
|
12
|
-
@
|
15
|
+
@octave=options[:octave]
|
13
16
|
@amp=options[:amp]
|
14
|
-
|
17
|
+
if options[:instrument].nil?
|
18
|
+
then @instrument = "default"
|
19
|
+
else @instrument=options[:instrument].to_s
|
20
|
+
end
|
15
21
|
end
|
16
22
|
|
17
23
|
# permet de set plein d'options à la fois, ce qui est plutôt cool
|
18
24
|
def set options
|
19
25
|
options.each do |key, value|
|
20
|
-
|
26
|
+
if value.is_a? Symbol
|
27
|
+
self.instance_variable_set "@#{key}", value.to_s
|
28
|
+
else
|
29
|
+
self.instance_variable_set "@#{key}", value
|
30
|
+
end
|
21
31
|
end
|
22
|
-
end
|
32
|
+
end
|
23
33
|
|
24
|
-
end
|
34
|
+
end
|
metadata
CHANGED
@@ -1,50 +1,170 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubySC
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
|
-
-
|
8
|
+
- simdax
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date:
|
12
|
-
dependencies:
|
13
|
-
|
12
|
+
date: 2014-01-11 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: osc-ruby
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: shoulda
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rdoc
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '3.12'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.12'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: bundler
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '1.0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '1.0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: jeweler
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ~>
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: 2.0.0
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ~>
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: 2.0.0
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: simplecov
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: osc-ruby
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ! '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
description: Petite bibliotheque permettant une communication simple entre SuperCollider/JITlib
|
14
127
|
et Ruby. Se concentre avant tout sur les capacités logiques de création de mélodies
|
15
|
-
plus que sur la génération de son.
|
128
|
+
plus que sur la génération de son. Nécessite d'installer supercollider sur l'ordinateur
|
129
|
+
(=> sudo aptitude install supercollider sur debian par exemple)"
|
16
130
|
email: simoncornaz@gmail.com
|
17
131
|
executables: []
|
18
132
|
extensions: []
|
19
|
-
extra_rdoc_files:
|
133
|
+
extra_rdoc_files:
|
134
|
+
- LICENSE.txt
|
135
|
+
- README.rdoc
|
20
136
|
files:
|
21
137
|
- lib/init.sc
|
22
138
|
- lib/rubySC.rb
|
23
139
|
- lib/voix.rb
|
24
|
-
|
140
|
+
- LICENSE.txt
|
141
|
+
- README.rdoc
|
142
|
+
homepage: http://github.com/simdax/rubySC
|
25
143
|
licenses:
|
26
144
|
- MIT
|
27
|
-
metadata: {}
|
28
145
|
post_install_message:
|
29
146
|
rdoc_options: []
|
30
147
|
require_paths:
|
31
148
|
- lib
|
32
149
|
required_ruby_version: !ruby/object:Gem::Requirement
|
150
|
+
none: false
|
33
151
|
requirements:
|
34
|
-
- -
|
152
|
+
- - ! '>='
|
35
153
|
- !ruby/object:Gem::Version
|
36
154
|
version: '0'
|
155
|
+
segments:
|
156
|
+
- 0
|
157
|
+
hash: 2342837960793631421
|
37
158
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
159
|
+
none: false
|
38
160
|
requirements:
|
39
|
-
- -
|
161
|
+
- - ! '>='
|
40
162
|
- !ruby/object:Gem::Version
|
41
163
|
version: '0'
|
42
164
|
requirements: []
|
43
165
|
rubyforge_project:
|
44
|
-
rubygems_version:
|
166
|
+
rubygems_version: 1.8.23
|
45
167
|
signing_key:
|
46
|
-
specification_version:
|
47
|
-
summary:
|
48
|
-
et Ruby. Se concentre avant tout sur les capacités logiques de création de mélodies
|
49
|
-
plus que sur la génération de son.
|
168
|
+
specification_version: 3
|
169
|
+
summary: simple and light music livecoding library
|
50
170
|
test_files: []
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: f13350897cecea058d9781ccebc092964541ba50
|
4
|
-
data.tar.gz: b25ccc3a0d73a09dc3a9ffd7639ea752352d8fb7
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: 61700ede2bde3a56853603bc710ed003be8f66a96918ba6bb7b81931eaae596086ac25561d3e02a416cfd36c5c835c583762abec9eaed9cde2fd7645a5372bad
|
7
|
-
data.tar.gz: acd06b3db224fb209f6075b5390ccceb815172d8305fec65cc0ac6eba3dbf2c36638ad74239a5e2ec92a0dcec35a68c729049f608a1a8341093ef0e6bb6db3b8
|