Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "-e rawout" to "play" a file to an OPL2/3 .RAW file #9

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ adplay_SOURCES = adplay.cc output.cc output.h players.h defines.h

EXTRA_adplay_SOURCES = oss.cc oss.h null.h disk.cc disk.h esound.cc esound.h \
qsa.cc qsa.h sdl.cc sdl_driver.h alsa.cc alsa.h ao.cc ao.h getopt.c \
getopt1.c getopt.h
getopt1.c getopt.h diskraw.h

adplay_LDADD = $(drivers) $(adplug_LIBS) @ESD_LIBS@ @QSA_LIBS@ @SDL_LIBS@ \
@ALSA_LIBS@ @AO_LIBS@ $(GETOPT_SOURCES)
Expand Down
25 changes: 22 additions & 3 deletions src/adplay.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <adplug/emuopl.h>
#include <adplug/kemuopl.h>
#include <adplug/wemuopl.h>
#include <adplug/diskopl.h>

/*
* Sun systems declare getopt in unistd.h,
Expand Down Expand Up @@ -79,6 +80,7 @@ typedef enum {
#ifdef HAVE_ADPLUG_NUKEDOPL
Emu_Nuked,
#endif
Emu_Rawout,
} EmuType;

/***** Global variables *****/
Expand Down Expand Up @@ -184,11 +186,11 @@ static void usage()
program_name);

// Print list of available output mechanisms
printf("Available emulators: satoh ken woody ");
printf("Available emulators: satoh ken woody");
#ifdef HAVE_ADPLUG_NUKEDOPL
printf("nuked");
printf(" nuked");
#endif
printf("\n");
printf(" rawout\n");
printf("Available output mechanisms: "
#ifdef DRIVER_OSS
"oss "
Expand Down Expand Up @@ -320,6 +322,11 @@ static int decode_switches(int argc, char **argv)
#ifdef HAVE_ADPLUG_NUKEDOPL
else if(!strcmp(optarg, "nuked")) cfg.emutype = Emu_Nuked;
#endif
else if(!strcmp(optarg, "rawout")) {
cfg.emutype = Emu_Rawout;
cfg.endless = false; // endless output is almost never desired here
}

mywave82 marked this conversation as resolved.
Show resolved Hide resolved
else {
message(MSG_ERROR, "unknown emulator -- %s", optarg);
exit(EXIT_FAILURE);
Expand All @@ -330,6 +337,10 @@ static int decode_switches(int argc, char **argv)
}
if (!cfg.loops) cfg.loops = 1;

if (cfg.emutype == Emu_Rawout) {
cfg.output = diskraw; // output must be diskraw when Emu_Rawout is selected
}

return optind;
}

Expand Down Expand Up @@ -426,6 +437,7 @@ int main(int argc, char **argv)
int optind, i;
const char *homedir;
char *userdb = NULL;
CDiskopl *dopl = 0;

// init
program_name = argv[0];
Expand Down Expand Up @@ -540,6 +552,9 @@ int main(int argc, char **argv)
}
break;
#endif
case Emu_Rawout:
dopl = new CDiskopl(cfg.device);
opl = dopl;
}

// init player
Expand Down Expand Up @@ -590,6 +605,10 @@ int main(int argc, char **argv)
cfg.buf_size);
break;
#endif
case diskraw:
player = new DiskRawWriter(dopl);
dopl = NULL;
break;
default:
message(MSG_ERROR, "output method not available");
exit(EXIT_FAILURE);
Expand Down
45 changes: 45 additions & 0 deletions src/diskraw.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* AdPlay/UNIX - OPL2 audio player
* Copyright (C) 2001, 2002 Simon Peter <[email protected]>
*
* 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, 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.
*/

#ifndef H_DISKRAW
#define H_DISKRAW

#include "output.h"

/* pairs up to AdPlay CDiskopl */
class DiskRawWriter: public Player
{
public:
DiskRawWriter(CDiskopl *nopl)
:opl(nopl)
{ }

virtual void frame() {
playing = p->update();
opl->update(p);
}

virtual Copl *get_opl()
{ return opl; }

private:
CDiskopl *opl;
};

#endif
4 changes: 3 additions & 1 deletion src/players.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include "config.h"

// Enumerate ALL outputs (regardless of availability)
enum Outputs {none, null, ao, oss, disk, esound, qsa, sdl, alsa};
enum Outputs {none, null, ao, oss, disk, esound, qsa, sdl, alsa, diskraw};

#define DEFAULT_DRIVER none

Expand Down Expand Up @@ -88,4 +88,6 @@ enum Outputs {none, null, ao, oss, disk, esound, qsa, sdl, alsa};
#define DEFAULT_DRIVER qsa
#endif

#include "diskraw.h"

#endif