Updated autotools to 1.10.
[synaesthesia.git] / syna.h
blob7ff64f941d0a8924d85886935a7d0ebd539881c6
1 /* Synaesthesia - program to display sound graphically
2 Copyright (C) 1997 Paul Francis Harrison
4 This program is free software; you can redistribute it and/or modify it
5 under the terms of the GNU General Public License as published by the
6 Free Software Foundation; either version 2 of the License, or (at your
7 option) any later version.
9 This program is distributed in the hope that it will be useful, but
10 WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 General Public License for more details.
14 You should have received a copy of the GNU General Public License along
15 with this program; if not, write to the Free Software Foundation, Inc.,
16 675 Mass Ave, Cambridge, MA 02139, USA.
18 The author may be contacted at:
19 phar6@student.monash.edu.au
21 27 Bond St., Mt. Waverley, 3149, Melbourne, Australia
24 #include "config.h"
26 #include "polygon.h"
28 /***************************************/
29 /* For the incurably fiddle prone: */
31 /* log2 of sample size */
32 #define LogSize 10 //was 9
34 /* Brightness */
35 #define Brightness 150
37 /* Sample frequency*/
38 #define Frequency 22050
40 #define DefaultWidth 200
41 #define DefaultHeight 200
43 /***************************************/
45 #define NumSamples (1<<LogSize)
46 #define RecSize (1<<LogSize-Overlap)
48 #ifdef __FreeBSD__
50 typedef unsigned short sampleType;
52 #else
54 typedef short sampleType;
56 #ifndef __linux__
58 #warning This target has not been tested!
60 #endif
61 #endif
63 #ifdef __FreeBSD__
64 #include <machine/endian.h>
65 #else
66 #include <endian.h>
67 #endif
69 #if BYTE_ORDER == BIG_ENDIAN
70 #define BIGENDIAN
71 #else
72 #define LITTLEENDIAN
73 #endif
75 void error(char *str,bool syscall=false);
76 void inline attempt(int x,char *y,bool syscall=false) { if (x == -1) error(y,syscall); }
77 void warning(char *str,bool syscall=false);
78 void inline attemptNoDie(int x,char *y,bool syscall=false) { if (x == -1) warning(y,syscall); }
80 /* *wrap */
81 struct BaseScreen {
82 virtual bool init(int xHint, int yHint, int widthHint, int heightHint, bool fullscreen) = 0;
83 virtual void setPalette(unsigned char *palette) = 0;
84 virtual void end() = 0;
85 virtual void inputUpdate(int &mouseX,int &mouseY,int &mouseButtons,char &keyHit) = 0;
86 virtual void show() = 0;
87 virtual void toggleFullScreen() { }
90 struct SvgaScreen : public BaseScreen {
91 bool init(int xHint, int yHint, int widthHint, int heightHint, bool fullscreen);
92 void setPalette(unsigned char *palette);
93 void end();
94 void inputUpdate(int &mouseX,int &mouseY,int &mouseButtons,char &keyHit);
95 void show();
98 struct SdlScreen : public BaseScreen {
99 bool init(int xHint, int yHint, int widthHint, int heightHint, bool fullscreen);
100 void setPalette(unsigned char *palette);
101 void end();
102 void inputUpdate(int &mouseX,int &mouseY,int &mouseButtons,char &keyHit);
103 void show();
104 void toggleFullScreen();
107 struct XScreen : public BaseScreen {
108 bool init(int xHint, int yHint, int widthHint, int heightHint, bool fullscreen);
109 void setPalette(unsigned char *palette);
110 void end();
111 void inputUpdate(int &mouseX,int &mouseY,int &mouseButtons,char &keyHit);
112 void show();
115 /* core */
116 extern BaseScreen *screen;
117 extern sampleType *data;
118 extern Bitmap<unsigned short> outputBmp, lastOutputBmp, lastLastOutputBmp;
119 #define output ((unsigned char*)outputBmp.data)
120 #define lastOutput ((unsigned char*)lastOutputBmp.data)
121 #define lastLastOutput ((unsigned char*)lastLastOutputBmp.data)
123 struct Combiner {
124 static unsigned short combine(unsigned short a,unsigned short b) {
125 //Not that i want to give the compiler a hint or anything...
126 unsigned char ah = a>>8, al = a&255, bh = b>>8, bl = b&255;
127 if (ah < 64) ah *= 4; else ah = 255;
128 if (al < 64) al *= 4; else al = 255;
129 if (bh > ah) ah = bh;
130 if (bl > al) al = bl;
131 return ah*256+al;
135 extern PolygonEngine<unsigned short,Combiner,2> polygonEngine;
137 extern int outWidth, outHeight;
139 void allocOutput(int w,int h);
141 void coreInit();
142 void setStarSize(double size);
143 int coreGo();
144 void fade();
146 /* ui */
147 void interfaceInit();
148 void interfaceSyncToState();
149 void interfaceEnd();
150 bool interfaceGo();
152 enum SymbolID {
153 Speaker, Bulb,
154 Play, Pause, Stop, SkipFwd, SkipBack,
155 Handle, Pointer, Open, NoCD, Exit,
156 Zero, One, Two, Three, Four,
157 Five, Six, Seven, Eight, Nine,
158 Slider, Selector, Plug, Loop, Box, Bar,
159 Flame, Wave, Stars, Star, Diamond, Size, FgColor, BgColor,
160 Save, Reset, TrackSelect,
161 NotASymbol
164 /* State information */
166 extern SymbolID state;
167 extern int track, frames;
168 extern double trackProgress;
169 extern char **playList;
170 extern int playListLength, playListPosition;
171 extern SymbolID fadeMode;
172 extern bool pointsAreDiamonds;
173 extern double brightnessTwiddler;
174 extern double starSize;
175 extern double fgRedSlider, fgGreenSlider, bgRedSlider, bgGreenSlider;
177 extern double volume;
179 void setStateToDefaults();
180 void saveConfig();
182 void putString(char *string,int x,int y,int red,int blue);
184 /* sound */
185 enum SoundSource { SourceLine, SourceCD, SourcePipe, SourceESD };
187 void cdOpen(char *cdromName);
188 void cdClose(void);
189 void cdGetStatus(int &track, int &frames, SymbolID &state);
190 void cdPlay(int trackFrame, int endFrame=-1);
191 void cdStop(void);
192 void cdPause(void);
193 void cdResume(void);
194 void cdEject(void);
195 void cdCloseTray(void);
196 int cdGetTrackCount(void);
197 int cdGetTrackFrame(int track);
198 void openSound(SoundSource sound, int downFactor, char *dspName, char *mixerName);
199 void closeSound();
200 void setupMixer(double &loudness);
201 void setVolume(double loudness);
202 int getNextFragment(void);