[Scummvm-cvs-logs] CVS: scummvm/sound adlib.cpp,1.11,1.12 gmidi.cpp,1.13,1.14 gmidi.h,1.5,1.6 imuse.cpp,1.20,1.21

Ludvig Strigeus strigeus at users.sourceforge.net
Sat Apr 13 11:32:16 CEST 2002


Update of /cvsroot/scummvm/scummvm/sound
In directory usw-pr-cvs1:/tmp/cvs-serv8171/sound

Modified Files:
	adlib.cpp gmidi.cpp gmidi.h imuse.cpp 
Log Message:
new midi driver API,
no more USE_ADLIB,
a couple of sdl graphics driver fixes.


Index: adlib.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sound/adlib.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** adlib.cpp	12 Apr 2002 21:26:35 -0000	1.11
--- adlib.cpp	13 Apr 2002 18:31:45 -0000	1.12
***************
*** 24,28 ****
  #include "fmopl.h"
  
- #if defined USE_ADLIB
  
  static byte lookup_table[64][32];
--- 24,27 ----
***************
*** 644,648 ****
  		break;
  	default:
! 		s10->start_value = part->_drv->adlib_read_param(mc->_channel, s11->param);
  	}
  
--- 643,647 ----
  		break;
  	default:
! 		s10->start_value = ((AdlibSoundDriver*)part->_drv)->adlib_read_param(mc->_channel, s11->param);
  	}
  
***************
*** 662,666 ****
  		case 0:
  			mc->_vol_2 = s10->start_value + s11->modify_val;
! 			part->_drv->adlib_set_param(mc->_channel, 0,
  																	volume_table[lookup_table[mc->_vol_2]
  																							 [part->_vol_eff >> 2]]);
--- 661,665 ----
  		case 0:
  			mc->_vol_2 = s10->start_value + s11->modify_val;
! 			((AdlibSoundDriver*)part->_drv)->adlib_set_param(mc->_channel, 0,
  																	volume_table[lookup_table[mc->_vol_2]
  																							 [part->_vol_eff >> 2]]);
***************
*** 669,677 ****
  			mc->_vol_1 = s10->start_value + s11->modify_val;
  			if (mc->_twochan) {
! 				part->_drv->adlib_set_param(mc->_channel, 13,
  																		volume_table[lookup_table[mc->_vol_1]
  																								 [part->_vol_eff >> 2]]);
  			} else {
! 				part->_drv->adlib_set_param(mc->_channel, 13, mc->_vol_1);
  			}
  			break;
--- 668,676 ----
  			mc->_vol_1 = s10->start_value + s11->modify_val;
  			if (mc->_twochan) {
! 				((AdlibSoundDriver*)part->_drv)->adlib_set_param(mc->_channel, 13,
  																		volume_table[lookup_table[mc->_vol_1]
  																								 [part->_vol_eff >> 2]]);
  			} else {
! 				((AdlibSoundDriver*)part->_drv)->adlib_set_param(mc->_channel, 13, mc->_vol_1);
  			}
  			break;
***************
*** 683,687 ****
  			break;
  		default:
! 			part->_drv->adlib_set_param(mc->_channel, s11->param,
  																	s10->start_value + s11->modify_val);
  			break;
--- 682,686 ----
  			break;
  		default:
! 			((AdlibSoundDriver*)part->_drv)->adlib_set_param(mc->_channel, s11->param,
  																	s10->start_value + s11->modify_val);
  			break;
***************
*** 690,694 ****
  
  	if (code & 2 && s11->flag0x10)
! 		part->_drv->adlib_key_onoff(mc->_channel);
  }
  
--- 689,693 ----
  
  	if (code & 2 && s11->flag0x10)
! 		((AdlibSoundDriver*)part->_drv)->adlib_key_onoff(mc->_channel);
  }
  
***************
*** 989,991 ****
  }
  
- #endif
--- 988,989 ----

