Top Level Namespace

Includes:
ObjectSpace

Defined Under Namespace

Modules: Calcul, Echelle, Forme, Harmonie, Helper, Intervalles, Marche, Motif, Partition, RubySC, RubySC_CONST, Rythme, SoundFile, Ui, VoiceLeading Classes: Accords, Melodie, SC, Ui_Form, Voix

Instance Method Summary collapse

Instance Method Details

#bicinium(consonances = [-2,2]) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/rubySC/contrepoint.rb', line 33

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

#consonnancesPossibles(consonnances, noteM, noteH, ecartMax) ⇒ Object



1
2
3
4
5
6
7
8
9
10
11
12
13
# File 'lib/rubySC/contrepoint.rb', line 1

def consonnancesPossibles consonnances, noteM, noteH, ecartMax

tmp=consonnances.reject	{|x|
((noteM+x) - noteH).abs > ecartMax
} 

if tmp==[] then
	p "attention écart à la règle !"
	tmp=consonnancesPossibles consonnances, noteM, noteH, ecartMax+1
end	

return tmp
end

#creerMelodie(nbNote = rand(10..30)) ⇒ Object



93
94
95
96
97
98
# File 'lib/rubySC/melodie/melodie.rb', line 93

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   #manière un peu bourrine de "pondérer" les notes possibles
  end
end

#deuxVoixObject



1
2
3
4
5
6
7
8
9
10
# File 'lib/rubySC/helper.rb', line 1

def deuxVoix

	a=Voix.new "voixUne", ({"degree"=> creerMelodie, "instrument" => "sax"})
	b=Voix.new "voixDeux"
	b.degree = harmoniser a.degree

	SC.updateScore
	SC.play

end

#harmoniser(melodie, consonnances = [0,2,4,5], ecartMax = 2) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/rubySC/contrepoint.rb', line 16

def harmoniser melodie, consonnances=[0,2,4,5], ecartMax=2

	harmo=Array.new (melodie.size) 
	harmo[0]=melodie[0]+consonnances.sample
	harmo[1..-1].map.with_index(1) {  |a,i| 		
		harmo[i]=melodie[i]+(consonnancesPossibles consonnances, melodie[i], harmo[i-1], ecartMax).sample 
	}

	p "mel = #{melodie}"
	p "harmo = #{harmo}"

	return	harmo
	
end

#melodieCachee(melUn, melDeux) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/rubySC/melodie/Schenker.rb', line 2

def melodieCachee melUn, melDeux

  i=0  
    tmpDeux=melUn.map {|x| 
      if x == melDeux[i] then i +=1 ; true 
      else false
      end 
    }
    p tmpDeux
  
    if tmpDeux.count(true) == melDeux.size 
    then tmpDeux
    else  nil end
end

#organum(voix, typeHarmonisation = [-2,0,2,4]) ⇒ Object



57
58
59
60
61
62
63
64
65
# File 'lib/rubySC/contrepoint.rb', line 57

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

#orner(note, nbNote) ⇒ Object



122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# File 'lib/rubySC/melodie/melodie.rb', line 122

def orner note, nbNote
  
appogiature = lambda { tmp=[note+1, note] }
mordant = lambda { tmp=[note, note-1, note] }
trille = lambda { tmp= [note-1, note, note+1, note] }

  case nbNote
  when 0
    return note
    when 1
     return appogiature.call
    when 2
     return  mordant.call
    when 3
     return  trille.call
  end
  if nbNote > 3 
    p "erreur !"
  end

end

#rejoindre(noteDepart, noteArrivee, nbTemps) ⇒ Object



105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/rubySC/melodie/melodie.rb', line 105

def rejoindre noteDepart, noteArrivee, nbTemps

  intervalle=(noteArrivee-noteDepart).abs
  if intervalle == nbTemps then
    p'jkl'
    tmp =(Range.new noteDepart+1, noteArrivee-1).to_a
  else
    p'hj'
    tmp=[]  
   nbTemps.times { |x|
    tmp<<noteDepart+2*(x+1)
  }
  end
  return tmp
end

#transpose(melodie, deCombien) ⇒ Object



100
101
102
# File 'lib/rubySC/melodie/melodie.rb', line 100

def transpose melodie, deCombien
    melodie.map { |e| e+= deCombien }
end