Class: Voix
- Inherits:
-
Object
- Object
- Voix
- Defined in:
- lib/rubySC/voix.rb
Overview
sorte de classe privée pour garder en mémoire ce qui se passe dans les ‘voix’…
Instance Attribute Summary collapse
-
#adsr ⇒ Object
readonly
Returns the value of attribute adsr.
-
#amp ⇒ Object
Returns the value of attribute amp.
-
#degree ⇒ Object
Returns the value of attribute degree.
-
#dur ⇒ Object
readonly
Returns the value of attribute dur.
-
#information ⇒ Object
Returns the value of attribute information.
-
#instrument ⇒ Object
Returns the value of attribute instrument.
-
#marche ⇒ Object
Returns the value of attribute marche.
-
#name ⇒ Object
Returns the value of attribute name.
-
#octave ⇒ Object
Returns the value of attribute octave.
-
#scale ⇒ Object
Returns the value of attribute scale.
Instance Method Summary collapse
-
#initialize(nom = nil, options = {}) ⇒ Voix
constructor
A new instance of Voix.
- #play ⇒ Object
- #setADSR(atk, dec, sus, rel) ⇒ Object
-
#setDuree(duree) ⇒ Object
def setMarche intervalles if intervalles.nil? @root=0 else @root=“Pstutter(#selfself.degreeself.degree.size, Pseq(#intervalles, inf))” end end.
- #setInstrument(instrument) ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(nom = nil, options = {}) ⇒ Voix
Returns a new instance of Voix.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/rubySC/voix.rb', line 9 def initialize nom=nil, ={} @information=nil ## cette information sert juste à stocker tout ce ## qui pourrait être utile, principalement dans ## les Marches et autres transformations de ## mélodie. Cette variable ne sert qu'à donner ## une indication @name=nom if nom.nil? puts "choisis un nom" nomTmp=gets.chomp @name=nomTmp end SC.listeVoix[@name]=self @information="en pause \n" self.setDuree [:dur] @adsr=[] if [:adsr].nil? then self.setADSR 0.2,1,0.9,0.4 else selfADSR [:adsr] end if [:degree].nil? then @degree=Array.new(rand(1..5)) do |x| x=rand(12) end else @degree=[:degree] end if [:octave].nil? then @octave=4 else @octave=[:octave] end if [:scale].nil? then @scale = "major" else @scale=[:scale] end if [:amp].nil? then @amp = "Pwhite(0.2,0.8)" else @amp=[:amp] end if [:instrument].nil? then @instrument = "default" p "pan!" else self.setInstrument [:instrument] end if [:dur] self.setDuree [:dur] end SC.updateScore end |
Instance Attribute Details
#adsr ⇒ Object (readonly)
Returns the value of attribute adsr.
8 9 10 |
# File 'lib/rubySC/voix.rb', line 8 def adsr @adsr end |
#amp ⇒ Object
Returns the value of attribute amp.
7 8 9 |
# File 'lib/rubySC/voix.rb', line 7 def amp @amp end |
#degree ⇒ Object
Returns the value of attribute degree.
7 8 9 |
# File 'lib/rubySC/voix.rb', line 7 def degree @degree end |
#dur ⇒ Object (readonly)
Returns the value of attribute dur.
8 9 10 |
# File 'lib/rubySC/voix.rb', line 8 def dur @dur end |
#information ⇒ Object
Returns the value of attribute information.
7 8 9 |
# File 'lib/rubySC/voix.rb', line 7 def information @information end |
#instrument ⇒ Object
Returns the value of attribute instrument.
7 8 9 |
# File 'lib/rubySC/voix.rb', line 7 def instrument @instrument end |
#marche ⇒ Object
Returns the value of attribute marche.
7 8 9 |
# File 'lib/rubySC/voix.rb', line 7 def marche @marche end |
#name ⇒ Object
Returns the value of attribute name.
7 8 9 |
# File 'lib/rubySC/voix.rb', line 7 def name @name end |
#octave ⇒ Object
Returns the value of attribute octave.
7 8 9 |
# File 'lib/rubySC/voix.rb', line 7 def octave @octave end |
#scale ⇒ Object
Returns the value of attribute scale.
7 8 9 |
# File 'lib/rubySC/voix.rb', line 7 def scale @scale end |
Instance Method Details
#play ⇒ Object
142 143 144 145 146 |
# File 'lib/rubySC/voix.rb', line 142 def play SC.updateScore SC.play @name @information="en train de jouer" end |
#setADSR(atk, dec, sus, rel) ⇒ Object
75 76 77 78 79 80 |
# File 'lib/rubySC/voix.rb', line 75 def setADSR atk, dec, sus, rel @adsr=[(atk/1.0), (dec/1.0), (sus/1.0), (rel/1.0)] SC.updateScore end |
#setDuree(duree) ⇒ Object
def setMarche intervalles
if intervalles.nil?
@root=0
else
@root="Pstutter(#{self.degree.size}, Pseq(#{intervalles}, inf))"
end
end
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/rubySC/voix.rb', line 103 def setDuree (duree) if duree.nil? then @dur=[4, [1]] ## valeur de base, tout en ronde, cantus ## firmus style, io! else if duree.is_a? Array if duree.length == 2 and duree[1].is_a? Array then @dur=duree ## quelqu'un a fait un vrai objet en RTM notation else tmp = true duree.each { |x| unless x.is_a? Fixnum tmp = false end } if tmp then @dur = [4, duree] ## on a juste mis un rythme pour la ## durée d'une mesure else begin raise ArgumentError rescue "mauvais argument pour la durée" end end end end end SC.updateScore end |
#setInstrument(instrument) ⇒ Object
82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/rubySC/voix.rb', line 82 def setInstrument instrument if instrument.is_a? Symbol @information = "le sample utilisé actuellement est #{instrument} \n" SC.sample instrument.to_s @instrument="sampler" else @instrument=instrument end end |
#stop ⇒ Object
137 138 139 140 |
# File 'lib/rubySC/voix.rb', line 137 def stop SC.stop @name @information=nil end |