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
-
#amp ⇒ Object
Returns the value of attribute amp.
-
#degree ⇒ Object
Returns the value of attribute degree.
-
#dur ⇒ Object
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
- #set(options) ⇒ Object
- #setDuree(duree) ⇒ Object
- #setMarche(intervalles) ⇒ 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 |
# 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 self.setDuree ["dur"] 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" else @instrument=["instrument"].to_s end self.setMarche ["marche"] SC.updateScore end |
Instance Attribute Details
#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
Returns the value of attribute dur.
7 8 9 |
# File 'lib/rubySC/voix.rb', line 7 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
124 125 126 127 128 |
# File 'lib/rubySC/voix.rb', line 124 def play SC.play @name @information="en train de jouer".colorize (:blue) end |
#set(options) ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/rubySC/voix.rb', line 62 def set .each do |key, value| if value.is_a? Symbol value=value.to_s end case key when "dur" self.setDuree value when "marche" self.setMarche value else self.instance_variable_set "@#{key}", value end end SC.updateScore end |
#setDuree(duree) ⇒ Object
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/rubySC/voix.rb', line 87 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 end |
#setMarche(intervalles) ⇒ Object
79 80 81 82 83 84 85 |
# File 'lib/rubySC/voix.rb', line 79 def setMarche intervalles if intervalles.nil? @root=0 else @root="Pstutter(#{self.degree.size}, Pseq(#{intervalles}, inf))" end end |
#stop ⇒ Object
119 120 121 122 |
# File 'lib/rubySC/voix.rb', line 119 def stop SC.stop @name @information=nil end |