Class: WSK::Actions::ApplyVolumeFct
- Inherits:
-
Object
- Object
- WSK::Actions::ApplyVolumeFct
- Defined in:
- lib/WSK/Actions/ApplyVolumeFct.rb
Constant Summary
Constants included from Functions
Functions::FCTTYPE_PIECEWISE_LINEAR
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 Common
#accessInputWaveFile, #accessOutputWaveFile, #getWaveFileAccesses, #parsePlugins, #readDuration, #readFFTProfile, #readThresholds, #val2db
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
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 |
# File 'lib/WSK/Actions/ApplyVolumeFct.rb', line 34 def execute(iInputData, oOutputData) rError = nil lIdxBegin = readDuration(@Begin, iInputData.Header.SampleRate) lIdxEnd = readDuration(@End, iInputData.Header.SampleRate) if (lIdxEnd == -1) lIdxEnd = iInputData.NbrSamples - 1 end if (lIdxEnd >= iInputData.NbrSamples) rError = RuntimeError.new("Transformation ends at #{lIdxEnd}, superceeding last sample (#{iInputData.NbrSamples-1})") else lFunction = WSK::Functions::Function.new begin lFunction.read_from_file(@FctFileName) rescue Exception rError = $! end if (rError == nil) # First, write samples before iInputData.each_raw_buffer(0, lIdxBegin-1) do |iInputRawBuffer, iNbrSamples, iNbrChannels| oOutputData.pushRawBuffer(iInputRawBuffer) end # Then apply volume transformation lFunction.apply_on_volume(iInputData, oOutputData, lIdxBegin, lIdxEnd, (@UnitDB == 1)) # Last, write samples after iInputData.each_raw_buffer(lIdxEnd+1) do |iInputRawBuffer, iNbrSamples, iNbrChannels| oOutputData.pushRawBuffer(iInputRawBuffer) end end 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
23 24 25 |
# File 'lib/WSK/Actions/ApplyVolumeFct.rb', line 23 def get_nbr_samples(iInputData) return iInputData.NbrSamples end |