view music2/music.h @ 36:6d1a5b7f0838

* Updated copyright/license information
author thib
date Sun, 15 Mar 2009 18:47:02 +0000
parents 5ae5533b3a9a
children 15a18fbe6f21
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>

#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;

extern int pcm_enable;

/* 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>
struct MuSys {
	class AyuSysConfig& config;
	char cdrom_track[128]; char effec_track[128];
	int movie_id;
	int music_enable;
	int volmod[4]; // BGM, KOE, PCM, Se
	MuSys(AyuSysConfig& _config);

	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);
};

#endif /* __MUSIC__ */