Index: gmidi.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sound/gmidi.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** gmidi.cpp	12 Apr 2002 21:26:35 -0000	1.13
--- gmidi.cpp	13 Apr 2002 18:31:45 -0000	1.14
***************
*** 20,410 ****
   */
  
- /*
-  * Timidity support by Lionel Ulmer <lionel.ulmer at free.fr>
-  * QuickTime support by Florent Boudet <flobo at ifrance.com>
-  * Raw output support by Michael Pearce
-  * MorphOS support by Ruediger Hanke 
-  */
- 
- #ifdef __MORPHOS__
- #include <devices/timer.h>
- #endif
- 
- 
  #include "stdafx.h"
  #include "scumm.h"
  #include "gmidi.h"
  
! void MidiSoundDriver::midiSetDriver(int devicetype)
! {
! 	_midi_driver.DeviceType = devicetype;
! 	_midi_driver.midiInit();
! }
! 
! void MidiDriver::midiInit()
! {
! 	if (MidiInitialized != true) {
! 		switch (DeviceType) {
! 		case MIDI_NULL:
! 			midiInitNull();
! 			break;
! 		case MIDI_WINDOWS:
! 			midiInitWindows();
! 			break;
! 		case MIDI_TIMIDITY:
! 			midiInitTimidity();
! 			break;
! 		case MIDI_SEQ:
! 			midiInitSeq();
! 			break;
! 		case MIDI_QTMUSIC:
! 			midiInitQuicktime();
! 			break;
! 		case MIDI_AMIDI:
! 			break;
! 		default:
! 			DeviceType = 0;
! 			midiInitNull();
! 			break;
! 		}
! 		MidiInitialized = true;
! 	} else {
! 		error("Midi driver already initialized");
! 	}
! }
! 
! void MidiDriver::MidiOut(int b)
! {
! 	if (MidiInitialized != true)
! 		midiInit();
! 
! 	if (MidiInitialized == true) {
! 		switch (DeviceType) {
! 		case MIDI_NULL:
! 			break;
! 		case MIDI_WINDOWS:
! 			MidiOutWindows(_mo, b);
! 			break;
! 		case MIDI_TIMIDITY:
! 		case MIDI_SEQ:
! 			MidiOutSeq(_mo, b);
! 			break;
! 		case MIDI_QTMUSIC:
! 			MidiOutQuicktime(_mo, b);
! 			break;
! 		case MIDI_AMIDI:
! 			MidiOutMorphOS(_mo, b);
! 			break;
! 		default:
! 			error("Invalid midi device type ");
! 			break;
! 		}
! 	} else {
! 		warning("Trying to write midi data without the driver being initialized");
! 	}
! }
! 
! /*********** Windows			*/
! void MidiDriver::midiInitWindows()
! {
! #ifdef WIN32
! 	if (midiOutOpen((HMIDIOUT *) & _mo, MIDI_MAPPER, NULL, NULL, 0) !=
! 			MMSYSERR_NOERROR)
! 		error("midiOutOpen failed");
! #endif
! }
! 
! void MidiDriver::MidiOutWindows(void *a, int b)
! {
! #ifdef WIN32
! 	midiOutShortMsg((HMIDIOUT) a, b);
! #endif
! }
! 
! /*********** Raw midi support	*/
! void MidiDriver::midiInitSeq()
! {
! 	int device = open_sequencer_device();
! 	_mo = (void *)device;
! }
! 
! int MidiDriver::open_sequencer_device()
! {
! 	int device = 0;
! #if !defined(__APPLE__CW)				// No getenv support on Apple Carbon
! 	char *device_name = getenv("SCUMMVM_MIDI");
! 	if (device_name != NULL) {
! 		device = (open((device_name), O_RDWR, 0));
! 	} else {
! 		warning
! 			("You need to set-up the SCUMMVM_MIDI environment variable properly (see readme.txt) ");
! 	}
! 	if ((device_name == NULL) || (device < 0)) {
! 		if (device_name == NULL)
! 			warning("Opening /dev/null (no music will be heard) ");
! 		else
! 			warning
! 				("Cannot open rawmidi device %s - using /dev/null (no music will be heard) ",
! 				 device_name);
! 		device = (open(("/dev/null"), O_RDWR, 0));
! 		if (device < 0)
! 			error("Cannot open /dev/null to dump midi output");
! 	}
! #endif
! 	return device;
! }
! 
! /*********** Timidity		*/
! int MidiDriver::connect_to_timidity(int port)
! {
! 	int s = 0;
! #if !defined(__APPLE__CW) && !defined(__MORPHOS__)	// No socket support on Apple Carbon or Morphos
! 	struct hostent *serverhost;
! 	struct sockaddr_in sadd;
! 
! 	serverhost = gethostbyname("localhost");
! 	if (serverhost == NULL)
! 		error("Could not resolve Timidity host ('localhost')");
! 
! 	sadd.sin_family = serverhost->h_addrtype;
! 	sadd.sin_port = htons(port);
! 	memcpy(&(sadd.sin_addr), serverhost->h_addr_list[0], serverhost->h_length);
! 
! 	s = socket(AF_INET, SOCK_STREAM, 0);
! 	if (s < 0)
! 		error("Could not open Timidity socket");
! 
! 	if (connect(s, (struct sockaddr *)&sadd, sizeof(struct sockaddr_in)) < 0)
! 		error("Could not connect to Timidity server");
! #endif
! 	return s;
! }
! 
! void MidiDriver::midiInitTimidity()
! {
! 	int s, s2;
! 	int len;
! 	int dummy, newport;
! 	char buf[256];
! 
! 	s = connect_to_timidity(7777);
! 	len = read(s, buf, 256);			// buf[len] = '\0'; printf("%s", buf);
! 	sprintf(buf, "SETBUF %f %f\n", 0.1, 0.15);
! 	write(s, buf, strlen(buf));
! 	len = read(s, buf, 256);			// buf[len] = '\0'; printf("%s", buf); 
! 
! 	sprintf(buf, "OPEN lsb\n");
! 	write(s, buf, strlen(buf));
! 	len = read(s, buf, 256);			// buf[len] = '\0'; printf("%s", buf); 
! 
! 	sscanf(buf, "%d %d", &dummy, &newport);
! 	printf("	 => port = %d\n", newport);
! 
! 	s2 = connect_to_timidity(newport);
! 	_mo = (void *)s2;
! }
! 
! void MidiDriver::MidiOutSeq(void *a, int b)
! {
! 	int s = (int)a;
! 	unsigned char buf[256];
! 	int position = 0;
! 
! 	switch (b & 0xF0) {
! 	case 0x80:
! 	case 0x90:
! 	case 0xA0:
! 	case 0xB0:
! 	case 0xE0:
! 		buf[position++] = SEQ_MIDIPUTC;
! 		buf[position++] = b;
! 		buf[position++] = DEVICE_NUM;
! 		buf[position++] = 0;
! 		buf[position++] = SEQ_MIDIPUTC;
! 		buf[position++] = (b >> 8) & 0x7F;
! 		buf[position++] = DEVICE_NUM;
! 		buf[position++] = 0;
! 		buf[position++] = SEQ_MIDIPUTC;
! 		buf[position++] = (b >> 16) & 0x7F;
! 		buf[position++] = DEVICE_NUM;
! 		buf[position++] = 0;
! 		break;
! 	case 0xC0:
! 	case 0xD0:
! 		buf[position++] = SEQ_MIDIPUTC;
! 		buf[position++] = b;
! 		buf[position++] = DEVICE_NUM;
! 		buf[position++] = 0;
! 		buf[position++] = SEQ_MIDIPUTC;
! 		buf[position++] = (b >> 8) & 0x7F;
! 		buf[position++] = DEVICE_NUM;
! 		buf[position++] = 0;
! 		break;
! 	default:
! 		fprintf(stderr, "Unknown : %08x\n", b);
! 		break;
! 	}
! 	write(s, buf, position);
! }
! 
! /* Quicktime music support */
! void MidiDriver::midiInitQuicktime()
! {
! #ifdef __APPLE__CW
! 	ComponentResult qtErr = noErr;
! 	qtNoteAllocator = NULL;
! 
! 	for (int i = 0; i < 15; i++)
! 		qtNoteChannel[i] = NULL;
! 
! 	qtNoteAllocator = OpenDefaultComponent(kNoteAllocatorComponentType, 0);
! 	if (qtNoteAllocator == NULL)
! 		goto bail;
! 
! 	simpleNoteRequest.info.flags = 0;
! 	*(short *)(&simpleNoteRequest.info.polyphony) = EndianS16_NtoB(15);	// simultaneous tones
! 	*(Fixed *) (&simpleNoteRequest.info.typicalPolyphony) =
! 		EndianU32_NtoB(0x00010000);
! 
! 	qtErr = NAStuffToneDescription(qtNoteAllocator, 1, &simpleNoteRequest.tone);
! 	if (qtErr != noErr)
! 		goto bail;
! 
! 	for (int i = 0; i < 15; i++) {
! 		qtErr =
! 			NANewNoteChannel(qtNoteAllocator, &simpleNoteRequest,
! 											 &(qtNoteChannel[i]));
! 		if ((qtErr != noErr) || (qtNoteChannel == NULL))
! 			goto bail;
! 	}
! 	return;
! 
! bail:
! 	fprintf(stderr, "Init QT failed %x %x %d\n", qtNoteAllocator, qtNoteChannel,
! 					qtErr);
! 	for (int i = 0; i < 15; i++) {
! 		if (qtNoteChannel[i] != NULL)
! 			NADisposeNoteChannel(qtNoteAllocator, qtNoteChannel[i]);
! 	}
! 
! 	if (qtNoteAllocator != NULL)
! 		CloseComponent(qtNoteAllocator);
! #endif
! }
! 
! void MidiDriver::MidiOutQuicktime(void *a, int b)
! {
! #ifdef __APPLE__CW
! 	MusicMIDIPacket midPacket;
! 	unsigned char *midiCmd = midPacket.data;
! 	midPacket.length = 3;
! 	midiCmd[3] = (b & 0xFF000000) >> 24;
! 	midiCmd[2] = (b & 0x00FF0000) >> 16;
! 	midiCmd[1] = (b & 0x0000FF00) >> 8;
! 	midiCmd[0] = b;
! 
! 	unsigned char chanID = midiCmd[0] & 0x0F;
! 	switch (midiCmd[0] & 0xF0) {
! 	case 0x80:										// Note off
! 		NAPlayNote(qtNoteAllocator, qtNoteChannel[chanID], midiCmd[1], 0);
! 		break;
! 
! 	case 0x90:										// Note on
! 		NAPlayNote(qtNoteAllocator, qtNoteChannel[chanID], midiCmd[1],
! 							 midiCmd[2]);
! 		break;
! 
! 	case 0xB0:										// Effect
! 		switch (midiCmd[1]) {
! 		case 0x01:									// Modulation
! 			NASetController(qtNoteAllocator, qtNoteChannel[chanID],
! 											kControllerModulationWheel, midiCmd[2] << 8);
! 			break;
! 
! 		case 0x07:									// Volume
! 			NASetController(qtNoteAllocator, qtNoteChannel[chanID],
! 											kControllerVolume, midiCmd[2] * 300);
! 			break;
! 
! 		case 0x0A:									// Pan
! 			NASetController(qtNoteAllocator, qtNoteChannel[chanID], kControllerPan,
! 											(midiCmd[2] << 1) + 0xFF);
! 			break;
! 
! 		case 0x40:									// Sustain on/off
! 			NASetController(qtNoteAllocator, qtNoteChannel[chanID],
! 											kControllerSustain, midiCmd[2]);
! 			break;
! 
! 		case 0x5b:									// ext effect depth
! 			NASetController(qtNoteAllocator, qtNoteChannel[chanID],
! 											kControllerReverb, midiCmd[2] << 8);
! 			break;
! 
! 		case 0x5d:									// chorus depth
! 			NASetController(qtNoteAllocator, qtNoteChannel[chanID],
! 											kControllerChorus, midiCmd[2] << 8);
! 			break;
! 
! 		case 0x7b:									// mode message all notes off
! 			for (int i = 0; i < 128; i++)
! 				NAPlayNote(qtNoteAllocator, qtNoteChannel[chanID], i, 0);
! 			break;
! 
! 		default:
! 			fprintf(stderr, "Unknown MIDI effect: %08x\n", b);
! 			break;
! 		}
! 		break;
! 
! 	case 0xC0:										// Program change
! 		NASetInstrumentNumber(qtNoteAllocator, qtNoteChannel[chanID], midiCmd[1]);
! 		break;
! 
! 	case 0xE0:{									// Pitch bend
! 			long theBend =
! 				((((long)midiCmd[1] + (long)(midiCmd[2] << 8))) - 0x4000) / 4;
! 			NASetController(qtNoteAllocator, qtNoteChannel[chanID],
! 											kControllerPitchBend, theBend);
! 		}
! 		break;
! 
! 	default:
! 		fprintf(stderr, "Unknown Command: %08x\n", b);
! 		NASendMIDI(qtNoteAllocator, qtNoteChannel[chanID], &midPacket);
! 		break;
! 	}
! #endif
! }
! 
! /*********** MorphOS            */
! void MidiDriver::MidiOutMorphOS(void *a, int b)
  {
! #ifdef __MORPHOS__
! 	if (ScummMidiRequest) {
! 		ULONG midi_data = b;				// you never know about an int's size ;-)
! 		ScummMidiRequest->amr_Std.io_Command = CMD_WRITE;
! 		ScummMidiRequest->amr_Std.io_Data = &midi_data;
! 		ScummMidiRequest->amr_Std.io_Length = 4;
! 		DoIO((struct IORequest *)ScummMidiRequest);
! 	}
! #endif
! }
! 
! 
! 
! 
! 
! 
  
