rubySC 0.3.2 → 0.3.3
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 +4 -4
- data/.document +5 -0
- data/.gitignore +54 -0
- data/Gemfile +18 -0
- data/LICENSE.txt +3 -0
- data/README.md +71 -0
- data/Rakefile +55 -0
- data/VERSION +1 -0
- data/examples/testMinimal.rb +5 -2
- data/lib/init.sc +3 -2
- data/lib/lib/circularList.rb +29 -0
- data/lib/lib/musique.rb +114 -0
- data/lib/lib/voix.rb +62 -0
- data/lib/rubySC.rb +15 -5
- data/lib/rubySC/musique.rb +44 -22
- data/lib/rubySC/version.rb +1 -1
- data/rubySC.gemspec +3 -1
- data/test/helper.rb +18 -0
- data/test/test_rubySC.rb +7 -0
- metadata +13 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2799b9b8fe0e889dd4df4867c8b948fd491daa5a
|
4
|
+
data.tar.gz: a04de37eb1d1783eb64ceb88cfff8173ad0fd2a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 21ee1dedd3927f897d6e4ed9fdeb53194d7d8baeb2bd00a50f0345f96c088b27fbe0d06f58bdcbb9a12dc33d3bbce80a9a1820e61730e3b61b7d289875281b69
|
7
|
+
data.tar.gz: e712e9f26ba600bfc80751dd527560067aa2bf606ab89251940dd2f543733d6a1f05cc1cb8f95ab86998af13d1fc0bd5407295199db81a0f742ddc684ad11f09
|
data/.document
ADDED
data/.gitignore
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
<<<<<<< HEAD
|
1
2
|
*.gem
|
2
3
|
*.rbc
|
3
4
|
.bundle
|
@@ -15,3 +16,56 @@ spec/reports
|
|
15
16
|
test/tmp
|
16
17
|
test/version_tmp
|
17
18
|
tmp
|
19
|
+
=======
|
20
|
+
test.json
|
21
|
+
|
22
|
+
# rcov generated
|
23
|
+
coverage
|
24
|
+
coverage.data
|
25
|
+
|
26
|
+
# rdoc generated
|
27
|
+
rdoc
|
28
|
+
|
29
|
+
# yard generated
|
30
|
+
doc
|
31
|
+
.yardoc
|
32
|
+
|
33
|
+
# bundler
|
34
|
+
.bundle
|
35
|
+
|
36
|
+
# jeweler generated
|
37
|
+
pkg
|
38
|
+
|
39
|
+
# Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
|
40
|
+
#
|
41
|
+
# * Create a file at ~/.gitignore
|
42
|
+
# * Include files you want ignored
|
43
|
+
# * Run: git config --global core.excludesfile ~/.gitignore
|
44
|
+
#
|
45
|
+
# After doing this, these files will be ignored in all your git projects,
|
46
|
+
# saving you from having to 'pollute' every project you touch with them
|
47
|
+
#
|
48
|
+
# Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line)
|
49
|
+
#
|
50
|
+
# For MacOS:
|
51
|
+
#
|
52
|
+
#.DS_Store
|
53
|
+
|
54
|
+
# For TextMate
|
55
|
+
#*.tmproj
|
56
|
+
#tmtags
|
57
|
+
|
58
|
+
# For emacs:
|
59
|
+
#*~
|
60
|
+
#\#*
|
61
|
+
#.\#*
|
62
|
+
|
63
|
+
# For vim:
|
64
|
+
#*.swp
|
65
|
+
|
66
|
+
# For redcar:
|
67
|
+
#.redcar
|
68
|
+
|
69
|
+
# For rubinius:
|
70
|
+
#*.rbc
|
71
|
+
>>>>>>> aff742cafef9b36d744548c85b04fe81943b7a2e
|
data/Gemfile
CHANGED
@@ -1,4 +1,22 @@
|
|
1
|
+
<<<<<<< HEAD
|
1
2
|
source 'https://rubygems.org'
|
2
3
|
|
3
4
|
# Specify your gem's dependencies in rubySC.gemspec
|
4
5
|
gemspec
|
6
|
+
=======
|
7
|
+
source "http://rubygems.org"
|
8
|
+
# Add dependencies required to use your gem here.
|
9
|
+
# Example:
|
10
|
+
# gem "activesupport", ">= 2.3.5"
|
11
|
+
|
12
|
+
# Add dependencies to develop your gem here.
|
13
|
+
# Include everything needed to run rake, tests, features, etc.
|
14
|
+
group :development do
|
15
|
+
gem "shoulda", ">= 0"
|
16
|
+
gem "rdoc", "~> 3.12"
|
17
|
+
gem "bundler", "~> 1.0"
|
18
|
+
gem "jeweler", "~> 2.0.0"
|
19
|
+
gem "simplecov", ">= 0"
|
20
|
+
end
|
21
|
+
|
22
|
+
>>>>>>> aff742cafef9b36d744548c85b04fe81943b7a2e
|
data/LICENSE.txt
CHANGED
@@ -1,7 +1,10 @@
|
|
1
1
|
Copyright (c) 2014 simdax
|
2
2
|
|
3
|
+
<<<<<<< HEAD
|
3
4
|
MIT License
|
4
5
|
|
6
|
+
=======
|
7
|
+
>>>>>>> aff742cafef9b36d744548c85b04fe81943b7a2e
|
5
8
|
Permission is hereby granted, free of charge, to any person obtaining
|
6
9
|
a copy of this software and associated documentation files (the
|
7
10
|
"Software"), to deal in the Software without restriction, including
|
data/README.md
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
<<<<<<< HEAD
|
1
2
|
# RubySC
|
2
3
|
|
3
4
|
TODO: Write a gem description
|
@@ -27,3 +28,73 @@ TODO: Write usage instructions here
|
|
27
28
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
29
|
4. Push to the branch (`git push origin my-new-feature`)
|
29
30
|
5. Create new Pull Request
|
31
|
+
=======
|
32
|
+
# rubySC
|
33
|
+
|
34
|
+
rubySC est une petite biliothèque qui complète à sa manière
|
35
|
+
[SCruby](https://github.com/maca/scruby) en offrant une interface avec
|
36
|
+
la bibliothèque JTLib de SuperCollider, cette dernière étant tournée
|
37
|
+
vers le live coding, et le scriptage de partition plus que la
|
38
|
+
recherche acoustique _per se_.
|
39
|
+
|
40
|
+
## Installation
|
41
|
+
|
42
|
+
vous devez avoir installé supercollider. Pour l'instant, je n'ai testé
|
43
|
+
le programme que sur linux, et l'appel au programme est fait par une
|
44
|
+
bonne grosse commande 'system'
|
45
|
+
|
46
|
+
## Utilisation
|
47
|
+
|
48
|
+
* Un objet "SC" s'occupe de l'interface OSC avec superCollider.
|
49
|
+
|
50
|
+
`SC.demarrer`
|
51
|
+
|
52
|
+
* On ajoute des "voix", c'est-à-dire un mélange de 7 paramètres
|
53
|
+
|
54
|
+
* instrument : regardez les noms des synthdef dans "init.sc" (ils proviennent tous de recherches sur [SCcode](http://sccode.org/))
|
55
|
+
* dur : les rythmes de votre mélodie
|
56
|
+
* degree : les notes de votre mélodie
|
57
|
+
* amp : le volume de la mélodie
|
58
|
+
* octave : le registre dans lequel se situe votre voix
|
59
|
+
* root : le micro-registre, utilisé pour faire des marches par exemple
|
60
|
+
* scale : l'echelle utilisé pour votre mélodie
|
61
|
+
|
62
|
+
`SC.set paramètre(hash), :nomVoix (ou "nomVoix")`
|
63
|
+
plus précisément, avec "au clair de la lune" :
|
64
|
+
|
65
|
+
` SC.set ({ :degree => [0,0,0,1,2,1,0,2,1,1,0], :dur => [1, [1, 1, 1 , 1 ,2 ,2 ,1 ,1 ,1 ,1 ,4]]}) , :superius
|
66
|
+
SC.set ({ :degree => [[0, 2, 4], [0,3,5], [0,2,4], [1,3,4], [0,2,4], [1,3,4], [0,2,4]], :dur => [1, [2,2,2,2,2,2,4]])}, :basse`
|
67
|
+
|
68
|
+
On peut ensuite modifier ces voix
|
69
|
+
|
70
|
+
`SC.set ({ :amp => 0.2, :instrument => :wobble, :
|
71
|
+
|
72
|
+
* arrêter ou reprenez vos voix :
|
73
|
+
|
74
|
+
` mu.stop :voixUn, :voixDeux ## arrête deux voix
|
75
|
+
mu.play :voixUn ## reprend voixUn
|
76
|
+
mu.remove :all ## arrête tout et supprime les voix `
|
77
|
+
|
78
|
+
Les voix sont stockées dans 'listeVoix'
|
79
|
+
|
80
|
+
SC.listeVoix.inspect
|
81
|
+
|
82
|
+
* Deux modules stockent des fonctions plus intéressantes.
|
83
|
+
|
84
|
+
1. Partition, gère tout ce qui est transposition de masse
|
85
|
+
1. Marche, permet de transposer la mélodie d'une voix
|
86
|
+
`Marche.diatonique :nomVoix, intervalleDeMarche, nbRepetitions`
|
87
|
+
`Marche.diatonique :superius, 2, 2 ## deux marches par tierce ascendante`
|
88
|
+
|
89
|
+
* Vous pouvez essayer de rajouter des instruments dans "init.sc", ou
|
90
|
+
bien en apprenant SuperCollider, ou bien en cherchant par vous-mêmes
|
91
|
+
des plugins sur le net.
|
92
|
+
|
93
|
+
==
|
94
|
+
|
95
|
+
|
96
|
+
Copiez-le comme des gros gorets, qu'un truc un peu simple un jour
|
97
|
+
surgisse de ce monde de fous de MAOistes qui veulent détruire le monde
|
98
|
+
à force de complexitudinités...
|
99
|
+
|
100
|
+
>>>>>>> aff742cafef9b36d744548c85b04fe81943b7a2e
|
data/Rakefile
CHANGED
@@ -1 +1,56 @@
|
|
1
|
+
<<<<<<< HEAD
|
1
2
|
require "bundler/gem_tasks"
|
3
|
+
=======
|
4
|
+
# encoding: utf-8
|
5
|
+
|
6
|
+
require 'rubygems'
|
7
|
+
require 'bundler'
|
8
|
+
begin
|
9
|
+
Bundler.setup(:default, :development)
|
10
|
+
rescue Bundler::BundlerError => e
|
11
|
+
$stderr.puts e.message
|
12
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
13
|
+
exit e.status_code
|
14
|
+
end
|
15
|
+
require 'rake'
|
16
|
+
|
17
|
+
require 'jeweler'
|
18
|
+
Jeweler::Tasks.new do |gem|
|
19
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
20
|
+
gem.name = "rubySC"
|
21
|
+
gem.homepage = "http://github.com/simdax/rubySC"
|
22
|
+
gem.license = "MIT"
|
23
|
+
gem.summary = %Q{simple and light music livecoding library}
|
24
|
+
gem.description = %Q{Petite bibliotheque permettant une communication simple entre SuperCollider/JITlib et Ruby. Se concentre avant tout sur les capacités logiques de création de mélodies plus que sur la génération de son. Nécessite d'installer supercollider sur l'ordinateur (=> sudo aptitude install supercollider sur debian par exemple)"}
|
25
|
+
gem.email = "simoncornaz@gmail.com"
|
26
|
+
gem.authors = ["simdax"]
|
27
|
+
|
28
|
+
# dependencies defined in Gemfile
|
29
|
+
gem.add_dependency 'osc-ruby', '>=0'
|
30
|
+
gem.add_dependency 'active_support', '>=0'
|
31
|
+
gem.files = Dir.glob('lib/*')
|
32
|
+
|
33
|
+
end
|
34
|
+
Jeweler::RubygemsDotOrgTasks.new
|
35
|
+
|
36
|
+
require 'rake/testtask'
|
37
|
+
Rake::TestTask.new(:test) do |test|
|
38
|
+
test.libs << 'lib' << 'test'
|
39
|
+
test.pattern = 'test/**/test_*.rb'
|
40
|
+
test.verbose = true
|
41
|
+
end
|
42
|
+
|
43
|
+
|
44
|
+
task :default => :test
|
45
|
+
|
46
|
+
require 'rdoc/task'
|
47
|
+
Rake::RDocTask.new do |rdoc|
|
48
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
49
|
+
|
50
|
+
rdoc.rdoc_dir = 'rdoc'
|
51
|
+
rdoc.title = "rubySC #{version}"
|
52
|
+
rdoc.rdoc_files.include('README*')
|
53
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
54
|
+
end
|
55
|
+
|
56
|
+
>>>>>>> aff742cafef9b36d744548c85b04fe81943b7a2e
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.2.0
|
data/examples/testMinimal.rb
CHANGED
data/lib/init.sc
CHANGED
@@ -56,6 +56,7 @@ snd = Pluck.ar(
|
|
56
56
|
Out.ar(0, [snd, snd]);
|
57
57
|
}).add;
|
58
58
|
|
59
|
+
|
59
60
|
///////// Lignes de fin pour mettre le bouzin en route
|
60
61
|
|
61
62
|
s.boot;
|
@@ -67,10 +68,10 @@ OSCFunc.newMatching(
|
|
67
68
|
{ |message, time, addr, responder|
|
68
69
|
message[1].asString.interpret
|
69
70
|
}, "/SC", n
|
70
|
-
)
|
71
|
+
);
|
71
72
|
|
72
73
|
///// Vous pouvez ajouter de nouveaux instruments en mettant du code en-dessous, dans la syntaxe:
|
73
74
|
/// SynthDef ("nomInstr", { argumentsModifiables }
|
74
75
|
/// son = code
|
75
76
|
/// Out.ar(son)
|
76
|
-
/// })
|
77
|
+
/// })
|
@@ -0,0 +1,29 @@
|
|
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
ADDED
@@ -0,0 +1,114 @@
|
|
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
ADDED
@@ -0,0 +1,62 @@
|
|
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
|
data/lib/rubySC.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
|
3
|
+
# -*- coding: utf-8 -*-
|
4
|
+
|
3
5
|
require_relative "rubySC/voix.rb"
|
4
6
|
require_relative "rubySC/musique.rb"
|
5
7
|
|
@@ -18,7 +20,8 @@ include ObjectSpace
|
|
18
20
|
|
19
21
|
class SC
|
20
22
|
|
21
|
-
|
23
|
+
|
24
|
+
cattr_reader :listeVoix, :portSuperCollider
|
22
25
|
include Singleton
|
23
26
|
|
24
27
|
# ouvre le contact avec SuperCollider
|
@@ -27,9 +30,10 @@ class SC
|
|
27
30
|
|
28
31
|
## démarre SuperCollider
|
29
32
|
|
33
|
+
|
30
34
|
if `which sclang` == "" then
|
31
35
|
begin
|
32
|
-
raise
|
36
|
+
raise SystemExit
|
33
37
|
rescue
|
34
38
|
exit
|
35
39
|
end
|
@@ -58,16 +62,16 @@ class SC
|
|
58
62
|
@@postMan= OSC::Client.new "localhost", @@portSuperCollider
|
59
63
|
|
60
64
|
# variables et méthodes de fin
|
65
|
+
|
61
66
|
|
62
67
|
@@listeVoix=Hash.new
|
63
68
|
define_finalizer(self, Proc.new {self.quit})
|
64
69
|
|
65
70
|
end
|
66
71
|
|
67
|
-
|
68
|
-
##Jack a toujours l'air de se vexer...
|
72
|
+
|
69
73
|
def self.quit
|
70
|
-
`killall scsynth
|
74
|
+
`killall sclang scsynth`
|
71
75
|
end
|
72
76
|
|
73
77
|
|
@@ -76,11 +80,13 @@ class SC
|
|
76
80
|
# ajustages directs. À ne pas utiliser normalement.
|
77
81
|
|
78
82
|
def self.send message
|
83
|
+
|
79
84
|
@@postMan.send OSC::Message.new "/SC", message.to_s
|
80
85
|
end
|
81
86
|
|
82
87
|
## fonction semi-privée
|
83
88
|
|
89
|
+
|
84
90
|
def self.updater voix, arg, value
|
85
91
|
case arg
|
86
92
|
when "dur"
|
@@ -96,6 +102,7 @@ class SC
|
|
96
102
|
end
|
97
103
|
end
|
98
104
|
|
105
|
+
|
99
106
|
def self.updateScore
|
100
107
|
@@listeVoix.each do |key, value|
|
101
108
|
value.instance_variables.each do |variable|
|
@@ -108,6 +115,7 @@ class SC
|
|
108
115
|
|
109
116
|
public
|
110
117
|
|
118
|
+
|
111
119
|
def self.set demarreBool, options=nil, *voix
|
112
120
|
|
113
121
|
if voix.nil?
|
@@ -117,6 +125,7 @@ class SC
|
|
117
125
|
puts "vous devez donner un nom à votre (vos) voix"
|
118
126
|
end
|
119
127
|
end
|
128
|
+
|
120
129
|
if @@listeVoix.nil? then
|
121
130
|
begin
|
122
131
|
raise ScriptError
|
@@ -139,6 +148,7 @@ class SC
|
|
139
148
|
@@listeVoix[voix.to_s].set options
|
140
149
|
end
|
141
150
|
self.updateScore
|
151
|
+
|
142
152
|
if demarreBool then
|
143
153
|
self.play voix.to_s end
|
144
154
|
end
|
data/lib/rubySC/musique.rb
CHANGED
@@ -4,25 +4,30 @@ require 'json'
|
|
4
4
|
|
5
5
|
## fonctions de plus haut niveau
|
6
6
|
|
7
|
-
## Quelques constantes, notamment pour les rythmes, c'est toujours
|
8
|
-
## plus pratique
|
9
7
|
|
10
|
-
##
|
11
|
-
## les plus connus
|
8
|
+
## Rythmes à 4 notes
|
12
9
|
|
13
10
|
|
14
|
-
## Rythmes à 3 notes
|
15
11
|
|
16
|
-
|
12
|
+
module SoundFile
|
13
|
+
|
14
|
+
def self.charger fileName, departBool=true, tpsDattente=1
|
15
|
+
SC.send %Q{b=Buffer.read(s,'#{fileName}')}
|
16
|
+
if departBool
|
17
|
+
sleep tpsDattente
|
18
|
+
self.play
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.play
|
23
|
+
SC.send "b.play"
|
24
|
+
end
|
17
25
|
|
18
|
-
|
19
|
-
Chabada=[3,2,1]
|
26
|
+
def self.pause
|
20
27
|
|
21
|
-
|
22
|
-
|
28
|
+
end
|
29
|
+
end
|
23
30
|
|
24
|
-
## Rythmes à 4 notes
|
25
|
-
|
26
31
|
## module utiliser pour faire des choses au niveau de toutes les voix.
|
27
32
|
|
28
33
|
module Partition
|
@@ -32,18 +37,18 @@ module Partition
|
|
32
37
|
## ----- voix
|
33
38
|
## ----- paramDeVoix
|
34
39
|
|
35
|
-
def self.importer nomFichierJSON
|
40
|
+
def self.importer nomFichierJSON, jouerBool=false
|
36
41
|
|
37
42
|
data = JSON.load File.open(nomFichierJSON)
|
38
43
|
data.each do |k, v|
|
39
|
-
SC.set v, k
|
44
|
+
SC.set jouerBool, v, k
|
40
45
|
end
|
41
46
|
|
42
47
|
end
|
43
48
|
|
44
49
|
def self.echelle echelle
|
45
50
|
SC.listeVoix.each_key do |voix|
|
46
|
-
SC.set ({"scale" => echelle}), voix
|
51
|
+
SC.set true, ({"scale" => echelle}), voix
|
47
52
|
end
|
48
53
|
SC.updateScore
|
49
54
|
end
|
@@ -51,7 +56,7 @@ module Partition
|
|
51
56
|
|
52
57
|
def self.transpose intervalle
|
53
58
|
SC.listeVoix.each_key do |voix|
|
54
|
-
SC.set ({"root" => intervalle}), voix
|
59
|
+
SC.set true, ({"root" => intervalle}), voix
|
55
60
|
end
|
56
61
|
self.updateScore
|
57
62
|
end
|
@@ -73,7 +78,7 @@ module Marche
|
|
73
78
|
else
|
74
79
|
begin
|
75
80
|
raise ArgumentException
|
76
|
-
|
81
|
+
rescue
|
77
82
|
end
|
78
83
|
end
|
79
84
|
tmp= Array.new(nbFois) do |x|
|
@@ -87,23 +92,40 @@ end
|
|
87
92
|
|
88
93
|
module Rythme
|
89
94
|
|
95
|
+
## Quelques constantes, notamment pour les rythmes, c'est toujours
|
96
|
+
## plus pratique
|
97
|
+
|
98
|
+
## Je n'ai mis que les rythmes qui me semblaient
|
99
|
+
## les plus connus
|
100
|
+
|
101
|
+
|
102
|
+
## Rythmes à 3 notes
|
103
|
+
|
104
|
+
Pavanne=[2,1,1]
|
105
|
+
|
106
|
+
Sicilienne=[3,1,2]
|
107
|
+
Chabada=[3,2,1]
|
108
|
+
|
109
|
+
Tresillo=[3,3,2]
|
110
|
+
Syncopette=[1,2,1]
|
111
|
+
|
90
112
|
## s'occupe du premier chiffre de la propriété "dur", c-à-d la vitesse
|
91
113
|
def self.mesure mesure, *voix
|
92
114
|
voix.each do |v|
|
93
|
-
tmp = SC.listeVoix[v].dur
|
115
|
+
tmp = SC.listeVoix[v.to_s].dur
|
94
116
|
tmp[0] = mesure
|
95
|
-
|
117
|
+
SC.set true, ({ "dur" => tmp }), v
|
96
118
|
end
|
97
119
|
end
|
98
|
-
|
120
|
+
|
99
121
|
## s'occupe du deuxième chiffre de la propriété "dur", c-à-d la
|
100
122
|
## gestalt rythmique.
|
101
123
|
|
102
124
|
def self.formule formule, *voix
|
103
125
|
voix.each do |v|
|
104
|
-
tmp = SC.listeVoix[v].dur
|
126
|
+
tmp = SC.listeVoix[v.to_s].dur
|
105
127
|
tmp[1] = formule
|
106
|
-
SC.set ({ "dur" => tmp }), v
|
128
|
+
SC.set true, ({ "dur" => tmp }), v
|
107
129
|
end
|
108
130
|
end
|
109
131
|
|
data/lib/rubySC/version.rb
CHANGED
data/rubySC.gemspec
CHANGED
data/test/helper.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'test/unit'
|
11
|
+
require 'shoulda'
|
12
|
+
|
13
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
14
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
15
|
+
require 'rubySC'
|
16
|
+
|
17
|
+
class Test::Unit::TestCase
|
18
|
+
end
|
data/test/test_rubySC.rb
ADDED
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.
|
4
|
+
version: 0.3.3
|
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-02-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -88,21 +88,29 @@ executables: []
|
|
88
88
|
extensions: []
|
89
89
|
extra_rdoc_files: []
|
90
90
|
files:
|
91
|
+
- ".document"
|
91
92
|
- ".gitignore"
|
92
93
|
- Gemfile
|
94
|
+
- Gemfile.lock
|
93
95
|
- LICENSE.txt
|
94
96
|
- README.md
|
95
97
|
- Rakefile
|
98
|
+
- VERSION
|
96
99
|
- examples/score.json
|
97
100
|
- examples/score.json~
|
98
101
|
- examples/testMinimal.rb
|
99
102
|
- examples/testMinimal.rb~
|
100
103
|
- lib/init.sc
|
104
|
+
- lib/lib/circularList.rb
|
105
|
+
- lib/lib/musique.rb
|
106
|
+
- lib/lib/voix.rb
|
101
107
|
- lib/rubySC.rb
|
102
108
|
- lib/rubySC/musique.rb
|
103
109
|
- lib/rubySC/version.rb
|
104
110
|
- lib/rubySC/voix.rb
|
105
111
|
- rubySC.gemspec
|
112
|
+
- test/helper.rb
|
113
|
+
- test/test_rubySC.rb
|
106
114
|
homepage: http://github.com/simdax/rubySC
|
107
115
|
licenses:
|
108
116
|
- MIT
|
@@ -127,4 +135,6 @@ rubygems_version: 2.2.0
|
|
127
135
|
signing_key:
|
128
136
|
specification_version: 4
|
129
137
|
summary: light music live_coding lib
|
130
|
-
test_files:
|
138
|
+
test_files:
|
139
|
+
- test/helper.rb
|
140
|
+
- test/test_rubySC.rb
|