Class: Ruck::Generators::WavOut
- Includes:
- MultiChannelTarget, Source, UGen
- Defined in:
- lib/ruck/ugen/wav.rb
Overview
saves all incoming samples in memory to export to disk later outputs 0.0 samples
Instance Attribute Summary collapse
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
Attributes included from UGen
Instance Method Summary collapse
- #attr_names ⇒ Object
-
#initialize(attrs = {}) ⇒ WavOut
constructor
A new instance of WavOut.
- #next(now) ⇒ Object
- #save ⇒ Object
Methods included from MultiChannelTarget
#add_source, #in, #in_channels, #remove_source
Methods included from Source
#<<, #>>, #last, #out, #out_channels
Methods included from UGen
Constructor Details
#initialize(attrs = {}) ⇒ WavOut
Returns a new instance of WavOut.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/ruck/ugen/wav.rb', line 16 def initialize(attrs = {}) require_attrs attrs, [:filename] @filename = attrs.delete(:filename) @num_channels = attrs.delete(:num_channels) || 1 @bits_per_sample = attrs.delete(:bits_per_sample) || 16 parse_attrs attrs @in_channels = (1..@num_channels).map { InChannel.new } @sample_rate = SAMPLE_RATE @samples = (1..@num_channels).map { [] } @ins = [] @last = 0.0 # TODO: this is necessary, but if UGen graph were explicitly # destructed, that would be nice. at_exit { save } end |
Instance Attribute Details
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
14 15 16 |
# File 'lib/ruck/ugen/wav.rb', line 14 def filename @filename end |
Instance Method Details
#attr_names ⇒ Object
47 48 49 |
# File 'lib/ruck/ugen/wav.rb', line 47 def attr_names [:filename] end |
#next(now) ⇒ Object
35 36 37 38 39 40 |
# File 'lib/ruck/ugen/wav.rb', line 35 def next(now) return @last if @now == now @now = now @samples << @in_channels.map { |chan| chan.next now } @last end |