! void MidiDriver::midiInitNull()
! {
! 	warning
! 		("Music not enabled - MIDI support selected with no MIDI driver available. Try Adlib");
  }
  
! 
! 
! /************************* Common midi code **********************/
  void MidiSoundDriver::midiPitchBend(byte chan, int16 pitchbend)
  {
--- 20,37 ----
   */
  
  #include "stdafx.h"
  #include "scumm.h"
  #include "gmidi.h"
  
! void MidiSoundDriver::midiSetDriver(MidiDriver *driver)
  {
! 	_md = driver;
  
! 	int result = _md->open(MidiDriver::MO_SIMPLE);
! 	if (result)
! 		error("MidiSoundDriver::error = %s", MidiDriver::get_error_name(result));
  }
  
! /****************** Common midi code (SCUMM specific) *****************/
  void MidiSoundDriver::midiPitchBend(byte chan, int16 pitchbend)
  {
***************
*** 414,419 ****
  		_midi_pitchbend_last[chan] = pitchbend;
  		tmp = (pitchbend << 2) + 0x2000;
! 		_midi_driver.
! 			MidiOut(((tmp >> 7) & 0x7F) << 16 | (tmp & 0x7F) << 8 | 0xE0 | chan);
  	}
  }
--- 41,45 ----
  		_midi_pitchbend_last[chan] = pitchbend;
  		tmp = (pitchbend << 2) + 0x2000;
