rubySC 0.0.1 → 0.0.2

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 (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rubySC.rb +43 -12
  3. data/lib/voix.rb +9 -8
  4. metadata +11 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 60afeecfcdf89e3419921997db1919b79df4184d
4
- data.tar.gz: 23a60a985aa742e511d5d79439362e7c533ffbef
3
+ metadata.gz: f13350897cecea058d9781ccebc092964541ba50
4
+ data.tar.gz: b25ccc3a0d73a09dc3a9ffd7639ea752352d8fb7
5
5
  SHA512:
6
- metadata.gz: bc238b5f02c08e56136d0934d7b09a11da7828110b176c04b0b0af891a2a96733c5a68173c5f2d9396eeb93f8b0e0af175547581d504a9092915b1ce6620a6e6
7
- data.tar.gz: e88bc0405eff33ab48bc06c6f7a0544271c2317556e32e80b05e8dc707e8775a37ece1479976bfdbc215bdff590d90f244b559894573cb0973e9e0c5e323bf2c
6
+ metadata.gz: 61700ede2bde3a56853603bc710ed003be8f66a96918ba6bb7b81931eaae596086ac25561d3e02a416cfd36c5c835c583762abec9eaed9cde2fd7645a5372bad
7
+ data.tar.gz: acd06b3db224fb209f6075b5390ccceb815172d8305fec65cc0ac6eba3dbf2c36638ad74239a5e2ec92a0dcec35a68c729049f608a1a8341093ef0e6bb6db3b8
@@ -1,35 +1,60 @@
1
1
  #! /usr/bin/ruby
2
+ # -*- coding: utf-8 -*-
2
3
 
3
4
  require 'osc-ruby'
4
5
  require 'singleton'
5
6
  include ObjectSpace
6
- require_relative './voix.rb'
7
+ load "#{File.join(File.dirname(__FILE__), "voix.rb")}"
7
8
 
8
9
 
10
+ ## classe principale, singleton
11
+ #
12
+ # permet de créer des voix, et puis de modifier à la volée chacune
13
+ # d'entre elle. L'intérêt consiste plutôt dans certaines fonctions
14
+ # "d'ordre supérieur" qui permet de modifier plusieurs voix ensemble,
15
+ # et donc de créer de la logique musicale
16
+
9
17
  class Musique
10
18
 
11
19
  include Singleton
12
20
 
13
- attr_accessor :listeVoix
21
+ # ouvre le contact avec SuperCollider
14
22
 
15
23
  def initialize
16
24
  unless p `ps -ef | grep "sclang" | grep -v "grep" | wc -l`.to_i > 0
17
- system "sclang -u 57119 #{File.dirname(__FILE__)}/init.sc &"
25
+ system "sclang -u 57119 #{File.join(File.dirname(__FILE__), "init.sc")} &"
18
26
  end
19
27
  @postMan= OSC::Client.new "localhost", 57119
20
28
  @listeVoix=Hash.new
21
29
  define_finalizer(self, Proc.new {self.quit})
22
30
  end
23
-
31
+
32
+ # fonction permettant de communiquer directement avec SuperCollider,
33
+ # ce qui permet pour qui connaît la syntaxe sclang de faire des
34
+ # ajustages directs
35
+
24
36
  def send message
25
37
  @postMan.send OSC::Message.new "SC", message.to_s
26
38
  end
27
-
28
- def creer voix, options={}
29
- @listeVoix[voix]=Voix.new options
39
+
40
+ # fonction principale
41
+
42
+ def creer voix
43
+ @listeVoix[voix]=Voix.new
30
44
  self.play voix
31
45
  end
32
-
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
+
33
58
  def play voix
34
59
  self.send "Pdef(\\#{voix}).play"
35
60
  end
@@ -38,12 +63,15 @@ class Musique
38
63
  self.send "Pdef(\\#{voix}).stop"
39
64
  end
40
65
 
66
+ ##
67
+
41
68
  def stopAll
42
69
  @listeVoix.each_key do |voix|
43
70
  puts voix
44
71
  self.stop voix
45
72
  end
46
73
  end
74
+
47
75
 
48
76
  def set voix, options
49
77
  # @listeVoix[voix.to_s].instance_variable_set "@#{var.to_s}", value
@@ -66,18 +94,21 @@ class Musique
66
94
 
67
95
  def updater voix, arg, value
68
96
  if voix.is_a? String then
69
- if arg == "dur" then
97
+ case arg
98
+ when "dur"
70
99
  self.send "Pbindef (\\#{voix}, \\#{arg}, Pseq(#{value}.convertRhythm, inf))"
71
- elsif arg == "degree" then
100
+ when "degree"
72
101
  self.send "Pbindef(\\#{voix}, \\#{arg}, Pseq(#{value}, inf))"
102
+ when "scale"
103
+ self.send "Pbindef(\\#{voix}, \\#{arg}, Scale.#{value})"
73
104
  else
74
105
  self.send "Pbindef(\\#{voix}, \\#{arg}, #{value})"
75
106
  end
76
107
  end
77
108
  end
78
-
109
+
79
110
  def quit
80
- `killall sclang scsynth`
111
+ `killall scsynth sclang`
81
112
  end
82
113
 
83
114
  end
@@ -1,22 +1,23 @@
1
+ # -*- coding: utf-8 -*-
2
+ # sorte de classe privée un peu inutile pour garder en mémoire
3
+ # ce qui se passe dans les 'voix'...
4
+
1
5
  class Voix
2
6
 
3
- attr_accessor :scale, :dur, :degree, :amp, :root
4
-
7
+ # pour initialiser directement TODO=marche pas... :'(
5
8
  def initialize options={}
6
-
7
9
  @scale=options[:scale]
8
10
  @dur=options[:dur]
9
11
  @degree=options[:degree]
10
12
  @root=options[:root]
11
13
  @amp=options[:amp]
12
- @instrument=options[:instrument]
13
-
14
+ @instrument=options[:instrument]
14
15
  end
15
16
 
17
+ # permet de set plein d'options à la fois, ce qui est plutôt cool
16
18
  def set options
17
- options.each_key do |key, value|
18
- p "caca"
19
- self.instance_variable_set "@#{key.to_s}", value
19
+ options.each do |key, value|
20
+ self.instance_variable_set "@#{key}", value
20
21
  end
21
22
  end
22
23
 
metadata CHANGED
@@ -1,17 +1,19 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubySC
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
- - moi
7
+ - Simon C.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
  date: 2013-01-05 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description:
14
- email:
13
+ description: petite bibliotheque permettant une communication simple entre SuperCollider/JITlib
14
+ 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.
16
+ email: simoncornaz@gmail.com
15
17
  executables: []
16
18
  extensions: []
17
19
  extra_rdoc_files: []
@@ -20,7 +22,8 @@ files:
20
22
  - lib/rubySC.rb
21
23
  - lib/voix.rb
22
24
  homepage:
23
- licenses: []
25
+ licenses:
26
+ - MIT
24
27
  metadata: {}
25
28
  post_install_message:
26
29
  rdoc_options: []
@@ -41,5 +44,7 @@ rubyforge_project:
41
44
  rubygems_version: 2.2.0
42
45
  signing_key:
43
46
  specification_version: 4
44
- summary: permet une communication avec SC et JITlib
47
+ summary: petite bibliotheque permettant une communication simple entre SuperCollider/JITlib
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.
45
50
  test_files: []