rubySC 0.3.3 → 0.4.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2799b9b8fe0e889dd4df4867c8b948fd491daa5a
4
- data.tar.gz: a04de37eb1d1783eb64ceb88cfff8173ad0fd2a8
3
+ metadata.gz: d5ef2e559ca532f4b888670b6574afaaafdab769
4
+ data.tar.gz: a7a749a1789610edc76d7535cbd7aaa161e3a587
5
5
  SHA512:
6
- metadata.gz: 21ee1dedd3927f897d6e4ed9fdeb53194d7d8baeb2bd00a50f0345f96c088b27fbe0d06f58bdcbb9a12dc33d3bbce80a9a1820e61730e3b61b7d289875281b69
7
- data.tar.gz: e712e9f26ba600bfc80751dd527560067aa2bf606ab89251940dd2f543733d6a1f05cc1cb8f95ab86998af13d1fc0bd5407295199db81a0f742ddc684ad11f09
6
+ metadata.gz: 7deb2c506bb13dde89b7e1c01c509ecac295bd67ffff061fde1e73d56d8d9aee1b2d92e06df5ffc6643e983c4cf3c9fdc3c8cc03fbfe788a28352fe1bf1bda58
7
+ data.tar.gz: cf52c3e1c92199fcc27cd6bde6b367d863bba88bdb7e4c817eb7b9610548b674bee0751aa6b027ebd01ead84bd3909bbc197cebea0b8c21a5dfc50dae33e14f9
@@ -69,7 +69,7 @@ OSCFunc.newMatching(
69
69
  message[1].asString.interpret
70
70
  }, "/SC", n
71
71
  );
72
-
72
+ Scale.major.semitones.asArray
73
73
  ///// Vous pouvez ajouter de nouveaux instruments en mettant du code en-dessous, dans la syntaxe:
74
74
  /// SynthDef ("nomInstr", { argumentsModifiables }
75
75
  /// son = code
@@ -21,7 +21,9 @@ include ObjectSpace
21
21
  class SC
22
22
 
23
23
 
24
- cattr_reader :listeVoix, :portSuperCollider
24
+ cattr_reader :listeVoix, :portSuperCollider, :valeurReceptrice
25
+ cattr_accessor :server
26
+
25
27
  include Singleton
26
28
 
27
29
  # ouvre le contact avec SuperCollider
@@ -40,6 +42,13 @@ class SC
40
42
  end
41
43
 
42
44
  @@server= OSC::EMServer.new 3333
45
+
46
+
47
+ @@server.add_method "/coucou" do |message|
48
+ p "demande de valeur"
49
+ @@valeurReceptrice=message.to_a
50
+ end
51
+
43
52
  @@server.add_method "/portSC" do |message|
44
53
  @@portSuperCollider=message.to_a[0]
45
54
  end
@@ -52,13 +61,6 @@ class SC
52
61
  sleep 1.5
53
62
  ## récupèrer l'adresse du port
54
63
 
55
- if @@portSuperCollider.nil?
56
- begin
57
- raise Error, "espece de porc"
58
- rescue exit
59
- end
60
- end
61
-
62
64
  @@postMan= OSC::Client.new "localhost", @@portSuperCollider
63
65
 
64
66
  # variables et méthodes de fin
@@ -66,7 +68,7 @@ class SC
66
68
 
67
69
  @@listeVoix=Hash.new
68
70
  define_finalizer(self, Proc.new {self.quit})
69
-
71
+
70
72
  end
71
73
 
72
74
 
@@ -84,6 +86,17 @@ class SC
84
86
  @@postMan.send OSC::Message.new "/SC", message.to_s
85
87
  end
86
88
 
