/***************************************************************************
                            FMOut.m -  description
                             -------------------
    begin                : Fri Mar  8 13:55:08 2002
    copyright            : (C) 2000-2002 Lost Highway Ltd. All rights reserved.
    email                : Lost_Highway@tipitina.demon.co.uk
    generated by         : duke@tipitina on Fri Mar  8 13:55:08 2002, using kalyptus 0.9.
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This library is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU Library General Public License as       *
 *   published by the Free Software Foundation; either version 2 of the    *
 *   License, or (at your option) any later version.                       *
 *                                                                         *
 ***************************************************************************/

#include <qtc/qt_QString.h>
#include <qtc/qt_QCString.h>
#include <kdec/kde_FMOut.h>
#include <kdeobjc/KDESupport.h>
#include <kdeobjc/FMOut.h>

@implementation  FMOut


- initWithInt: (int)d total: (int)total
{
	if ([self qt] == 0L) {
		[self setQt: kde_new_FMOut((int)d, (int)total)];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

- init
{
	if ([self qt] == 0L) {
		[self setQt: kde_new_FMOut(0, 12)];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

- (void) dealloc
{
	if ([self qt] != 0L) {
		if ([self allocatedInObjcWorld]) {
			kde_del_FMOut((kde_FMOut *)[self qt]);
		}
		[QtSupport removeQtKey: [self qt]];
		[self setQt: 0L];
	}
	[super dealloc];
}

- openDev: (int)sqfd
{
	kde_FMOut_openDev((kde_FMOut *)[self qt], (int)sqfd);
	return self;
}

- closeDev
{
	kde_FMOut_closeDev((kde_FMOut *)[self qt]);
	return self;
}

- initDev
{
	kde_FMOut_initDev((kde_FMOut *)[self qt]);
	return self;
}

- noteOn: (unsigned char)chn note: (unsigned char)note vel: (unsigned char)vel
{
	kde_FMOut_noteOn((kde_FMOut *)[self qt], (unsigned char)chn, (unsigned char)note, (unsigned char)vel);
	return self;
}

- noteOff: (unsigned char)chn note: (unsigned char)note vel: (unsigned char)vel
{
	kde_FMOut_noteOff((kde_FMOut *)[self qt], (unsigned char)chn, (unsigned char)note, (unsigned char)vel);
	return self;
}

- keyPressure: (unsigned char)chn note: (unsigned char)note vel: (unsigned char)vel
{
	kde_FMOut_keyPressure((kde_FMOut *)[self qt], (unsigned char)chn, (unsigned char)note, (unsigned char)vel);
	return self;
}

- chnPatchChange: (unsigned char)chn patch: (unsigned char)patch
{
	kde_FMOut_chnPatchChange((kde_FMOut *)[self qt], (unsigned char)chn, (unsigned char)patch);
	return self;
}

- chnPressure: (unsigned char)chn vel: (unsigned char)vel
{
	kde_FMOut_chnPressure((kde_FMOut *)[self qt], (unsigned char)chn, (unsigned char)vel);
	return self;
}

- chnPitchBender: (unsigned char)chn lsb: (unsigned char)lsb msb: (unsigned char)msb
{
	kde_FMOut_chnPitchBender((kde_FMOut *)[self qt], (unsigned char)chn, (unsigned char)lsb, (unsigned char)msb);
	return self;
}

- chnController: (unsigned char)chn ctl: (unsigned char)ctl v: (unsigned char)v
{
	kde_FMOut_chnController((kde_FMOut *)[self qt], (unsigned char)chn, (unsigned char)ctl, (unsigned char)v);
	return self;
}

- sysex: (unsigned char*)data size: (unsigned long)size
{
	kde_FMOut_sysex((kde_FMOut *)[self qt], (unsigned char*)data, (unsigned long)size);
	return self;
}

- setVolumePercentage: (int)i
{
	kde_FMOut_setVolumePercentage((kde_FMOut *)[self qt], (int)i);
	return self;
}

- (int) patch: (int)p
{
	return (int) kde_FMOut_patch((kde_FMOut *)[self qt], (int)p);
}

+ setFMPatchesDirectory: (NSString *)dir
{
	kde_FMOut_setFMPatchesDirectory((char*) [dir cString]);
	return self;
}

@end
