audio demo - change aiRange to be compatible

// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
// Copyright (C) 2011-2014 - INRIA - Serge Steer
//
// Copyright (C) 2012 - 2016 - Scilab Enterprises
//
// This file is hereby licensed under the terms of the GNU GPL v2.0,
// pursuant to article 5.3.4 of the CeCILL v.2.1.
// This file was originally licensed under the terms of the CeCILL v2.1,
// and continues to be available under such terms.
// For more information, see the COPYING file which you should have received
// along with this program.
//
//
// Edited by Witczenko from MicroDAQ.org
// Real time signal processing with MicroDAQ
// Toolbox ver. 1.2, scan functions - DEMO

START = %F;
FILTER = [];
GAIN = [];
NO_FILTER = [];

function [ok,values_res,exprs]=wfir_gui_demo(exprs)
    global START;
    global FILTER;
    global GAIN;
    global NO_FILTER;

    START = %F;
    NO_FILTER = %T;
    FILTER = [];
    GAIN = 1.0;

    FT=["lp","hp","bp","sb", "nf"]
    WT=["re","tr","hn","hm","kr","ch","ch"]
    //  errcatch(-1,'continue')
    if argn(2)<1 then
        exprs=["""bp""";
        """hn"""
        "48";
        "44100";
        "300"
        "3000";
        "1000"]
    end
    ftype=exprs(1)
    wtype=exprs(2)
    if execstr("forder="+exprs(3)+";freq_ech="+exprs(4)+";low="+exprs(5)+";high="+exprs(6)+";fp="+exprs(7),"errcatch")<>0 then
        values_res=[]
        exprs=[]
        ok=%f
        return
    end
    global ret
    ret=0

    margin_x     = 5;      // Horizontal margin between each elements
    margin_y     = 5;      // Vertical margin between each elements
    button_w     = 70;
    button_h     = 30;
    frame_h     = 350;
    frame_w     = 440;
    label_h      = 20;
    list_h       = 120;
    list_w       = 100;
    list_incr    = list_w;
    axes_w       = 2*margin_x+frame_w;
    axes_h       = 2*margin_y+frame_h;// Frame height
    defaultfont  = "arial"; // Default Font

    fig_id = max(winsid())
    if isempty(fig_id)
        fig_id = 1;
    else
        fig_id = fig_id + 1;
    end

    fig = scf(fig_id)

    // Remove Scilab graphics menus & toolbar
    delmenu(fig.figure_id, gettext("&File"));
    delmenu(fig.figure_id, gettext("&Tools"));
    delmenu(fig.figure_id, gettext("&Edit"));
    delmenu(fig.figure_id, gettext("&?"));
    toolbar(fig.figure_id, "off");
    fig.axes_size       = [axes_w axes_h];

    fig.background      = addcolor([0.8 0.8 0.8]);
    fig.figure_name     = _("WFIR settings");
    ax=fig.children;
    ax.background= fig.background ;

    gui=uicontrol( ...
    "parent"              , fig,...
    "style"               , "frame",...
    "units"               , "pixels",...
    "position"            , [0 0 axes_w axes_h],...
    "background"          , [1 1 1]*0.8, ...
    "visible"             , "on");

    yo=axes_h-button_h;

    yft=frame_h-margin_y-label_h
    xft=margin_x;
    //Filter type selection -----------------------------------------------------------------
    listf_h       = 100;
    listf_w       = 150;
    label_w       = 75;
    uicontrol( ...
    "parent"              , gui,...
    "style"               , "text",...
    "string"              , _("Filter type"),...
    "units"               , "pixels",...
    "position"            , [xft yft label_w label_h], ...
    "fontname"            , defaultfont,...
    "fontunits"           , "points",...
    "fontsize"            , 12,...
    "fontweight"          , "bold", ...
    "horizontalalignment" , "left", ...
    "background"          , [1 1 1]*0.8, ...
    "visible"             , "on");
    Ftv=uicontrol( ...
    "parent"              , gui,...
    "style"               , "edit",...
    "string"              , ftype,...
    "units"               , "pixels",...
    "position"            , [xft+label_w+margin_x yft listf_w-label_w-margin_x label_h], ...
    "fontname"            , defaultfont,...
    "fontunits"           , "points",...
    "fontsize"            , 12,...
    "fontweight"          , "bold", ...
    "horizontalalignment" , "left", ...
    "background"          , [1 1 1]*0.8, ...
    "callback"            , "wfirSetFilterType()", ...
    "visible"             , "on");
    Filtertype=uicontrol( ...
    "parent"              , gui,...
    "style"               , "listbox",...
    "string"              , [_("Low pass");_("High pass");_("Band pass");_("Stop Band"); _("No filter")],...
    "value"               , find(FT==evstr(ftype)),...
    "units"               , "pixels",...
    "position"            , [xft,yft-listf_h,listf_w,listf_h],...
    "fontname"            , defaultfont,...
    "fontunits"           , "points",...
    "fontsize"            , 12,...
    "horizontalalignment" , "left", ...
    "BackgroundColor"     , [1 1 1], ...
    "ForegroundColor"     , [1 1 1]*0, ...
    "visible"             , "on", ...
    "callback"            , "wfirSetFilterType()");
    set(Ftv,"userdata",list([],Filtertype))

    //Window type selection -----------------------------------------------------------------
    ywt=yft-listf_h-4*margin_y
    xwt=xft
    listw_h       = 140;
    listw_w       = listf_w;
    uicontrol( ...
    "parent"              , gui,...
    "style"               , "text",...
    "string"              , _("Window type"),...
    "units"               , "pixels",...
    "position"            , [xwt ywt label_w label_h],...
    "fontname"            , defaultfont,...
    "fontunits"           , "points",...
    "fontsize"            , 12,...
    "fontweight"          , "bold", ...
    "horizontalalignment" , "left", ...
    "background"          , [1 1 1]*0.8, ...
    "visible"             , "on");
    Wtv=uicontrol( ...
    "parent"              , gui,...
    "style"               , "edit",...
    "string"              , wtype,...
    "units"               , "pixels",...
    "position"            , [xwt+label_w+margin_x ywt listw_w-label_w-margin_x label_h],...
    "fontname"            , defaultfont,...
    "fontunits"           , "points",...
    "fontsize"            , 12,...
    "fontweight"          , "bold", ...
    "horizontalalignment" , "left", ...
    "background"          , [1 1 1]*0.8, ...
    "callback"            , "wfirSetWindowType()",...
    "visible"             , "on");

    W=[_("Rectangular");_("Triangular");_("Hanning");
    _("Hamming");_("Kaiser");_("Chebychev main lobe");_("Chebychev side lobe")];
    index=find(WT==evstr(wtype))
    if index==[] then index=1,end//for debug
    Windowtype=uicontrol( ...
    "parent"              , gui,...
    "style"               , "listbox",...
    "string"              , W,...
    "value"               , find(WT==evstr(wtype)),...
    "units"               , "pixels",...
    "position"            , [xwt,ywt-listw_h,listw_w,listw_h],...
    "fontname"            , defaultfont,...
    "fontunits"           , "points",...
    "fontsize"            , 12,...
    "horizontalalignment" , "left", ...
    "BackgroundColor"     , [1 1 1], ...
    "ForegroundColor"     , [1 1 1]*0, ...
    "visible"             , "on", ...
    "callback"            , "wfirSetWindowType()");
    set(Wtv,"userdata",list([],Windowtype))

    //Sampling Frequency -----------------------------------------------------------------
    ysf=frame_h-margin_y-label_h
    xsf=xft+listf_w+2*margin_x
    labelsf_w=180
    editsf_w=80
    sfreq=1
    uicontrol( ...
    "parent"              , gui,...
    "style"               , "text",...
    "string"              ,  _("Sampling Frequency (Hz)"),...
    "units"               , "pixels",...
    "position"            , [xsf ysf labelsf_w label_h],...
    "fontname"            , defaultfont,...
    "fontunits"           , "points",...
    "fontsize"            , 12,...
    "fontweight"          , "bold", ...
    "horizontalalignment" , "left", ...
    "background"          , [1 1 1]*0.8, ...
    "visible"             , "on");
    Sfreq =uicontrol( ...
    "parent"              , gui,...
    "style"               , "edit",...
    "string"               , exprs(4),...
    "units"               , "pixels",...
    "position"            , [xsf+margin_x+labelsf_w,ysf,editsf_w,label_h],...
    "fontname"            , defaultfont,...
    "fontunits"           , "points",...
    "fontsize"            , 12,...
    "horizontalalignment" , "left", ...
    "BackgroundColor"     , [1 1 1], ...
    "ForegroundColor"     , [1 1 1]*0, ...
    "callback"            , "wfirSetSamplingFrequency()", ...
    "userdata"            ,sfreq,...
    "visible"             , "on", ...
    "enable"              , "off")
    //Filter order -----------------------------------------------------------------
    yfo=ysf-margin_y-label_h
    xfo=xsf
    labelfo_w=labelsf_w;
    editfo_w= editsf_w;
    scroll_w=160
    uicontrol( ...
    "parent"              , gui,...
    "style"               , "text",...
    "string"              ,  _("Filter Order"),...
    "units"               , "pixels",...
    "position"            , [xfo yfo labelfo_w label_h],...
    "fontname"            , defaultfont,...
    "fontunits"           , "points",...
    "fontsize"            , 12,...
    "fontweight"          , "bold", ...
    "horizontalalignment" , "left", ...
    "background"          , [1 1 1]*0.8, ...
    "visible"             , "on");
    Forderv=uicontrol( ...
    "parent"              , gui,...
    "style"               , "edit",...
    "string"              , exprs(3),...
    "units"               , "pixels",...
    "position"            , [xfo,yfo-label_h-margin_y,editfo_w,label_h],...
    "fontname"            , defaultfont,...
    "fontunits"           , "points",...
    "fontsize"            , 12,...
    "horizontalalignment" , "left", ...
    "BackgroundColor"     , [1 1 1], ...
    "ForegroundColor"     , [1 1 1]*0, ...
    "callback"            , "wfirValue2Sliderpos()", ...
    "visible"             , "on")

    Forders=uicontrol( ...
    "parent"              , gui,...
    "style"               , "slider",...
    "min"                 , 2,...
    "max"                 , 100,...
    "sliderstep"          , [1 10],...
    "value"               , forder,...
    "units"               , "pixels",...
    "position"            , [xfo+editfo_w+margin_x,yfo-label_h-margin_y,scroll_w,label_h],...
    "fontname"            , defaultfont,...
    "fontunits"           , "points",...
    "fontsize"            , 12,...
    "horizontalalignment" , "left", ...
    "BackgroundColor"     , [1 1 1], ...
    "ForegroundColor"     , [1 1 1]*0, ...
    "userdata"            , list(Forderv,1), ...
    "callback"            , "wfirSliderpos2ValueI()",...
    "visible"             , "on")
    set(Forderv,"userdata",Forders);

    //Low cutoff frequency -----------------------------------------------------------------
    ylcf=yfo-2*(margin_y+label_h)
    xlcf=xsf
    labellcf_w=labelsf_w;
    editlcf_w= editsf_w;
    if ftype=="""hp""" then visible="off";else visible="on";end
    Lcfl=uicontrol( ...
    "parent"              , gui,...
    "style"               , "text",...
    "visible"             , visible,...
    "string"              ,  _("Low cutoff frequency (Hz)"),...
    "units"               , "pixels",...
    "position"            , [xlcf ylcf labellcf_w label_h],...
    "fontname"            , defaultfont,...
    "fontunits"           , "points",...
    "fontsize"            , 12,...
    "fontweight"          , "bold", ...
    "horizontalalignment" , "left", ...
    "background"          , [1 1 1]*0.8);
    fact=1;
    Lcfv=uicontrol( ...
    "parent"              , gui,...
    "style"               , "edit",...
    "visible"             , visible,...
    "units"               , "pixels",...
    "string"              , exprs(5),...
    "position"            , [xlcf,ylcf-label_h-margin_y,editlcf_w,label_h],...
    "fontname"            , defaultfont,...
    "fontunits"           , "points",...
    "fontsize"            , 12,...
    "horizontalalignment" , "left", ...
    "BackgroundColor"     , [1 1 1], ...
    "ForegroundColor"     , [1 1 1]*0, ...
    "callback"            , "wfirValue2Sliderpos()")
    Lcfs=uicontrol( ...
    "parent"              , gui,...
    "style"               , "slider",...
    "visible"             , visible,...
    "min"                 , 0,...
    "max"                 , 16000,...
    "sliderstep"          , [50 500],...
    "value"               , 300,...
    "units"               , "pixels",...
    "position"            , [xlcf+editlcf_w+margin_x,ylcf-label_h-margin_y,scroll_w,label_h],...
    "fontname"            , defaultfont,...
    "fontunits"           , "points",...
    "fontsize"            , 12,...
    "horizontalalignment" , "left", ...
    "BackgroundColor"     , [1 1 1], ...
    "ForegroundColor"     , [1 1 1]*0, ...
    "userdata"            , list(Lcfv,fact), ...
    "callback"            , "wfirSliderpos2Value()")
    set(Lcfv,"userdata",Lcfs);

    //High cutoff frequency -----------------------------------------------------------------
    yhcf=ylcf-2*(margin_y+label_h)
    xhcf=xsf
    labelhcf_w=labelsf_w;
    edithcf_w= editsf_w;
    if ftype=="""lp""" then visible="off";else visible="on";end
    Hcfl=uicontrol( ...
    "parent"              , gui,...
    "style"               , "text",...
    "visible"             , visible,...
    "string"              ,  _("High cutoff frequency (Hz)"),...
    "units"               , "pixels",...
    "position"            , [xhcf yhcf labelhcf_w label_h],...
    "fontname"            , defaultfont,...
    "fontunits"           , "points",...
    "fontsize"            , 12,...
    "fontweight"          , "bold", ...
    "horizontalalignment" , "left", ...
    "background"          , [1 1 1]*0.8);
    fact=1;
    Hcfv=uicontrol( ...
    "parent"              , gui,...
    "style"               , "edit",...
    "visible"             , visible,...
    "units"               , "pixels",...
    "string"              , exprs(6),...
    "position"            , [xhcf,yhcf-label_h-margin_y,edithcf_w,label_h],...
    "fontname"            , defaultfont,...
    "fontunits"           , "points",...
    "fontsize"            , 12,...
    "horizontalalignment" , "left", ...
    "BackgroundColor"     , [1 1 1], ...
    "ForegroundColor"     , [1 1 1]*0, ...
    "callback"            , "wfirValue2Sliderpos()")
    Hcfs=uicontrol( ...
    "parent"              , gui,...
    "style"               , "slider",...
    "visible"             , visible,...
    "min"                 , 0,...
    "max"                 , 16000,...
    "sliderstep"          , [50 500],...
    "value"               , 3000,...
    "units"               , "pixels",...
    "position"            , [xhcf+edithcf_w+margin_x,yhcf-label_h-margin_y,scroll_w,label_h],...
    "fontname"            , defaultfont,...
    "fontunits"           , "points",...
    "fontsize"            , 12,...
    "horizontalalignment" , "left", ...
    "BackgroundColor"     , [1 1 1], ...
    "ForegroundColor"     , [1 1 1]*0, ...
    "userdata"            , list(Hcfv,fact), ...
    "callback"            , "wfirSliderpos2Value()")
    set(Hcfv,"userdata",Hcfs);

    //Chebychev or Kaiser window parameter -----------------------------------------------------------------
    yfp=yhcf-2*(margin_y+label_h)
    xfp=xsf
    labelfp_w=labelsf_w;
    editfp_w= editsf_w;
    if and(wtype<>["""kr""" """ch"""]) then visible="off";else visible="on";end
    Fpl=uicontrol( ...
    "parent"              , gui,...
    "style"               , "text",...
    "visible"             , visible,...
    "string"              ,  _("Parameter"),...
    "units"               , "pixels",...
    "position"            , [xfp yfp labelfp_w label_h],...
    "fontname"            , defaultfont,...
    "fontunits"           , "points",...
    "fontsize"            , 12,...
    "fontweight"          , "bold", ...
    "horizontalalignment" , "left", ...
    "background"          , [1 1 1]*0.8);
    fact=1000;

    Fpv=uicontrol( ...
    "parent"              , gui,...
    "style"               , "edit",...
    "visible"             , visible,...
    "units"               , "pixels",...
    "string"              , exprs(7),...
    "position"            , [xfp,yfp-label_h-margin_y,editfp_w,label_h],...
    "fontname"            , defaultfont,...
    "fontunits"           , "points",...
    "fontsize"            , 12,...
    "horizontalalignment" , "left", ...
    "BackgroundColor"     , [1 1 1], ...
    "ForegroundColor"     , [1 1 1]*0, ...
    "callback"            , "wfirValue2Sliderpos()")
    Fps=uicontrol( ...
    "parent"              , gui,...
    "style"               , "slider",...
    "visible"             , visible,...
    "min"                 , 0,...
    "max"                 , 500,...
    "sliderstep"          , [1 10],...
    "value"               , fp*fact,...
    "units"               , "pixels",...
    "position"            , [xfp+editfp_w+margin_x,yfp-label_h-margin_y,scroll_w,label_h],...
    "fontname"            , defaultfont,...
    "fontunits"           , "points",...
    "fontsize"            , 12,...
    "horizontalalignment" , "left", ...
    "BackgroundColor"     , [1 1 1], ...
    "ForegroundColor"     , [1 1 1]*0, ...
    "userdata"            , list(Fpv,fact), ...
    "callback"            , "wfirSliderpos2Value()")

    set(Fpv,"userdata",Fps);

    set(Filtertype,"userdata",list([Lcfl Lcfv Lcfs;Hcfl Hcfv Hcfs],Ftv))
    set(Windowtype,"userdata",list([Fpl Fpv Fps], Wtv))