! 		_md->send(((tmp >> 7) & 0x7F) << 16 | (tmp & 0x7F) << 8 | 0xE0 | chan);
  	}
  }
***************
*** 423,427 ****
  	if (_midi_volume_last[chan] != volume) {
  		_midi_volume_last[chan] = volume;
! 		_midi_driver.MidiOut(volume << 16 | 7 << 8 | 0xB0 | chan);
  	}
  }
--- 49,53 ----
  	if (_midi_volume_last[chan] != volume) {
  		_midi_volume_last[chan] = volume;
! 		_md->send(volume << 16 | 7 << 8 | 0xB0 | chan);
  	}
  }
***************
*** 430,434 ****
  	if (_midi_pedal_last[chan] != pedal) {
  		_midi_pedal_last[chan] = pedal;
! 		_midi_driver.MidiOut(pedal << 16 | 64 << 8 | 0xB0 | chan);
  	}
  }
--- 56,60 ----
  	if (_midi_pedal_last[chan] != pedal) {
  		_midi_pedal_last[chan] = pedal;
! 		_md->send(pedal << 16 | 64 << 8 | 0xB0 | chan);
  	}
  }
***************
*** 438,442 ****
  	if (_midi_modwheel_last[chan] != modwheel) {
  		_midi_modwheel_last[chan] = modwheel;
! 		_midi_driver.MidiOut(modwheel << 16 | 1 << 8 | 0xB0 | chan);
  	}
  }
