1 /*
2 Copyright (C) 1994-1995 Apogee Software, Ltd.
3 
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
8 
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 
13 See the 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
18 
19 Modifications for JonoF's port by Jonathon Fowler (jf@jonof.id.au)
20 */
21 /**********************************************************************
22    module: MUSIC.H
23 
24    author: James R. Dose
25    date:   March 25, 1994
26 
27    Public header for MUSIC.C
28 
29    (c) Copyright 1994 James R. Dose.  All Rights Reserved.
30 **********************************************************************/
31 
32 #ifndef __MUSIC_H
33 #define __MUSIC_H
34 
35 #include "compat.h"
36 #include "sndcards.h"
37 
38 extern int MUSIC_ErrorCode;
39 
40 #ifdef __linux__
41 #include <vector>
42 
43 struct alsa_mididevinfo_t
44 {
45   char *name;
46   int clntid;
47   int portid;
48 
alsa_mididevinfo_talsa_mididevinfo_t49   alsa_mididevinfo_t(const char *insrcname, int inclntid, int inportid) :
50     name(Xstrdup(insrcname)), clntid(inclntid), portid(inportid) {}
51 
alsa_mididevinfo_talsa_mididevinfo_t52   alsa_mididevinfo_t(const alsa_mididevinfo_t &rhs)
53   {
54     name = Xstrdup(rhs.name);
55     clntid = rhs.clntid;
56     portid = rhs.portid;
57   }
58 
~alsa_mididevinfo_talsa_mididevinfo_t59   ~alsa_mididevinfo_t() { Xfree(name); }
60 
61   alsa_mididevinfo_t &operator=(const alsa_mididevinfo_t &rhs)
62   {
63     if (this != &rhs)
64     {
65         Xfree(name);
66         name = Xstrdup(rhs.name);
67         clntid = rhs.clntid;
68         portid = rhs.portid;
69     }
70     return *this;
71   }
72 };
73 
74 std::vector<alsa_mididevinfo_t> const ALSADrv_MIDI_ListPorts();
75 
76 extern int32_t ALSA_ClientID;
77 extern int32_t ALSA_PortID;
78 #endif
79 
80 enum MUSIC_ERRORS
81 {
82     MUSIC_Warning = -2,
83     MUSIC_Error   = -1,
84     MUSIC_Ok      = 0,
85     MUSIC_MidiError,
86 };
87 
88 typedef struct
89 {
90     uint32_t tickposition;
91     uint32_t milliseconds;
92     uint32_t measure;
93     uint32_t beat;
94     uint32_t tick;
95 } songposition;
96 
97 #define MUSIC_LoopSong ( 1 == 1 )
98 #define MUSIC_PlayOnce ( !MUSIC_LoopSong )
99 
100 #define MUSIC_SetErrorCode(status) MUSIC_ErrorCode = (status);
101 
102 extern const char *MUSIC_ErrorString(int ErrorNumber);
103 
104 int  MUSIC_Init(int SoundCard);
105 int  MUSIC_Shutdown(void);
106 int  MIDI_GetDevice(void);
107 void MUSIC_SetVolume(int volume);
108 int  MUSIC_GetVolume(void);
109 void MUSIC_SetLoopFlag(int loopflag);
110 void MUSIC_Continue(void);
111 void MUSIC_Pause(void);
112 int  MUSIC_StopSong(void);
113 int  MUSIC_PlaySong(char *song, int songsize, int loopflag, const char *fn = nullptr);
114 void MUSIC_Update(void);
115 
116 /* returns true only after program startup */
MUSIC_WarmedUp(void)117 static FORCE_INLINE int MUSIC_WarmedUp(void)
118 {
119     return ASS_MIDISoundDriver != ASS_AutoDetect;
120 }
121 
122 extern char SF2_BankFile[BMAX_PATH];
123 extern int SF2_EffectSampleBlockSize;
124 
125 #endif
126