/*	Phrase Shaper

	© 1989 Blue Ribbon Bakery

*/

#include "bars.h"  
#include <libraries/dos.h>
#include <exec/memory.h>
#include <string.h>
#include <intuition/intuition.h>

#define ID_PHRS	0x50485253

static UWORD phrase[] = { 
/*------ plane # 0: --------*/

  0x0,   0x0, 
  0x0,   0x0, 
  0x0,   0x0, 
  0x0,   0x0, 
  0x0,   0x0, 
  0xdc,   0x0, 
  0x5dd,   0xdc00, 
  0x3ddd,   0xdc00, 
  0x3111,   0x1c00, 
  0x3111,   0x1c00, 
  0xfff,   0xf000, 
  0x0,   0x0,
 /*------ plane # 1: --------*/

  0x0,   0x0, 
  0x0,   0x0, 
  0x0,   0x0, 
  0x0,   0x0, 
  0xc0fc,   0x300, 
  0xc7df,   0xff00, 
  0xfddd,   0xdf00, 
  0xfddd,   0xdf00, 
  0x3111,   0x1c00, 
  0x3111,   0x1c00, 
  0xfff,   0xf000, 
  0x0,   0x0,
 /*------ plane # 2: --------*/

  0x0,   0x0, 
  0xfff,   0xf000, 
  0x3fff,   0xfc00, 
  0x3fff,   0xfc00, 
  0x3fff,   0xfc00, 
  0x3fdf,   0xfc00, 
  0x3ddd,   0xdc00, 
  0x3ddd,   0xdc00, 
  0x3111,   0x1c00, 
  0x3111,   0x1c00, 
  0xfff,   0xf000, 
  0x0,   0x0};
static struct  Image phraseimage =
 {
 0,0,
 24 , 12 , 3 ,
 &phrase[0],
 0x1f,0x00,
 NULL,
 };
 

extern struct Functions *functions;

/*	If this is a note, just call the system routine, 
	timetodynamics(clip,time), which returns the point in the
	dynamics curve at this point in time.
*/

static struct Event *processeventcode(event)

struct NoteEvent *event;

{
    struct Tool *tool = event->tool;
    if (event->status == MIDI_NOTEON) {
	if (event->velocity) {
	    event->velocity = (*functions->timetodynamics)(tool->clip,event->time);
	}
    }
    event->tool = tool->next;
    return((struct Event *)event);
}

static struct ToolMaster master;

struct ToolMaster *inittoolmaster()

{
    memset((char *)&master,0,sizeof(struct ToolMaster));
    master.toolid = ID_PHRS;
    master.image = &phraseimage;
    strcpy(master.name,"Phrase Shaper");
    master.processevent = processeventcode;
    master.tooltype = TOOL_NORMAL;
    return(&master);
}
