Top Level Namespace
Defined Under Namespace
Modules: Echelle, Marche, Partition, RubySC, RubySC_CONST, Rythme, SoundFile
Classes: SC, Voix
Instance Method Summary
collapse
Instance Method Details
#bicinium(consonances = [-2,2]) ⇒ Object
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/rubySC/contrepoint.rb', line 1
def bicinium consonances=[-2,2]
a = Voix.new "cantusFirmus"
b = Voix.new "organum"
a.degree=creerMelodie
a.play ; b.play
l= lambda { |x, y|
tmp=harmoniser x.degree, consonances
y.set ({ :degree=> tmp })
}
Thread.new do
20.times do
l.call a, b
sleep 2
l.call b, a
end
end
end
|
#creerMelodie(nbNote = rand(10..30)) ⇒ Object
1
2
3
4
5
6
|
# File 'lib/rubySC/melodie.rb', line 1
def creerMelodie nbNote=rand(10..30)
Array.new (nbNote) do |note|
note=[0,0,1,1,2,3,3,3,3,4,4,4,4,5,6].sample end
end
|
#creerRythme(melodie) ⇒ Object
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/rubySC/melodie.rb', line 24
def creerRythme melodie
rythme = intervallesMel melodie
rythme.map! { |inter|
if inter.abs > 1
note= 2
else
note=1
end
}
rythme << 3
end
|
#harmoniser(melodie, consonnances) ⇒ Object
38
39
40
41
42
43
44
|
# File 'lib/rubySC/melodie.rb', line 38
def harmoniser melodie, consonnances
harmonisation= melodie.map do |note|
note+=consonnances.sample
end
end
|
#intervallesMel(melodie) ⇒ Object
analyse rythmique basique si intervalle grand => pt d’appui si note conjointes et/ou similaire => plus rapide pour l’instant, pas de note d’approche
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/rubySC/melodie.rb', line 13
def intervallesMel melodie
tmp=melodie.each_with_index.map{ |a, i|
if melodie[i+1]
then melodie[i+1]-a
end
}
tmp[0..-2]
end
|
#organum(voix, typeHarmonisation = [-2,0,2,4]) ⇒ Object
25
26
27
28
29
30
31
32
33
|
# File 'lib/rubySC/contrepoint.rb', line 25
def organum voix, typeHarmonisation=[-2,0,2,4]
a= Voix.new "harmonisationDe"+voix.name
a.degree= harmoniser voix.degree, typeHarmonisation
a.setDuree voix.dur
SC.updateScore
end
|