2002-04-21 17:46:42 +00:00
|
|
|
/* ScummVM - Scumm Interpreter
|
|
|
|
* Copyright (C) 2001 Ludvig Strigeus
|
2003-03-06 21:46:56 +00:00
|
|
|
* Copyright (C) 2001-2003 The ScummVM project
|
2002-04-21 17:46:42 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*
|
|
|
|
* $Header$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2002-09-08 01:08:12 +00:00
|
|
|
#ifndef SOUND_MIDIDRV_H
|
|
|
|
#define SOUND_MIDIDRV_H
|
|
|
|
|
2003-08-01 12:21:04 +00:00
|
|
|
#include "common/scummsys.h"
|
2002-09-08 01:08:12 +00:00
|
|
|
|
2002-11-26 16:54:58 +00:00
|
|
|
class MidiChannel;
|
2003-08-05 23:58:24 +00:00
|
|
|
class SoundMixer;
|
2002-11-26 16:54:58 +00:00
|
|
|
|
|
|
|
// Abstract MIDI Driver Class
|
2002-04-13 18:34:11 +00:00
|
|
|
class MidiDriver {
|
|
|
|
public:
|
2003-05-23 04:19:47 +00:00
|
|
|
virtual ~MidiDriver() { }
|
|
|
|
|
2002-12-18 07:13:42 +00:00
|
|
|
// Error codes returned by open.
|
|
|
|
// Can be converted to a string with getErrorName()
|
2002-04-13 18:34:11 +00:00
|
|
|
enum {
|
|
|
|
MERR_CANNOT_CONNECT = 1,
|
2002-12-11 16:09:58 +00:00
|
|
|
// MERR_STREAMING_NOT_AVAILABLE = 2,
|
2002-04-13 18:34:11 +00:00
|
|
|
MERR_DEVICE_NOT_AVAILABLE = 3,
|
2002-12-25 00:36:04 +00:00
|
|
|
MERR_ALREADY_OPEN = 4
|
2002-04-13 18:34:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
2003-05-23 04:19:47 +00:00
|
|
|
// PROP_TIMEDIV = 1,
|
2003-05-17 17:20:27 +00:00
|
|
|
PROP_OLD_ADLIB = 2
|
2002-04-13 18:34:11 +00:00
|
|
|
};
|
|
|
|
|
2002-12-18 07:13:42 +00:00
|
|
|
// Open the midi driver.
|
|
|
|
// Returns 0 if successful, otherwise an error code.
|
2002-12-11 16:09:58 +00:00
|
|
|
virtual int open() = 0;
|
2002-04-13 18:34:11 +00:00
|
|
|
|
2002-12-18 07:13:42 +00:00
|
|
|
// Close the midi driver
|
2002-04-13 18:34:11 +00:00
|
|
|
virtual void close() = 0;
|
|
|
|
|
2002-12-18 07:13:42 +00:00
|
|
|
// Output a packed midi command to the midi stream
|
2002-04-13 18:34:11 +00:00
|
|
|
virtual void send(uint32 b) = 0;
|
|
|
|
|
2002-12-18 07:13:42 +00:00
|
|
|
// Get or set a property
|
2003-05-17 14:27:58 +00:00
|
|
|
virtual uint32 property(int prop, uint32 param) { return 0; }
|
2002-04-13 18:34:11 +00:00
|
|
|
|
2002-12-18 07:13:42 +00:00
|
|
|
// Retrieve a string representation of an error code
|
2002-12-11 16:09:58 +00:00
|
|
|
static const char *getErrorName(int error_code);
|
2002-10-21 09:32:38 +00:00
|
|
|
|
|
|
|
// HIGH-LEVEL SEMANTIC METHODS
|
2002-11-04 18:29:26 +00:00
|
|
|
virtual void setPitchBendRange (byte channel, uint range)
|
|
|
|
{
|
|
|
|
send(( 0 << 16) | (101 << 8) | (0xB0 | channel));
|
|
|
|
send(( 0 << 16) | (100 << 8) | (0xB0 | channel));
|
|
|
|
send((range << 16) | ( 6 << 8) | (0xB0 | channel));
|
|
|
|
send(( 0 << 16) | ( 38 << 8) | (0xB0 | channel));
|
|
|
|
}
|
2002-11-21 19:06:42 +00:00
|
|
|
|
2002-12-18 07:13:42 +00:00
|
|
|
virtual void sysEx (byte *msg, uint16 length) { }
|
2002-11-21 19:06:42 +00:00
|
|
|
virtual void sysEx_customInstrument (byte channel, uint32 type, byte *instr) { }
|
2003-05-18 14:50:10 +00:00
|
|
|
virtual void metaEvent (byte type, byte*data, uint16 length) { }
|
2002-11-21 19:06:42 +00:00
|
|
|
|
|
|
|
// Timing functions - MidiDriver now operates timers
|
|
|
|
virtual void setTimerCallback (void *timer_param, void (*timer_proc) (void *)) = 0;
|
|
|
|
virtual uint32 getBaseTempo (void) = 0;
|
2002-11-26 16:54:58 +00:00
|
|
|
|
|
|
|
// Channel allocation functions
|
|
|
|
virtual MidiChannel *allocateChannel() = 0;
|
|
|
|
virtual MidiChannel *getPercussionChannel() = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
class MidiChannel {
|
|
|
|
public:
|
2002-12-18 07:13:42 +00:00
|
|
|
virtual MidiDriver *device() = 0;
|
2002-12-18 07:48:35 +00:00
|
|
|
virtual byte getNumber() = 0;
|
2002-11-26 16:54:58 +00:00
|
|
|
virtual void release() = 0;
|
|
|
|
|
2003-08-08 11:54:24 +00:00
|
|
|
virtual void send (uint32 b) = 0; // 4-bit channel portion is ignored
|
|
|
|
|
2002-11-26 16:54:58 +00:00
|
|
|
// Regular messages
|
|
|
|
virtual void noteOff (byte note) = 0;
|
|
|
|
virtual void noteOn (byte note, byte velocity) = 0;
|
|
|
|
virtual void programChange (byte program) = 0;
|
|
|
|
virtual void pitchBend (int16 bend) = 0; // -0x2000 to +0x1FFF
|
|
|
|
|
|
|
|
// Control Change messages
|
|
|
|
virtual void controlChange (byte control, byte value) = 0;
|
|
|
|
virtual void modulationWheel (byte value) = 0;
|
|
|
|
virtual void volume (byte value) = 0;
|
|
|
|
virtual void panPosition (byte value) = 0;
|
|
|
|
virtual void pitchBendFactor (byte value) = 0;
|
|
|
|
virtual void detune (byte value) = 0;
|
|
|
|
virtual void priority (byte value) = 0;
|
|
|
|
virtual void sustain (bool value) = 0;
|
|
|
|
virtual void effectLevel (byte value) = 0;
|
|
|
|
virtual void chorusLevel (byte value) = 0;
|
|
|
|
virtual void allNotesOff() = 0;
|
|
|
|
|
|
|
|
// SysEx messages
|
|
|
|
virtual void sysEx_customInstrument (uint32 type, byte *instr) = 0;
|
2002-04-13 18:34:11 +00:00
|
|
|
};
|
|
|
|
|
2002-11-26 16:54:58 +00:00
|
|
|
// MIDI Driver Types
|
2002-03-21 16:12:02 +00:00
|
|
|
enum {
|
2002-04-13 18:34:11 +00:00
|
|
|
MD_AUTO = 0,
|
|
|
|
MD_NULL = 1,
|
|
|
|
MD_WINDOWS = 2,
|
|
|
|
MD_TIMIDITY = 3,
|
|
|
|
MD_SEQ = 4,
|
|
|
|
MD_QTMUSIC = 5,
|
2002-10-02 23:31:40 +00:00
|
|
|
MD_ETUDE = 6,
|
2002-04-26 13:18:49 +00:00
|
|
|
MD_COREAUDIO = 7,
|
2002-05-16 06:46:50 +00:00
|
|
|
MD_MIDIEMU = 8,
|
|
|
|
MD_ALSA = 9,
|
2003-04-30 12:51:07 +00:00
|
|
|
MD_ADLIB = 10,
|
2003-08-13 14:08:21 +00:00
|
|
|
MD_PCSPK = 11,
|
|
|
|
MD_PCJR = 12,
|
2003-04-30 12:51:07 +00:00
|
|
|
|
|
|
|
MD_YPA1 = 100 // palmos
|
2002-03-21 16:12:02 +00:00
|
|
|
};
|
|
|
|
|
2002-12-18 07:13:42 +00:00
|
|
|
// Factory functions, for faster compile
|
2002-04-26 13:18:49 +00:00
|
|
|
extern MidiDriver *MidiDriver_NULL_create();
|
2003-08-05 23:58:24 +00:00
|
|
|
extern MidiDriver *MidiDriver_ADLIB_create(SoundMixer *mixer);
|
2002-04-26 13:18:49 +00:00
|
|
|
extern MidiDriver *MidiDriver_WIN_create();
|
|
|
|
extern MidiDriver *MidiDriver_SEQ_create();
|
|
|
|
extern MidiDriver *MidiDriver_QT_create();
|
|
|
|
extern MidiDriver *MidiDriver_CORE_create();
|
2002-10-02 23:31:40 +00:00
|
|
|
extern MidiDriver *MidiDriver_ETUDE_create();
|
2002-05-16 06:46:50 +00:00
|
|
|
extern MidiDriver *MidiDriver_ALSA_create();
|
2003-04-30 12:51:07 +00:00
|
|
|
extern MidiDriver *MidiDriver_YamahaPa1_create();
|
2002-09-08 01:08:12 +00:00
|
|
|
|
|
|
|
#endif
|