Class: WSK::Actions::GenAllValues
- Inherits:
-
Object
- Object
- WSK::Actions::GenAllValues
- Defined in:
- lib/WSK/Actions/GenAllValues.rb
Constant Summary collapse
- MAX_BUFFER_SAMPLES =
65536
Instance Method Summary collapse
-
#execute(iInputData, oOutputData) ⇒ Object
Execute.
-
#get_nbr_samples(iInputData) ⇒ Object
Get the number of samples that will be written.
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
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 61 |
# File 'lib/WSK/Actions/GenAllValues.rb', line 36 def execute(iInputData, oOutputData) # Create buffer lNbrBuffers = ((@MaxValue-@MinValue+1) / MAX_BUFFER_SAMPLES)+1 lSizeofLastBuffer = ((@MaxValue-@MinValue+1) % MAX_BUFFER_SAMPLES) lIdxValue = @MinValue log_debug "Will output #{@MaxValue-@MinValue+1} samples in #{lNbrBuffers} buffers." lNbrBuffers.times do |iIdxBuffer| lBuffer = [] lSamplesInBuffer = nil if (iIdxBuffer == lNbrBuffers-1) # The last one lSamplesInBuffer = lSizeofLastBuffer else lSamplesInBuffer = MAX_BUFFER_SAMPLES end lSamplesInBuffer.times do |iIdxSampleBuffer| iInputData.Header.NbrChannels.times do |iIdxChannel| lBuffer << lIdxValue end lIdxValue += 1 end oOutputData.pushBuffer(lBuffer) 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 25 26 27 |
# File 'lib/WSK/Actions/GenAllValues.rb', line 22 def get_nbr_samples(iInputData) @MaxValue = 2**(iInputData.Header.NbrBitsPerSample-1)-1 @MinValue = -2**(iInputData.Header.NbrBitsPerSample-1) return @MaxValue-@MinValue+1 end |