Class: WSK::Actions::Multiply
- Inherits:
-
Object
- Object
- WSK::Actions::Multiply
- Includes:
- Maps
- Defined in:
- lib/WSK/Actions/Multiply.rb
Instance Method Summary collapse
-
#execute(iInputData, oOutputData) ⇒ Object
Execute.
-
#get_nbr_samples(iInputData) ⇒ Object
Get the number of samples that will be written.
Methods included from Maps
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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/WSK/Actions/Multiply.rb', line 33 def execute(iInputData, oOutputData) rError = nil lCoeff = nil lMatch = @Coeff.match(/^(.*)db$/) if (lMatch == nil) lMatch = @Coeff.match(/^(\d*)\/(\d*)$/) if (lMatch == nil) log_err "Incorrect coefficient: #{@Coeff} is not in the form X/Y or in the form Xdb" rError = RuntimeError.new("Incorrect coefficient: #{@Coeff} is not in the form X/Y or in the form Xdb") else lNum, lDenom = lMatch[1..2].map { |iStrValue| iStrValue.to_i } lCoeff = Rational(lNum, lDenom) end else lCoeff = 2**(lMatch[1].to_f/6) end if (rError == nil) lMaxValue = 2**(iInputData.Header.NbrBitsPerSample-1) - 1 lMinValue = -2**(iInputData.Header.NbrBitsPerSample-1) lFunction = { :FunctionType => WSK::Functions::FCTTYPE_PIECEWISE_LINEAR, :MinValue => lMinValue, :MaxValue => lMaxValue, :Points => { lMinValue => (lMinValue*lCoeff).to_i, lMaxValue => (lMaxValue*lCoeff).to_i } } apply_map_functions(iInputData, oOutputData, [lFunction]*iInputData.Header.NbrChannels) end return rError 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/Multiply.rb', line 22 def get_nbr_samples(iInputData) return iInputData.NbrSamples end |