%% %% Abstract: Target file for the S-Function sdspwindow2.c %% Used for the Window Function Block %% %% $RCSfile: sdspwindow2.tlc,v $ %% Copyright 1995-2000 The MathWorks, Inc. %% $Revision: 1.9 $ $Date: 2000/08/29 20:29:19 $ %implements "sdspwindow2" "C" %% Function: BlockOutputSignal =============================================== %% Abstract: %% %% %function BlockOutputSignal(block,system,portIdx,ucv,lcv,idx,retType) void %switch retType %case "Signal" %return LibBlockParameter(WindowSamples,ucv,lcv,idx) %case "SignalAddr" %return LibBlockParameterAddr(WindowSamples,ucv,lcv,idx) %default %assign errTxt = "Unhandled retType: %" % %endswitch %endfunction %% Function: Start ============================================================= %% Abstract: %% %% %function Start(block, system) Output %assign outMode = SFcnParamSettings.OutputMode %% %if (outMode == "GenerateOnly") || !LibIsEqual(TID, "constant") %% %if (outMode == "GenerateOnly") %assign nChans = 1 %else %assign INPORT = 0 %assign numDims = LibBlockInputSignalNumDimensions(INPORT) %assign inDims = LibBlockInputSignalDimensions(INPORT) %assign inCols = (numDims == 2) ? inDims[1] : 1 %assign inRows = inDims[0] %% %assign considerInputAsVector = (numDims == 1) || (inCols == 1) || (inRows == 1) %% %if ( considerInputAsVector && (!LibBlockInputSignalIsFrameData(INPORT)) ) %assign nChans = 1 %else %assign nChans = inCols %endif %endif %% %assign N = LibDataOutputPortWidth(0) / nChans %assign genPortIdx = (outMode == "GenerateOnly") ? 0 : 1 %% %% %if (outMode != "ApplyOnly") %% %% GenerateOnly or GenerateAndApply %% %if LibBlockOutputSignalStorageClass(genPortIdx) != "DefinedInTLC" %% %% != DefinedInTLC %% We must copy the parameter into the block I/O vector %% These are the window samples being "output" on the %% block's "Generate" port %% %% Note: these windows are NEVER complex (that is not supported) %% %assign dType_ID = LibBlockOutputSignalDataTypeId(genPortIdx) %assign bytes_per_real = SLibGetDataTypeSizeFromId(dType_ID) %% /* DSP Blockset Window (%) - % * Copy window samples to the block output port buffer */ memcpy(%, \ %, \ %); %endif %endif %endif %endfunction %function GetWindowSample(varName) %if outMode == "ApplyOnly" %return LibBlockParameter(WindowSamples,varName,"",0) %% %else %return LibBlockOutputSignal(1,varName,"",0) %endif %endfunction %% Function: Outputs =========================================================== %% Abstract: %% %% %function Outputs(block, system) Output /* DSP Blockset Window (%) - % */ %assign outMode = SFcnParamSettings.OutputMode %% %if outMode != "GenerateOnly" && !LibIsEqual(TID, "constant") %% %% %% outMode must be "ApplyOnly" or "ApplyAndGenerate" %assign INPORT = 0 %assign numDims = LibBlockInputSignalNumDimensions(INPORT) %assign inDims = LibBlockInputSignalDimensions(INPORT) %assign inCols = (numDims == 2) ? inDims[1] : 1 %assign inRows = inDims[0] %% %assign considerInputAsVector = (numDims == 1) || (inCols == 1) || (inRows == 1) %% %if ( considerInputAsVector && (!LibBlockInputSignalIsFrameData(INPORT)) ) %assign nChannels = 1 %else %assign nChannels = inCols %endif %% %assign samplesPerChannel = LibDataInputPortWidth(INPORT) / nChannels %% %if nChannels > 1 %% /* Apply window to % channels */ { %if LibBlockInputSignalBufferDstPort(0) == 0 /* In-place window computation: */ int_T i; int_T iw = 0; for (i=0; i<%; i++) { %% %% Sharing buffers: %% %if LibBlockOutputSignalIsComplex(0) %% Yi *= w %")> *= %; %endif %% Yr *= w %")> *= %; if (iw == %) iw = 0; } %else %% Not sharing buffers: int_T i; int_T iw = 0; for (i=0; i<%; i++) { %% %if LibBlockOutputSignalIsComplex(0) %% Yi = Ui * W %")> = ... %")> * %; %endif %% Yr = Ur * W %")> = ... %")> * %; if (iw == %) iw = 0; } %endif %% } %% %% %else %% Single Channel %% %if LibBlockInputSignalBufferDstPort(0) != 0 %% %% Not sharing buffers: %% %% Yr = Ur * w %if (inRows*inCols == 1) %")> = ... %")> * %; %% %if LibBlockOutputSignalIsComplex(0) %% Yi = Ui * w %")> = ... %")> * %; %endif %else { int_T i; for (i=0; i<%; i++) { %")> = ... %")> * %; %% %if LibBlockOutputSignalIsComplex(0) %% Yi = Ui * w %")> = ... %")> * %; %endif } } %endif %else %% %% Sharing buffers: %% %% Yr *= w %% %if (inRows*inCols == 1) %")> *= %; %if LibBlockOutputSignalIsComplex(0) %% Yi *= w %")> *= %; %endif %else { int_T i; for (i=0; i<%; i++) { %")> *= %; %if LibBlockOutputSignalIsComplex(0) %% Yi *= w %")> *= %; %endif } } %endif %endif %endif %endif %endfunction %% Outputs %% EOF: sdspwindow2.tlc