home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format 119 / af119sub.adf / SamEd.lzx / SamEd / Developers / WaveEditClass.c < prev    next >
C/C++ Source or Header  |  2001-06-09  |  20KB  |  582 lines

  1. #define MAX_PNTS 100
  2.  
  3. void DrawOldRange(struct IClass *,Object *);
  4. void DrawNewRange(struct IClass *,Object *);
  5. void DrawWave(struct IClass *,Object *);
  6. void DrawEnv(struct IClass *,Object *);
  7. void DrawEnvPnt(struct IClass *,Object *);
  8.  
  9. LONG FindPnt(struct IClass *, Object *, ULONG, UBYTE);
  10. ULONG FindSamp(struct IClass *, Object *, ULONG, UBYTE);
  11. ULONG Bytes_To_Samples(struct IClass *, Object *, ULONG);
  12. ULONG Samples_To_Bytes(struct IClass *, Object *, ULONG);
  13.  
  14.  
  15. struct WaveData
  16. {
  17.     BYTE *waveform;
  18.     ULONG length;
  19.     LONG curs, start, end, oldstart, oldend, shown, visible, loop_start, loop_end;
  20.     ULONG draw, quickdraw, vlinegap, type;
  21.     ULONG used, current;
  22.     UWORD x[MAX_PNTS], lev[MAX_PNTS];
  23.     UWORD oldx, oldlev;
  24.     UWORD editmode;
  25. };
  26.  
  27. #define MUIM_Waveform_Update        0x80500000
  28. #define MUIM_Envelope_AddPnt        0x80500001
  29. #define MUIM_Envelope_DelPnt        0x80500002
  30.  
  31. #define MUIA_Waveform_Waveform      0x8022
  32. #define MUIA_Waveform_Length        0x8023
  33. #define MUIA_Waveform_Curs          0x8024
  34. #define MUIA_Waveform_RangeStart    0x8025
  35. #define MUIA_Waveform_RangeEnd      0x8026
  36. #define MUIA_Waveform_ShownStart    0x8027
  37. #define MUIA_Waveform_Visible       0x8028
  38. #define MUIA_Waveform_Draw          0x8029
  39. #define MUIA_Envelope_Used          0x8030
  40. #define MUIA_Envelope_Current       0x8031
  41. #define MUIA_Envelope_X             0x8032
  42. #define MUIA_Envelope_Level         0x8033
  43. #define MUIA_Waveform_EditMode      0x8034
  44. #define MUIA_Waveform_VLineGap      0x8035
  45. #define MUIA_Waveform_Type          0x8036
  46. #define MUIA_Waveform_RangeStartSam 0x8037
  47. #define MUIA_Waveform_RangeEndSam   0x8038
  48.  
  49. /*waveform draw modes*/
  50. #define WDM_NONE        0
  51. #define WDM_LINE        1
  52. #define WDM_PIXEL1      2
  53. #define WDM_PIXEL2      3
  54. #define WDM_PIXEL3      4
  55. #define WDM_PIXELALL    5
  56. #define WDM_VFILLHALF   6
  57. #define WDM_VFILL       7
  58. #define WDM_RANGE       8
  59. #define WDM_HGRID       16
  60. #define WDM_VGRID       32
  61. #define WDM_ENVBLOCKS   64
  62. #define WDM_ENVLINES    128
  63.  
  64. /*quick draw modes*/
  65. #define QDM_ALL         0
  66. #define QDM_RANGE       1
  67. #define QDM_ENVPNT      2
  68. #define QDM_WAVE        3
  69.  
  70. /*edit modes*/
  71. #define EM_NONE         0
  72. #define EM_RANGE        1
  73. #define EM_RANGELOOP    2
  74. #define EM_ENV          3
  75.  
  76. #include "waveeditclassdraw.c"
  77.  
  78. SAVEDS ULONG mNew(struct IClass *cl,Object *obj,Msg msg)
  79. {
  80.     struct WaveData *data;
  81.  
  82.     if (!(obj = (Object *)DoSuperMethodA(cl,obj,msg)))
  83.             return(0);
  84.  
  85.     data = INST_DATA(cl,obj);
  86.  
  87.     data->waveform = NULL;
  88.     data->length = NULL;
  89.     data->curs = data->start = data->end = data->oldstart = data->oldend = data->draw = NULL;
  90.     data->current =  data->quickdraw = 0;
  91.     data->draw = WDM_LINE | WDM_RANGE | WDM_HGRID | WDM_VGRID;
  92.     data->vlinegap = 10000;
  93.     data->type = STYPE_M8;
  94.     data->editmode = EM_RANGE;
  95.     data->used = 2;
  96.     for(ULONG n = 0; n < MAX_PNTS; n++)
  97.     {
  98.         data->lev[n]  = 32768;
  99.         data->x[n] = 32768;
  100.     }
  101.     data->x[0] = 0;
  102.     data->x[1] = 65535;
  103.     data->oldx = data->x[data->current];
  104.     data->oldlev = data->lev[data->current];
  105.  
  106.     msg->MethodID = OM_SET;
  107.     DoMethodA(obj, (Msg)msg);
  108.     msg->MethodID = OM_NEW;
  109.  
  110.     return((ULONG)obj);
  111. }
  112.  
  113.  
  114.  
  115. SAVEDS ULONG mDispose(struct IClass *cl,Object *obj,Msg msg)
  116. {
  117.         /* OM_NEW didnt allocate anything */
  118.         return(DoSuperMethodA(cl,obj,msg));
  119. }
  120.  
  121.  
  122. SAVEDS ULONG mSet(struct IClass *cl,Object *obj,Msg msg)
  123. {
  124.     struct WaveData *data = INST_DATA(cl,obj);
  125.     struct TagItem *tags,*tag;
  126.  
  127.     for (tags=((struct opSet *)msg)->ops_AttrList;tag=NextTagItem(&tags);)
  128.     {
  129.         switch (tag->ti_Tag)
  130.         {
  131.             case MUIA_Waveform_Waveform:
  132.                 data->waveform = (BYTE *)tag->ti_Data;
  133.                 /*MUI_Redraw(obj,MADF_DRAWOBJECT);*/
  134.                 break;
  135.  
  136.             case MUIA_Waveform_Length:
  137.                 data->length = Bytes_To_Samples(cl, obj, tag->ti_Data);
  138.                 /*MUI_Redraw(obj,MADF_DRAWOBJECT);*/
  139.                 break;
  140.  
  141.             case MUIA_Waveform_RangeStart:
  142.                 data->start = Bytes_To_Samples(cl, obj, tag->ti_Data);
  143.                 data->quickdraw = QDM_RANGE;
  144.                 MUI_Redraw(obj,MADF_DRAWUPDATE);
  145.                 data->quickdraw = QDM_ALL;
  146.                 break;
  147.  
  148.             case MUIA_Waveform_RangeEnd:
  149.                 data->end = Bytes_To_Samples(cl, obj, tag->ti_Data);
  150.                 data->quickdraw = QDM_RANGE;
  151.                 MUI_Redraw(obj,MADF_DRAWUPDATE);
  152.                 data->quickdraw = QDM_ALL;
  153.                 break;
  154.  
  155.             case MUIA_Waveform_RangeStartSam:
  156.                 data->start = tag->ti_Data;
  157.                 data->quickdraw = QDM_RANGE;
  158.                 MUI_Redraw(obj,MADF_DRAWUPDATE);
  159.                 data->quickdraw = QDM_ALL;
  160.                 break;
  161.  
  162.             case MUIA_Waveform_RangeEndSam:
  163.                 data->end = tag->ti_Data;
  164.                 data->quickdraw = QDM_RANGE;
  165.                 MUI_Redraw(obj,MADF_DRAWUPDATE);
  166.                 data->quickdraw = QDM_ALL;
  167.                 break;
  168.  
  169.             case MUIA_Waveform_Curs:
  170.                 data->curs = Bytes_To_Samples(cl, obj, tag->ti_Data);
  171.                 /*MUI_Redraw(obj,MADF_DRAWUPDATE);*/
  172.                 break;
  173.  
  174.             case MUIA_Waveform_ShownStart:
  175.                 data->shown = (LONG)Bytes_To_Samples(cl, obj, tag->ti_Data);
  176.                 /*MUI_Redraw(obj,MADF_DRAWUPDATE);*/
  177.                 break;
  178.  
  179.             case MUIA_Waveform_Visible:
  180.                 data->visible = Bytes_To_Samples(cl, obj, tag->ti_Data);
  181.                 /*MUI_Redraw(obj,MADF_DRAWOBJECT);*/
  182.                 break;
  183.  
  184.             case MUIA_Waveform_Draw:
  185.                 data->draw = (ULONG)tag->ti_Data;
  186.                 /*MUI_Redraw(obj,MADF_DRAWOBJECT);*/
  187.                 break;
  188.  
  189.             case MUIA_Envelope_Used:
  190.                 data->used = (ULONG)tag->ti_Data;
  191.                 data->x[data->used -1] = 65535;
  192.                 MUI_Redraw(obj,MADF_DRAWOBJECT);
  193.                 break;
  194.  
  195.             case MUIA_Envelope_Current:
  196.                 data->current = (ULONG)tag->ti_Data;
  197.                 /*MUI_Redraw(obj,MADF_DRAWUPDATE);*/
  198.                 break;
  199.  
  200.             case MUIA_Envelope_X:
  201.                 data->x[data->current] = (UWORD)tag->ti_Data;
  202.                 data->quickdraw = QDM_ENVPNT;
  203.                 MUI_Redraw(obj,MADF_DRAWUPDATE);
  204.                 data->quickdraw = QDM_ALL;
  205.                 break;
  206.  
  207.             case MUIA_Envelope_Level:
  208.                 data->lev[data->current] = (UWORD)tag->ti_Data;
  209.                 data->quickdraw = QDM_ENVPNT;
  210.                 MUI_Redraw(obj,MADF_DRAWUPDATE);
  211.                 data->quickdraw = QDM_ALL;
  212.                 break;
  213.  
  214.             case MUIA_Waveform_EditMode:
  215.                 data->editmode = (UWORD)tag->ti_Data;
  216.                 break;
  217.  
  218.             case MUIA_Waveform_VLineGap:
  219.                 data->vlinegap = (ULONG)tag->ti_Data;
  220.                 MUI_Redraw(obj,MADF_DRAWOBJECT);
  221.                 break;
  222.  
  223.             case MUIA_Waveform_Type:
  224.                 data->type = (ULONG)tag->ti_Data;
  225.                 break;
  226.  
  227.         }
  228.  
  229.         /*if (data->start <0) data->start =0;
  230.         if (data->start > data->length) data->start = data->length;
  231.         if (data->end <0) data->end =0;
  232.         if (data->end > data->length) data->end = data->length;*/
  233.         if (data->shown > data->length) data->shown = 0; /*set(obj,MUIA_Waveform_ShownStart,0);*/
  234.         if ((data->visible + data->shown) > data->length) data->visible = data->length - data->shown; /*set(obj,MUIA_Waveform_Visible,data->length - data->shown);*/
  235.     }
  236.  
  237.     return(DoSuperMethodA(cl,obj,msg));
  238. }
  239.  
  240.  
  241. static ULONG mGet(struct IClass *cl,Object *obj,Msg msg)
  242. {
  243.     struct WaveData *data = INST_DATA(cl,obj);
  244.     ULONG *store = ((struct opGet *)msg)->opg_Storage;
  245.  
  246.     switch (((struct opGet *)msg)->opg_AttrID)
  247.     {
  248.         case MUIA_Waveform_Waveform: *store = (ULONG)data->waveform; return(TRUE);
  249.  
  250.         case MUIA_Waveform_Length: *store = Samples_To_Bytes(cl, obj, data->length); return(TRUE);
  251.  
  252.         case MUIA_Waveform_RangeStart:
  253.             if(data->start > data->end) /*make sure the start is before the end*/
  254.             {
  255.                 LONG temp = data->end;
  256.                 data->end = data->start;
  257.                 data->start = temp;
  258.             }
  259.             *store = Samples_To_Bytes(cl, obj, data->start); return(TRUE);
  260.  
  261.         case MUIA_Waveform_RangeEnd:
  262.             if(data->start > data->end) /*make sure the start is before the end*/
  263.             {
  264.                 LONG temp = data->end;
  265.                 data->end = data->start;
  266.                 data->start = temp;
  267.             }
  268.             *store = Samples_To_Bytes(cl, obj, data->end); return(TRUE);
  269.  
  270.         case MUIA_Waveform_RangeStartSam:
  271.             if(data->start > data->end) /*make sure the start is before the end*/
  272.             {
  273.                 LONG temp = data->end;
  274.                 data->end = data->start;
  275.                 data->start = temp;
  276.             }
  277.             *store = data->start; return(TRUE);
  278.  
  279.         case MUIA_Waveform_RangeEndSam:
  280.             if(data->start > data->end) /*make sure the start is before the end*/
  281.             {
  282.                 LONG temp = data->end;
  283.                 data->end = data->start;
  284.                 data->start = temp;
  285.             }
  286.             *store = data->end; return(TRUE);
  287.  
  288.         case MUIA_Waveform_Curs: *store = Samples_To_Bytes(cl, obj, data->curs); return(TRUE);
  289.  
  290.         case MUIA_Waveform_ShownStart: *store = Samples_To_Bytes(cl, obj, data->shown); return(TRUE);
  291.  
  292.         case MUIA_Waveform_Visible: *store = Samples_To_Bytes(cl, obj, data->visible); return(TRUE);
  293.  
  294.         case MUIA_Waveform_Draw: *store = (ULONG)data->draw; return(TRUE);
  295.  
  296.         case MUIA_Envelope_Used: *store = (ULONG)data->used; return(TRUE);
  297.  
  298.         case MUIA_Envelope_Current: *store = (ULONG)data->current; return(TRUE);
  299.  
  300.         case MUIA_Envelope_X: *store = (ULONG)data->x[data->current]; return(TRUE);
  301.  
  302.         case MUIA_Envelope_Level: *store = (ULONG)data->lev[data->current]; return(TRUE);
  303.  
  304.         case MUIA_Waveform_EditMode: *store = (ULONG)data->lev[data->editmode]; return(TRUE);
  305.  
  306.         case MUIA_Waveform_VLineGap: *store = (ULONG)data->vlinegap; return(TRUE);
  307.  
  308.         case MUIA_Waveform_Type: *store = (ULONG)data->type; return(TRUE);
  309.     }
  310.  
  311.     return(DoSuperMethodA(cl,obj,msg));
  312. }
  313.  
  314.  
  315. ULONG Bytes_To_Samples(struct IClass *cl, Object *obj, ULONG bytes)
  316. {
  317.     struct WaveData *data = INST_DATA(cl,obj);
  318.     ULONG samples;
  319.     if (data->type == STYPE_M8) samples = bytes;
  320.     if ((data->type == STYPE_M16) || (data->type == STYPE_S8)) samples = bytes /2;
  321.     if ((data->type == STYPE_M32) || (data->type == STYPE_S16)) samples = bytes /4;
  322.     if (data->type == STYPE_S32) samples = bytes /8;
  323.     return(samples);
  324. }
  325.  
  326.  
  327. ULONG Samples_To_Bytes(struct IClass *cl, Object *obj, ULONG samples)
  328. {
  329.     struct WaveData *data = INST_DATA(cl,obj);
  330.     ULONG bytes;
  331.     if (data->type == STYPE_M8) bytes = samples;
  332.     if ((data->type == STYPE_M16) || (data->type == STYPE_S8)) bytes = samples *2;
  333.     if ((data->type == STYPE_M32) || (data->type == STYPE_S16)) bytes = samples *4;
  334.     if (data->type == STYPE_S32) bytes = samples *8;
  335.     return(bytes);
  336. }
  337.  
  338. SAVEDS ULONG mSetup(struct IClass *cl,Object *obj,Msg msg)
  339. {
  340.     struct MyData *data = INST_DATA(cl,obj);
  341.  
  342.     if (!DoSuperMethodA(cl,obj,msg))
  343.             return(FALSE);
  344.  
  345.     MUI_RequestIDCMP(obj, IDCMP_MOUSEBUTTONS);
  346.  
  347.     return(TRUE);
  348. }
  349.  
  350.  
  351. SAVEDS ULONG mCleanup(struct IClass *cl,Object *obj,Msg msg)
  352. {
  353.     struct MyData *data = INST_DATA(cl,obj);
  354.  
  355.     MUI_RejectIDCMP(obj, IDCMP_MOUSEBUTTONS);
  356.  
  357.     return(DoSuperMethodA(cl,obj,msg));
  358. }
  359.  
  360.  
  361. SAVEDS ULONG mAskMinMax(struct IClass *cl,Object *obj,struct MUIP_AskMinMax *msg)
  362. {
  363.     DoSuperMethodA(cl,obj,(VOID *)msg);
  364.  
  365.     msg->MinMaxInfo->MinWidth  += 50;
  366.     msg->MinMaxInfo->DefWidth  += 300;
  367.     msg->MinMaxInfo->MaxWidth  += 1000;
  368.  
  369.     msg->MinMaxInfo->MinHeight += 50;
  370.     msg->MinMaxInfo->DefHeight += 70;
  371.     msg->MinMaxInfo->MaxHeight += 500;
  372.  
  373.     return(0);
  374. }
  375.  
  376.  
  377. SAVEDS ULONG mHandleInput(struct IClass *cl,Object *obj,struct MUIP_HandleInput *msg)
  378. {
  379.     #define _between(a,x,b) ((x)>=(a) && (x)<=(b))
  380.     #define _isinobject(x,y) (_between(_mleft(obj),(x),_mright(obj)) && _between(_mtop(obj),(y),_mbottom(obj)))
  381.  
  382.  
  383.     struct WaveData *data = INST_DATA(cl,obj);
  384.  
  385.     if (!msg->imsg) return (0);
  386.  
  387.     if ((data->editmode == EM_RANGE) || (data->editmode == EM_RANGELOOP))
  388.     {
  389.         switch (msg->imsg->Class)
  390.         {
  391.             case IDCMP_MOUSEBUTTONS:
  392.             {
  393.                 if (msg->imsg->Code==SELECTDOWN)
  394.                 {
  395.                     if (_isinobject(msg->imsg->MouseX,msg->imsg->MouseY))
  396.                     {
  397.                         /*Check to edit loop...*/
  398.                         /*lleft = ;
  399.                         if((_between(lleft,msg->imsg->MouseX,lright)) && (_between(ltop,msg->imsg->MouseY,lbottom)))
  400.                         {
  401.                         }
  402.                         else*/
  403.  
  404.                         data->start = (msg->imsg->MouseX - _mleft(obj)) * data->visible / _mwidth(obj) + data->shown;
  405.                         data->end = (msg->imsg->MouseX - _mleft(obj)) * data->visible / _mwidth(obj) + data->shown;
  406.                         data->quickdraw = QDM_RANGE;
  407.                         MUI_Redraw(obj,MADF_DRAWUPDATE);
  408.                         MUI_RequestIDCMP(obj,IDCMP_MOUSEMOVE);
  409.                         data->quickdraw = QDM_ALL;
  410.                     }
  411.                 }
  412.                 else
  413.                 {
  414.                     MUI_RejectIDCMP(obj,IDCMP_MOUSEMOVE);
  415.                     set(obj, MUIA_Waveform_RangeStartSam, data->start);
  416.                     set(obj, MUIA_Waveform_RangeEndSam, data->end);
  417.                 }
  418.             }
  419.             break;
  420.  
  421.             case IDCMP_MOUSEMOVE:
  422.             {
  423.                 if (_between(_mleft(obj),msg->imsg->MouseX,_mright(obj)) )
  424.                 {
  425.                     data->quickdraw = QDM_RANGE;
  426.                     data->end = (msg->imsg->MouseX - _mleft(obj)) * data->visible / _mwidth(obj) + data->shown;
  427.                     MUI_Redraw(obj,MADF_DRAWUPDATE);
  428.                     data->quickdraw = QDM_ALL;
  429.                 }
  430.                 else
  431.                 {
  432.                     if (msg->imsg->MouseX > _mright(obj))
  433.                     {
  434.                         if (!((data->shown += (msg->imsg->MouseX - _mright(obj)) * data->visible / 100) < (data->length - data->visible))) data->shown = (data->length - data->visible);
  435.                         data->end = (msg->imsg->MouseX - _mleft(obj)) * data->visible / _mwidth(obj) + data->shown;
  436.                         /*MUI_Redraw(obj,MADF_DRAWUPDATE);*/
  437.                         SetAttrs(obj,MUIA_Waveform_ShownStart, Samples_To_Bytes(cl ,obj ,data->shown), TAG_DONE);
  438.                     }
  439.                     if (msg->imsg->MouseX < _mleft(obj))
  440.                     {
  441.                         if (!((data->shown += (msg->imsg->MouseX - _mleft(obj)) * data->visible / 100) > 0)) data->shown = 0;
  442.                         data->end = (msg->imsg->MouseX - _mleft(obj)) * data->visible / _mwidth(obj) + data->shown;
  443.                         /*MUI_Redraw(obj,MADF_DRAWUPDATE);*/
  444.                         SetAttrs(obj,MUIA_Waveform_ShownStart, Samples_To_Bytes(cl ,obj ,data->shown), TAG_DONE);
  445.                     }
  446.                 }
  447.             }
  448.             break;
  449.         }
  450.     }
  451.  
  452.  
  453.     if (data->editmode == EM_ENV)
  454.     {
  455.         switch (msg->imsg->Class)
  456.         {
  457.             case IDCMP_MOUSEBUTTONS:
  458.             {
  459.                 if (msg->imsg->Code==SELECTDOWN)
  460.                 {
  461.                     for(UWORD n = 0; n < data->used ; n++)
  462.                     {
  463.                         ULONG x = _mleft(obj) + data->x[n] * (_mwidth(obj) -3) / 65535;
  464.                         ULONG y = _mbottom(obj) -1 - data->lev[n] * (_mheight(obj) -3) / 65535;
  465.  
  466.                         if (_between(x - 2, msg->imsg->MouseX, x + 2) && _between(y - 2, msg->imsg->MouseY, y + 2))
  467.                         {
  468.                             data->current = n;
  469.                             MUI_RequestIDCMP(obj,IDCMP_MOUSEMOVE);
  470.                         }
  471.                     }
  472.  
  473.                     data->quickdraw = QDM_ENVPNT;
  474.                     MUI_Redraw(obj,MADF_DRAWUPDATE);
  475.                     data->quickdraw = QDM_ALL;
  476.                 }
  477.                 else
  478.                     MUI_RejectIDCMP(obj,IDCMP_MOUSEMOVE);
  479.                     MUI_Redraw(obj,MADF_DRAWOBJECT);
  480.             }
  481.             break;
  482.  
  483.             case IDCMP_MOUSEMOVE:
  484.             {
  485.                 LONG x, prevx;
  486.                 ULONG lev;
  487.  
  488.                 if (data->current == 0)
  489.                     data->x[0] = 0;
  490.                 else
  491.                     if (data->current == (data->used -1))
  492.                         data->x[data->used -1] = 65535;
  493.                     else
  494.                     {
  495.                         x = (msg->imsg->MouseX - _mleft(obj)) * 65535 / (_mwidth(obj) -3);
  496.                         prevx = data->x[data->current -1];
  497.                         if (x < prevx) x = data->x[data->current -1];
  498.                         if (x > data->x[data->current +1]) x = data->x[data->current +1];
  499.                         data->x[data->current] = x;
  500.                    }
  501.                 
  502.                 if (_between(_mtop(obj)+4, msg->imsg->MouseY, _mbottom(obj)))
  503.                     lev = msg->imsg->MouseY;
  504.                 else
  505.                     if (msg->imsg->MouseY < (_mtop(obj) +4))
  506.                         lev = _mtop(obj) +4;
  507.                     else
  508.                         lev = _mbottom(obj);
  509.                 
  510.                 data->lev[data->current] = (_mbottom(obj) - lev +1) * 65535 / (_mheight(obj) -3);
  511.                 set(obj,MUIA_Envelope_Level,data->lev[data->current]);
  512.                 data->quickdraw = QDM_ENVPNT;
  513.                 MUI_Redraw(obj,MADF_DRAWUPDATE);
  514.                 data->quickdraw = QDM_ALL;
  515.             }
  516.             break;
  517.         }
  518.     }
  519.  
  520. }
  521.  
  522.  
  523. SAVEDS ULONG mUpdate(struct IClass *cl,Object *obj,Msg msg)
  524. {
  525.     struct WaveData *data = INST_DATA(cl,obj);
  526.  
  527.     set(obj, MUIA_Waveform_Waveform, data->waveform);
  528.     /*set(obj, MUIA_Waveform_Length, data->length);
  529.     set(obj, MUIA_Waveform_ShownStart, data->shown);
  530.     set(obj, MUIA_Waveform_Visible, data->visible);*/
  531.  
  532.     MUI_Redraw(obj,MADF_DRAWOBJECT);
  533.     return(0);
  534. }
  535.  
  536.  
  537. SAVEDS ULONG mAddPnt(struct IClass *cl,Object *obj,Msg msg)
  538. {
  539.     struct WaveData *data = INST_DATA(cl,obj);
  540.  
  541.     data->used++;
  542.  
  543.  
  544.     MUI_Redraw(obj,MADF_DRAWOBJECT);
  545.     return(0);
  546. }
  547.  
  548.  
  549. SAVEDS ULONG mDelPnt(struct IClass *cl,Object *obj,Msg msg)
  550. {
  551.     struct WaveData *data = INST_DATA(cl,obj);
  552.  
  553.     if (data->used > 2) data->used--;
  554.  
  555.  
  556.     MUI_Redraw(obj,MADF_DRAWOBJECT);
  557.     return(0);
  558. }
  559.  
  560.  
  561. SAVEDS ASM ULONG WaveDispatcher(REG(a0) struct IClass *cl,REG(a2) Object *obj,REG(a1) Msg msg)
  562. {
  563.         switch (msg->MethodID)
  564.         {
  565.                 case OM_NEW        : return(mNew      (cl,obj,(APTR)msg));
  566.                 case OM_DISPOSE    : return(mDispose  (cl,obj,(APTR)msg));
  567.                 case OM_SET        : return(mSet      (cl,obj,(APTR)msg));
  568.                 case OM_GET        : return(mGet      (cl,obj,(APTR)msg));
  569.                 case MUIM_AskMinMax: return(mAskMinMax(cl,obj,(APTR)msg));
  570.                 case MUIM_Setup    : return(mSetup    (cl,obj,(APTR)msg));
  571.                 case MUIM_Cleanup  : return(mCleanup  (cl,obj,(APTR)msg));
  572.                 case MUIM_Draw     : return(mDraw     (cl,obj,(APTR)msg));
  573.                 case MUIM_HandleInput   : return(mHandleInput(cl,obj,(APTR)msg));
  574.                 case MUIM_Waveform_Update   : return(mUpdate(cl,obj,(APTR)msg));
  575.                 case MUIM_Envelope_AddPnt   : return(mAddPnt(cl,obj,(APTR)msg));
  576.                 case MUIM_Envelope_DelPnt   : return(mDelPnt(cl,obj,(APTR)msg));
  577.         }
  578.  
  579.         return(DoSuperMethodA(cl,obj,msg));
  580. }
  581.  
  582.