[Scummvm-cvs-logs] CVS: scummvm Makefile,1.13,1.14 imuse.cpp,1.1,1.2 readme.txt,1.4,1.5
Claudio Matsuoka
cmatsuoka at users.sourceforge.net
Sun Nov 18 16:24:02 CET 2001
Update of /cvsroot/scummvm/scummvm
In directory usw-pr-cvs1:/tmp/cvs-serv18056
Modified Files:
Makefile imuse.cpp readme.txt
Log Message:
Merged Lionel Ulmer's support to play music in unix using
Timidity.
Index: Makefile
===================================================================
RCS file: /cvsroot/scummvm/scummvm/Makefile,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** Makefile 2001/11/19 00:04:34 1.13
--- Makefile 2001/11/19 00:23:52 1.14
***************
*** 3,7 ****
CC = gcc
CFLAGS = -g -Wno-multichar
! DEFINES = -DUNIX -DHAVE_READLINE
LDFLAGS :=
INCLUDES:= `sdl-config --cflags`
--- 3,7 ----
CC = gcc
CFLAGS = -g -Wno-multichar
! DEFINES = -DUNIX -DHAVE_READLINE -DUSE_TIMIDITY
LDFLAGS :=
INCLUDES:= `sdl-config --cflags`
***************
*** 28,31 ****
--- 28,33 ----
scummvm: $(OBJS)
$(CC) $(LDFLAGS) -o $(@) $(OBJS) $(LIBS)
+
+ $(OBJS): Makefile
clean:
Index: imuse.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/imuse.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** imuse.cpp 2001/11/14 18:37:38 1.1
--- imuse.cpp 2001/11/19 00:23:52 1.2
***************
*** 6,15 ****
* 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
--- 6,15 ----
* 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
***************
*** 17,21 ****
*
* $Header$
! *
*/
--- 17,24 ----
*
* $Header$
! */
!
! /*
! * Timidity support by Lionel Ulmer <lionel.ulmer at free.fr>
*/
***************
*** 24,27 ****
--- 27,46 ----
#include "sound.h"
+ #ifdef USE_TIMIDITY
+ #include <sys/time.h>
+ #include <unistd.h>
+ #include <sys/types.h>
+ #include <sys/socket.h>
+ #include <netinet/in.h>
+ #include <netdb.h>
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+
+ /* Copy-pasted from Timidity */
+ #define SEQ_MIDIPUTC 5
+
+ #endif /* USE_TIMIDITY */
+
#define ARRAYSIZE(x) (sizeof(x)/sizeof(x[0]))
***************
*** 2444,2458 ****
}
void SoundEngine::midiInit() {
- #ifdef WIN32
if (midiOutOpen((HMIDIOUT*)&_mo, MIDI_MAPPER, NULL, NULL, 0) != MMSYSERR_NOERROR)
error("midiOutOpen failed");
- #endif
}
- #ifdef WIN32
#define MIDI_OUT(a,b) midiOutShortMsg((HMIDIOUT)(a), (b))
#else
#define MIDI_OUT(a,b)
#endif
--- 2463,2576 ----
}
+ #if defined(WIN32)
+
void SoundEngine::midiInit() {
if (midiOutOpen((HMIDIOUT*)&_mo, MIDI_MAPPER, NULL, NULL, 0) != MMSYSERR_NOERROR)
error("midiOutOpen failed");
}
#define MIDI_OUT(a,b) midiOutShortMsg((HMIDIOUT)(a), (b))
+
+ #elif defined(USE_TIMIDITY)
+
+ static int connect_to_timidity(int port)
+ {
+ struct hostent *serverhost;
+ struct sockaddr_in sadd;
+ int s;
+
+ serverhost = gethostbyname("localhost");
+ if (serverhost == NULL)
+ error("Could not resolve host");
+ 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 socket");
+ if (connect(s, (struct sockaddr *) &sadd, sizeof(struct sockaddr_in)) < 0)
+ error("Could not connect to server");
+
+ return s;
+ }
+
+ void SoundEngine::midiInit() {
+ 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;
+ }
+
+ #define DEVICE_NUM 0
+
+ static inline void MIDI_OUT(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);
+ }
+
#else
#define MIDI_OUT(a,b)
+ void SoundEngine::midiInit() { }
#endif
***************
*** 2527,2529 ****
MIDI_OUT(_mo, (64<<8)|0xB0|chan);
MIDI_OUT(_mo, (123<<8)|0xB0|chan);
! }
\ No newline at end of file
--- 2645,2647 ----
MIDI_OUT(_mo, (64<<8)|0xB0|chan);
MIDI_OUT(_mo, (123<<8)|0xB0|chan);
! }
Index: readme.txt
===================================================================
RCS file: /cvsroot/scummvm/scummvm/readme.txt,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** readme.txt 2001/11/06 20:07:42 1.4
--- readme.txt 2001/11/19 00:23:52 1.5
***************
*** 42,45 ****
--- 42,55 ----
Ctrl-s shows memory consumption.
+
+ Playing sound with Timidity:
+ ----------------------------
+ Start Timidity with the following command line :
+
+ $ timidity -irv 7777
+
+ Then just start ScummVM and you should have sound.
+
+
Good Luck,
Ludvig Strigeus
More information about the Scummvm-git-logs
mailing list