Module: AudioStream::AudioObservable

Includes:
Observable
Included in:
AudioBus, AudioInput, AudioObservableFx, AudioObservableFxBus, AudioObservableLambda
Defined in:
lib/audio_stream/audio_observable.rb

Instance Method Summary collapse

Instance Method Details

#fx(effector, **kwargs) ⇒ Object

Parameters:



20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/audio_stream/audio_observable.rb', line 20

def fx(effector, **kwargs)
  if Fx::MultiAudioInputtable===effector
    bus = AudioObservableFxBus.new(effector)
    bus.connect_observable(:main, self)
    kwargs.each {|key, observable|
      bus.connect_observable(key, observable)
    }
    bus
  else
    observer = AudioObservableFx.new(effector)
    add_observer(observer)
    observer
  end
end

#monoObject



43
44
45
46
47
48
49
# File 'lib/audio_stream/audio_observable.rb', line 43

def mono
  observer = AudioObservableLambda.new {|input|
    input.mono
  }
  add_observer(observer)
  observer
end

#notify_completeObject



13
14
15
16
# File 'lib/audio_stream/audio_observable.rb', line 13

def notify_complete
  changed
  notify_observers(AudioNotification.new(AudioNotification::STAT_COMPLETE, nil, self))
end

#notify_next(input) ⇒ Object



8
9
10
11
# File 'lib/audio_stream/audio_observable.rb', line 8

def notify_next(input)
  changed
  notify_observers(AudioNotification.new(AudioNotification::STAT_NEXT, input, self))
end

#send_to(bus, gain: nil, pan: nil) ⇒ Object

Parameters:



54
55
56
57
# File 'lib/audio_stream/audio_observable.rb', line 54

def send_to(bus, gain: nil, pan: nil)
  bus.add(self, gain: gain, pan: pan)
  self
end

#stereoObject



35
36
37
38
39
40
41
# File 'lib/audio_stream/audio_observable.rb', line 35

def stereo
  observer = AudioObservableLambda.new {|input|
    input.stereo
  }
  add_observer(observer)
  observer
end

#subscribe(on_next:, on_complete: nil) ⇒ Object



59
60
61
62
63
# File 'lib/audio_stream/audio_observable.rb', line 59

def subscribe(on_next:, on_complete: nil)
  observer = AudioObserverLambda.new(on_next: on_next, on_complete: on_complete)
  add_observer(observer)
  observer
end

#subscribe_on_next(&block) ⇒ Object



65
66
67
# File 'lib/audio_stream/audio_observable.rb', line 65

def subscribe_on_next(&block)
  subscribe(on_next: block)
end