//Gain -----------------------------------------------------------------
    yfp=yfp-2*(margin_y+label_h)
    xfp=xfp
    labelhcf_w=labelsf_w;
    edithcf_w= editsf_w;
    Gainlabel=uicontrol( ...
    "parent"              , gui,...
    "style"               , "text",...
    "visible"             , "on",...
    "string"              ,  _("Gain"),...
    "units"               , "pixels",...
    "position"            , [xfp yfp labelhcf_w label_h],...
    "fontname"            , defaultfont,...
    "fontunits"           , "points",...
    "fontsize"            , 12,...
    "fontweight"          , "bold", ...
    "horizontalalignment" , "left", ...
    "background"          , [1 1 1]*0.8);
    fact=1;
    GainEdit=uicontrol( ...
    "parent"              , gui,...
    "style"               , "edit",...
    "visible"             , "on",...
    "units"               , "pixels",...
    "string"              , "1.0",...
    "position"            , [xfp,yfp-label_h-margin_y,edithcf_w,label_h],...
    "fontname"            , defaultfont,...
    "fontunits"           , "points",...
    "fontsize"            , 12,...
    "horizontalalignment" , "left", ...
    "BackgroundColor"     , [1 1 1], ...
    "ForegroundColor"     , [1 1 1]*0, ...
    "callback"            , "gainEditCall()")
    GainSlider=uicontrol( ...
    "parent"              , gui,...
    "style"               , "slider",...
    "visible"             , "on",...
    "min"                 , 0,...
    "max"                 , 2.5,...
    "sliderstep"          , [0.05 0.4],...
    "value"               , 1.0,...
    "units"               , "pixels",...
    "position"            , [xfp+edithcf_w+margin_x,yfp-label_h-margin_y,scroll_w,label_h],...
    "fontname"            , defaultfont,...
    "fontunits"           , "points",...
    "fontsize"            , 12,...
    "horizontalalignment" , "left", ...
    "BackgroundColor"     , [1 1 1], ...
    "ForegroundColor"     , [1 1 1]*0, ...
    "userdata"            , list(GainEdit), ...
    "callback"            , "gainSliderCall()")
    set(GainEdit,"userdata",GainSlider);
    //Display -----------------------------------------------------------------
    yd=yfp-2*(margin_y+label_h)
    xd=xsf
    labeld_w=40
    uicontrol( ...
    "parent"              , gui,...
    "style"               , "text",...
    "string"              ,  _("View"),...
    "units"               , "pixels",...
    "position"            , [xd yd labeld_w label_h],...
    "fontname"            , defaultfont,...
    "fontunits"           , "points",...
    "fontsize"            , 12,...
    "fontweight"          , "bold", ...
    "horizontalalignment" , "left", ...
    "background"          , [1 1 1]*0.8, ...
    "visible"             , "on");
    Fview=uicontrol( ...
    "parent"              , gui,...
    "style"               , "checkbox",...
    "units"               , "pixels",...
    "min"                 , 0, ...
    "max"                 , 1, ...
    "value"               , 0, ...
    "position"            , [xd+margin_x+labeld_w yd label_h label_h],...
    "background"          , [1 1 1]*0.8, ...
    "callback"            , "wfirSetFilterView()",...
    "visible"             , "on");

    ybuttons=margin_y
    xbuttons=xhcf
    Start = uicontrol( ...
    "parent"              , gui,...
    "relief"              , "groove",...
    "style"               , "pushbutton",...
    "string"              , _("Start"),...
    "units"               , "pixels",...
    "position"            , [xbuttons,ybuttons,button_w button_h],..
    "fontname"            , "arial",...
    "fontunits"           , "points",...
    "fontsize"            , 12,...
    "fontweight"          , "bold", ...
    "horizontalalignment" , "center", ...
    "visible"             , "on", ...
    "callback"            , "start()");
    xbuttons=xbuttons+margin_x+button_w
    Stop = uicontrol( ...
    "parent"              , gui,...
    "relief"              , "groove",...
    "style"               , "pushbutton",...
    "string"              , _("Stop"),...
    "units"               , "pixels",...
    "position"            , [xbuttons,ybuttons,button_w button_h],..
    "fontname"            , "arial",...
    "fontunits"           , "points",...
    "fontsize"            , 12,...
    "fontweight"          , "bold", ...
    "horizontalalignment" , "center", ...
    "visible"             , "on", ...
    "callback"            , "stop()");
    xbuttons=xbuttons+margin_x+button_w

    set(gui,"userdata",[Fview,Filtertype,Windowtype,Forderv,Forders,Lcfv,Lcfs,Hcfv,Hcfs,Fpv,Fps,Sfreq,Ftv,Wtv])

    Rate = 44100;
    ChannelIN = [1 2];
    ChannelOUT = [1 2];
    aiRange = [-1 1]; // analog input range: ±5V
    aoRange = [-2.5 2.5]; // analog output range: ±2.5V
    IsContinuous = %T;
    IsDifferential = %F;
    ChunkSize = Rate/6;
    SampleOffset = 100;

    initialData = [zeros(ChunkSize,1) zeros(ChunkSize,1)];

    [ftype,forder,low,high,wtype,fpar,freq_ech]=wfirGetFilterParameters(gui.userdata);
    FILTER = wfir(ftype, 48,[low/Rate high/Rate],wtype,fpar);

    realtimeinit(0.1);
    t=0;

    info_msg = ["This example shows simple audio processing using MicroDAQ device and Scilab software.";
                "Source of audio stream connect to analog input channels: AI1, AI2. You can adjust ";
                "demo parameters in real time during processing. Filtered signal will be available on" ;
                "output channels: AO1, AO2.";
                "";
                "WARNING: On some platforms, GUI sliders cause Scilab random crashes."];
    messagebox(info_msg, "Demo usage", "info");
    mdaqClose();

    while ret==0&or(winsid()==fig_id) then
        if START == %T then
            // Init analog input/output scanning
            mdaqAIScanInit(ChannelIN, aiRange, IsDifferential, Rate, -1);
            mdaqAOScanInit(ChannelOUT, initialData, aoRange, IsContinuous, Rate, -1);

            audioData = mdaqAIScan(ChunkSize, %T);
            mdaqAOScan();
            mdaqAOScanData(ChannelOUT, audioData, %T);

            mprintf("\nFiltering h as been started...\n");
            sample_count = 0;

            while START==%T then

                // Acquire data
                pastAudioData = audioData;
                audioData = mdaqAIScan(ChunkSize, %T);
                audioDataExt = [pastAudioData(ChunkSize-SampleOffset+1:ChunkSize, :); audioData];

                // FIR Filter
                //left channel
                filtAudioDataLeft = filter(FILTER, 1, audioDataExt(:, 1));
                filtAudioDataLeft = filtAudioDataLeft(SampleOffset+1:size(filtAudioDataLeft, '*'));

                //right channel
                filtAudioDataRight = filter(FILTER, 1, audioDataExt(:, 2));
                filtAudioDataRight = filtAudioDataRight(SampleOffset+1:size(filtAudioDataRight, '*'));

                // Analog Output
                if NO_FILTER == %F then
                    mdaqAOScanData( ChannelOUT, [(filtAudioDataLeft*GAIN) (filtAudioDataRight*GAIN)], %T);
                else
                    mdaqAOScanData(ChannelOUT, (audioData*GAIN), %T);
                end

                sample_count = sample_count + size(audioData, '*');
                mprintf("Filtered samples: %d\n", sample_count);
                realtime(t);
                t=t+1;
            end

            mdaqAOScanStop();
            mdaqAIScanStop();

            mprintf("Filtering has been stopped.\n");
        end

        realtime(t);
        t=t+1;
    end

    if ret==1&or(winsid()==fig_id) then
        ok=%t
        [ftype,forder,low,high,wtype,fpar,freq_ech]=wfirGetFilterParameters(gui.userdata)
        values_res=tlist(["wfir","ftype","forder","low","high","wtype","fpar","freq_ech"],ftype,forder,low,high,wtype,fpar,freq_ech)
        exprs= wfirGetFilterExprs(gui.userdata)
        delete(fig)
    else
        //user had canceled or closed the gui window
        ok=%f
        values_res=[]
        exprs=[]
    end
    clearglobal ret idle;

