rubySC 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +0 -3
- data/Gemfile +2 -5
- data/Rakefile +0 -3
- data/VERSION +1 -1
- data/lib/rubySC.rb +36 -70
- data/lib/rubySC/bip.wav +0 -0
- data/lib/rubySC/contrepoint.rb +31 -0
- data/lib/rubySC/melodie.rb +44 -0
- data/lib/rubySC/musique.rb +90 -69
- data/lib/rubySC/version.rb +1 -1
- data/lib/rubySC/voix.rb +42 -26
- metadata +7 -10
- data/examples/score.json +0 -6
- data/examples/score.json~ +0 -6
- data/examples/testMinimal.rb +0 -17
- data/examples/testMinimal.rb~ +0 -9
- data/lib/lib/circularList.rb +0 -29
- data/lib/lib/musique.rb +0 -114
- data/lib/lib/voix.rb +0 -62
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4c715abbf1240f534cab6767762f9e89c2b9d50e
|
4
|
+
data.tar.gz: 176efdd566e7bb588b0ad853ce1524c7cc133489
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0c49e497d1af6da7de5669e2b3c0272a856c066070722cc97e098c28041b84752cd3ab3a205a06708db2b09222d151cd40bbe8a3780b601bda634107974891be
|
7
|
+
data.tar.gz: 8fe82bb7e78e2b616255b9ede8e0ff4c88119263dfa78c875dd96d7510b2503407074ea7e5accfd6bfcb18f91d36985c99b72e89ced0eec4330a0537d8f8cf08
|
data/.gitignore
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
<<<<<<< HEAD
|
2
1
|
*.gem
|
3
2
|
*.rbc
|
4
3
|
.bundle
|
@@ -16,7 +15,6 @@ spec/reports
|
|
16
15
|
test/tmp
|
17
16
|
test/version_tmp
|
18
17
|
tmp
|
19
|
-
=======
|
20
18
|
test.json
|
21
19
|
|
22
20
|
# rcov generated
|
@@ -68,4 +66,3 @@ pkg
|
|
68
66
|
|
69
67
|
# For rubinius:
|
70
68
|
#*.rbc
|
71
|
-
>>>>>>> aff742cafef9b36d744548c85b04fe81943b7a2e
|
data/Gemfile
CHANGED
@@ -1,14 +1,13 @@
|
|
1
|
-
<<<<<<< HEAD
|
2
1
|
source 'https://rubygems.org'
|
3
2
|
|
4
3
|
# Specify your gem's dependencies in rubySC.gemspec
|
5
4
|
gemspec
|
6
|
-
|
5
|
+
|
7
6
|
source "http://rubygems.org"
|
8
7
|
# Add dependencies required to use your gem here.
|
9
8
|
# Example:
|
10
9
|
# gem "activesupport", ">= 2.3.5"
|
11
|
-
|
10
|
+
gem "colorize"
|
12
11
|
# Add dependencies to develop your gem here.
|
13
12
|
# Include everything needed to run rake, tests, features, etc.
|
14
13
|
group :development do
|
@@ -18,5 +17,3 @@ group :development do
|
|
18
17
|
gem "jeweler", "~> 2.0.0"
|
19
18
|
gem "simplecov", ">= 0"
|
20
19
|
end
|
21
|
-
|
22
|
-
>>>>>>> aff742cafef9b36d744548c85b04fe81943b7a2e
|
data/Rakefile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0
|
data/lib/rubySC.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
|
3
|
-
# -*- coding: utf-8 -*-
|
4
|
-
|
5
3
|
require_relative "rubySC/voix.rb"
|
6
4
|
require_relative "rubySC/musique.rb"
|
5
|
+
require_relative "rubySC/melodie.rb"
|
6
|
+
require_relative "rubySC/contrepoint.rb"
|
7
7
|
|
8
8
|
require 'active_support'
|
9
9
|
require 'singleton'
|
@@ -21,8 +21,8 @@ include ObjectSpace
|
|
21
21
|
class SC
|
22
22
|
|
23
23
|
|
24
|
-
cattr_reader :listeVoix, :
|
25
|
-
cattr_accessor :server
|
24
|
+
cattr_reader :listeVoix, :valeurReceptrice
|
25
|
+
cattr_accessor :server, :portSuperCollider
|
26
26
|
|
27
27
|
include Singleton
|
28
28
|
|
@@ -40,32 +40,29 @@ class SC
|
|
40
40
|
exit
|
41
41
|
end
|
42
42
|
end
|
43
|
-
|
44
|
-
@@server= OSC::EMServer.new 3333
|
45
43
|
|
44
|
+
@@server= OSC::EMServer.new 3333
|
46
45
|
|
47
46
|
@@server.add_method "/coucou" do |message|
|
48
47
|
p "demande de valeur"
|
49
48
|
@@valeurReceptrice=message.to_a
|
50
49
|
end
|
51
|
-
|
50
|
+
|
52
51
|
@@server.add_method "/portSC" do |message|
|
53
52
|
@@portSuperCollider=message.to_a[0]
|
54
53
|
end
|
55
|
-
|
56
|
-
unless
|
54
|
+
|
55
|
+
unless `ps -ef | grep "sclang" | grep -v "grep" | wc -l`.chomp.to_i > 0
|
56
|
+
then
|
57
57
|
system "sclang #{File.join(File.dirname(__FILE__), "init.sc")} &"
|
58
|
-
|
58
|
+
end
|
59
59
|
|
60
60
|
Thread.new do @@server.run end
|
61
61
|
sleep 1.5
|
62
62
|
## récupèrer l'adresse du port
|
63
|
-
|
64
63
|
@@postMan= OSC::Client.new "localhost", @@portSuperCollider
|
65
|
-
|
66
|
-
# variables et méthodes de fin
|
67
64
|
|
68
|
-
|
65
|
+
# variables et méthodes de fin
|
69
66
|
@@listeVoix=Hash.new
|
70
67
|
define_finalizer(self, Proc.new {self.quit})
|
71
68
|
|
@@ -82,25 +79,19 @@ class SC
|
|
82
79
|
# ajustages directs. À ne pas utiliser normalement.
|
83
80
|
|
84
81
|
def self.send message
|
85
|
-
|
86
82
|
@@postMan.send OSC::Message.new "/SC", message.to_s
|
87
83
|
end
|
88
84
|
|
89
85
|
def self.ask valeurRequise, tpsAttente=0.5
|
90
|
-
|
91
86
|
Thread.new do @@server.run end
|
92
87
|
self.send %Q[m.sendMsg("/coucou", #{valeurRequise.delete("\"")})]
|
93
88
|
sleep tpsAttente
|
94
89
|
return @@valeurReceptrice
|
95
|
-
|
96
90
|
end
|
97
91
|
|
98
|
-
|
99
|
-
|
100
92
|
## fonction semi-privée
|
101
93
|
|
102
|
-
|
103
|
-
def self.updater voix, arg, value
|
94
|
+
def self.set voix, arg, value
|
104
95
|
case arg
|
105
96
|
when "dur"
|
106
97
|
self.send "Pbindef (\\#{voix}, \\#{arg}, Pseq(#{value}.convertRhythm, inf))"
|
@@ -111,7 +102,7 @@ class SC
|
|
111
102
|
when "instrument"
|
112
103
|
self.send "Pbindef(\\#{voix}, \\#{arg}, \\#{value})"
|
113
104
|
else
|
114
|
-
self.send "Pbindef(\\#{voix}, \\#{arg}, #{value.to_s})"
|
105
|
+
#self.send "Pbindef(\\#{voix}, \\#{arg}, #{value.to_s})"
|
115
106
|
end
|
116
107
|
end
|
117
108
|
|
@@ -119,65 +110,39 @@ class SC
|
|
119
110
|
def self.updateScore
|
120
111
|
@@listeVoix.each do |key, value|
|
121
112
|
value.instance_variables.each do |variable|
|
122
|
-
self.
|
113
|
+
self.set key, variable[1..-1], value.instance_variable_get(variable) unless value.instance_variable_get(variable).nil?
|
123
114
|
end
|
124
115
|
end
|
125
116
|
end
|
126
117
|
|
127
|
-
# fonctions principales
|
128
|
-
|
118
|
+
# fonctions principales
|
119
|
+
|
129
120
|
public
|
130
|
-
|
131
|
-
def self.set demarreBool=true, options=nil, *voix
|
132
121
|
|
133
|
-
|
134
|
-
begin
|
135
|
-
raise ArgumentError
|
136
|
-
rescue
|
137
|
-
puts "vous devez donner un nom à votre (vos) voix"
|
138
|
-
end
|
139
|
-
end
|
122
|
+
def self.play *args
|
140
123
|
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
rescue
|
155
|
-
puts " vous ne pouvez appeler une voix \"all\", renommez-la'"
|
156
|
-
end
|
157
|
-
elsif @@listeVoix[voix.to_s].nil? then
|
158
|
-
@@listeVoix[voix.to_s]=Voix.new options
|
124
|
+
SC.updateScore
|
125
|
+
|
126
|
+
args.each do |arg|
|
127
|
+
if arg.is_a? Voix
|
128
|
+
@@listeVoix[arg.name]=arg
|
129
|
+
self.updateScore
|
130
|
+
self.send "Pdef(\\#{arg.name}).play"
|
131
|
+
else
|
132
|
+
if arg==nil then
|
133
|
+
tmpargs=@@listeVoix.keys
|
134
|
+
tmpargs.each do |voix|
|
135
|
+
self.send "Pdef(\\#{voix.to_s}).play"
|
136
|
+
end
|
159
137
|
else
|
160
|
-
|
138
|
+
self.send "Pdef(\\#{arg.to_s}).play"
|
161
139
|
end
|
162
|
-
|
163
|
-
|
164
|
-
if demarreBool then
|
165
|
-
self.play voix.to_s end
|
140
|
+
end
|
166
141
|
end
|
167
142
|
end
|
168
|
-
|
169
143
|
|
170
|
-
def self.play *args
|
171
|
-
if args[0]==:all then
|
172
|
-
args=@@listeVoix.keys
|
173
|
-
end
|
174
|
-
args.each do |voix|
|
175
|
-
self.send "Pdef(\\#{voix.to_s}).play"
|
176
|
-
end
|
177
|
-
end
|
178
|
-
|
179
144
|
def self.stop *args
|
180
|
-
if args[0]
|
145
|
+
if args[0]==nil then
|
181
146
|
args=@@listeVoix.keys
|
182
147
|
end
|
183
148
|
args.each do |voix|
|
@@ -185,7 +150,6 @@ class SC
|
|
185
150
|
end
|
186
151
|
end
|
187
152
|
|
188
|
-
|
189
153
|
def self.remove *args
|
190
154
|
if args[0]==:all then
|
191
155
|
args=@@listeVoix.keys
|
@@ -195,5 +159,7 @@ class SC
|
|
195
159
|
@@listeVoix.delete voix
|
196
160
|
end
|
197
161
|
end
|
198
|
-
|
162
|
+
|
199
163
|
end
|
164
|
+
|
165
|
+
SC.demarrer
|
data/lib/rubySC/bip.wav
ADDED
Binary file
|
@@ -0,0 +1,31 @@
|
|
1
|
+
def bicinium consonances=[-2,2]
|
2
|
+
|
3
|
+
a = Voix.new "cantusFirmus"
|
4
|
+
b = Voix.new "organum"
|
5
|
+
|
6
|
+
a.degree=creerMelodie
|
7
|
+
a.play ; b.play
|
8
|
+
|
9
|
+
l= lambda { |x, y|
|
10
|
+
tmp=harmoniser x.degree, consonances
|
11
|
+
y.set ({ :degree=> tmp })
|
12
|
+
}
|
13
|
+
|
14
|
+
Thread.new do
|
15
|
+
20.times do
|
16
|
+
l.call a, b
|
17
|
+
sleep 2
|
18
|
+
l.call b, a
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
def organum voix
|
26
|
+
|
27
|
+
a= Voix.new "harmonisationDe"+voix.name
|
28
|
+
|
29
|
+
a.degree= harmoniser voix.degree, [2]
|
30
|
+
|
31
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
def creerMelodie nbNote=rand(4..12)
|
2
|
+
|
3
|
+
Array.new (nbNote) do |note|
|
4
|
+
note=[0,0,1,2,3,3,4,4,5,6].sample
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
#analyse rythmique basique
|
9
|
+
# si intervalle grand => pt d'appui
|
10
|
+
# si note conjointes et/ou similaire => plus rapide
|
11
|
+
#pour l'instant, pas de note d'approche
|
12
|
+
|
13
|
+
def intervallesMel melodie
|
14
|
+
|
15
|
+
tmp=melodie.each_with_index.map{ |a, i|
|
16
|
+
if melodie[i+1]
|
17
|
+
then melodie[i+1]-a
|
18
|
+
end
|
19
|
+
}
|
20
|
+
tmp[0..-2]
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
def creerRythme melodie #analyse
|
25
|
+
|
26
|
+
rythme = intervallesMel melodie
|
27
|
+
rythme.map { |inter|
|
28
|
+
if inter.abs>1
|
29
|
+
note= 2
|
30
|
+
else
|
31
|
+
note=1
|
32
|
+
end
|
33
|
+
}
|
34
|
+
rythme << 3
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
def harmoniser melodie, consonnances
|
39
|
+
|
40
|
+
harmonisation= melodie.map do |note|
|
41
|
+
note+=consonnances.sample
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
data/lib/rubySC/musique.rb
CHANGED
@@ -1,30 +1,52 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
|
3
3
|
require 'json'
|
4
|
+
require 'yaml'
|
4
5
|
|
5
6
|
## fonctions de plus haut niveau
|
7
|
+
module RubySC_CONST
|
6
8
|
|
9
|
+
## Quelques constantes, notamment pour les rythmes, c'est toujours
|
10
|
+
## plus pratique
|
7
11
|
|
8
|
-
##
|
12
|
+
## Je n'ai mis que les rythmes qui me semblaient
|
13
|
+
## les plus connus
|
9
14
|
|
10
15
|
|
16
|
+
## Rythmes à 3 notes
|
11
17
|
|
12
|
-
|
13
|
-
|
14
|
-
|
18
|
+
Pavanne=[2,1,1]
|
19
|
+
Syncopette=[1,2,1]
|
20
|
+
|
21
|
+
Sicilienne=[3,1,2]
|
22
|
+
Chabada=[3,2,1]
|
23
|
+
|
24
|
+
Tresillo=[3,3,2]
|
25
|
+
|
26
|
+
#########
|
27
|
+
|
28
|
+
# Pour les accords
|
29
|
+
|
30
|
+
AccordMaj=[[0,4,7]]
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
module SoundFile
|
35
|
+
|
36
|
+
def self.charger fileName, departBool=true, tpsDattente=0.05
|
15
37
|
SC.send %Q{b=Buffer.read(s,'#{fileName}')}
|
16
38
|
if departBool
|
17
39
|
sleep tpsDattente
|
18
40
|
self.play
|
19
41
|
end
|
20
42
|
end
|
21
|
-
|
43
|
+
|
22
44
|
def self.play
|
23
45
|
SC.send "b.play"
|
24
46
|
end
|
25
47
|
|
26
48
|
def self.pause
|
27
|
-
|
49
|
+
SC.send "b.pause"
|
28
50
|
end
|
29
51
|
end
|
30
52
|
|
@@ -37,8 +59,8 @@ module Partition
|
|
37
59
|
## ----- voix
|
38
60
|
## ----- paramDeVoix
|
39
61
|
|
40
|
-
def self.
|
41
|
-
|
62
|
+
def self.importerJSON nomFichierJSON, jouerBool=false
|
63
|
+
|
42
64
|
data = JSON.load File.open(nomFichierJSON)
|
43
65
|
data.each do |k, v|
|
44
66
|
SC.set jouerBool, v, k
|
@@ -46,6 +68,16 @@ module Partition
|
|
46
68
|
|
47
69
|
end
|
48
70
|
|
71
|
+
|
72
|
+
def self.importerYAML nomFichierYAML, jouerBool=false
|
73
|
+
|
74
|
+
data = YAML.load File.open(nomFichierJSON)
|
75
|
+
data.each do |k, v|
|
76
|
+
SC.set jouerBool, v, k
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
|
49
81
|
def self.echelle echelle
|
50
82
|
SC.listeVoix.each_key do |voix|
|
51
83
|
SC.set true, ({"scale" => echelle}), voix
|
@@ -53,7 +85,6 @@ module Partition
|
|
53
85
|
SC.updateScore
|
54
86
|
end
|
55
87
|
|
56
|
-
|
57
88
|
def self.transpose intervalle
|
58
89
|
SC.listeVoix.each_key do |voix|
|
59
90
|
SC.set true, ({"root" => intervalle}), voix
|
@@ -66,88 +97,78 @@ end
|
|
66
97
|
## module pour gérer des marches.
|
67
98
|
|
68
99
|
module Marche
|
69
|
-
|
70
|
-
def self.
|
71
|
-
|
72
|
-
nbFois=SC.listeVoix[voix].degree.length
|
73
|
-
|
74
|
-
|
100
|
+
|
101
|
+
def self.marcheChromatique intervalles, voix
|
102
|
+
|
103
|
+
nbFois=SC.listeVoix[voix.name].degree.length
|
104
|
+
voix.setRoot ({"root" => "Pstutter(#{nbFois}, Pseq(#{intervalles}, inf))"})
|
105
|
+
SC.updateScore
|
106
|
+
|
75
107
|
end
|
76
108
|
|
77
|
-
def self.
|
109
|
+
def self.marcheDiatonique voix, intervalle
|
78
110
|
|
79
111
|
melodie=SC.listeVoix[voix].degree
|
80
112
|
|
81
113
|
tmp= Array.new(intervalle.size) do |x|
|
82
|
-
|
114
|
+
t=melodie.map { |note|
|
115
|
+
if note.is_a? Array then
|
116
|
+
note.map do |y| y+intervalle[x] end
|
117
|
+
else
|
118
|
+
note+intervalle[x]*x
|
119
|
+
end }
|
120
|
+
"Pseq(#{t})"
|
83
121
|
end
|
84
|
-
|
85
|
-
|
86
|
-
p tmp
|
122
|
+
|
87
123
|
SC.updater voix, "degree", "[#{tmp.join(',')}]"
|
88
|
-
SC.listeVoix.information="en marche ! ..."
|
89
|
-
|
124
|
+
SC.listeVoix[voix].information="en marche ! ..."
|
125
|
+
|
90
126
|
end
|
91
127
|
end
|
92
128
|
|
93
|
-
|
94
|
-
|
95
|
-
def self.determineEchelle voix
|
96
|
-
|
97
|
-
## fonction lente à cause d'un comportement étrange de Super Collider pour donner les valeurs de Scale..
|
98
|
-
|
99
|
-
echelleVoix="Scale."+SC.listeVoix[voix].scale
|
100
|
-
longueurEchelle=SC.ask("#{echelleVoix+".semitones.size"}")[0]
|
101
|
-
|
102
|
-
valeursEchelles= Array.new(longueurEchelle) do |x|
|
103
|
-
x = SC.ask("#{echelleVoix+".semitones[#{x}]"}")[0]
|
104
|
-
end
|
105
|
-
|
106
|
-
p valeursEchelles
|
107
|
-
|
108
|
-
end
|
109
|
-
|
110
|
-
end
|
129
|
+
module Echelle
|
111
130
|
|
112
|
-
|
131
|
+
def self.determineEchelle voix
|
113
132
|
|
114
|
-
##
|
115
|
-
## plus pratique
|
133
|
+
## fonction lente à cause d'un comportement étrange de Super Collider pour donner les valeurs de Scale..
|
116
134
|
|
117
|
-
|
118
|
-
|
135
|
+
echelleVoix="Scale."+SC.listeVoix[voix].scale
|
136
|
+
longueurEchelle=SC.ask("#{echelleVoix+".semitones.size"}")[0]
|
119
137
|
|
138
|
+
valeursEchelles= Array.new(longueurEchelle) do |x|
|
139
|
+
x = SC.ask("#{echelleVoix+".semitones[#{x}]"}")[0]
|
140
|
+
end
|
120
141
|
|
121
|
-
|
142
|
+
p valeursEchelles
|
122
143
|
|
123
|
-
|
124
|
-
Syncopette=[1,2,1]
|
144
|
+
end
|
125
145
|
|
126
|
-
|
127
|
-
Chabada=[3,2,1]
|
146
|
+
end
|
128
147
|
|
129
|
-
|
148
|
+
module Rythme
|
130
149
|
|
150
|
+
def self.Tempo vitesse
|
151
|
+
SC.send "TempoClock.default.tempo = #{vitesse}"
|
152
|
+
end
|
131
153
|
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
end
|
139
|
-
end
|
140
|
-
|
141
|
-
## s'occupe du deuxième chiffre de la propriété "dur", c-à-d la
|
142
|
-
## gestalt rythmique.
|
143
|
-
|
144
|
-
def self.formule formule, *voix
|
145
|
-
voix.each do |v|
|
146
|
-
tmp = SC.listeVoix[v.to_s].dur
|
147
|
-
tmp[1] = formule
|
148
|
-
SC.set true, ({ "dur" => tmp }), v
|
149
|
-
end
|
154
|
+
## s'occupe du premier chiffre de la propriété "dur", c-à-d la vitesse
|
155
|
+
def self.mesure mesure, *voix
|
156
|
+
voix.each do |v|
|
157
|
+
tmp = SC.listeVoix[v.to_s].dur
|
158
|
+
tmp[0] = mesure
|
159
|
+
SC.set true, ({ "dur" => tmp }), v
|
150
160
|
end
|
161
|
+
end
|
151
162
|
|
163
|
+
## s'occupe du deuxième chiffre de la propriété "dur", c-à-d la
|
164
|
+
## gestalt rythmique.
|
152
165
|
|
166
|
+
def self.formule formule, *voix
|
167
|
+
voix.each do |v|
|
168
|
+
tmp = SC.listeVoix[v.to_s].dur
|
169
|
+
tmp[1] = formule
|
170
|
+
SC.set true, ({ "dur" => tmp }), v
|
171
|
+
end
|
153
172
|
end
|
173
|
+
|
174
|
+
end
|
data/lib/rubySC/version.rb
CHANGED
data/lib/rubySC/voix.rb
CHANGED
@@ -4,40 +4,44 @@
|
|
4
4
|
|
5
5
|
class Voix
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
7
|
+
attr_accessor :information, :dur, :degree, :octave, :marche, :scale, :amp, :instrument, :name
|
8
|
+
|
9
|
+
def initialize nom=nil, options={}
|
10
|
+
|
12
11
|
@information=nil ## cette information sert juste à stocker tout ce
|
13
12
|
## qui pourrait être utile, principalement dans
|
14
13
|
## les Marches et autres transformations de
|
15
14
|
## mélodie. Cette variable ne sert qu'à donner
|
16
15
|
## une indication
|
17
16
|
|
17
|
+
@name=nom
|
18
|
+
if nom.nil?
|
19
|
+
puts "choisis un nom"
|
20
|
+
nomTmp=gets.chomp
|
21
|
+
@name=nomTmp
|
22
|
+
end
|
23
|
+
|
24
|
+
SC.listeVoix[@name]=self
|
18
25
|
|
19
|
-
|
20
26
|
self.setDuree options["dur"]
|
21
|
-
|
27
|
+
|
22
28
|
if options["degree"].nil?
|
23
|
-
then @degree=Array.new(rand(1..
|
29
|
+
then @degree=Array.new(rand(1..5)) do |x| x=rand(12) end
|
24
30
|
else
|
25
31
|
@degree=options["degree"]
|
26
32
|
end
|
27
|
-
|
33
|
+
|
28
34
|
if options["octave"].nil?
|
29
35
|
then @octave=4
|
30
36
|
else
|
31
37
|
@octave=options["octave"]
|
32
38
|
end
|
33
39
|
|
34
|
-
|
35
40
|
if options["scale"].nil?
|
36
41
|
then @scale = "major"
|
37
42
|
else
|
38
43
|
@scale=options["scale"]
|
39
44
|
end
|
40
|
-
|
41
45
|
if options["amp"].nil?
|
42
46
|
then @amp = "Pwhite(0.2,0.8)"
|
43
47
|
else
|
@@ -50,46 +54,48 @@ class Voix
|
|
50
54
|
@instrument=options["instrument"].to_s
|
51
55
|
end
|
52
56
|
|
53
|
-
self.
|
57
|
+
self.setMarche options["marche"]
|
58
|
+
SC.updateScore
|
54
59
|
|
55
60
|
end
|
56
|
-
|
61
|
+
|
57
62
|
def set options
|
58
63
|
options.each do |key, value|
|
59
64
|
if value.is_a? Symbol
|
60
65
|
value=value.to_s
|
61
66
|
end
|
62
|
-
|
63
67
|
case key
|
64
68
|
when "dur"
|
65
69
|
self.setDuree value
|
66
|
-
when "
|
67
|
-
self.
|
70
|
+
when "marche"
|
71
|
+
self.setMarche value
|
68
72
|
else
|
69
73
|
self.instance_variable_set "@#{key}", value
|
70
74
|
end
|
71
75
|
end
|
76
|
+
SC.updateScore
|
72
77
|
end
|
73
|
-
|
74
|
-
def
|
78
|
+
|
79
|
+
def setMarche intervalles
|
75
80
|
if intervalles.nil?
|
76
81
|
@root=0
|
77
82
|
else
|
78
83
|
@root="Pstutter(#{self.degree.size}, Pseq(#{intervalles}, inf))"
|
79
84
|
end
|
80
85
|
end
|
81
|
-
|
82
|
-
def setDuree duree
|
83
|
-
|
86
|
+
|
87
|
+
def setDuree (duree)
|
88
|
+
|
89
|
+
if duree.nil?
|
84
90
|
then @dur=[4, [1]] ## valeur de base, tout en ronde, cantus
|
85
91
|
## firmus style, io!
|
86
92
|
else
|
87
|
-
if duree.is_a? Array
|
93
|
+
if duree.is_a? Array
|
88
94
|
if duree.length == 2 and duree[1].is_a? Array
|
89
95
|
then
|
90
96
|
@dur=duree ## quelqu'un a fait un vrai objet en RTM notation
|
91
97
|
else
|
92
|
-
tmp = true
|
98
|
+
tmp = true
|
93
99
|
duree.each {
|
94
100
|
|x|
|
95
101
|
unless x.is_a? Fixnum
|
@@ -100,7 +106,7 @@ class Voix
|
|
100
106
|
@dur = [4, duree] ## on a juste mis un rythme pour la
|
101
107
|
## durée d'une mesure
|
102
108
|
else
|
103
|
-
begin
|
109
|
+
begin
|
104
110
|
raise ArgumentError
|
105
111
|
rescue "mauvais argument pour la durée"
|
106
112
|
end
|
@@ -109,6 +115,16 @@ class Voix
|
|
109
115
|
end
|
110
116
|
end
|
111
117
|
end
|
112
|
-
|
113
|
-
end
|
114
118
|
|
119
|
+
def stop
|
120
|
+
SC.stop @name
|
121
|
+
@information=nil
|
122
|
+
end
|
123
|
+
|
124
|
+
def play
|
125
|
+
SC.play @name
|
126
|
+
@information="en train de jouer".colorize (:blue)
|
127
|
+
|
128
|
+
end
|
129
|
+
|
130
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubySC
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- simdax
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-11-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -96,15 +96,11 @@ files:
|
|
96
96
|
- README.md
|
97
97
|
- Rakefile
|
98
98
|
- VERSION
|
99
|
-
- examples/score.json
|
100
|
-
- examples/score.json~
|
101
|
-
- examples/testMinimal.rb
|
102
|
-
- examples/testMinimal.rb~
|
103
99
|
- lib/init.sc
|
104
|
-
- lib/lib/circularList.rb
|
105
|
-
- lib/lib/musique.rb
|
106
|
-
- lib/lib/voix.rb
|
107
100
|
- lib/rubySC.rb
|
101
|
+
- lib/rubySC/bip.wav
|
102
|
+
- lib/rubySC/contrepoint.rb
|
103
|
+
- lib/rubySC/melodie.rb
|
108
104
|
- lib/rubySC/musique.rb
|
109
105
|
- lib/rubySC/version.rb
|
110
106
|
- lib/rubySC/voix.rb
|
@@ -131,10 +127,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
131
127
|
version: '0'
|
132
128
|
requirements: []
|
133
129
|
rubyforge_project:
|
134
|
-
rubygems_version: 2.2.
|
130
|
+
rubygems_version: 2.2.2
|
135
131
|
signing_key:
|
136
132
|
specification_version: 4
|
137
133
|
summary: light music live_coding lib
|
138
134
|
test_files:
|
139
135
|
- test/helper.rb
|
140
136
|
- test/test_rubySC.rb
|
137
|
+
has_rdoc:
|
data/examples/score.json
DELETED
data/examples/score.json~
DELETED
data/examples/testMinimal.rb
DELETED
data/examples/testMinimal.rb~
DELETED
data/lib/lib/circularList.rb
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
class CircularList < Array
|
2
|
-
def index
|
3
|
-
@index ||=0
|
4
|
-
@index.abs
|
5
|
-
end
|
6
|
-
def current
|
7
|
-
@index ||= 0
|
8
|
-
get_at(@index)
|
9
|
-
end
|
10
|
-
def next(num=1)
|
11
|
-
@index ||= 0
|
12
|
-
@index += num
|
13
|
-
get_at(@index)
|
14
|
-
end
|
15
|
-
def previous(num=1)
|
16
|
-
@index ||= 0
|
17
|
-
@index -= num
|
18
|
-
get_at(@index)
|
19
|
-
end
|
20
|
-
private
|
21
|
-
def get_at(index)
|
22
|
-
if index >= 0
|
23
|
-
at(index % self.size)
|
24
|
-
else
|
25
|
-
index = self.size + index
|
26
|
-
get_at(index)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
data/lib/lib/musique.rb
DELETED
@@ -1,114 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
|
3
|
-
load 'lib/circularList.rb'
|
4
|
-
require 'json'
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
## fonctions de plus haut niveau
|
9
|
-
|
10
|
-
## Quelques constantes, notamment pour les rythmes, c'est toujours
|
11
|
-
## plus pratique
|
12
|
-
|
13
|
-
## Je n'ai mis que les rythmes qui me semblaient
|
14
|
-
## les plus connus
|
15
|
-
|
16
|
-
|
17
|
-
## Rythmes à 3 notes
|
18
|
-
|
19
|
-
Pavanne=[2,1,1]
|
20
|
-
|
21
|
-
Sicilienne=[3,1,2]
|
22
|
-
Chabada=[3,2,1]
|
23
|
-
|
24
|
-
Tresillo=[3,3,2]
|
25
|
-
Syncopette=[1,2,1]
|
26
|
-
|
27
|
-
## Rythmes à 4 notes
|
28
|
-
|
29
|
-
## module utiliser pour faire des choses au niveau de toutes les voix.
|
30
|
-
|
31
|
-
module Partition
|
32
|
-
|
33
|
-
## importation par JSON la structure attendue est la suivante:
|
34
|
-
## section (une par fichier)
|
35
|
-
## ----- voix
|
36
|
-
## ----- paramDeVoix
|
37
|
-
|
38
|
-
def self.importer nomFichierJSON
|
39
|
-
|
40
|
-
data = JSON.load File.open(nomFichierJSON)
|
41
|
-
data.each do |k, v|
|
42
|
-
SC.set v, k
|
43
|
-
end
|
44
|
-
|
45
|
-
end
|
46
|
-
|
47
|
-
def self.echelle echelle
|
48
|
-
SC.listeVoix.each_key do |voix|
|
49
|
-
SC.set ({:scale => echelle}), voix
|
50
|
-
end
|
51
|
-
SC.updateScore
|
52
|
-
end
|
53
|
-
|
54
|
-
|
55
|
-
def self.transpose intervalle
|
56
|
-
SC.listeVoix.each_key do |voix|
|
57
|
-
SC.set ({:root => intervalle}), voix
|
58
|
-
end
|
59
|
-
self.updateScore
|
60
|
-
end
|
61
|
-
|
62
|
-
end
|
63
|
-
|
64
|
-
## module pour gérer des marches.
|
65
|
-
|
66
|
-
|
67
|
-
module Marche
|
68
|
-
|
69
|
-
def self.diatonique voixOuMelodie, nbFois, intervalle
|
70
|
-
if voixOuMelodie.is_a? String
|
71
|
-
melodie=SC.listeVoix[voixOuMelodie.to_s].degree
|
72
|
-
voix=voixOuMelodie
|
73
|
-
elsif voixOuMelodie.is_a? Array
|
74
|
-
melodie=voixOuMelodie
|
75
|
-
voix=rand(50).to_s ## le super truc porkasse !!
|
76
|
-
else
|
77
|
-
begin
|
78
|
-
raise ArgumentException
|
79
|
-
rescue
|
80
|
-
end
|
81
|
-
end
|
82
|
-
tmp= Array.new(nbFois) do |x|
|
83
|
-
"Pseq(#{melodie.map { |note| note+intervalle*x }})"
|
84
|
-
end
|
85
|
-
tmp.delete("\"")
|
86
|
-
SC.set ({"degree" => "[#{tmp.join ","}]"}), voix
|
87
|
-
end
|
88
|
-
|
89
|
-
end
|
90
|
-
|
91
|
-
module Rythme
|
92
|
-
|
93
|
-
## s'occupe du premier chiffre de la propriété "dur", c-à-d la vitesse
|
94
|
-
def self.mesure mesure, *voix
|
95
|
-
voix.each do |v|
|
96
|
-
tmp = SC.listeVoix[v].dur
|
97
|
-
tmp[0] = mesure
|
98
|
-
SC.set ({ "dur" => tmp }), v
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
## s'occupe du deuxième chiffre de la propriété "dur", c-à-d la
|
103
|
-
## gestalt rythmique.
|
104
|
-
|
105
|
-
def self.formule formule, *voix
|
106
|
-
voix.each do |v|
|
107
|
-
tmp = SC.listeVoix[v].dur
|
108
|
-
tmp[1] = formule
|
109
|
-
SC.set ({ "dur" => tmp }), v
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
|
114
|
-
end
|
data/lib/lib/voix.rb
DELETED
@@ -1,62 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
# sorte de classe privée pour garder en mémoire
|
3
|
-
# ce qui se passe dans les 'voix'...
|
4
|
-
|
5
|
-
class Voix
|
6
|
-
|
7
|
-
attr_reader :dur, :degree, :octave, :root, :scale, :amp, :instrument
|
8
|
-
|
9
|
-
def initialize options={}
|
10
|
-
|
11
|
-
@root=nil
|
12
|
-
|
13
|
-
if options["dur"].nil?
|
14
|
-
then @dur=[1, [1]]
|
15
|
-
else
|
16
|
-
@dur=options["dur"]
|
17
|
-
end
|
18
|
-
|
19
|
-
if options["degree"].nil?
|
20
|
-
then @degree=Array.new(rand(6)) do |x| x=rand(12) end
|
21
|
-
else
|
22
|
-
@degree=options["degree"]
|
23
|
-
end
|
24
|
-
|
25
|
-
if options["octave"].nil?
|
26
|
-
then @octave=4
|
27
|
-
else
|
28
|
-
@octave=options["octave"]
|
29
|
-
end
|
30
|
-
|
31
|
-
|
32
|
-
if options["scale"].nil?
|
33
|
-
then @scale = "major"
|
34
|
-
else
|
35
|
-
@scale=options["scale"]
|
36
|
-
end
|
37
|
-
|
38
|
-
if options["amp"].nil?
|
39
|
-
then @amp = "Pwhite(0.2,0.5)"
|
40
|
-
else
|
41
|
-
@amp=options["amp"]
|
42
|
-
end
|
43
|
-
|
44
|
-
if options["instrument"].nil?
|
45
|
-
then @instrument = "default"
|
46
|
-
else
|
47
|
-
@instrument=options["instrument"].to_s
|
48
|
-
end
|
49
|
-
|
50
|
-
end
|
51
|
-
|
52
|
-
def set options
|
53
|
-
options.each do |key, value|
|
54
|
-
if value.is_a? Symbol
|
55
|
-
self.instance_variable_set "@#{key}", value.to_s
|
56
|
-
else
|
57
|
-
self.instance_variable_set "@#{key}", value
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
end
|