view music2/music.h @ 55:f1a27ee7e03c

* started the same changes on scn2k_text.cc * handle opcodes childObj*. In fact, it was handled (in a strange way, but it worked) before the previous changeset
author thib
date Wed, 22 Apr 2009 15:01:42 +0000
parents ddbcbd000206
children
line wrap: on
line source

/*
 * Copyright (c) 2004-2006  Kazunori "jagarl" Ueno
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. The name of the author may not be used to endorse or promote products
 *    derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */


#ifndef __MUSIC__ /* __MUSIC__ */
#define __MUSIC__

#ifdef HAVE_CONFIG_H
#  include "config.h"
#endif

#include <sys/types.h>
#include <sys/time.h>
#include <SDL_mixer.h>

#define MIX_PCM_BGM	4
#define MIX_PCM_EFFEC	5
#define MIX_PCM_KOE	6
#define MIX_PCM_SIZE	8

#define DEFAULT_AUDIOBUF	4096

enum KoeType { koe_unknown, koe_nwk, koe_ovk, koe_ogg};

typedef struct {
	FILE* stream;
	int length;
	int offset;
	int rate;
	KoeType type;
} AvgKoeInfo;

/* koedec.cc */
extern AvgKoeInfo OpenKoeFile(const char* path);
extern char* decode_koe(AvgKoeInfo info, int* len);
extern char* decode_koe_nwa(AvgKoeInfo info, int* len);
extern const char* MakeWavHeader(int rate, int ch, int bps, int size);
extern AvgKoeInfo FindKoe(int file_number, int index);

#include <unistd.h>

class MuSys {
	public:
		static MuSys* GetInstance(void);
		static void Quit(void);
		void PlayCDROM(char* name, int play_count);
		void StopCDROM(int time);
		void PlaySE(const char* name, int loop_flag=0, int channel=0);
		void PlaySE(int number);
		void StopSE(int time = 0);
		bool IsStopSE(void);
		void PlayKoe(const char* fname);
		void StopKoe(int time);
		void PlayMovie(const char* fname, int x1, int y1, int x2, int y2, int loop_count);
		void StopMovie(void);
		bool IsStopMovie(void);
		void InitMusic(void);
		void FinalizeMusic(void);

	private:
		MuSys();

	public:
		int volmod[4]; // BGM, KOE, PCM, Se
		int pcm_enable;
		Mix_Chunk *play_chunk[MIX_PCM_SIZE];

	private:
		class AyuSysConfig *config;
		char cdrom_track[128]; char effec_track[128];
		int movie_id;
		int music_enable;
		static MuSys *_singleton;
};

#endif /* __MUSIC__ */