endfunction

function start()
    global START;
    START = %T;
endfunction

function stop()
    global START;
    START = %F;
endfunction

function gainEditCall(hv)
    global GAIN;
    if argn(2)<1 then hv=gcbo,end
    hs=hv.userdata;
    if execstr("v="+hv.string,"errcatch")==0 then
        hs.value=v
        if v > hs.max then
            GAIN = hs.max
        elseif v < hs.min then
            GAIN = hs.min
        else
            GAIN = v;
        end
    end
endfunction

function gainSliderCall(hs)
    global GAIN;
    xpause(200);
    if argn(2)<1 then hs=gcbo,end
    ud=hs.userdata;
    hv=ud(1);
    hv.string=string(hs.value)
    GAIN = hs.value;
endfunction

function wfirSliderpos2Value(hs)
    xpause(200);
    if argn(2)<1 then hs=gcbo,end
    hs.value=floor(hs.value)
    ud=hs.userdata
    hv=ud(1);//handle on edition zone
    fact=ud(2)// scale factor
    hv.string=string(hs.value)
    wfirUpdate(hs)
endfunction
function wfirSliderpos2ValueI(hs)
    xpause(200);
    if argn(2)<1 then hs=gcbo,end
    hs.value=round(hs.value)
    ud=hs.userdata
    hv=ud(1);//handle on edition zone
    fact=ud(2)// scale factor
    hv.string=string(hs.value/fact)
    wfirUpdate(hs)
endfunction

function wfirValue2Sliderpos(hv)
    // hv handle on edition zone
    if argn(2)<1 then hv=gcbo,end
    if execstr("v="+hv.string,"errcatch")==0 then
        hs=hv.userdata //handle on the slider
        ud=hs.userdata
        fact=ud(2)// scale factor
        hs.value=fact*v
        hv.ForegroundColor=[0 0 0];
        wfirUpdate(hv)
    else
        hv.ForegroundColor=[1 0 0];
    end
endfunction

function wfirSetFilterType()
    global NO_FILTER;
    FT=["lp","hp","bp","sb","nf"]
    ud=gcbo.userdata

    if gcbo.style=="edit" then
        he=gcbo //handle on the edit area
        hl=ud(2) //handle on the list area

        ok=execstr("k=find("+he.string+"==FT)","errcatch")==0
        if ~ok|k==[] then
            he.ForegroundColor=[1 0 0];
            return
        else
            he.ForegroundColor=[0 0 0];
            hl.value=k
        end
    else
        hl=gcbo //handle on the list area
        he=ud(2) //handle on the edit area
        he.string=sci2exp(FT(hl.value),0)
    end
    ud=hl.userdata
    Handles=ud(1)
    select hl.value
    case 1 then //low pass
        Handles(1,:).visible="on";
        Handles(2,:).visible="off";
    case 2 then //high pass
        Handles(1,:).visible="off";
        Handles(2,:).visible="on";
    case 3 then //band pass
        Handles(1,:).visible="on";
        Handles(2,:).visible="on";
    case 4 then //stop band
        Handles(1,:).visible="on";
        Handles(2,:).visible="on";
    case 5 then //stop band
        Handles(1,:).visible="off";
        Handles(2,:).visible="off";
    end

    if hl.value <> 5 then
        wfirUpdate(gcbo)
        NO_FILTER = %F;
    else
        NO_FILTER = %T;
    end

endfunction

function wfirSetWindowType()
    WT=["re","tr","hn","hm","kr","ch","ch"]
    ud=gcbo.userdata
    if gcbo.style=="edit" then
        he=gcbo //handle on the edit area
        hl=ud(2) //handle on the list area
        ok=execstr("k=find("+he.string+"==WT)","errcatch")==0

        if ~ok|k==[] then
            he.ForegroundColor=[1 0 0];
            return
        else
            he.ForegroundColor=[0 0 0];
            hl.value=k
        end
    else
        hl=gcbo //handle on the list area
        he=ud(2) //handle on the edit area
        he.string=sci2exp(WT(hl.value),0)
    end

    ud=hl.userdata
    Handles=ud(1)
    k=hl.value
    if and(k<>[5 6 7]) then
        Handles.visible="off"
    else
        label=Handles(1)
        value=Handles(2)
        scroll=Handles(3)

        if k==5 then //Kaiser
            label.string="Beta"
            label.visible="on";
            value.visible="on";

            init=2.5;fact=100;
            value.string=string(init)
            scroll.min=0
            scroll.max=10*fact
            scroll.value=init*fact
            d=scroll.userdata;d(2)=fact
            set(scroll,"userdata",d)
            scroll.visible="on";
        elseif k==6 then //Chebychev, main lobe constraint df in [0 0.5]
            label.string=_("Window main lobe width")
            label.visible="on";
            value.visible="on";
            init=0.2;fact=1000;
            value.string=string(init)
            scroll.min=1d-10*fact
            scroll.max=0.5*fact
            scroll.value=init*fact
            d=scroll.userdata;d(2)=fact
            set(scroll,"userdata",d)
            scroll.visible="on";

        elseif k==7 then //Chebychev, side lobe constraint dp>0
            label.string=_("maximum side-lobe height")
            label.visible="on";
            value.visible="on";
            init=0.001;fact=1000;
            value.string=string(init)
            scroll.min=1d-10*fact
            scroll.max=1*fact
            scroll.value=init*fact
            d=scroll.userdata;d(2)=fact
            set(scroll,"userdata",d)
            scroll.visible="on";
        end
    end
    wfirUpdate(gcbo)
endfunction

function wfirSetFilterView()
    h=gcbo //handle on the view check box
    if h.value==0 //disable
        fig=h.userdata
        execstr("delete(fig)","errcatch")
        h.userdata=[]
    else //enable
        nwin=size(winsid(),"*")
        if nwin==0 then win=1;else win=max(winsid())+1;end
        fig=scf(win)
        a=gca();
        a.x_label.text=_("frequency (Hz)")
        a.y_label.text=_("Magnitude (dB)")
        a.axes_visible="on"
        a.grid=ones(1,2)*color("gray");
        xpoly([],[])
        set(h,"userdata",fig)
        clearglobal idle
        wfirUpdate(gcbo)
    end
endfunction

function wfirSetSamplingFrequency()
    Sfreq=gcbo
    ok=execstr("newfreq="+Sfreq.string,"errcatch")==0
    ok=ok&newfreq>0

    if ok then
        Sfreq.ForegroundColor=[0 0 0];
        curfreq=Sfreq.userdata
        gui=gcbo.parent
        H=gui.userdata
        //H=[Fview,Filtertype,Windowtype,Forderv,Forders,Lcfv,Lcfs,Hcfv,Hcfs,Fpv,Fps,Sfreq,Ftv,Wtv]
        //update low and high cutoff frequencies
        r=newfreq/curfreq
        Lcfv=H(6),Lcfs=H(7),Hcfv=H(8),Hcfs=H(9)

        Lcfs.min=Lcfs.min*r
        Lcfs.max=Lcfs.max*r
        Lcfs.value=Lcfs.value*r
        Lcfv.string=string(evstr(Lcfv.string)*r)

        Hcfs.min=Hcfs.min*r
        Hcfs.max=Hcfs.max*r
        Hcfs.value=Hcfs.value*r
        Hcfv.string=string(evstr(Hcfv.string)*r)

        Sfreq.userdata=newfreq
        wfirUpdate(gcbo)
    else
        Sfreq.ForegroundColor=[1 0 0];
    end

endfunction

function [ftype,forder,low,high,wtype,fpar,freq_ech]=wfirGetFilterParameters(H)
    //  low,high,freq_ech are returned in Hz
    //H=[Fview,Filtertype,Windowtype,Forderv,Forders,Lcfv,Lcfs,Hcfv,Hcfs,Fpv,Fps,Sfreq,Ftv,Wtv]
    FT=["lp","hp","bp","sb"]
    WT=["re","tr","hn","hm","kr","ch","ch"]
    Filtertype=H(2);
    Windowtype=H(3);
    Forderv=H(4);
    Lcfv=H(6);
    Hcfv=H(8);
    Fpv=H(10);
    Sfreq=H(12)
    ftype=FT(Filtertype.value)
    wtype=WT(Windowtype.value)
    forder=evstr(Forderv.string)
    if or(ftype==["hp" "sb"]) then
        //force odd ordrer
        if 2*int(forder/2)==forder then forder=forder+1,end
    end
    freq_ech=evstr(Sfreq.string)
    if ftype=="lp" then
        low=evstr(Lcfv.string)
        high=0
    elseif ftype=="hp" then
        low=evstr(Hcfv.string)
        high=0
    else
        low=evstr(Lcfv.string)
        high=evstr(Hcfv.string)
    end
    if Windowtype.value==5 //Kaiser
        fpar=[evstr(Fpv.string) 0]
    elseif Windowtype.value==6 //Chebychev, main lobe constraint df in [0 0.5]
        fpar=[-1 evstr(Fpv.string)]
    elseif Windowtype.value==7  //Chebychev, side lobe constraint dp>0
        fpar=[evstr(Fpv.string) -1]
    else
        fpar=[-1 -1]
    end
endfunction

function  wfirUpdate(h)
    global FILTER;
    gui=h.parent
    H=gui.userdata
    [ftype,forder,low,high,wtype,fpar,freq_ech]= ...
    wfirGetFilterParameters(H)

    if ftype == 'bp' | ftype == 'sb' then
        if low >= high then
                low = high - 1;
        end
    end

    cfreq=[low,high]/freq_ech;
    FILTER =wfir(ftype,forder,cfreq,wtype,fpar);

    if H(1).value==1 then
        old=gcf()
        [ftype,forder,low,high,wtype,fpar,freq_ech]= ...
        wfirGetFilterParameters(H)

    if ftype == 'bp' | ftype == 'sb' then
        if low >= high then
                low = high - 1;
        end
    end

        cfreq=[low,high]/freq_ech;
        [filt,wfm,fr]=wfir(ftype,forder,cfreq,wtype,fpar);
        fig=H(1).userdata
        if ~is_handle_valid(fig) then
            //the window has been closed by user
            fig=scf(max(winsid())+1)
            a=gca();
            a.x_label.text=_("frequency (Hz)")
            a.y_label.text=_("Magnitude (dB)")
            a.axes_visible="on"
            a.grid=ones(1,2)*color("gray");
            xpoly([],[])
            set(H(1),"userdata",fig)
        end
        eps=1d-6;
        frq=linspace(eps,0.5-eps,10*size(FILTER,"*"))
        [frq,repf]=repfreq(syslin("d",poly(FILTER,"z","c"),1),frq)
        scf(fig);drawlater()
        a=gca();p=a.children
        frq=frq(:)*freq_ech
        m=20*log10(abs(repf(:)))
        a.data_bounds=[min(frq) min(m);max(frq) max(m)]
        p.data=[frq m];
        drawnow()
        scf(old)
    end
endfunction

function exprs= wfirGetFilterExprs(H)
    // H=[Fview,Filtertype,Windowtype,Forderv,Forders,Lcfv,Lcfs,Hcfv,Hcfs,Fpv,Fps,Sfreq,Ftv,Wtv]
    FT=["lp","hp","bp","sb"]
    WT=["re","tr","hn","hm","kr","ch","ch"]
    Filtertype=H(2);
    Windowtype=H(3);
    Forderv=H(4);
    Lcfv=H(6);
    Hcfv=H(8);
    Fpv=H(10);
    Sfreq=H(12)
    exprs=[Ftv.string;
    Wtv.string;
    Forderv.string;
    Sfreq.string;
    Lcfv.string
    Hcfv.string;
    Fpv.string]
endfunction

clc;
wfir_gui_demo();

// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
// Copyright (C) 2011-2014 - INRIA - Serge Steer
//
// Copyright (C) 2012 - 2016 - Scilab Enterprises
//
// This file is hereby licensed under the terms of the GNU GPL v2.0,
// pursuant to article 5.3.4 of the CeCILL v.2.1.
// This file was originally licensed under the terms of the CeCILL v2.1,
// and continues to be available under such terms.
// For more information, see the COPYING file which you should have received
// along with this program.
//
//
// Edited by Witczenko from MicroDAQ.org
// Real time signal processing with MicroDAQ
// Toolbox ver. 1.2, scan functions - DEMO

