Class: WSK::Actions::GenConstant

Inherits:
Object
  • Object
show all
Defined in:
lib/WSK/Actions/GenConstant.rb

Constant Summary collapse

MAX_BUFFER_SAMPLES =
65536

Instance Method Summary collapse

Instance Method Details

#execute(iInputData, oOutputData) ⇒ Object

Execute

Parameters
  • iInputData (WSK::Model::InputData): The input data

  • oOutputData (Object): The output data to fill

Return
  • Exception: An error, or nil if success



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/WSK/Actions/GenConstant.rb', line 33

def execute(iInputData, oOutputData)
  lRawSample = iInputData.Header.getEncodedString([@Value]*iInputData.Header.NbrChannels)
  # Write complete buffers
  lNbrCompleteBuffers = @NbrSamples/MAX_BUFFER_SAMPLES
  if (lNbrCompleteBuffers > 0)
    lCompleteRawBuffer = lRawSample*MAX_BUFFER_SAMPLES
    lNbrCompleteBuffers.times do |iIdx|
      oOutputData.pushRawBuffer(lCompleteRawBuffer)
    end
  end
  # Write last buffer
  lLastBufferSize = @NbrSamples % MAX_BUFFER_SAMPLES
  if (lLastBufferSize > 0)
    oOutputData.pushRawBuffer(lRawSample*lLastBufferSize)
  end

  return nil
end

#get_nbr_samples(iInputData) ⇒ Object

Get the number of samples that will be written. This is called before execute, as it is needed to write the output file. It is possible to give a majoration: it will be padded with silence.

Parameters
  • iInputData (WSK::Model::InputData): The input data

Return
  • Integer: The number of samples to be written



22
23
24
# File 'lib/WSK/Actions/GenConstant.rb', line 22

def get_nbr_samples(iInputData)
  return @NbrSamples
end