1 /* $Id: Sound.h,v 1.18 2003/08/03 10:12:59 nan Exp $ */
2 
3 // Copyright (C) 2000-2003  ���� �ȹ�(Kanna Yoshihiro)
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18 
19 #ifndef _Sound_
20 #define _Sound_
21 
22 #define SOUND_QUEUESIZE 16
23 
24 struct buffer {
25   unsigned char const *start;
26   unsigned long length;
27 };
28 
29 class Sound {
30 public:
31   virtual ~Sound();
32 
33   static Sound* TheSound();
34 
35   virtual bool Init( long sndMode );
36   virtual void Clear();
37 
38   //bool Play( char *sndData, long count );
39   bool Play( long soundID, double x, double y );
40   bool PlayScore( long score1, long score2 );
41   bool PlayNumber( long number );
42 
43   long GetSoundMode();
44 
45   long InitBGM( char *filename );
46   long PlayBGM();
47   long StopBGM();
48 
49   // For BGM
50   char *m_bgmSound;
51 
52 #ifdef HAVE_LIBSDL_MIXER
53   Mix_Chunk *m_sound[16];
54   Mix_Chunk *m_score[31];
55   Mix_Music *m_opening;
56 
57   static void PlayFinishHandler( int channel );
58 #endif
59 
60   long m_soundMode;
61 private:
62   Sound();
63   static Sound *m_theSound;
64 
65 #ifdef HAVE_LIBSDL_MIXER
66   Mix_Chunk *m_chunkqueue[SOUND_QUEUESIZE];
67   int m_queuehead;
68   int m_queuetail;
69 
70   bool PlayBlocking( int channel, Mix_Chunk *chunk );
71 #endif
72 };
73 
74 #endif // _Sound_
75