START = %F;
FILTER = [];
GAIN = [];
NO_FILTER = [];

function [ok,values_res,exprs]=wfir_gui_demo(exprs)
    global START;
    global FILTER;
    global GAIN;
    global NO_FILTER;

    START = %F;
    NO_FILTER = %T;
    FILTER = [];
    GAIN = 1.0;

    FT=["lp","hp","bp","sb", "nf"]
    WT=["re","tr","hn","hm","kr","ch","ch"]
    //  errcatch(-1,'continue')
    if argn(2)<1 then
        exprs=["""bp""";
        """hn"""
        "48";
        "44100";
        "300"
        "3000";
        "1000"]
    end
    ftype=exprs(1)
    wtype=exprs(2)
    if execstr("forder="+exprs(3)+";freq_ech="+exprs(4)+";low="+exprs(5)+";high="+exprs(6)+";fp="+exprs(7),"errcatch")<>0 then
        values_res=[]
        exprs=[]
        ok=%f
        return
    end
    global ret
    ret=0

    margin_x     = 5;      // Horizontal margin between each elements
    margin_y     = 5;      // Vertical margin between each elements
    button_w     = 70;
    button_h     = 30;
    frame_h     = 350;
    frame_w     = 440;
    label_h      = 20;
    list_h       = 120;
    list_w       = 100;
    list_incr    = list_w;
    axes_w       = 2*margin_x+frame_w;
    axes_h       = 2*margin_y+frame_h;// Frame height
    defaultfont  = "arial"; // Default Font

    fig_id = max(winsid())
    if isempty(fig_id)
        fig_id = 1;
    else
        fig_id = fig_id + 1;
    end

    fig = scf(fig_id)

    // Remove Scilab graphics menus & toolbar
    delmenu(fig.figure_id, gettext("&File"));
    delmenu(fig.figure_id, gettext("&Tools"));
    delmenu(fig.figure_id, gettext("&Edit"));
    delmenu(fig.figure_id, gettext("&?"));
    toolbar(fig.figure_id, "off");
    fig.axes_size       = [axes_w axes_h];

    fig.background      = addcolor([0.8 0.8 0.8]);
    fig.figure_name     = _("WFIR settings");
    ax=fig.children;
    ax.background= fig.background ;

    gui=uicontrol( ...
    "parent"              , fig,...
    "style"               , "frame",...
    "units"               , "pixels",...
    "position"            , [0 0 axes_w axes_h],...
    "background"          , [1 1 1]*0.8, ...
    "visible"             , "on");

    yo=axes_h-button_h;

    yft=frame_h-margin_y-label_h
    xft=margin_x;
    //Filter type selection -----------------------------------------------------------------
    listf_h       = 100;
    listf_w       = 150;
    label_w       = 75;
    uicontrol( ...
    "parent"              , gui,...
    "style"               , "text",...
    "string"              , _("Filter type"),...
    "units"               , "pixels",...
    "position"            , [xft yft label_w label_h], ...
    "fontname"            , defaultfont,...
    "fontunits"           , "points",...
    "fontsize"            , 12,...
    "fontweight"          , "bold", ...
    "horizontalalignment" , "left", ...
    "background"          , [1 1 1]*0.8, ...
    "visible"             , "on");
    Ftv=uicontrol( ...
    "parent"              , gui,...
    "style"               , "edit",...
    "string"              , ftype,...
    "units"               , "pixels",...
    "position"            , [xft+label_w+margin_x yft listf_w-label_w-margin_x label_h], ...
    "fontname"            , defaultfont,...
    "fontunits"           , "points",...
    "fontsize"            , 12,...
    "fontweight"          , "bold", ...
    "horizontalalignment" , "left", ...
    "background"          , [1 1 1]*0.8, ...
    "callback"            , "wfirSetFilterType()", ...
    "visible"             , "on");
    Filtertype=uicontrol( ...
    "parent"              , gui,...
    "style"               , "listbox",...
    "string"              , [_("Low pass");_("High pass");_("Band pass");_("Stop Band"); _("No filter")],...
    "value"               , find(FT==evstr(ftype)),...
    "units"               , "pixels",...
    "position"            , [xft,yft-listf_h,listf_w,listf_h],...
    "fontname"            , defaultfont,...
    "fontunits"           , "points",...
    "fontsize"            , 12,...
    "horizontalalignment" , "left", ...
    "BackgroundColor"     , [1 1 1], ...
    "ForegroundColor"     , [1 1 1]*0, ...
    "visible"             , "on", ...
    "callback"            , "wfirSetFilterType()");
    set(Ftv,"userdata",list([],Filtertype))

    //Window type selection -----------------------------------------------------------------
    ywt=yft-listf_h-4*margin_y
    xwt=xft
    listw_h       = 140;
    listw_w       = listf_w;
    uicontrol( ...
    "parent"              , gui,...
    "style"               , "text",...
    "string"              , _("Window type"),...
    "units"               , "pixels",...
    "position"            , [xwt ywt label_w label_h],...
    "fontname"            , defaultfont,...
    "fontunits"           , "points",...
    "fontsize"            , 12,...
    "fontweight"          , "bold", ...
    "horizontalalignment" , "left", ...
    "background"          , [1 1 1]*0.8, ...
    "visible"             , "on");
    Wtv=uicontrol( ...
    "parent"              , gui,...
    "style"               , "edit",...
    "string"              , wtype,...
    "units"               , "pixels",...
    "position"            , [xwt+label_w+margin_x ywt listw_w-label_w-margin_x label_h],...
    "fontname"            , defaultfont,...
    "fontunits"           , "points",...
    "fontsize"            , 12,...
    "fontweight"          , "bold", ...
    "horizontalalignment" , "left", ...
    "background"          , [1 1 1]*0.8, ...
    "callback"            , "wfirSetWindowType()",...
    "visible"             , "on");

    W=[_("Rectangular");_("Triangular");_("Hanning");
    _("Hamming");_("Kaiser");_("Chebychev main lobe");_("Chebychev side lobe")];
    index=find(WT==evstr(wtype))
    if index==[] then index=1,end//for debug
    Windowtype=uicontrol( ...
    "parent"              , gui,...
    "style"               , "listbox",...
    "string"              , W,...
    "value"               , find(WT==evstr(wtype)),...
    "units"               , "pixels",...
    "position"            , [xwt,ywt-listw_h,listw_w,listw_h],...
    "fontname"            , defaultfont,...
    "fontunits"           , "points",...
    "fontsize"            , 12,...
    "horizontalalignment" , "left", ...
    "BackgroundColor"     , [1 1 1], ...
    "ForegroundColor"     , [1 1 1]*0, ...
    "visible"             , "on", ...
    "callback"            , "wfirSetWindowType()");
    set(Wtv,"userdata",list([],Windowtype))

    //Sampling Frequency -----------------------------------------------------------------
    ysf=frame_h-margin_y-label_h
    xsf=xft+listf_w+2*margin_x
    labelsf_w=180
    editsf_w=80
    sfreq=1
    uicontrol( ...
    "parent"              , gui,...
    "style"               , "text",...
    "string"              ,  _("Sampling Frequency (Hz)"),...
    "units"               , "pixels",...
    "position"            , [xsf ysf labelsf_w label_h],...
    "fontname"            , defaultfont,...
    "fontunits"           , "points",...
    "fontsize"            , 12,...
    "fontweight"          , "bold", ...
    "horizontalalignment" , "left", ...
    "background"          , [1 1 1]*0.8, ...
    "visible"             , "on");
    Sfreq =uicontrol( ...
    "parent"              , gui,...
    "style"               , "edit",...
    "string"               , exprs(4),...
    "units"               , "pixels",...
    "position"            , [xsf+margin_x+labelsf_w,ysf,editsf_w,label_h],...
    "fontname"            , defaultfont,...
    "fontunits"           , "points",...
    "fontsize"            , 12,...
    "horizontalalignment" , "left", ...
    "BackgroundColor"     , [1 1 1], ...
    "ForegroundColor"     , [1 1 1]*0, ...
    "callback"            , "wfirSetSamplingFrequency()", ...
    "userdata"            ,sfreq,...
    "visible"             , "on", ...
    "enable"              , "off")
    //Filter order -----------------------------------------------------------------
    yfo=ysf-margin_y-label_h
    xfo=xsf
    labelfo_w=labelsf_w;
    editfo_w= editsf_w;
    scroll_w=160
    uicontrol( ...
    "parent"              , gui,...
    "style"               , "text",...
    "string"              ,  _("Filter Order"),...
    "units"               , "pixels",...
    "position"            , [xfo yfo labelfo_w label_h],...
    "fontname"            , defaultfont,...
    "fontunits"           , "points",...
    "fontsize"            , 12,...
    "fontweight"          , "bold", ...
    "horizontalalignment" , "left", ...
    "background"          , [1 1 1]*0.8, ...
    "visible"             , "on");
    Forderv=uicontrol( ...
    "parent"              , gui,...
    "style"               , "edit",...
    "string"              , exprs(3),...
    "units"               , "pixels",...
    "position"            , [xfo,yfo-label_h-margin_y,editfo_w,label_h],...
    "fontname"            , defaultfont,...
    "fontunits"           , "points",...
    "fontsize"            , 12,...
    "horizontalalignment" , "left", ...
    "BackgroundColor"     , [1 1 1], ...
    "ForegroundColor"     , [1 1 1]*0, ...
    "callback"            , "wfirValue2Sliderpos()", ...
    "visible"             , "on")

    Forders=uicontrol( ...
    "parent"              , gui,...
    "style"               , "slider",...
    "min"                 , 2,...
    "max"                 , 100,...
    "sliderstep"          , [1 10],...
    "value"               , forder,...
    "units"               , "pixels",...
    "position"            , [xfo+editfo_w+margin_x,yfo-label_h-margin_y,scroll_w,label_h],...
    "fontname"            , defaultfont,...
    "fontunits"           , "points",...
    "fontsize"            , 12,...
    "horizontalalignment" , "left", ...
    "BackgroundColor"     , [1 1 1], ...
    "ForegroundColor"     , [1 1 1]*0, ...
    "userdata"            , list(Forderv,1), ...
    "callback"            , "wfirSliderpos2ValueI()",...
    "visible"             , "on")
    set(Forderv,"userdata",Forders);

    //Low cutoff frequency -----------------------------------------------------------------
    ylcf=yfo-2*(margin_y+label_h)
    xlcf=xsf
    labellcf_w=labelsf_w;
    editlcf_w= editsf_w;
    if ftype=="""hp""" then visible="off";else visible="on";end
    Lcfl=uicontrol( ...
    "parent"              , gui,...
    "style"               , "text",...
    "visible"             , visible,...
    "string"              ,  _("Low cutoff frequency (Hz)"),...
    "units"               , "pixels",...
    "position"            , [xlcf ylcf labellcf_w label_h],...
    "fontname"            , defaultfont,...
    "fontunits"           , "points",...
    "fontsize"            , 12,...
    "fontweight"          , "bold", ...
    "horizontalalignment" , "left", ...
    "background"          , [1 1 1]*0.8);
    fact=1;
    Lcfv=uicontrol( ...
    "parent"              , gui,...
    "style"               , "edit",...
    "visible"             , visible,...
    "units"               , "pixels",...
    "string"              , exprs(5),...
    "position"            , [xlcf,ylcf-label_h-margin_y,editlcf_w,label_h],...
    "fontname"            , defaultfont,...
    "fontunits"           , "points",...
    "fontsize"            , 12,...
    "horizontalalignment" , "left", ...
    "BackgroundColor"     , [1 1 1], ...
    "ForegroundColor"     , [1 1 1]*0, ...
    "callback"            , "wfirValue2Sliderpos()")
    Lcfs=uicontrol( ...
    "parent"              , gui,...
    "style"               , "slider",...
    "visible"             , visible,...
    "min"                 , 0,...
    "max"                 , 16000,...
    "sliderstep"          , [50 500],...
    "value"               , 300,...
    "units"               , "pixels",...
    "position"            , [xlcf+editlcf_w+margin_x,ylcf-label_h-margin_y,scroll_w,label_h],...
    "fontname"            , defaultfont,...
    "fontunits"           , "points",...
    "fontsize"            , 12,...
    "horizontalalignment" , "left", ...
    "BackgroundColor"     , [1 1 1], ...
    "ForegroundColor"     , [1 1 1]*0, ...
    "userdata"            , list(Lcfv,fact), ...
    "callback"            , "wfirSliderpos2Value()")
    set(Lcfv,"userdata",Lcfs);

    //High cutoff frequency -----------------------------------------------------------------
    yhcf=ylcf-2*(margin_y+label_h)
    xhcf=xsf
    labelhcf_w=labelsf_w;
    edithcf_w= editsf_w;
    if ftype=="""lp""" then visible="off";else visible="on";end
    Hcfl=uicontrol( ...
    "parent"              , gui,...
    "style"               , "text",...
    "visible"             , visible,...
    "string"              ,  _("High cutoff frequency (Hz)"),...
    "units"               , "pixels",...
    "position"            , [xhcf yhcf labelhcf_w label_h],...
    "fontname"            , defaultfont,...
    "fontunits"           , "points",...
    "fontsize"            , 12,...
    "fontweight"          , "bold", ...
    "horizontalalignment" , "left", ...
    "background"          , [1 1 1]*0.8);
    fact=1;
    Hcfv=uicontrol( ...
    "parent"              , gui,...
    "style"               , "edit",...
    "visible"             , visible,...
    "units"               , "pixels",...
    "string"              , exprs(6),...
    "position"            , [xhcf,yhcf-label_h-margin_y,edithcf_w,label_h],...
    "fontname"            , defaultfont,...
    "fontunits"           , "points",...
    "fontsize"            , 12,...
    "horizontalalignment" , "left", ...
    "BackgroundColor"     , [1 1 1], ...
    "ForegroundColor"     , [1 1 1]*0, ...
    "callback"            , "wfirValue2Sliderpos()")
    Hcfs=uicontrol( ...
    "parent"              , gui,...
    "style"               , "slider",...
    "visible"             , visible,...
    "min"                 , 0,...
    "max"                 , 16000,...
    "sliderstep"          , [50 500],...
    "value"               , 3000,...
    "units"               , "pixels",...
    "position"            , [xhcf+edithcf_w+margin_x,yhcf-label_h-margin_y,scroll_w,label_h],...
    "fontname"            , defaultfont,...
    "fontunits"           , "points",...
    "fontsize"            , 12,...
    "horizontalalignment" , "left", ...
    "BackgroundColor"     , [1 1 1], ...
    "ForegroundColor"     , [1 1 1]*0, ...
    "userdata"            , list(Hcfv,fact), ...
    "callback"            , "wfirSliderpos2Value()")
    set(Hcfv,"userdata",Hcfs);

    //Chebychev or Kaiser window parameter -----------------------------------------------------------------
    yfp=yhcf-2*(margin_y+label_h)
    xfp=xsf
    labelfp_w=labelsf_w;
    editfp_w= editsf_w;
    if and(wtype<>["""kr""" """ch"""]) then visible="off";else visible="on";end
    Fpl=uicontrol( ...
    "parent"              , gui,...
    "style"               , "text",...
    "visible"             , visible,...
    "string"              ,  _("Parameter"),...
    "units"               , "pixels",...
    "position"            , [xfp yfp labelfp_w label_h],...
    "fontname"            , defaultfont,...
    "fontunits"           , "points",...
    "fontsize"            , 12,...
    "fontweight"          , "bold", ...
    "horizontalalignment" , "left", ...
    "background"          , [1 1 1]*0.8);
    fact=1000;

    Fpv=uicontrol( ...
    "parent"              , gui,...
    "style"               , "edit",...
    "visible"             , visible,...
    "units"               , "pixels",...
    "string"              , exprs(7),...
    "position"            , [xfp,yfp-label_h-margin_y,editfp_w,label_h],...
    "fontname"            , defaultfont,...
    "fontunits"           , "points",...
    "fontsize"            , 12,...
    "horizontalalignment" , "left", ...
    "BackgroundColor"     , [1 1 1], ...
    "ForegroundColor"     , [1 1 1]*0, ...
    "callback"            , "wfirValue2Sliderpos()")
    Fps=uicontrol( ...
    "parent"              , gui,...
    "style"               , "slider",...
    "visible"             , visible,...
    "min"                 , 0,...
    "max"                 , 500,...
    "sliderstep"          , [1 10],...
    "value"               , fp*fact,...
    "units"               , "pixels",...
    "position"            , [xfp+editfp_w+margin_x,yfp-label_h-margin_y,scroll_w,label_h],...
    "fontname"            , defaultfont,...
    "fontunits"           , "points",...
    "fontsize"            , 12,...
    "horizontalalignment" , "left", ...
    "BackgroundColor"     , [1 1 1], ...
    "ForegroundColor"     , [1 1 1]*0, ...
    "userdata"            , list(Fpv,fact), ...
    "callback"            , "wfirSliderpos2Value()")

    set(Fpv,"userdata",Fps);

    set(Filtertype,"userdata",list([Lcfl Lcfv Lcfs;Hcfl Hcfv Hcfs],Ftv))
    set(Windowtype,"userdata",list([Fpl Fpv Fps], Wtv))

