/***************************************************************************
                            MidiOut.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_MidiOut.h>
#include <kdeobjc/KDESupport.h>
#include <kdeobjc/MidiOut.h>
#include <kdeobjc/MidiMapper.h>


@implementation  MidiOut

- (void *) qt
{
	return _qt;
}

- setQt: (void *) qt
{
	_qt = qt;
	return self;
}

- (BOOL) allocatedInObjcWorld
{
	return _allocatedInObjcWorld;
}

- setAllocatedInObjcWorld: (BOOL) yn
{
	_allocatedInObjcWorld = yn;
	return self;
}


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

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

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

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

- closeDev
{
	kde_MidiOut_closeDev((kde_MidiOut *)[self qt]);
	return self;
}

- initDev
{
	kde_MidiOut_initDev((kde_MidiOut *)[self qt]);
	return self;
}

- (int) deviceType
{
	return (int) kde_MidiOut_deviceType((kde_MidiOut *)[self qt]);
}

- (NSString *) deviceName
{
	return (NSString *) [NSString stringWithCString: kde_MidiOut_deviceName((kde_MidiOut *)[self qt])];
}

- setMidiMapper: (MidiMapper*)map
{
	kde_MidiOut_setMidiMapper((kde_MidiOut *)[self qt], (kde_MidiMapper*) [map qt]);
	return self;
}

- noteOn: (unsigned char)chn note: (unsigned char)note vel: (unsigned char)vel
{
	kde_MidiOut_noteOn((kde_MidiOut *)[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_MidiOut_noteOff((kde_MidiOut *)[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_MidiOut_keyPressure((kde_MidiOut *)[self qt], (unsigned char)chn, (unsigned char)note, (unsigned char)vel);
	return self;
}

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

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

- chnPitchBender: (unsigned char)chn lsb: (unsigned char)lsb msb: (unsigned char)msb
{
	kde_MidiOut_chnPitchBender((kde_MidiOut *)[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_MidiOut_chnController((kde_MidiOut *)[self qt], (unsigned char)chn, (unsigned char)ctl, (unsigned char)v);
	return self;
}

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

- allNotesOff
{
	kde_MidiOut_allNotesOff((kde_MidiOut *)[self qt]);
	return self;
}

- channelSilence: (unsigned char)chn
{
	kde_MidiOut_channelSilence((kde_MidiOut *)[self qt], (unsigned char)chn);
	return self;
}

- channelMute: (unsigned char)chn a: (int)a
{
	kde_MidiOut_channelMute((kde_MidiOut *)[self qt], (unsigned char)chn, (int)a);
	return self;
}

- setVolumePercentage: (int)volper
{
	kde_MidiOut_setVolumePercentage((kde_MidiOut *)[self qt], (int)volper);
	return self;
}

- (int) ok
{
	return (int) kde_MidiOut_ok((kde_MidiOut *)[self qt]);
}

- (NSString *) midiMapFilename
{
	return (NSString *) [NSString stringWithCString: kde_MidiOut_midiMapFilename((kde_MidiOut *)[self qt])];
}

- sync: (int)i
{
	kde_MidiOut_sync((kde_MidiOut *)[self qt], (int)i);
	return self;
}

- sync
{
	kde_MidiOut_sync((kde_MidiOut *)[self qt], 0);
	return self;
}

- seqbuf_dump
{
	kde_MidiOut_seqbuf_dump((kde_MidiOut *)[self qt]);
	return self;
}

- seqbuf_clean
{
	kde_MidiOut_seqbuf_clean((kde_MidiOut *)[self qt]);
	return self;
}

@end
