Class: Snd

Inherits:
Api show all
Defined in:
lib/api/snd.rb

Overview

a consecutave sequence of morphable tones (TonePart) of varying lengths, and rate of morphs, played without gaps.

Instance Method Summary collapse

Methods inherited from Api

#<<, #>>, #parent

Constructor Details

#initializeSnd

Returns a new instance of Snd.



4
5
6
7
# File 'lib/api/snd.rb', line 4

def initialize
  @snd=ToneSeq.new
  super
end

Instance Method Details

#amp=(val) ⇒ Object



19
20
21
22
23
24
25
26
# File 'lib/api/snd.rb', line 19

def amp= val
  toneseq.do_all {|tp| 
    tp.do_all {|tone| 
      tone.amp.start = val
      tone.amp.final = 0.0
      }
    }
end

#countObject

number of tones



49
50
51
# File 'lib/api/snd.rb', line 49

def count
  toneseq.toneparts.count
end

#fadeObject

ensure all tones fade out to 0 as the final volume. note: re-run after changing amp.



54
55
56
# File 'lib/api/snd.rb', line 54

def fade
  toneseq.fade
end

#freqObject

freq of first tone only



15
16
17
# File 'lib/api/snd.rb', line 15

def freq
  tone.freq.start
end

#freq=(val) ⇒ Object

assumes one tone only



10
11
12
# File 'lib/api/snd.rb', line 10

def freq= val
  tone.set_freq val
end

#lengthObject

get length



46
47
# File 'lib/api/snd.rb', line 46

def length
@snd.frames end

#length=(val) ⇒ Object

set length



41
42
43
44
# File 'lib/api/snd.rb', line 41

def length= val
  @snd.frames=val
  self
end

#tone(i = 0, j = 0) ⇒ Object

return its TonePart at j and thats Tone at i.



37
38
39
# File 'lib/api/snd.rb', line 37

def tone i=0, j=0
  @snd.tonepart(j).tone(i)
end

#tonepart(i = 0) ⇒ Object

return its TonePart.



29
30
31
32
33
34
# File 'lib/api/snd.rb', line 29

def tonepart i=0
  child = @snd.tonepart i
  raise "This Snd has no tone at index #{i}. " +
    "It has #{count} tones." if child.nil?
  child
end

#toneseqObject

return my ToneSeq



58
59
60
# File 'lib/api/snd.rb', line 58

def toneseq
  @snd
end