//Gain -----------------------------------------------------------------
    yfp=yfp-2*(margin_y+label_h)
    xfp=xfp
    labelhcf_w=labelsf_w;
    edithcf_w= editsf_w;
    Gainlabel=uicontrol( ...
    "parent"              , gui,...
    "style"               , "text",...
    "visible"             , "on",...
    "string"              ,  _("Gain"),...
    "units"               , "pixels",...
    "position"            , [xfp yfp labelhcf_w label_h],...
    "fontname"            , defaultfont,...
    "fontunits"           , "points",...
    "fontsize"            , 12,...
    "fontweight"          , "bold", ...
    "horizontalalignment" , "left", ...
    "background"          , [1 1 1]*0.8);
    fact=1;
    GainEdit=uicontrol( ...
    "parent"              , gui,...
    "style"               , "edit",...
    "visible"             , "on",...
    "units"               , "pixels",...
    "string"              , "1.0",...
    "position"            , [xfp,yfp-label_h-margin_y,edithcf_w,label_h],...
    "fontname"            , defaultfont,...
    "fontunits"           , "points",...
    "fontsize"            , 12,...
    "horizontalalignment" , "left", ...
    "BackgroundColor"     , [1 1 1], ...
    "ForegroundColor"     , [1 1 1]*0, ...
    "callback"            , "gainEditCall()")
    GainSlider=uicontrol( ...
    "parent"              , gui,...
    "style"               , "slider",...
    "visible"             , "on",...
    "min"                 , 0,...
    "max"                 , 2.5,...
    "sliderstep"          , [0.05 0.4],...
    "value"               , 1.0,...
    "units"               , "pixels",...
    "position"            , [xfp+edithcf_w+margin_x,yfp-label_h-margin_y,scroll_w,label_h],...
    "fontname"            , defaultfont,...
    "fontunits"           , "points",...
    "fontsize"            , 12,...
    "horizontalalignment" , "left", ...
    "BackgroundColor"     , [1 1 1], ...
    "ForegroundColor"     , [1 1 1]*0, ...
    "userdata"            , list(GainEdit), ...
    "callback"            , "gainSliderCall()")
    set(GainEdit,"userdata",GainSlider);
    //Display -----------------------------------------------------------------
    yd=yfp-2*(margin_y+label_h)
    xd=xsf
    labeld_w=40
    uicontrol( ...
    "parent"              , gui,...
    "style"               , "text",...
    "string"              ,  _("View"),...
    "units"               , "pixels",...
    "position"            , [xd yd labeld_w label_h],...
    "fontname"            , defaultfont,...
    "fontunits"           , "points",...
    "fontsize"            , 12,...
    "fontweight"          , "bold", ...
    "horizontalalignment" , "left", ...
    "background"          , [1 1 1]*0.8, ...
    "visible"             , "on");
    Fview=uicontrol( ...
    "parent"              , gui,...
    "style"               , "checkbox",...
    "units"               , "pixels",...
    "min"                 , 0, ...
    "max"                 , 1, ...
    "value"               , 0, ...
    "position"            , [xd+margin_x+labeld_w yd label_h label_h],...
    "background"          , [1 1 1]*0.8, ...
    "callback"            , "wfirSetFilterView()",...
    "visible"             , "on");

    ybuttons=margin_y
    xbuttons=xhcf
    Start = uicontrol( ...
    "parent"              , gui,...
    "relief"              , "groove",...
    "style"               , "pushbutton",...
    "string"              , _("Start"),...
    "units"               , "pixels",...
    "position"            , [xbuttons,ybuttons,button_w button_h],..
    "fontname"            , "arial",...
    "fontunits"           , "points",...
    "fontsize"            , 12,...
    "fontweight"          , "bold", ...
    "horizontalalignment" , "center", ...
    "visible"             , "on", ...
    "callback"            , "start()");
    xbuttons=xbuttons+margin_x+button_w
    Stop = uicontrol( ...
    "parent"              , gui,...
    "relief"              , "groove",...
    "style"               , "pushbutton",...
    "string"              , _("Stop"),...
    "units"               , "pixels",...
    "position"            , [xbuttons,ybuttons,button_w button_h],..
    "fontname"            , "arial",...
    "fontunits"           , "points",...
    "fontsize"            , 12,...
    "fontweight"          , "bold", ...
    "horizontalalignment" , "center", ...
    "visible"             , "on", ...
    "callback"            , "stop()");
    xbuttons=xbuttons+margin_x+button_w

    set(gui,"userdata",[Fview,Filtertype,Windowtype,Forderv,Forders,Lcfv,Lcfs,Hcfv,Hcfs,Fpv,Fps,Sfreq,Ftv,Wtv])

    Rate = 44100;
    ChannelIN = [1 2];
    ChannelOUT = [1 2];
    aiRange = [-0.64 0.64]; // analog input range: ±5V
    aoRange = [-2.5 2.5]; // analog output range: ±2.5V
    IsContinuous = %T;
    IsDifferential = %F;
    ChunkSize = Rate/6;
    SampleOffset = 100;

    initialData = [zeros(ChunkSize,1) zeros(ChunkSize,1)];

    [ftype,forder,low,high,wtype,fpar,freq_ech]=wfirGetFilterParameters(gui.userdata);
    FILTER = wfir(ftype, 48,[low/Rate high/Rate],wtype,fpar);

    realtimeinit(0.1);
    t=0;

    info_msg = ["This example shows simple audio processing using MicroDAQ device and Scilab software.";
                "Source of audio stream connect to analog input channels: AI1, AI2. You can adjust ";
                "demo parameters in real time during processing. Filtered signal will be available on" ;
                "output channels: AO1, AO2.";
                "";
                "WARNING: On some platforms, GUI sliders cause Scilab random crashes."];
    messagebox(info_msg, "Demo usage", "info");
    mdaqClose();

    while ret==0&or(winsid()==fig_id) then
        if START == %T then
            // Init analog input/output scanning
            mdaqAIScanInit(ChannelIN, aiRange, IsDifferential, Rate, -1);
            mdaqAOScanInit(ChannelOUT, initialData, aoRange, IsContinuous, Rate, -1);

            audioData = mdaqAIScan(ChunkSize, %T);
            mdaqAOScan();
            mdaqAOScanData(ChannelOUT, audioData, %T);

            mprintf("\nFiltering h as been started...\n");
            sample_count = 0;

            while START==%T then

                // Acquire data
                pastAudioData = audioData;
                audioData = mdaqAIScan(ChunkSize, %T);
                audioDataExt = [pastAudioData(ChunkSize-SampleOffset+1:ChunkSize, :); audioData];

                // FIR Filter
                //left channel
                filtAudioDataLeft = filter(FILTER, 1, audioDataExt(:, 1));
                filtAudioDataLeft = filtAudioDataLeft(SampleOffset+1:size(filtAudioDataLeft, '*'));

                //right channel
                filtAudioDataRight = filter(FILTER, 1, audioDataExt(:, 2));
                filtAudioDataRight = filtAudioDataRight(SampleOffset+1:size(filtAudioDataRight, '*'));

                // Analog Output
                if NO_FILTER == %F then
                    mdaqAOScanData( ChannelOUT, [(filtAudioDataLeft*GAIN) (filtAudioDataRight*GAIN)], %T);
                else
                    mdaqAOScanData(ChannelOUT, (audioData*GAIN), %T);
                end

                sample_count = sample_count + size(audioData, '*');
                mprintf("Filtered samples: %d\n", sample_count);
                realtime(t);
                t=t+1;
            end

            mdaqAOScanStop();
            mdaqAIScanStop();

            mprintf("Filtering has been stopped.\n");
        end

        realtime(t);
        t=t+1;
    end

    if ret==1&or(winsid()==fig_id) then
        ok=%t
        [ftype,forder,low,high,wtype,fpar,freq_ech]=wfirGetFilterParameters(gui.userdata)
        values_res=tlist(["wfir","ftype","forder","low","high","wtype","fpar","freq_ech"],ftype,forder,low,high,wtype,fpar,freq_ech)
        exprs= wfirGetFilterExprs(gui.userdata)
        delete(fig)
    else
        //user had canceled or closed the gui window
        ok=%f
        values_res=[]
        exprs=[]
    end
    clearglobal ret idle;

endfunction

function start()
    global START;
    START = %T;
endfunction

function stop()
    global START;
    START = %F;
endfunction

function gainEditCall(hv)
    global GAIN;
    if argn(2)<1 then hv=gcbo,end
    hs=hv.userdata;
    if execstr("v="+hv.string,"errcatch")==0 then
        hs.value=v
        if v > hs.max then
            GAIN = hs.max
        elseif v < hs.min then
            GAIN = hs.min
        else
            GAIN = v;
        end
    end
endfunction

function gainSliderCall(hs)
    global GAIN;
    xpause(200);
    if argn(2)<1 then hs=gcbo,end
    ud=hs.userdata;
    hv=ud(1);
    hv.string=string(hs.value)
    GAIN = hs.value;
endfunction

function wfirSliderpos2Value(hs)
    xpause(200);
    if argn(2)<1 then hs=gcbo,end
    hs.value=floor(hs.value)
    ud=hs.userdata
    hv=ud(1);//handle on edition zone
    fact=ud(2)// scale factor
    hv.string=string(hs.value)
    wfirUpdate(hs)
endfunction
function wfirSliderpos2ValueI(hs)
    xpause(200);
    if argn(2)<1 then hs=gcbo,end
    hs.value=round(hs.value)
    ud=hs.userdata
    hv=ud(1);//handle on edition zone
    fact=ud(2)// scale factor
    hv.string=string(hs.value/fact)
    wfirUpdate(hs)
endfunction

function wfirValue2Sliderpos(hv)
    // hv handle on edition zone
    if argn(2)<1 then hv=gcbo,end
    if execstr("v="+hv.string,"errcatch")==0 then
        hs=hv.userdata //handle on the slider
        ud=hs.userdata
        fact=ud(2)// scale factor
        hs.value=fact*v
        hv.ForegroundColor=[0 0 0];
        wfirUpdate(hv)
    else
        hv.ForegroundColor=[1 0 0];
    end
endfunction

function wfirSetFilterType()
    global NO_FILTER;
    FT=["lp","hp","bp","sb","nf"]
    ud=gcbo.userdata

    if gcbo.style=="edit" then
        he=gcbo //handle on the edit area
        hl=ud(2) //handle on the list area

        ok=execstr("k=find("+he.string+"==FT)","errcatch")==0
        if ~ok|k==[] then
            he.ForegroundColor=[1 0 0];
            return
        else
            he.ForegroundColor=[0 0 0];
            hl.value=k
        end
    else
        hl=gcbo //handle on the list area
        he=ud(2) //handle on the edit area
        he.string=sci2exp(FT(hl.value),0)
    end
    ud=hl.userdata
    Handles=ud(1)
    select hl.value
    case 1 then //low pass
        Handles(1,:).visible="on";
        Handles(2,:).visible="off";
    case 2 then //high pass
        Handles(1,:).visible="off";
        Handles(2,:).visible="on";
    case 3 then //band pass
        Handles(1,:).visible="on";
        Handles(2,:).visible="on";
    case 4 then //stop band
        Handles(1,:).visible="on";
        Handles(2,:).visible="on";
    case 5 then //stop band
        Handles(1,:).visible="off";
        Handles(2,:).visible="off";
    end

    if hl.value <> 5 then
        wfirUpdate(gcbo)
        NO_FILTER = %F;
    else
        NO_FILTER = %T;
    end

endfunction

function wfirSetWindowType()
    WT=["re","tr","hn","hm","kr","ch","ch"]
    ud=gcbo.userdata
    if gcbo.style=="edit" then
        he=gcbo //handle on the edit area
        hl=ud(2) //handle on the list area
        ok=execstr("k=find("+he.string+"==WT)","errcatch")==0

        if ~ok|k==[] then
            he.ForegroundColor=[1 0 0];
            return
        else
            he.ForegroundColor=[0 0 0];
            hl.value=k
        end
    else
        hl=gcbo //handle on the list area
        he=ud(2) //handle on the edit area
        he.string=sci2exp(WT(hl.value),0)
    end

    ud=hl.userdata
    Handles=ud(1)
    k=hl.value
    if and(k<>[5 6 7]) then
        Handles.visible="off"
    else
        label=Handles(1)
        value=Handles(2)
        scroll=Handles(3)

        if k==5 then //Kaiser
            label.string="Beta"
            label.visible="on";
            value.visible="on";

            init=2.5;fact=100;
            value.string=string(init)
            scroll.min=0
            scroll.max=10*fact
            scroll.value=init*fact
            d=scroll.userdata;d(2)=fact
            set(scroll,"userdata",d)
            scroll.visible="on";
        elseif k==6 then //Chebychev, main lobe constraint df in [0 0.5]
            label.string=_("Window main lobe width")
            label.visible="on";
            value.visible="on";
            init=0.2;fact=1000;
            value.string=string(init)
            scroll.min=1d-10*fact
            scroll.max=0.5*fact
            scroll.value=init*fact
            d=scroll.userdata;d(2)=fact
            set(scroll,"userdata",d)
            scroll.visible="on";

        elseif k==7 then //Chebychev, side lobe constraint dp>0
            label.string=_("maximum side-lobe height")
            label.visible="on";
            value.visible="on";
            init=0.001;fact=1000;
            value.string=string(init)
            scroll.min=1d-10*fact
            scroll.max=1*fact
            scroll.value=init*fact
            d=scroll.userdata;d(2)=fact
            set(scroll,"userdata",d)
            scroll.visible="on";
        end
    end
    wfirUpdate(gcbo)
endfunction

function wfirSetFilterView()
    h=gcbo //handle on the view check box
    if h.value==0 //disable
        fig=h.userdata
        execstr("delete(fig)","errcatch")
        h.userdata=[]
    else //enable
        nwin=size(winsid(),"*")
        if nwin==0 then win=1;else win=max(winsid())+1;end
        fig=scf(win)
        a=gca();
        a.x_label.text=_("frequency (Hz)")
        a.y_label.text=_("Magnitude (dB)")
        a.axes_visible="on"
        a.grid=ones(1,2)*color("gray");
        xpoly([],[])
        set(h,"userdata",fig)
        clearglobal idle
        wfirUpdate(gcbo)
    end
endfunction

function wfirSetSamplingFrequency()
    Sfreq=gcbo
    ok=execstr("newfreq="+Sfreq.string,"errcatch")==0
    ok=ok&newfreq>0

    if ok then
        Sfreq.ForegroundColor=[0 0 0];
        curfreq=Sfreq.userdata
        gui=gcbo.parent
        H=gui.userdata
        //H=[Fview,Filtertype,Windowtype,Forderv,Forders,Lcfv,Lcfs,Hcfv,Hcfs,Fpv,Fps,Sfreq,Ftv,Wtv]
        //update low and high cutoff frequencies
        r=newfreq/curfreq
        Lcfv=H(6),Lcfs=H(7),Hcfv=H(8),Hcfs=H(9)

        Lcfs.min=Lcfs.min*r
        Lcfs.max=Lcfs.max*r
        Lcfs.value=Lcfs.value*r
        Lcfv.string=string(evstr(Lcfv.string)*r)

        Hcfs.min=Hcfs.min*r
        Hcfs.max=Hcfs.max*r
        Hcfs.value=Hcfs.value*r
        Hcfv.string=string(evstr(Hcfv.string)*r)

        Sfreq.userdata=newfreq
        wfirUpdate(gcbo)
    else
        Sfreq.ForegroundColor=[1 0 0];
    end

endfunction

function [ftype,forder,low,high,wtype,fpar,freq_ech]=wfirGetFilterParameters(H)
    //  low,high,freq_ech are returned in Hz
    //H=[Fview,Filtertype,Windowtype,Forderv,Forders,Lcfv,Lcfs,Hcfv,Hcfs,Fpv,Fps,Sfreq,Ftv,Wtv]
    FT=["lp","hp","bp","sb"]
    WT=["re","tr","hn","hm","kr","ch","ch"]
    Filtertype=H(2);
    Windowtype=H(3);
    Forderv=H(4);
    Lcfv=H(6);
    Hcfv=H(8);
    Fpv=H(10);
    Sfreq=H(12)
    ftype=FT(Filtertype.value)
    wtype=WT(Windowtype.value)
    forder=evstr(Forderv.string)
    if or(ftype==["hp" "sb"]) then
        //force odd ordrer
        if 2*int(forder/2)==forder then forder=forder+1,end
    end
    freq_ech=evstr(Sfreq.string)
    if ftype=="lp" then
        low=evstr(Lcfv.string)
        high=0
    elseif ftype=="hp" then
        low=evstr(Hcfv.string)
        high=0
    else
        low=evstr(Lcfv.string)
        high=evstr(Hcfv.string)
    end
    if Windowtype.value==5 //Kaiser
        fpar=[evstr(Fpv.string) 0]
    elseif Windowtype.value==6 //Chebychev, main lobe constraint df in [0 0.5]
        fpar=[-1 evstr(Fpv.string)]
    elseif Windowtype.value==7  //Chebychev, side lobe constraint dp>0
        fpar=[evstr(Fpv.string) -1]
    else
        fpar=[-1 -1]
    end
endfunction

function  wfirUpdate(h)
    global FILTER;
    gui=h.parent
    H=gui.userdata
    [ftype,forder,low,high,wtype,fpar,freq_ech]= ...
    wfirGetFilterParameters(H)

    if ftype == 'bp' | ftype == 'sb' then
        if low >= high then
                low = high - 1;
        end
    end

    cfreq=[low,high]/freq_ech;
    FILTER =wfir(ftype,forder,cfreq,wtype,fpar);

    if H(1).value==1 then
        old=gcf()
        [ftype,forder,low,high,wtype,fpar,freq_ech]= ...
        wfirGetFilterParameters(H)

    if ftype == 'bp' | ftype == 'sb' then
        if low >= high then
                low = high - 1;
        end
    end

        cfreq=[low,high]/freq_ech;
        [filt,wfm,fr]=wfir(ftype,forder,cfreq,wtype,fpar);
        fig=H(1).userdata
        if ~is_handle_valid(fig) then
            //the window has been closed by user
            fig=scf(max(winsid())+1)
            a=gca();
            a.x_label.text=_("frequency (Hz)")
            a.y_label.text=_("Magnitude (dB)")
            a.axes_visible="on"
            a.grid=ones(1,2)*color("gray");
            xpoly([],[])
            set(H(1),"userdata",fig)
        end
        eps=1d-6;
        frq=linspace(eps,0.5-eps,10*size(FILTER,"*"))
        [frq,repf]=repfreq(syslin("d",poly(FILTER,"z","c"),1),frq)
        scf(fig);drawlater()
        a=gca();p=a.children
        frq=frq(:)*freq_ech
        m=20*log10(abs(repf(:)))
        a.data_bounds=[min(frq) min(m);max(frq) max(m)]
        p.data=[frq m];
        drawnow()
        scf(old)
    end
endfunction

function exprs= wfirGetFilterExprs(H)
    // H=[Fview,Filtertype,Windowtype,Forderv,Forders,Lcfv,Lcfs,Hcfv,Hcfs,Fpv,Fps,Sfreq,Ftv,Wtv]
    FT=["lp","hp","bp","sb"]
    WT=["re","tr","hn","hm","kr","ch","ch"]
    Filtertype=H(2);
    Windowtype=H(3);
    Forderv=H(4);
    Lcfv=H(6);
    Hcfv=H(8);
    Fpv=H(10);
    Sfreq=H(12)
    exprs=[Ftv.string;
    Wtv.string;
    Forderv.string;
    Sfreq.string;
    Lcfv.string
    Hcfv.string;
    Fpv.string]
endfunction

clc;
wfir_gui_demo();


Temporarily disabling a failing API test. I'll fix it soon.

Change-Id: Ibeee491989fd9ae4104a0a3ae3bc7f78f95294a1


fdo#35690: reenable toolkit.AccessibleStatusBarItem as it appears stable

#i86007 -o toolkit.AccessibleButton
#i88332 -o toolkit.AccessibleCheckBox
#i86008 -o toolkit.AccessibleComboBox
-o toolkit.AccessibleDropDownComboBox
-o toolkit.AccessibleDropDownListBox
#i86110 -o toolkit.AccessibleEdit
-o toolkit.AccessibleFixedText
#i86110 -o toolkit.AccessibleList
#i86110 -o toolkit.AccessibleListBox
#i86110 -o toolkit.AccessibleListItem
-o toolkit.AccessibleMenu
-o toolkit.AccessibleMenuBar
#i86009 -o toolkit.AccessibleMenuItem
-o toolkit.AccessibleMenuSeparator
#i52607 -o toolkit.AccessiblePopupMenu
#i86107,i86110 -o toolkit.AccessibleRadioButton
-o toolkit.AccessibleScrollBar
#i111225 -o toolkit.AccessibleStatusBar
-o toolkit.AccessibleStatusBarItem
#i109643 -o toolkit.AccessibleTabControl
#i109643 -o toolkit.AccessibleTabPage
#i86287 -o toolkit.AccessibleToolBox
#i88605 -o toolkit.AccessibleToolBoxItem
-o toolkit.AccessibleWindow
-o toolkit.MutableTreeDataModel
-o toolkit.MutableTreeNode
-o toolkit.TabController
-o toolkit.TabControllerModel
-o toolkit.Toolkit
-o toolkit.UnoControlButton
-o toolkit.UnoControlButtonModel
-o toolkit.UnoControlCheckBox
-o toolkit.UnoControlCheckBoxModel
-o toolkit.UnoControlComboBox
-o toolkit.UnoControlComboBoxModel
-o toolkit.UnoControlContainer
-o toolkit.UnoControlContainerModel
-o toolkit.UnoControlCurrencyField
-o toolkit.UnoControlCurrencyFieldModel
-o toolkit.UnoControlDateField
-o toolkit.UnoControlDateFieldModel
#allegedly was i80788, but still broken: -o toolkit.UnoControlDialog
-o toolkit.UnoControlDialogModel
-o toolkit.UnoControlEdit
-o toolkit.UnoControlEditModel
#i86011 -o toolkit.UnoControlFileControl
-o toolkit.UnoControlFileControlModel
-o toolkit.UnoControlFixedLineModel
-o toolkit.UnoControlFixedText
-o toolkit.UnoControlFixedTextModel
#i86013 -o toolkit.UnoControlFormattedField
-o toolkit.UnoControlFormattedFieldModel
-o toolkit.UnoControlGroupBox
-o toolkit.UnoControlGroupBoxModel
-o toolkit.UnoControlImageControl
-o toolkit.UnoControlImageControlModel
#i86019 -o toolkit.UnoControlListBox
-o toolkit.UnoControlListBoxModel
-o toolkit.UnoControlNumericField
-o toolkit.UnoControlNumericFieldModel
-o toolkit.UnoControlPatternField
-o toolkit.UnoControlPatternFieldModel
-o toolkit.UnoControlProgressBarModel
-o toolkit.UnoControlRadioButton
-o toolkit.UnoControlRadioButtonModel
-o toolkit.UnoControlScrollBarModel
-o toolkit.UnoControlTimeField
-o toolkit.UnoControlTimeFieldModel
-o toolkit.UnoScrollBarControl
#i86020 -o toolkit.UnoSimpleAnimationControl
#i86021 -o toolkit.UnoSimpleAnimationControlModel
-o toolkit.UnoSpinButtonControl
-o toolkit.UnoSpinButtonControlModel
#i86022 -o toolkit.UnoThrobberControl
#i86023 -o toolkit.UnoThrobberControlModel
#i86298 -o toolkit.UnoTreeControl
-o toolkit.UnoTreeModel

#i86007 -o toolkit.AccessibleButton
#i88332 -o toolkit.AccessibleCheckBox
#i86008 -o toolkit.AccessibleComboBox
-o toolkit.AccessibleDropDownComboBox
-o toolkit.AccessibleDropDownListBox
#i86110 -o toolkit.AccessibleEdit
-o toolkit.AccessibleFixedText
#i86110 -o toolkit.AccessibleList
#i86110 -o toolkit.AccessibleListBox
#i86110 -o toolkit.AccessibleListItem
-o toolkit.AccessibleMenu
-o toolkit.AccessibleMenuBar
#i86009 -o toolkit.AccessibleMenuItem
-o toolkit.AccessibleMenuSeparator
#i52607 -o toolkit.AccessiblePopupMenu
#i86107,i86110 -o toolkit.AccessibleRadioButton
-o toolkit.AccessibleScrollBar
#i111225 -o toolkit.AccessibleStatusBar
#fdo#35690 -o toolkit.AccessibleStatusBarItem
#i109643 -o toolkit.AccessibleTabControl
#i109643 -o toolkit.AccessibleTabPage
#i86287 -o toolkit.AccessibleToolBox
#i88605 -o toolkit.AccessibleToolBoxItem
-o toolkit.AccessibleWindow
-o toolkit.MutableTreeDataModel
-o toolkit.MutableTreeNode
-o toolkit.TabController
-o toolkit.TabControllerModel
-o toolkit.Toolkit
-o toolkit.UnoControlButton
-o toolkit.UnoControlButtonModel
-o toolkit.UnoControlCheckBox
-o toolkit.UnoControlCheckBoxModel
-o toolkit.UnoControlComboBox
-o toolkit.UnoControlComboBoxModel
-o toolkit.UnoControlContainer
-o toolkit.UnoControlContainerModel
-o toolkit.UnoControlCurrencyField
-o toolkit.UnoControlCurrencyFieldModel
-o toolkit.UnoControlDateField
-o toolkit.UnoControlDateFieldModel
#allegedly was i80788, but still broken: -o toolkit.UnoControlDialog
-o toolkit.UnoControlDialogModel
-o toolkit.UnoControlEdit
-o toolkit.UnoControlEditModel
#i86011 -o toolkit.UnoControlFileControl
-o toolkit.UnoControlFileControlModel
-o toolkit.UnoControlFixedLineModel
-o toolkit.UnoControlFixedText
-o toolkit.UnoControlFixedTextModel
#i86013 -o toolkit.UnoControlFormattedField
-o toolkit.UnoControlFormattedFieldModel
-o toolkit.UnoControlGroupBox
-o toolkit.UnoControlGroupBoxModel
-o toolkit.UnoControlImageControl
-o toolkit.UnoControlImageControlModel
#i86019 -o toolkit.UnoControlListBox
-o toolkit.UnoControlListBoxModel
-o toolkit.UnoControlNumericField
-o toolkit.UnoControlNumericFieldModel
-o toolkit.UnoControlPatternField
-o toolkit.UnoControlPatternFieldModel
-o toolkit.UnoControlProgressBarModel
-o toolkit.UnoControlRadioButton
-o toolkit.UnoControlRadioButtonModel
-o toolkit.UnoControlScrollBarModel
-o toolkit.UnoControlTimeField
-o toolkit.UnoControlTimeFieldModel
-o toolkit.UnoScrollBarControl
#i86020 -o toolkit.UnoSimpleAnimationControl
#i86021 -o toolkit.UnoSimpleAnimationControlModel
-o toolkit.UnoSpinButtonControl
-o toolkit.UnoSpinButtonControlModel
#i86022 -o toolkit.UnoThrobberControl
#i86023 -o toolkit.UnoThrobberControlModel
#i86298 -o toolkit.UnoTreeControl
-o toolkit.UnoTreeModel


neues Auswertungsskript, 12 neue Funktionen, Dokumentation

clear(); // Löschen aller Variablen
clearglobal(); // Löschen aller globalen Variablen

//********************************************
//              CONSTANTS
//********************************************

PI = 3.14;

//********************************************
//              DATA-IMPORT
//********************************************

// Öffnendialog starten
data_path = uigetfile("*.*","","Select CSV data",%t);

// Einlesen der Daten
delimiter = " ";                                // Ist klar
regex_ignore = '/(Track).*$/';                  // Löschen aller mit "Track" beginnenden Zeilen
header = 5;                                     // Anzahl an Zeilen im Kopf
data = csvRead(data_path, delimiter, [], [], [], regex_ignore, [], header);

// Meta-Daten der Bilder
nOfT = size(data,1) / max(data(:, 2))           // Number of Tracks
nOfI = max(data(:, 2))                          // Number of Images per Track
DELTA_T = 0.02;                                 // 50 FPS
CALIBRATION = 300;                              // Pix per m / mm?
Y_RESOLUTION = 576;                             // Höhe in Pixeln

// Kalibrieren
data = data / CALIBRATION;

// Eingelesenen Datensatz gemäß der Logik beim Tracken in 8 Datensätze unterteilen
// Jeder Datensatz wird logisch in x und y Werte unterteilt
// Gelenk.x und Gelenk.y enthalten jeweils eine 1 spaltige Matrix mit Koordinatenwerten
// Multiplikation mit -1 der y-Werte um "natürliches Koordinatensystem" zu erhalten
for i = 1 : nOfT
    if i == 1 then
        toes.x = data(nOfI*(i - 1) + 1:i*nOfI , 3);
        toes.y = data(nOfI*(i - 1) + 1:i*nOfI , 4) * (-1) + Y_RESOLUTION;
    elseif i == 2 then
        ankle.x = data(nOfI*(i - 1) + 1:i*nOfI , 3);
        ankle.y = data(nOfI*(i - 1) + 1:i*nOfI , 4) * (-1) + Y_RESOLUTION;
    elseif i == 3 then
        knee.x = data(nOfI*(i - 1) + 1:i*nOfI , 3);
        knee.y = data(nOfI*(i - 1) + 1:i*nOfI , 4) * (-1) + Y_RESOLUTION;
    elseif i == 4 then
        hip.x = data(nOfI*(i - 1) + 1:i*nOfI , 3);
        hip.y = data(nOfI*(i - 1) + 1:i*nOfI , 4) * (-1) + Y_RESOLUTION;
    elseif i == 5 then
        shoulder.x = data(nOfI*(i - 1) + 1:i*nOfI , 3);
        shoulder.y = data(nOfI*(i - 1) + 1:i*nOfI , 4) * (-1) + Y_RESOLUTION;
    elseif i == 6 then
        elbow.x = data(nOfI*(i - 1) + 1:i*nOfI , 3);
        elbow.y = data(nOfI*(i - 1) + 1:i*nOfI , 4) * (-1) + Y_RESOLUTION;
    elseif i == 7 then
        hand.x = data(nOfI*(i - 1) + 1:i*nOfI , 3);
        hand.y = data(nOfI*(i - 1) + 1:i*nOfI , 4) * (-1) + Y_RESOLUTION;
    elseif i == 8 then
        neck.x = data(nOfI*(i - 1) + 1:i*nOfI , 3);
        neck.y = data(nOfI*(i - 1) + 1:i*nOfI , 4) * (-1) + Y_RESOLUTION;
    end
end

//********************************************
//              NUMERICS
//********************************************

// Ableiten per Vorwärtsdifferenz, erster Wert wird gesetzt
// Übergabe: 1 Spaltige Matrix, Skalares Delta-t
// Rückgabe: 1 Spaltige Matrix
function [fdiff] = ForwardDiff (values, delta)
    fdiff(1) = (values(2) - values(1)) / delta;
    for i = 2 : size(values, 1)
        fdiff(i, 1) = (values(i) - values(i - 1)) / delta;
    end
endfunction

// Ableiten per Rückwärtsdifferenz, letzter Wert wird gesetzt
// Übergabe: 1 Spaltige Matrix, Skalares Delta-t
// Rückgabe: 1 Spaltige Matrix
function [bdiff] = BackwardDiff (values, delta)
    endofdata = size(values,1)
    for i = 1 : endofdata - 1
        bdiff(i) = (values(i + 1) - values(i)) / delta;
    end
    bdiff(endofdata) = (values(endofdata) - values(endofdata - 1)) / delta;
endfunction

// Ableiten per Zentraldifferenz, Mittelwert aus Vorwärts und Rückwärtsdifferenz
// Übergabe: 1 Spaltige Matrix, Skalares Delta-t
// Rückgabe: 1 Spaltige Matrix
function [cdiff]= CentralDiff (values, delta)
    cdiff = (BackwardDiff(values, delta) + ForwardDiff(values, delta)) / 2
endfunction

// Vektorielle Größe in Skalare Größe umwandeln
// Übergabe: Struct mit 1 Spalte x und 1 Spalte y Werten
// Rückgabe: Matrix mit 1 Spalte absoluten Werten
function [scalarValues] = GetScalar(jointData)
    for i = 0 : size(jointData.x, 1)
        scalarValues(i) = sqrt(jointData.x(i)^2 + jointData.y(i)^2);
    end
endfunction

// Gleitenden Mittelwert eines Datensatzes berechnen
// Übergabe: Eine 1 spaltige Matrix
// Rückgabewert: Eine 1 spaltige Matrix
// Erster und letzter Wert werden nicht verändert, Länge der Matrix wird
// beibehalten
function [movingMean] = MovingMean (values)
    movingMean(1) = values(1);
    endofdata = size(values,1)
    for i = 2 : endofdata - 1
        movingMean = (values(i-1) + values(i) + values(i+1)) / 3;
    end
    movingMean(endofdata) = values(endofdata);
endfunction