--- 64,68 ----
  	if (_midi_modwheel_last[chan] != modwheel) {
  		_midi_modwheel_last[chan] = modwheel;
! 		_md->send(modwheel << 16 | 1 << 8 | 0xB0 | chan);
  	}
  }
***************
*** 446,450 ****
  	if (_midi_effectlevel_last[chan] != level) {
  		_midi_effectlevel_last[chan] = level;
! 		_midi_driver.MidiOut(level << 16 | 91 << 8 | 0xB0 | chan);
  	}
  }
--- 72,76 ----
  	if (_midi_effectlevel_last[chan] != level) {
  		_midi_effectlevel_last[chan] = level;
! 		_md->send(level << 16 | 91 << 8 | 0xB0 | chan);
  	}
  }
***************
*** 454,458 ****
  	if (_midi_chorus_last[chan] != chorus) {
  		_midi_chorus_last[chan] = chorus;
! 		_midi_driver.MidiOut(chorus << 16 | 93 << 8 | 0xB0 | chan);
  	}
  }
--- 80,84 ----
  	if (_midi_chorus_last[chan] != chorus) {
  		_midi_chorus_last[chan] = chorus;
! 		_md->send(chorus << 16 | 93 << 8 | 0xB0 | chan);
  	}
  }
***************
*** 460,464 ****
  void MidiSoundDriver::midiControl0(byte chan, byte value)
  {
! 	_midi_driver.MidiOut(value << 16 | 0 << 8 | 0xB0 | chan);
  }
  
--- 86,90 ----
  void MidiSoundDriver::midiControl0(byte chan, byte value)
  {
! 	_md->send(value << 16 | 0 << 8 | 0xB0 | chan);
  }
  
***************
*** 469,473 ****
  			program = mt32_to_gmidi[program];
  
! 		_midi_driver.MidiOut(program << 8 | 0xC0 | chan);
  	}
  }
--- 95,99 ----
  			program = mt32_to_gmidi[program];
  
! 		_md->send(program << 8 | 0xC0 | chan);
  	}
  }
***************
*** 477,481 ****
  	if (_midi_pan_last[chan] != pan) {
  		_midi_pan_last[chan] = pan;
! 		_midi_driver.MidiOut(((pan - 64) & 0x7F) << 16 | 10 << 8 | 0xB0 | chan);
  	}
  }
--- 103,107 ----
  	if (_midi_pan_last[chan] != pan) {
  		_midi_pan_last[chan] = pan;
! 		_md->send(((pan - 64) & 0x7F) << 16 | 10 << 8 | 0xB0 | chan);
  	}
  }
***************
*** 483,498 ****
  void MidiSoundDriver::midiNoteOn(byte chan, byte note, byte velocity)
  {
! 	_midi_driver.MidiOut(velocity << 16 | note << 8 | 0x90 | chan);
  }
  
  void MidiSoundDriver::midiNoteOff(byte chan, byte note)
  {
! 	_midi_driver.MidiOut(note << 8 | 0x80 | chan);
  }
  
  void MidiSoundDriver::midiSilence(byte chan)
  {
! 	_midi_driver.MidiOut((64 << 8) | 0xB0 | chan);
! 	_midi_driver.MidiOut((123 << 8) | 0xB0 | chan);
  }
  
--- 109,124 ----
  void MidiSoundDriver::midiNoteOn(byte chan, byte note, byte velocity)
  {
! 	_md->send(velocity << 16 | note << 8 | 0x90 | chan);
  }
  
  void MidiSoundDriver::midiNoteOff(byte chan, byte note)
  {
! 	_md->send(note << 8 | 0x80 | chan);
  }
  
  void MidiSoundDriver::midiSilence(byte chan)
  {
! 	_md->send((64 << 8) | 0xB0 | chan);
! 	_md->send((123 << 8) | 0xB0 | chan);
  }
  

Index: gmidi.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sound/gmidi.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** gmidi.h	10 Apr 2002 20:48:27 -0000	1.5
--- gmidi.h	13 Apr 2002 18:31:45 -0000	1.6
***************
*** 7,19 ****
  #define DEVICE_NUM 0
  
! /* Sound output type - MIDI */
  enum {
! 	MIDI_NULL = 0,
! 	MIDI_WINDOWS = 1,
! 	MIDI_TIMIDITY = 2,
! 	MIDI_SEQ = 3,
! 	MIDI_QTMUSIC = 4,
! 	MIDI_AMIDI = 5
  };
  
  /* Roland to General Midi patch table. Still needs much work. */
--- 7,111 ----
  #define DEVICE_NUM 0
  
! struct MidiEvent {
! 	uint32 delta;
! 	uint32 event;
! };
! 
! /* Lowlevel Abstract Midi Driver Class */
! class MidiDriver {
! 	
! public:
! 	/* called whenever the midi driver is in streaming mode,
! 	 * and more midi commands need to be generated
! 	 * return 0 to tell the mididriver that the end of stream was reached
! 	 */
! 	typedef int StreamCallback(void *param, MidiEvent *ev, int num);
! 	
! 
! 	/* open modes, pass one of those to open() */
! 	enum {
! 		MO_SIMPLE = 1,
! 		MO_STREAMING = 2,
! 	};
! 
! 	/* Special events that can be inserted in a MidiEvent.
! 	 * event = (ME_xxx<<24) | <24-bit data associated with event>
! 	 */
! 	enum {
! 		ME_NONE  = 0,
! 		ME_TEMPO = 1,
! 	};
! 
! 	/* error codes returned by open.
! 	 * can be converted to a string with get_error_name()
! 	 */
! 	enum {
! 		MERR_CANNOT_CONNECT = 1,
! 		MERR_STREAMING_NOT_AVAILABLE = 2,
! 		MERR_DEVICE_NOT_AVAILABLE = 3,
! 		MERR_ALREADY_OPEN = 4,
! 	};
! 
! 	enum {
! 		PROP_TIMEDIV = 1,
! 	};
! 
! 	
! 	/* destroy the midi object */
! 	virtual void destroy() = 0;
! 
! 	/* open the midi driver.
! 	 * returns 0 if successful.
! 	 * otherwise an error code. */
! 	virtual int open(int mode) = 0;
! 
! 	/* close the midi driver */
! 	virtual void close() = 0;
! 
! 	/* output a packed midi command to the midi stream
! 	 * valid only if mode is MO_SIMPLE
! 	 */
! 	virtual void send(uint32 b) = 0;
! 
! 	/* set callback when more streams need to be generated.
! 	 * valid only when mode==MO_STREAMING
! 	 */
! 	virtual void set_stream_callback(void *param, StreamCallback *sc) = 0;
! 
! 	/* Pause or resume streaming MIDI */
! 	virtual void pause(bool pause) = 0;
! 
! 
! 	/* Get or set a property */
! 	virtual uint32 property(int prop, uint32 param) = 0;
! 
! 	/* retrieve a string representation of an error code */
! 	static const char *get_error_name(int error_code);
! };
! 
! 
! 
! /* driver types */
  enum {
! 	MD_AUTO = 0,
! 	MD_NULL = 1,
! 	MD_WINDOWS = 2,
! 	MD_TIMIDITY = 3,
! 	MD_SEQ = 4,
! 	MD_QTMUSIC = 5,
! 	MD_AMIDI = 6,
  };
