mirror of
https://github.com/kichikuou/xsystem35-sdl2.git
synced 2026-10-04 12:48:00 +03:00
MIDI: drop extplayer backend and add sdlmixer backend
This commit is contained in:
+3
-6
@@ -36,12 +36,12 @@
|
||||
/* define this if you use ltdl */
|
||||
#undef ENABLE_LTDL
|
||||
|
||||
/* define this if you use external midi player */
|
||||
#undef ENABLE_MIDI_EXTPLAYER
|
||||
|
||||
/* define this if you use oss raw midi interface */
|
||||
#undef ENABLE_MIDI_RAWMIDI
|
||||
|
||||
/* define this if you use SDL_mixer for midi */
|
||||
#undef ENABLE_MIDI_SDLMIXER
|
||||
|
||||
/* define thsi if you use oss sequencer interface */
|
||||
#undef ENABLE_MIDI_SEQMIDI
|
||||
|
||||
@@ -241,9 +241,6 @@
|
||||
/* midi device */
|
||||
#undef MIDI_DEVICE
|
||||
|
||||
/* midi player */
|
||||
#undef MIDI_PLAYER
|
||||
|
||||
/* Define if dlsym() requires a leading underscore in symbol names. */
|
||||
#undef NEED_USCORE
|
||||
|
||||
|
||||
@@ -871,7 +871,6 @@ with_cdromdev
|
||||
with_locale
|
||||
enable_bgr
|
||||
enable_midi
|
||||
with_midi_player
|
||||
enable_qmidi
|
||||
with_mididev
|
||||
with_seqdev
|
||||
@@ -1568,7 +1567,7 @@ Optional Features:
|
||||
You should check whether your X server is RGB or
|
||||
BGR order, especially in sparc architecture.
|
||||
--enable-midi=mode_list Enable midi (Specify comma separated mode list):
|
||||
extp: External midi player(default)
|
||||
sdl: SDL_mixer(default)
|
||||
raw: Raw midi interface
|
||||
seq: Sequencer interface
|
||||
--enable-qmidi No display midi stdout
|
||||
@@ -1603,7 +1602,6 @@ Optional Packages:
|
||||
--with-sdl-exec-prefix=PFX Exec prefix where SDL is installed (optional)
|
||||
--with-cdromdev=# CDROM Device Name. [default=/dev/cdrom]
|
||||
--with-locale=LOCALE locale name you want to use(ex. ja_JP.ujis)
|
||||
--with-midi-player=xxx External Midi Player default=playmidi -4
|
||||
--with-mididev=# MIDI Raw Device Name. [default=/dev/midi]
|
||||
--with-seqdev=# MIDI Sequencer Device Name. [default=/dev/sequencer]
|
||||
--with-cachesize=# General Cache size (MB)
|
||||
@@ -17076,16 +17074,16 @@ fi
|
||||
if test "x$enable_midi" = xdefault; then
|
||||
case "$target" in
|
||||
*)
|
||||
enable_midi_extp=yes
|
||||
enable_midi_sdl=yes
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
SRC_MIDI=
|
||||
if test "x$enable_midi_extp" = xyes; then
|
||||
SRC_MIDI="midi.extplayer.c"
|
||||
if test "x$enable_midi_sdl" = xyes; then
|
||||
SRC_MIDI="midi.sdlmixer.c"
|
||||
|
||||
$as_echo "#define ENABLE_MIDI_EXTPLAYER 1" >>confdefs.h
|
||||
$as_echo "#define ENABLE_MIDI_SDLMIXER 1" >>confdefs.h
|
||||
|
||||
fi
|
||||
if test "x$enable_midi_raw" = xyes || test "x$enable_midi_seq" = xyes; then
|
||||
@@ -17103,20 +17101,6 @@ $as_echo "#define ENABLE_MIDI_SEQMIDI 1" >>confdefs.h
|
||||
fi
|
||||
|
||||
|
||||
|
||||
# Check whether --with-midi-player was given.
|
||||
if test "${with_midi_player+set}" = set; then :
|
||||
withval=$with_midi_player; midiplayer="$withval"
|
||||
else
|
||||
midiplayer="playmidi -4"
|
||||
fi
|
||||
|
||||
|
||||
cat >>confdefs.h <<_ACEOF
|
||||
#define MIDI_PLAYER "$midiplayer"
|
||||
_ACEOF
|
||||
|
||||
|
||||
# Check whether --enable-qmidi was given.
|
||||
if test "${enable_qmidi+set}" = set; then :
|
||||
enableval=$enable_qmidi;
|
||||
@@ -17870,8 +17854,8 @@ fi
|
||||
if test "x$enable_midi_seq" = xyes; then
|
||||
echo " - OSS sequencer interface"
|
||||
fi
|
||||
if test "x$enable_midi_extp" = xyes; then
|
||||
echo " - External MIDI Player"
|
||||
if test "x$enable_midi_sdl" = xyes; then
|
||||
echo " - SDL_mixer MIDI Player"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
|
||||
+7
-14
@@ -333,7 +333,7 @@ dnl Select Midi Play Methods
|
||||
dnl
|
||||
AC_ARG_ENABLE(midi,
|
||||
[ --enable-midi[=mode_list] Enable midi (Specify comma separated mode list):
|
||||
extp: External midi player(default)
|
||||
sdl: SDL_mixer(default)
|
||||
raw: Raw midi interface
|
||||
seq: Sequencer interface],
|
||||
[ enable_midi=$enableval],
|
||||
@@ -351,15 +351,15 @@ fi
|
||||
if test "x$enable_midi" = xdefault; then
|
||||
case "$target" in
|
||||
*)
|
||||
enable_midi_extp=yes
|
||||
enable_midi_sdl=yes
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
SRC_MIDI=
|
||||
if test "x$enable_midi_extp" = xyes; then
|
||||
SRC_MIDI="midi.extplayer.c"
|
||||
AC_DEFINE(ENABLE_MIDI_EXTPLAYER,1,[define this if you use external midi player])
|
||||
if test "x$enable_midi_sdl" = xyes; then
|
||||
SRC_MIDI="midi.sdlmixer.c"
|
||||
AC_DEFINE(ENABLE_MIDI_SDLMIXER,1,[define this if you use SDL_mixer for midi])
|
||||
fi
|
||||
if test "x$enable_midi_raw" = xyes || test "x$enable_midi_seq" = xyes; then
|
||||
SRC_MIDI="$SRC_MIDI midi.rawmidi.c midifile.c"
|
||||
@@ -372,13 +372,6 @@ if test "x$enable_midi_raw" = xyes || test "x$enable_midi_seq" = xyes; then
|
||||
fi
|
||||
AC_SUBST(SRC_MIDI)
|
||||
|
||||
dnl
|
||||
dnl set midi player
|
||||
dnl
|
||||
AC_ARG_WITH(midi-player,[ --with-midi-player=xxx External Midi Player [default=playmidi -4]],
|
||||
midiplayer="$withval",midiplayer="playmidi -4")
|
||||
AC_DEFINE_UNQUOTED(MIDI_PLAYER,"$midiplayer",[midi player])
|
||||
|
||||
dnl
|
||||
dnl Quiet mode for external midi player
|
||||
dnl
|
||||
@@ -594,8 +587,8 @@ fi
|
||||
if test "x$enable_midi_seq" = xyes; then
|
||||
echo " - OSS sequencer interface"
|
||||
fi
|
||||
if test "x$enable_midi_extp" = xyes; then
|
||||
echo " - External MIDI Player"
|
||||
if test "x$enable_midi_sdl" = xyes; then
|
||||
echo " - SDL_mixer MIDI Player"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
|
||||
+5
-5
@@ -34,8 +34,8 @@ static char *player;
|
||||
static char default_mode = 'e';
|
||||
static int subdev = -1;
|
||||
|
||||
#ifdef ENABLE_MIDI_EXTPLAYER
|
||||
extern mididevice_t midi_extplayer;
|
||||
#ifdef ENABLE_MIDI_SDLMIXER
|
||||
extern mididevice_t midi_sdlmixer;
|
||||
#endif
|
||||
|
||||
#if defined(ENABLE_MIDI_RAWMIDI) || defined(ENABLE_MIDI_SEQMIDI)
|
||||
@@ -54,9 +54,9 @@ int midi_init(mididevice_t *midi) {
|
||||
#endif
|
||||
break;
|
||||
case 'e':
|
||||
#ifdef ENABLE_MIDI_EXTPLAYER
|
||||
ret = midi_extplayer.init(player, 0);
|
||||
memcpy(midi, &midi_extplayer, sizeof(mididevice_t));
|
||||
#ifdef ENABLE_MIDI_SDLMIXER
|
||||
ret = midi_sdlmixer.init(player, 0);
|
||||
memcpy(midi, &midi_sdlmixer, sizeof(mididevice_t));
|
||||
#endif
|
||||
break;
|
||||
case '0':
|
||||
|
||||
@@ -1,344 +0,0 @@
|
||||
/*
|
||||
* midi.extplayer.c midi play with external player
|
||||
*
|
||||
* Copyright (C) 1999- Fumihiko Murata <fmurata@p1.tcnet.ne.jp>
|
||||
*
|
||||
* 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
|
||||
*
|
||||
*/
|
||||
/* $Id: midi.extplayer.c,v 1.22 2003/11/09 15:06:13 chikama Exp $ */
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#include <errno.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
#include "portab.h"
|
||||
#include "system.h"
|
||||
#include "counter.h"
|
||||
#include "midi.h"
|
||||
#include "music_private.h"
|
||||
#include "music_pcm.h"
|
||||
#include "nact.h"
|
||||
|
||||
|
||||
/* for debugging */
|
||||
#if 0
|
||||
# define KILL(pid, sig) ( \
|
||||
fprintf(stderr, "%s:%d:kill %d %d\n", \
|
||||
__FILE__, __LINE__, (pid), (sig)), \
|
||||
fflush(stderr), \
|
||||
kill((pid), (sig))\
|
||||
)
|
||||
|
||||
# define KILLPG(pid, sig) ( \
|
||||
fprintf(stderr, "%s:%d:killpg %d %d\n", \
|
||||
__FILE__, __LINE__, (pid), (sig)), \
|
||||
fflush(stderr), \
|
||||
killpg((pid), (sig))\
|
||||
)
|
||||
#else
|
||||
# define KILL(pid, sig) kill((pid), (sig))
|
||||
# define KILLPG(pid, sig) killpg((pid), (sig))
|
||||
#endif
|
||||
|
||||
extern void sys_set_signalhandler(int SIG, void (*handler)(int));
|
||||
|
||||
static int midi_initilize(char *pname, int subdev);
|
||||
static int midi_exit();
|
||||
static int midi_start(int no, char *data, int datalen);
|
||||
static int midi_stop();
|
||||
static int midi_pause(void);
|
||||
static int midi_unpause(void);
|
||||
static int midi_get_playing_info(midiplaystate *st);
|
||||
static int midi_getflag(int mode, int index);
|
||||
static int midi_setflag(int mode, int index, int val);
|
||||
static int midi_setVolumePipe(int vol);
|
||||
static int midi_getVolumePipe();
|
||||
|
||||
|
||||
#define midi midi_extplayer
|
||||
mididevice_t midi = {
|
||||
midi_initilize,
|
||||
midi_exit,
|
||||
midi_start,
|
||||
midi_stop,
|
||||
midi_pause,
|
||||
midi_unpause,
|
||||
midi_get_playing_info,
|
||||
midi_getflag,
|
||||
midi_setflag,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
static boolean enabled = FALSE;
|
||||
static char midi_player[256];
|
||||
static int argc;
|
||||
static char **argv;
|
||||
static int midino; // 現在演奏中の番号
|
||||
static pid_t midipid; // 外部プレーヤーの pid
|
||||
static int counter; // 演奏時間
|
||||
static boolean pipedplay; // pipe play モードかどうか
|
||||
|
||||
static void player_set(char *buf) {
|
||||
char *b, *bb;
|
||||
int i, j;
|
||||
|
||||
if (buf[0] == '-') {
|
||||
pipedplay = TRUE;
|
||||
buf++;
|
||||
} else {
|
||||
pipedplay = FALSE;
|
||||
}
|
||||
|
||||
strncpy(midi_player, buf, sizeof(midi_player));
|
||||
b = midi_player;
|
||||
|
||||
if (!pipedplay) {
|
||||
/* count arguments */
|
||||
i = j = 0;
|
||||
while (*b != 0) {
|
||||
if (*(b++) == ' ' && j > 0) {
|
||||
i++; j = 0;
|
||||
while (*b == ' ') b++;
|
||||
} else {
|
||||
j++;
|
||||
}
|
||||
if (*b == '\n') *b = 0;
|
||||
}
|
||||
if (j == 0 && i > 0) i--;
|
||||
if (NULL == (argv = (char **)malloc(sizeof(char *) * (i +3)))) {
|
||||
return;
|
||||
}
|
||||
argc = i +1;
|
||||
|
||||
/* devide argument */
|
||||
b = midi_player;
|
||||
j = 0;
|
||||
while (j <= i) {
|
||||
argv[j] = b;
|
||||
while (*b != ' ' && *b != 0) b++;
|
||||
*(b++) = 0;
|
||||
while (*b == ' ' || *b == 0) b++;
|
||||
j++;
|
||||
}
|
||||
argv[j +1] = NULL;
|
||||
|
||||
/* cut down argv[0] */
|
||||
bb = b = argv[0];
|
||||
while (*b != 0) {
|
||||
if ( *b == '/') bb = b +1;
|
||||
b++;
|
||||
}
|
||||
argv[0] = bb;
|
||||
}
|
||||
}
|
||||
|
||||
static int midi_initilize(char *pname, int sub) {
|
||||
if (pname == NULL) return -1;
|
||||
player_set(pname);
|
||||
|
||||
reset_counter_high(SYSTEMCOUNTER_MIDI, 10, 0);
|
||||
enabled = TRUE;
|
||||
|
||||
if (pipedplay) {
|
||||
midi.setvol = midi_setVolumePipe;
|
||||
midi.getvol = midi_getVolumePipe;
|
||||
NOTICE("midi piped play mode\n");
|
||||
} else {
|
||||
NOTICE("midi external player mode\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int midi_exit() {
|
||||
char tmpfilename[256];
|
||||
int i;
|
||||
|
||||
if (enabled) {
|
||||
midi_stop();
|
||||
}
|
||||
|
||||
for (i = 0; i < 256; i++) {
|
||||
snprintf(tmpfilename, sizeof(tmpfilename)-1, "%s/xsys35-midi_%03d.mid", nact->tmpdir, i);
|
||||
unlink(tmpfilename);
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
/* no = 0~ */
|
||||
static int midi_start(int no, char *data, int datalen) {
|
||||
char tmpfilename[256];
|
||||
FILE *fd;
|
||||
char cmd_pipe[256];
|
||||
pid_t pid;
|
||||
|
||||
snprintf(tmpfilename, sizeof(tmpfilename) -1, "%s/xsys35-midi_%03d.mid", nact->tmpdir, no);
|
||||
if (NULL == (fd = fopen(tmpfilename, "rb"))) {
|
||||
if (NULL == (fd = fopen(tmpfilename, "wb"))) {
|
||||
WARNING("cannot open tmporaryfile");
|
||||
return NG;
|
||||
}
|
||||
fwrite(data, 1, datalen, fd);
|
||||
}
|
||||
fclose(fd);
|
||||
|
||||
if (pipedplay) {
|
||||
snprintf(cmd_pipe, sizeof(cmd_pipe) -1, "%s %s", midi_player, tmpfilename);
|
||||
if (-1 == muspcm_load_pipe(SLOT_MIDIPIPE, cmd_pipe)) {
|
||||
return NG;
|
||||
}
|
||||
muspcm_start(SLOT_MIDIPIPE, 1);
|
||||
pid = 1; // dummy
|
||||
} else {
|
||||
/* arg set */
|
||||
argv[argc] = tmpfilename;
|
||||
argv[argc +1] = NULL;
|
||||
|
||||
pid = fork();
|
||||
if (pid == 0) {
|
||||
/* child process */
|
||||
pid_t mine = getpid();
|
||||
#ifdef QUITE_MIDI
|
||||
close(1);
|
||||
#endif
|
||||
setpgid(mine, mine);
|
||||
sys_set_signalhandler(SIGTERM, SIG_DFL);
|
||||
execvp(midi_player, argv);
|
||||
perror("execvp");
|
||||
_exit(-1);
|
||||
} else if (pid < 0) {
|
||||
WARNING("fork failed");
|
||||
return NG;
|
||||
}
|
||||
}
|
||||
|
||||
midino = no;
|
||||
midipid = pid;
|
||||
counter = get_high_counter(SYSTEMCOUNTER_MIDI);
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
static int midi_stop() {
|
||||
int status = 0;
|
||||
|
||||
if (!enabled || midipid == 0) {
|
||||
return OK;
|
||||
}
|
||||
|
||||
if (!pipedplay) {
|
||||
KILL(midipid, SIGCONT);
|
||||
KILLPG(midipid, SIGCONT);
|
||||
KILL(midipid, SIGTERM);
|
||||
KILLPG(midipid, SIGTERM);
|
||||
while (0 >= waitpid(midipid, &status, WNOHANG));
|
||||
} else {
|
||||
muspcm_stop(SLOT_MIDIPIPE);
|
||||
}
|
||||
|
||||
midipid = 0;
|
||||
midino = 0;
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
static int midi_pause(void) {
|
||||
if (!enabled || midipid == 0) return OK;
|
||||
|
||||
if (pipedplay) {
|
||||
muspcm_pause(SLOT_MIDIPIPE);
|
||||
} else {
|
||||
KILLPG(midipid, SIGTSTP);
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
static int midi_unpause(void) {
|
||||
if (!enabled || midipid == 0) return OK;
|
||||
|
||||
if (pipedplay) {
|
||||
muspcm_unpause(SLOT_MIDIPIPE);
|
||||
} else {
|
||||
KILLPG(midipid, SIGCONT);
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
static int midi_get_playing_info(midiplaystate *st) {
|
||||
int status, cnt, err;
|
||||
|
||||
if (!enabled || midipid == 0) {
|
||||
goto errout;
|
||||
}
|
||||
|
||||
if (pipedplay) {
|
||||
cnt = muspcm_getpos(SLOT_MIDIPIPE);
|
||||
if (cnt == 0) {
|
||||
goto errout;
|
||||
}
|
||||
} else {
|
||||
if (midipid == (err = waitpid(midipid, &status, WNOHANG))) {
|
||||
midipid = 0;
|
||||
goto errout;
|
||||
}
|
||||
cnt = (get_high_counter(SYSTEMCOUNTER_MIDI) - counter) * 10;
|
||||
}
|
||||
|
||||
st->in_play = TRUE;
|
||||
st->play_no = midino;
|
||||
st->loc_ms = cnt;
|
||||
|
||||
return OK;
|
||||
|
||||
errout:
|
||||
st->in_play = FALSE;
|
||||
st->play_no = 0;
|
||||
st->loc_ms = 0;
|
||||
return NG;
|
||||
}
|
||||
|
||||
static int midi_getflag(int mode, int index) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int midi_setflag(int mode, int index, int val) {
|
||||
return NG;
|
||||
}
|
||||
|
||||
static int midi_setVolumePipe(int vol) {
|
||||
if (prv.pcm[SLOT_CDROMPIPE] != NULL) {
|
||||
prv.pcm[SLOT_CDROMPIPE]->vollv = vol;
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
static int midi_getVolumePipe() {
|
||||
if (prv.pcm[SLOT_CDROMPIPE] != NULL) {
|
||||
return prv.pcm[SLOT_CDROMPIPE]->vollv;
|
||||
}
|
||||
return 100;
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
/*
|
||||
* midi.sdlmixer.c midi play with SDL_mixer
|
||||
*
|
||||
* Copyright (C) 2019 <KichikuouChrome@gmail.com>
|
||||
*
|
||||
* 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
|
||||
*
|
||||
*/
|
||||
|
||||
#include <SDL_mixer.h>
|
||||
|
||||
#include "portab.h"
|
||||
#include "counter.h"
|
||||
#include "midi.h"
|
||||
|
||||
static int midi_initilize(char *pname, int subdev);
|
||||
static int midi_exit();
|
||||
static int midi_start(int no, char *data, int datalen);
|
||||
static int midi_stop();
|
||||
static int midi_pause(void);
|
||||
static int midi_unpause(void);
|
||||
static int midi_get_playing_info(midiplaystate *st);
|
||||
static int midi_getflag(int mode, int index);
|
||||
static int midi_setflag(int mode, int index, int val);
|
||||
static int midi_setvol(int vol);
|
||||
static int midi_getvol();
|
||||
|
||||
#define midi midi_sdlmixer
|
||||
mididevice_t midi = {
|
||||
midi_initilize,
|
||||
midi_exit,
|
||||
midi_start,
|
||||
midi_stop,
|
||||
midi_pause,
|
||||
midi_unpause,
|
||||
midi_get_playing_info,
|
||||
midi_getflag,
|
||||
midi_setflag,
|
||||
midi_setvol,
|
||||
midi_getvol
|
||||
};
|
||||
|
||||
static Mix_Music *mix_music;
|
||||
static int midino;
|
||||
static int counter;
|
||||
|
||||
static int midi_initilize(char *pname, int subdev) {
|
||||
if (Mix_Init(MIX_INIT_MID) != MIX_INIT_MID)
|
||||
return NG;
|
||||
reset_counter_high(SYSTEMCOUNTER_MIDI, 10, 0);
|
||||
return OK;
|
||||
}
|
||||
|
||||
static int midi_exit() {
|
||||
Mix_Quit();
|
||||
return OK;
|
||||
}
|
||||
|
||||
static int midi_start(int no, char *data, int datalen) {
|
||||
midi_stop();
|
||||
|
||||
SDL_RWops *rwops = SDL_RWFromConstMem(data, datalen);
|
||||
mix_music = Mix_LoadMUSType_RW(rwops, MUS_MID, SDL_TRUE /* freesrc */);
|
||||
if (!mix_music)
|
||||
return NG;
|
||||
|
||||
if (Mix_PlayMusic(mix_music, 1) != 0) {
|
||||
Mix_FreeMusic(mix_music);
|
||||
mix_music = NULL;
|
||||
return NG;
|
||||
}
|
||||
|
||||
midino = no;
|
||||
counter = get_high_counter(SYSTEMCOUNTER_MIDI);
|
||||
return OK;
|
||||
}
|
||||
|
||||
static int midi_stop() {
|
||||
if (!mix_music)
|
||||
return OK;
|
||||
Mix_FreeMusic(mix_music);
|
||||
mix_music = NULL;
|
||||
midino = 0;
|
||||
return OK;
|
||||
}
|
||||
|
||||
static int midi_pause(void) {
|
||||
// FIXME: adjust counter
|
||||
Mix_PauseMusic();
|
||||
return OK;
|
||||
}
|
||||
|
||||
static int midi_unpause(void) {
|
||||
// FIXME: adjust counter
|
||||
Mix_ResumeMusic();
|
||||
return OK;
|
||||
}
|
||||
|
||||
static int midi_get_playing_info(midiplaystate *st) {
|
||||
if (midino == 0) {
|
||||
st->in_play = FALSE;
|
||||
st->play_no = 0;
|
||||
st->loc_ms = 0;
|
||||
return OK;
|
||||
}
|
||||
|
||||
int cnt = get_high_counter(SYSTEMCOUNTER_MIDI) - counter;
|
||||
|
||||
st->in_play = TRUE;
|
||||
st->play_no = midino;
|
||||
st->loc_ms = cnt * 10;
|
||||
return OK;
|
||||
}
|
||||
|
||||
static int midi_getflag(int mode, int index) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int midi_setflag(int mode, int index, int val) {
|
||||
return NG;
|
||||
}
|
||||
|
||||
static int midi_setvol(int vol) {
|
||||
Mix_VolumeMusic(vol * MIX_MAX_VOLUME / 100);
|
||||
return OK;
|
||||
}
|
||||
|
||||
static int midi_getvol() {
|
||||
return Mix_VolumeMusic(-1) * 100 / MIX_MAX_VOLUME;
|
||||
}
|
||||
+10
-16
@@ -99,32 +99,28 @@ boolean mus_cdrom_get_state() {
|
||||
* loop: 繰り返し回数 (0の場合は無限)
|
||||
*/
|
||||
int mus_midi_start(int no, int loop) {
|
||||
printf("%s not implemented\n", __func__);
|
||||
return NG;
|
||||
return musmidi_start(no, loop);
|
||||
}
|
||||
|
||||
/*
|
||||
* midi の演奏停止
|
||||
*/
|
||||
int mus_midi_stop(void) {
|
||||
printf("%s not implemented\n", __func__);
|
||||
return NG;
|
||||
return musmidi_stop();
|
||||
}
|
||||
|
||||
/*
|
||||
* midi の一時停止
|
||||
*/
|
||||
int mus_midi_pause(void) {
|
||||
printf("%s not implemented\n", __func__);
|
||||
return NG;
|
||||
return musmidi_pause();
|
||||
}
|
||||
|
||||
/*
|
||||
* midi の一時停止解除
|
||||
*/
|
||||
int mus_midi_unpause(void) {
|
||||
printf("%s not implemented\n", __func__);
|
||||
return NG;
|
||||
return musmidi_unpause();
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -133,8 +129,9 @@ int mus_midi_unpause(void) {
|
||||
* 停止している場合は 0 が入る
|
||||
*/
|
||||
int mus_midi_get_playposition(midiplaystate *state) {
|
||||
printf("%s not implemented\n", __func__);
|
||||
return NG;
|
||||
midiplaystate st = musmidi_getpos();
|
||||
*state = st;
|
||||
return OK;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -145,8 +142,7 @@ int mus_midi_get_playposition(midiplaystate *state) {
|
||||
* val : 書き込む値
|
||||
*/
|
||||
int mus_midi_set_flag(int mode, int index, int val) {
|
||||
printf("%s not implemented\n", __func__);
|
||||
return NG;
|
||||
return musmidi_setflag(mode, index, val);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -158,8 +154,7 @@ int mus_midi_set_flag(int mode, int index, int val) {
|
||||
* return : flag/variable の値
|
||||
*/
|
||||
int mus_midi_get_flag(int mode, int index) {
|
||||
printf("%s not implemented\n", __func__);
|
||||
return NG;
|
||||
return musmidi_getflag(mode, index);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -168,8 +163,7 @@ int mus_midi_get_flag(int mode, int index) {
|
||||
* TRUE -> 有効
|
||||
*/
|
||||
boolean mus_midi_get_state() {
|
||||
printf("%s not implemented\n", __func__);
|
||||
return FALSE;
|
||||
return prv.midi_valid;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
+5
-1
@@ -77,22 +77,26 @@ int musmidi_start(int no, int loop) {
|
||||
prv.midi.in_play = FALSE;
|
||||
|
||||
prv.midi.dfile = dfile;
|
||||
|
||||
musmidi_cb();
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
int musmidi_stop() {
|
||||
prv.midi.st = MIDI_STOP;
|
||||
musmidi_cb();
|
||||
return OK;
|
||||
}
|
||||
|
||||
int musmidi_pause() {
|
||||
prv.midi.st = MIDI_PAUSE;
|
||||
musmidi_cb();
|
||||
return OK;
|
||||
}
|
||||
|
||||
int musmidi_unpause() {
|
||||
prv.midi.st = MIDI_UNPAUSE;
|
||||
musmidi_cb();
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -131,8 +131,8 @@ static void sys35_usage(boolean verbose) {
|
||||
puts(" -O0 : Disable Audio output");
|
||||
|
||||
puts(" -M? : select output midi methos");
|
||||
#ifdef ENABLE_MIDI_EXTPLAYER
|
||||
puts(" -Me : External midi player");
|
||||
#ifdef ENABLE_MIDI_SDLMIXER
|
||||
puts(" -Me : SDL_mixer midi player");
|
||||
#endif
|
||||
#ifdef ENABLE_MIDI_RAWMIDI
|
||||
puts(" -Mr : Raw Midi device");
|
||||
|
||||
Reference in New Issue
Block a user