// Gewichteter Mittelwert eines Datensatzes berechnen
// Übergabe: Eine 1 spaltige Matrix, drei Gewichtungswerte für vorhergehenden
//           aktuellen und nachfolgenden Wert
// Rückgabe: Eine 1 spaltige Matrix
function [weightedMovingMean] = WeightedMovingMean (values, weightA, weightB, weightC)
    weightedMovingMean(1) = values(1);
    endofdata = size(values,1)
    for i = 2 : endofdata - 1
        weightedMovingMean = (values(i-1) * weightA + values(i) * weightB + values(i+1) * weightC) / (weightA + weightB + weightC);
    end
    weightedMovingMean(endofdata) = values(endofdata);
endfunction

// Abstand zwischen zwei Punkten über Satz des Pythagoras
// Übergabe: Zwei 2 Spaltige Matrizen
// Rückgabe: Eine 1 Spaltige Matrix mit Skalaren Entfernungswerten
function [limbLength] = GetLimbLength (proximalJoint, distalJoint)
        dx = distalJoint.x(i) - proximalJoint.x(i);
        dy = distalJoint.y(i) - proximalJoint.y(i);
        limbLength(i) = sqrt((dx)^2 + (dy)^2);
endfunction

//********************************************
//              LOKO-FUNCTIONS
//********************************************

// Massenschwerpunkt eines Körperteils berechnen per Anthroprometrie
// Übergabe: Zwei 2 Spaltige Matrizen und skalarer Wert aus Tabelle
// Rückgabe: Eine Zweispaltige Matrix mit Koordinaten des Masseschwerpunkts
function [CoM] = CalcCoM(proximalJoint, distalJoint, anthrof)
    for i = 1 : size(proximalJoint.x,1)
        dx = distalJoint.x(i) - proximalJoint.x(i);
        dy = distalJoint.y(i) - proximalJoint.y(i);
        CoM(i, 1) = dx * anthrof + proximalJoint.x(i);
        CoM(i, 2) = dy * anthrof + proximalJoint.y(i);
    end
endfunction

// Translative Geschwindigkeit eines Punktes / Gelenks berechnen per Zentraldiff
// Übergabe: Eine 2 Spaltige Matrix mit Ortskoordinaten
// Rückgabe: Eine 2 Spaltige Matrix mit Geschwindigkeitsvektoren
function [speed]= CalcSpeed (joint)
    speed.x = CentralDiff(joint.x, DELTA_T);
    speed.y = CentralDiff(joint.y, DELTA_T);
endfunction

// Translative Beschleunigung eines Punktes per Zentraldifferenz
// Übergabe: Eine 2 spaltige Matrix mit Ortskoordinaten
// Rückgabe: Eine 2 spaltige Matrix mit Beschleunigungsvektoren
function [transAcc] = CalcAcceleration (joint)
    speed = CalcSpeed(joint);
    transAcc = CalcSpeed(speed);
endfunction
// Winkel der am mittleren Gelenk von drei übergebenen Gelenken anliegt
// Übergabe: Drei 2 spaltige Matrizen mit Koordinaten
// Rückgabe: Eine 1 spaltige Matrix mit skalaren Winkelwerten (Einheit Grad)
function [angle] = CalcAngle(proximalJoint, middleJoint, distalJoint)
    dxProx = proximalJoint.x - middleJoint.x;
    dyProx = proximalJoint.y - middleJoint.y;
    dxDist = middleJoint.x - distalJoint.x;
    dyDist = middleJoint.y - distalJoint.y;
    angle = (atan(dyProx, dxProx) + atan(dxDist, dyDist)) / (2 * PI) * 180;
endfunction

// Winkelgeschwindigkeit am mittleren Gelenk von drei übergebenen Gelenken
// Übergabe: Drei 2 spaltige Matrizen mit Koordinaten
// Rückgabe: Eine 1 spaltige Matrix mit skalaren Winkelgeschw.werten (Einheit Grad/s)
function [angSpeed]= CalcAngSpeed (proximalJoint, middleJoint, distalJoint)
    angle = CalcAngle(proximalJoint, middleJoint, distalJoint);
    angSpeed = CentralDiff(angle, DELTA_T);
endfunction

plot(knee.x,knee.y,'or'); // Plot x, y, ?

//savetarget = uiputfile("*.txt*");

//fprintfMat(savetarget, UsS); // Speichern fprintfMat(Zielpfad, Daten)

clear(); // Löschen aller Variablen
clearglobal(); // Löschen aller globalen Variablen

// Öffnendialog starten
data_path = uigetfile("*.*","","Select CSV data",%t);

// einlesen der Daten
data = fscanfMat(data_path);

numOfTracks = max(data(:,2));
numOfImg = max(data(:,3));

// Spalten
// 2 = TrackID
// 3 = ImageID
// 4 = Xcoord
// 5 = Ycoord

// Trackfolge
// 1 = Ferse
// 2 = Ballen
// 3 = Knöchel
// 4 = Knie

toes = struct('x','y');
heel = struct('x','y');
ankle = struct('x','y');
knee = struct('x','y');

// Bool Anweisung, >, >=, <, <=, ==, ~=
// Größer, Grö.gl., Kleiner, Kl.gl., Gl., ungl.

lowerLimbLength = [];

for i = 1 : numOfImg

    if i == 1 then
        heel.x = data(10*(i - 1) + 1:i*10 , 4);
        heel.y = data(10*(i - 1) + 1:i*10 , 5) * (-1) + 2;
    elseif i == 2 then
        toes.x = data(10*(i - 1) + 1:i*10 , 4);
        toes.y = data(10*(i - 1) + 1:i*10 , 5) * (-1) + 2;
    elseif i == 3 then
        ankle.x = data(10*(i - 1) + 1:i*10 , 4);
        ankle.y = data(10*(i - 1) + 1:i*10 , 5) * (-1) + 2;
    elseif i == 4 then
        knee.x = data(10*(i - 1) + 1:i*10 , 4);
        knee.y = data(10*(i - 1) + 1:i*10 , 5) * (-1) + 2;
    end
end

disp(ankle.x)       // Equivalent zu print()
disp(ankle.y)

function [distance, CoM] = calcCoM(proximalJoint, distalJoint, anthrof)
    for i = 1 : size(proximalJoint.x,1)
        dx = distalJoint.x(i) - proximalJoint.x(i);
        dy = distalJoint.y(i) - proximalJoint.y(i);
        distance(i) = sqrt((dx)^2 + (dy)^2);
        CoM(i, 1) = dx * anthrof + proximalJoint.x(i);
        CoM(i, 2) = dy * anthrof + proximalJoint.y(i);
    end
endfunction

lowerLimb = [];
centerOfMassLowerLimb = [];

lowerLimb, centerOfMassLowerLimb = calcCoM(knee, ankle, 0.433)

for i = 1:size(ankle.x,1)
    dx = ankle.x(i) - knee.x(i);
    dy = ankle.y(i) - knee.y(i);
    lowerLimbLength(i) = sqrt( (dx)^2 + (dy)^2);
    UsS(i,1) = dx*0.433 + knee.x(i);
    UsS(i,2) = dy*0.433 + knee.y(i);
end

plot(knee.x,knee.y,'or'); // Plot x, y, ?

savetarget = uiputfile("*.txt*");

fprintfMat(savetarget, UsS); // Speichern fprintfMat(Zielpfad, Daten)


sb123: #i112746# disabled fwk.ModuleManager for now

-o fwl.ContentHandlerFactory
-o fwl.FilterFactory
-o fwl.FrameLoaderFactory
-o fwl.SubstituteVariables
-o fwl.TypeDetection
#i84346 -o fwl.PathSettings
-o fwk.DispatchRecorder
-o fwk.DispatchRecorderSupplier
-o fwk.FooterMenuController
-o fwk.ObjectMenuController
-o fwk.StatusBarControllerFactory
-o fwk.ToolBarsMenuController
-o fwk.UICategoryDescription
#i84423 -o fwk.JobExecutor
#i84423 -o fwk.JobHandler
-o fwk.MailToDispatcher
-o fwk.ServiceHandler
-o fwk.URLTransformer
-o fwk.MacrosMenuController
#i112746 -o fwk.ModuleManager
-o fwk.UIElementFactoryManager
-o fwk.UICommandDescription
-o fwk.LayoutManager
-o fwk.UIConfigurationManager
-o fwk.MenuBarFactory
-o fwk.FontSizeMenuController
-o fwk.HeaderMenuController
-o fwk.ControlMenuController
-o fwk.FontMenuController
-o fwk.ModuleUIConfigurationManagerSupplier
-o fwk.ModuleUIConfigurationManager
#i84321 -o fwk.PopupMenuControllerFactory
#i88644 -o fwk.Frame
-o fwk.Desktop

-o fwl.ContentHandlerFactory
-o fwl.FilterFactory
-o fwl.FrameLoaderFactory
-o fwl.SubstituteVariables
-o fwl.TypeDetection
#i84346 -o fwl.PathSettings
-o fwk.DispatchRecorder
-o fwk.DispatchRecorderSupplier
-o fwk.FooterMenuController
-o fwk.ObjectMenuController
-o fwk.StatusBarControllerFactory
-o fwk.ToolBarsMenuController
-o fwk.UICategoryDescription
#i84423 -o fwk.JobExecutor
#i84423 -o fwk.JobHandler
-o fwk.MailToDispatcher
-o fwk.ServiceHandler
-o fwk.URLTransformer
-o fwk.MacrosMenuController
-o fwk.ModuleManager
-o fwk.UIElementFactoryManager
-o fwk.UICommandDescription
-o fwk.LayoutManager
-o fwk.UIConfigurationManager
-o fwk.MenuBarFactory
-o fwk.FontSizeMenuController
-o fwk.HeaderMenuController
-o fwk.ControlMenuController
-o fwk.FontMenuController
-o fwk.ModuleUIConfigurationManagerSupplier
-o fwk.ModuleUIConfigurationManager
#i84321 -o fwk.PopupMenuControllerFactory
#i88644 -o fwk.Frame
-o fwk.Desktop


INTEGRATION: CWS qadev32 (1.6.34); FILE MERGED 2008/04/16 18:05:59 cn 1.6.34.1: #i87216# update lists

-o forms.OButtonControl
-o forms.OButtonModel
-o forms.OCheckBoxControl
-o forms.OCheckBoxModel
-o forms.OComboBoxControl
-o forms.OComboBoxModel
-o forms.OCurrencyControl
-o forms.OCurrencyModel
#-o forms.ODatabaseForm
-o forms.ODateControl
-o forms.ODateModel
-o forms.OEditControl
-o forms.OEditModel
-o forms.OFileControlModel
-o forms.OFixedTextModel
-o forms.OFormattedControl
-o forms.OFormattedFieldWrapper
# LSST EIN DOKUMENT OFFEN -o forms.OFormsCollection
-o forms.OGridControlModel
-o forms.OGroupBoxControl
-o forms.OGroupBoxModel
-o forms.OHiddenModel
-o forms.OImageButtonControl
-o forms.OImageButtonModel
-o forms.OImageControlControl
-o forms.OImageControlModel
-o forms.OListBoxControl
-o forms.OListBoxModel
-o forms.ONavigationBarControl
-o forms.ONavigationBarModel
-o forms.ONumericControl
-o forms.ONumericModel
-o forms.OPatternControl
-o forms.OPatternModel
-o forms.ORadioButtonControl
-o forms.ORadioButtonModel
-o forms.OScrollBarModel
-o forms.OSpinButtonModel
-o forms.OTimeControl
-o forms.OTimeModel

-o forms.OButtonControl
-o forms.OButtonModel
-o forms.OCheckBoxControl
-o forms.OCheckBoxModel
-o forms.OComboBoxControl
-o forms.OComboBoxModel
-o forms.OCurrencyControl
-o forms.OCurrencyModel
#-o forms.ODatabaseForm
-o forms.ODateControl
-o forms.ODateModel
-o forms.OEditControl
-o forms.OEditModel
-o forms.OFileControlModel
-o forms.OFixedTextModel
-o forms.OFormattedControl
-o forms.OFormattedFieldWrapper
-o forms.OFormsCollection
-o forms.OGridControlModel
-o forms.OGroupBoxControl
-o forms.OGroupBoxModel
-o forms.OHiddenModel
-o forms.OImageButtonControl
-o forms.OImageButtonModel
-o forms.OImageControlControl
-o forms.OImageControlModel
-o forms.OListBoxControl
-o forms.OListBoxModel
-o forms.ONavigationBarControl
-o forms.ONavigationBarModel
-o forms.ONumericControl
-o forms.ONumericModel
-o forms.OPatternControl
-o forms.OPatternModel
-o forms.ORadioButtonControl
-o forms.ORadioButtonModel
-o forms.OScrollBarModel
-o forms.OSpinButtonModel
-o forms.OTimeControl
-o forms.OTimeModel