89
+ def self.ask valeurRequise, tpsAttente=0.5
90
+
91
+ Thread.new do @@server.run end
92
+ self.send %Q[m.sendMsg("/coucou", #{valeurRequise.delete("\"")})]
93
+ sleep tpsAttente
94
+ return @@valeurReceptrice
95
+
96
+ end
97
+
98
+
99
+
87
100
  ## fonction semi-privée
88
101
 
89
102
 
@@ -115,8 +128,7 @@ class SC
115
128
 
116
129
  public
117
130
 
118
-
119
- def self.set demarreBool, options=nil, *voix
131
+ def self.set demarreBool=true, options=nil, *voix
120
132
 
121
133
  if voix.nil?
122
134
  begin
@@ -14,7 +14,7 @@ module SoundFile
14
14
  def self.charger fileName, departBool=true, tpsDattente=1
15
15
  SC.send %Q{b=Buffer.read(s,'#{fileName}')}
16
16
  if departBool
17
- sleep tpsDattente
17
+ sleep tpsDattente
18
18
  self.play
19
19
  end
20
20
  end
@@ -65,69 +65,89 @@ end
65
65
 
66
66
  ## module pour gérer des marches.
67
67
 
68
-
69
- module Marche
68
+ module Marche
70
69
 
71
- def self.diatonique voixOuMelodie, nbFois, intervalle
72
- if voixOuMelodie.is_a? String
73
- melodie=SC.listeVoix[voixOuMelodie.to_s].degree
74
- voix=voixOuMelodie
75
- elsif voixOuMelodie.is_a? Array
76
- melodie=voixOuMelodie
77
- voix=rand(50).to_s ## le super truc porkasse !!
78
- else
79
- begin
80
- raise ArgumentException
81
- rescue
82
- end
70
+ def self.chromatique intervalles, voix
71
+
72
+ nbFois=SC.listeVoix[voix].degree.length
73
+ SC.set true, ({"root" => "Pstutter(#{nbFois}, Pseq(#{intervalles}, inf))"}), voix
74
+
75
+ end
76
+
77
+ def self.diatonique voix, intervalle
78
+
79
+ melodie=SC.listeVoix[voix].degree
80
+
81
+ tmp= Array.new(intervalle.size) do |x|
82
+ "Pseq(#{melodie.map { |note| note+intervalle[x]*x}})"
83
83
  end
84
- tmp= Array.new(nbFois) do |x|
85
- "Pseq(#{melodie.map { |note| note+intervalle*x }})"
84
+
85
+
86
+ p tmp
87
+ SC.updater voix, "degree", "[#{tmp.join(',')}]"
88
+ SC.listeVoix.information="en marche ! ..."
89
+
90
+ end
91
+ end
92
+
93
+ module Echelle
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
+
86
108
  end
87
- tmp.delete("\"")
88
- SC.set ({"degree" => "[#{tmp.join ","}]"}), voix
109
+
89
110
  end
90
111
 
91
- end
112
+ module Rythme
92
113
 
93
- module Rythme
114
+ ## Quelques constantes, notamment pour les rythmes, c'est toujours
115
+ ## plus pratique
94
116
 
95
- ## Quelques constantes, notamment pour les rythmes, c'est toujours
96
- ## plus pratique
117
+ ## Je n'ai mis que les rythmes qui me semblaient
118
+ ## les plus connus
97
119
 
98
- ## Je n'ai mis que les rythmes qui me semblaient
99
- ## les plus connus
100
120
 
121
+ ## Rythmes à 3 notes
101
122
 
102
- ## Rythmes à 3 notes
123
+ Pavanne=[2,1,1]
124
+ Syncopette=[1,2,1]
103
125
 
104
- Pavanne=[2,1,1]
126
+ Sicilienne=[3,1,2]
127
+ Chabada=[3,2,1]
105
128
 
106
- Sicilienne=[3,1,2]
107
- Chabada=[3,2,1]
129
+ Tresillo=[3,3,2]
108
130
 
109
- Tresillo=[3,3,2]
110
- Syncopette=[1,2,1]
111
131
 
112
- ## s'occupe du premier chiffre de la propriété "dur", c-à-d la vitesse
113
- def self.mesure mesure, *voix
114
- voix.each do |v|
115
- tmp = SC.listeVoix[v.to_s].dur
116
- tmp[0] = mesure
117
- SC.set true, ({ "dur" => tmp }), v
132
+ ## s'occupe du premier chiffre de la propriété "dur", c-à-d la vitesse
133
+ def self.mesure mesure, *voix
134
+ voix.each do |v|
135
+ tmp = SC.listeVoix[v.to_s].dur
136
+ tmp[0] = mesure
137
+ SC.set true, ({ "dur" => tmp }), v
138
+ end
118
139
  end
119
- end
120
-
121
- ## s'occupe du deuxième chiffre de la propriété "dur", c-à-d la
122
- ## gestalt rythmique.
123
-
124
- def self.formule formule, *voix
125
- voix.each do |v|
126
- tmp = SC.listeVoix[v.to_s].dur
127
- tmp[1] = formule
128
- SC.set true, ({ "dur" => tmp }), v
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
129
150
  end
130
- end
131
151
 
132
152
 
133
- end
153
+ end
@@ -1,3 +1,3 @@
1
1
  module RubySC
2
- VERSION = "0.3.3"
2
+ VERSION = "0.4.0"
3
3
  end
@@ -5,11 +5,18 @@
5
5
  class Voix
6
6
 
7
7
  attr_reader :dur, :degree, :octave, :root, :scale, :amp, :instrument
8
+ attr_accessor :information
8
9
 
9
10
  def initialize options={}
10
11
 
11
- @root=nil
12
-
12
+ @information=nil ## cette information sert juste à stocker tout ce
13
+ ## qui pourrait être utile, principalement dans
14
+ ## les Marches et autres transformations de
15
+ ## mélodie. Cette variable ne sert qu'à donner
16
+ ## une indication
17
+
18
+
19
+
13
20
  self.setDuree options["dur"]
14
21
 
15
22
  if options["degree"].nil?
@@ -32,7 +39,7 @@ class Voix
32
39
  end
33
40
 
34
41
  if options["amp"].nil?
35
- then @amp = "Pwhite(0.2,0.5)"
42
+ then @amp = "Pwhite(0.2,0.8)"
36
43
  else
37
44
  @amp=options["amp"]
38
45
  end
@@ -43,6 +50,8 @@ class Voix
43
50
  @instrument=options["instrument"].to_s
44
51
  end
45
52
 
53
+ self.setRoot options["root"]
54
+
46
55
  end
47
56
 
48
57
  def set options
@@ -54,23 +63,31 @@ class Voix
54
63
  case key
55
64
  when "dur"
56
65
  self.setDuree value
66
+ when "root"
67
+ self.setRoot value
57
68
  else
58
69
  self.instance_variable_set "@#{key}", value
59
70
  end
60
71
  end
61
72
  end
62
73
 
74
+ def setRoot intervalles
75
+ if intervalles.nil?
76
+ @root=0
77
+ else
78
+ @root="Pstutter(#{self.degree.size}, Pseq(#{intervalles}, inf))"
79
+ end
80
+ end
63
81
 
64
82
  def setDuree duree
65
83
  if duree.nil?
66
84
  then @dur=[4, [1]] ## valeur de base, tout en ronde, cantus
67
- ## firmus style, io!
85
+ ## firmus style, io!
68
86
  else
69
87
  if duree.is_a? Array
70
88
  if duree.length == 2 and duree[1].is_a? Array
71
89
  then
72
- @dur=duree ## quelqu'un a fait un vrai objet en RTM
73
- ## notation
90
+ @dur=duree ## quelqu'un a fait un vrai objet en RTM notation
74
91
  else
75
92
  tmp = true
76
93
  duree.each {
@@ -81,7 +98,7 @@ class Voix
81
98
  }
82
99
  if tmp then
83
100
  @dur = [4, duree] ## on a juste mis un rythme pour la
84
- ## durée d'une mesure
101
+ ## durée d'une mesure
85
102
  else
86
103
  begin
87
104
  raise ArgumentError
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.3.3
4
+ version: 0.4.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-02-02 00:00:00.000000000 Z
11
+ date: 2014-02-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler