IMAGE record

EXTERNAL olib
EXTERNAL hwim

INCLUDE p_std.h
INCLUDE p_gen.h
INCLUDE p_que.h
INCLUDE p_object.h
INCLUDE p_file.h
INCLUDE epoc.h
INCLUDE wlib.h
INCLUDE olib.g
INCLUDE varray.g
INCLUDE appman.g
INCLUDE timer.g
INCLUDE bwin.g
INCLUDE matcher.g
INCLUDE listbox.g
INCLUDE pulldown.g
INCLUDE hwimman.g

CLASS waveao active
Sound file record and play
    {
    REPLACE ao_init            Queue into appman and init callback
    REPLACE ao_run             Call back
    REPLACE ao_cancel          Cancel sound
    ADD wv_record              Start recording a file
    ADD wv_play                Start playing a file
    ADD wv_stop                Start playing/recording a file
    PROPERTY
        {
        WORD request;          Request type
        PR_ROOT *hdone;        Callback handle on completion
        UWORD done_record;     Callback method on record completion
        UWORD done_play;       Callback method on playback completion
        }
    }

CLASS wvefile root
Sound file
    {
    ADD wve_new               Create a new file
    ADD wve_open              Open an existing file
    ADD wve_sense_fname       Sense the file name (for reading)
    ADD wve_sense_info        Fill in a WVEFILE_INFO struct
    ADD wve_set_repeats       Set the repeat and silence
    TYPES
        {
        typedef struct
            {
            TEXT *device;       address of device character
            TEXT *name;         file name component
            WORD ret;           possible error return
            WORD nmlen;         length of file name
            UWORD duration;     duration in 10ths of a sec
            UWORD silence;      silence in 10ths of a second
            UWORD repeats;      number of repeats
            ULONG total;        total time in seconds (with repeats & silence)
            ULONG samples;      number of samples
            ULONG flen;         file length
            } WVEFILE_INFO;
        }
    PROPERTY
        {
        VOID *fcb;
        WORD ret;
        P_FPARSE crk;
        TEXT fname[P_FNAMESIZE];
        P_INFO info;
        SndFile head;
        }
    }

CLASS receng root
    {
    ADD eng_init
    ADD eng_new_file         Start a new file
    ADD eng_open_file        Open an existing file (close any current file)
    ADD eng_sense_file       Get the current file name
    ADD eng_file_info        Get information on the current file
    ADD eng_default_disk     Return default device for new file
    ADD eng_view_update      Call back view to update itself
    ADD eng_done_record      Callback from active object on record completion
    ADD eng_done_play        Callback from active object on play completion
    ADD eng_sound_play       Play the current file
    ADD eng_sound_record     Record to the current file
    ADD eng_sound_stop       Stop the current record or playback
    ADD eng_set_repeats      Set the number of repeats and trailing silence
    ADD eng_set_prefs        Set the persistent preferences
    ADD eng_sense_prefs      Sense the persistent preferences
    TYPES
        {
        typedef struct
            {
            WORD volume;             volume for playback
            WORD duration;           maximum duration in 10ths of a sec
            WORD disk;               preferred disk for new files
            } RECENG_PREFS;
        }
    PROPERTY 2
        {
        PR_WVEFILE *wvefile;         digital sound file
        PR_WAVEAO *waveao;           record/play active object
        PR_ROOT *hview;              callback view handle
        UWORD mupdate;               callback view method for update
        UWORD msound;                callback view method for begin sound
        RECENG_PREFS prefs;          persistent preferences
        }
    }

CLASS reccom  comman
    {
    REPLACE com_file_change      from System application
    ADD com_set_repeat           Set repeat menu command
    ADD com_rep_alarm            Repeat for alarm menu command
    ADD com_preferences          Set preferences menu command
    ADD com_new_file             New file menu command
    ADD com_open_file            Open file menu command
    ADD com_record_new           Record new (Tab) button
    ADD com_re_record            Record over (Space) button
    TYPES
        {
        typedef struct
            {
            WORD duration;
            TEXT fname[P_FNAMESIZE];
            } RECRBUF;
        }
    }

CLASS recman hwimman
    {
    REPLACE am_clean_up
    }

CLASS recwserv    wserv
    {
    REPLACE ws_dyn_init
    }

CLASS timebar  active
    {
    REPLACE ao_init         Queue into appman and set priority
    REPLACE ao_queue        Queue next read
    REPLACE ao_run          Update on tick
    ADD tb_start            Start time bar
    ADD tb_stop             Stop time bar
    ADD tb_draw             For redraw
    PROPERTY
        {
        WORD visible;       Visible if TRUE
        WORD wid;           Window id of landlord
        LONG tenths0;       Initial value of timer
        LONG tenths;        Counted down value of timer
        WORD x;             Bar value in pixels
        P_RECT rect;        Bar rectangle
        }
    }

CLASS recbut  root
    {
    REPLACE destroy
    ADD rb_init
    ADD rb_draw
    ADD rb_depress
    ADD rb_hide
    PROPERTY
        {
        WORD hide;          Hide button if TRUE
        WORD wid;           Window id of landlord
        P_RECT rect;        Button rectangle
        VOID *buttxt;       As loaded from resource file
        TEXT *inlabel;      Button label
        TEXT *caption;      Caption above button
        WORD caplen;        Caption length
        }
    }

CLASS reccli  bwin
    {
    REPLACE destroy
    REPLACE wn_connect
    REPLACE wn_draw
    REPLACE wn_key
    ADD cl_update                 Viewed data has changed
    ADD cl_sound_filter           To catch keys while recording or playing
    ADD cl_pause_filter           To catch keys while waiting to record
    ADD cl_begin_sound
    ADD cl_pause
    PROPERTY 6
        {
        PR_TIMEBAR *timebar;
        PR_RECBUT *recbut[5];
        UINT duration;            Stored for pause to record
        WORD running;             TRUE if sound record/play running
        WORD width;               Window width
        VOID *clitxt;             Allocated resource
        TEXT *secs;               Seconds suffix
        TEXT *title;              Title format string
        TEXT *sub;                Subtitle format string
        TEXT tsep;                Time separator
        UBYTE spare;
        }
    }

CLASS setrep  dlgbox
    {
    REPLACE dl_dyn_init
    REPLACE dl_key
    }

CLASS setpref  dlgbox
    {
    REPLACE dl_dyn_init
    REPLACE dl_key
    }

CLASS recnew  dlgbox
Record to new file dialog
    {
    REPLACE dl_dyn_init
    REPLACE dl_key
    }

CLASS recnewdef  recnew
Record to new file dialog with a default name
    {
    REPLACE dl_set_size
    }

CLASS recexist  recnew
Record to existing file dialog
    {
    REPLACE dl_dyn_init
    REPLACE dl_set_size
    }

CLASS recopen  dlgbox
Open file dialog
    {
    REPLACE dl_key
    }