+ 
+ 
+ /* Factory functions => no need to include the specific classes
+  * in this header => faster compile */
+ MidiDriver *MidiDriver_NULL_create();
+ MidiDriver *MidiDriver_WIN_create();
+ MidiDriver *MidiDriver_TIMIDITY_create();
+ MidiDriver *MidiDriver_SEQ_create();
+ MidiDriver *MidiDriver_QT_create();
+ MidiDriver *MidiDriver_AMIDI_create();
+ 
+ 
  
  /* Roland to General Midi patch table. Still needs much work. */

Index: imuse.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sound/imuse.cpp,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -d -r1.20 -r1.21
*** imuse.cpp	12 Apr 2002 21:26:35 -0000	1.20
--- imuse.cpp	13 Apr 2002 18:31:45 -0000	1.21
***************
*** 28,43 ****
  #define TICKS_PER_BEAT 480
  
- #ifdef USE_ADLIB
- #ifdef _WIN32_WCE
- #define TEMPO_BASE 0x1F0000 * 2	// Sampled down to 11 kHz
- #else
- #define TEMPO_BASE 0x1924E0
- #endif
- #define HARDWARE_TYPE 1
- #else
- #define TEMPO_BASE 0x400000
- #define HARDWARE_TYPE 5
- #endif
- 
  #define SYSEX_ID 0x7D
  #define SPECIAL_CHANNEL 9
--- 28,31 ----
***************
*** 985,989 ****
  	_s = scumm;
  
! 	_driver = (SOUND_DRIVER_TYPE *) driver;
  
  	_master_volume = 127;
--- 973,979 ----
  	_s = scumm;
  
! 	_driver = driver;
! 
! 	_hardware_type = driver->get_hardware_type();
  
  	_master_volume = 127;
***************
*** 1161,1165 ****
  
  	if (_se->_s->_gameTempo < 1000)
! 		i = TEMPO_BASE;
  	else
  		i = _se->_s->_gameTempo;
--- 1151,1155 ----
  
  	if (_se->_s->_gameTempo < 1000)
! 		i = _se->_driver->get_base_tempo();
  	else
  		i = _se->_s->_gameTempo;
***************
*** 1358,1362 ****
  	case 16:											/* set instrument in part */
  		a = *p++ & 0x0F;
! 		if (HARDWARE_TYPE != *p++)
  			break;
  		decode_sysex_bytes(p, buf, len - 3);
--- 1348,1352 ----
  	case 16:											/* set instrument in part */
  		a = *p++ & 0x0F;
! 		if (_se->_hardware_type != *p++)
  			break;
  		decode_sysex_bytes(p, buf, len - 3);
***************
*** 1368,1372 ****
  	case 17:											/* set global instrument */
  		p++;
! 		if (HARDWARE_TYPE != *p++)
  			break;
  		a = *p++;
--- 1358,1362 ----
  	case 17:											/* set global instrument */
  		p++;
! 		if (_se->_hardware_type != *p++)
  			break;
  		a = *p++;
***************
*** 1377,1381 ****
  	case 33:											/* param adjust */
  		a = *p++ & 0x0F;
! 		if (HARDWARE_TYPE != *p++)
  			break;
  		decode_sysex_bytes(p, buf, len - 3);
--- 1367,1371 ----
  	case 33:											/* param adjust */
  		a = *p++ & 0x0F;
! 		if (_se->_hardware_type != *p++)
  			break;
  		decode_sysex_bytes(p, buf, len - 3);
***************
*** 2401,2405 ****
  void Part::init(SoundDriver * driver)
  {
! 	_drv = (SOUND_DRIVER_TYPE *) driver;
  	_player = NULL;
  	_next = NULL;
--- 2391,2395 ----
  void Part::init(SoundDriver * driver)
  {
! 	_drv = driver;
  	_player = NULL;
  	_next = NULL;





More information about the Scummvm-git-logs mailing list