/* DELINST.C
 * The routine that implements the 'Delete Instrument' message.
 *
 * Copyright (C) 1991 by Andrew Arensburger. Permission is granted to
 * use, copy and/or distribute this file freely for non-commercial purposes,
 * as long as this notice remains intact. Any commercial use is prohibited
 * without express permission from the author.
 *
 * If you make any changes, fix bugs, etc., please send them to me that I
 * might coordinate fixes and improvements.
 */

#include <stdio.h>
#include "eps.h"

/* DEL_INSTRUMENT
 * Delete the instrument described in 'inst'.
 * Returns 0 on no error, or a negative error code.
 */
int del_instrument(chan,inst)
int chan;			/* MIDI channel */
edit_spec *inst;		/* Which instrument? */
{
	int i;
	int waiting;		/* Are we waiting for the EPS to do things? */

	/* Send instruction to await instrument parameters */
	send_head(chan);	/* Send SysEx head */
	mpu_sbyte(DEL_INST);	/* 'Delete Instrument' message */
	send12(inst->inst_num);	/* Instrument number */
	send12(inst->layer_num);/* Layer number */
	send12(inst->ws_num);	/* Wavesample number */
	send_tail();		/* Send SysEx tail */

	if (timeout(SHORT_TIMEOUT))
		return(-1);	/* Short timeout occurred */

	/* Receive response to see if everything went well */
	i = recv_response(NULL);

	wait(BREATHER);
	if (i == ACK)
		return(0);		/* All went well */
	else
		return(-1);		/* There was some error */
}
