Stub for the raw output.
[synaesthesia.git] / syna.h
blob747137fa1a4ea847d663c096f8d7222ebb15c4b5
1 /* Synaesthesia - program to display sound graphically
2 Copyright (C) 1997 Paul Francis Harrison
3 Copyright (C) 2009 RafaƂ Rzepecki <divided.mind@gmail.com>
5 This program is free software; you can redistribute it and/or modify it
6 under the terms of the GNU General Public License as published by the
7 Free Software Foundation; either version 2 of the License, or (at your
8 option) any later version.
10 This program is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
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 St, Fifth Floor, Boston, MA 02110-1301 USA
19 The author may be contacted at:
20 phar6@student.monash.edu.au
22 27 Bond St., Mt. Waverley, 3149, Melbourne, Australia
25 #include "config.h"
27 #include "polygon.h"
29 /***************************************/
30 /* For the incurably fiddle prone: */
32 /* log2 of sample size */
33 #define LogSize 10 //was 9
35 /* Brightness */
36 #define Brightness 150
38 /* Sample frequency*/
39 #define Frequency 22050
41 #define DefaultWidth 200
42 #define DefaultHeight 200
44 /***************************************/
46 #define NumSamples (1<<LogSize)
47 #define RecSize (1<<LogSize-Overlap)
49 #ifdef __FreeBSD__
51 typedef unsigned short sampleType;
53 #else
55 typedef short sampleType;
57 #ifndef __linux__
59 #warning This target has not been tested!
61 #endif
62 #endif
64 #ifdef __FreeBSD__
65 #include <machine/endian.h>
66 #else
67 #include <endian.h>
68 #endif
70 #if BYTE_ORDER == BIG_ENDIAN
71 #define BIGENDIAN
72 #else
73 #define LITTLEENDIAN
74 #endif
76 void error(char *str,bool syscall=false);
77 void inline attempt(int x,char *y,bool syscall=false) { if (x == -1) error(y,syscall); }
78 void warning(char *str,bool syscall=false);
79 void inline attemptNoDie(int x,char *y,bool syscall=false) { if (x == -1) warning(y,syscall); }
81 /* *wrap */
82 struct BaseScreen {
83 virtual bool init(int xHint, int yHint, int widthHint, int heightHint, bool fullscreen) = 0;
84 virtual void setPalette(unsigned char *palette) = 0;
85 virtual void end() = 0;
86 virtual void inputUpdate(int &mouseX,int &mouseY,int &mouseButtons,char &keyHit) = 0;
87 virtual void show() = 0;
88 virtual void toggleFullScreen() { }
91 struct SvgaScreen : public BaseScreen {
92 bool init(int xHint, int yHint, int widthHint, int heightHint, bool fullscreen);
93 void setPalette(unsigned char *palette);
94 void end();
95 void inputUpdate(int &mouseX,int &mouseY,int &mouseButtons,char &keyHit);
96 void show();
99 struct RawScreen : public BaseScreen {
100 bool init(int xHint, int yHint, int widthHint, int heightHint, bool fullscreen);
101 void setPalette(unsigned char *palette);
102 void end();
103 void inputUpdate(int &mouseX,int &mouseY,int &mouseButtons,char &keyHit);
104 void show();
107 struct SdlScreen : 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();
113 void toggleFullScreen();
116 struct XScreen : public BaseScreen {
117 bool init(int xHint, int yHint, int widthHint, int heightHint, bool fullscreen);
118 void setPalette(unsigned char *palette);
119 void end();
120 void inputUpdate(int &mouseX,int &mouseY,int &mouseButtons,char &keyHit);
121 void show();
124 /* core */
125 extern BaseScreen *screen;
126 extern sampleType *data;
127 extern Bitmap<unsigned short> outputBmp, lastOutputBmp, lastLastOutputBmp;
128 #define output ((unsigned char*)outputBmp.data)
129 #define lastOutput ((unsigned char*)lastOutputBmp.data)
130 #define lastLastOutput ((unsigned char*)lastLastOutputBmp.data)
132 struct Combiner {
133 static unsigned short combine(unsigned short a,unsigned short b) {
134 //Not that i want to give the compiler a hint or anything...
135 unsigned char ah = a>>8, al = a&255, bh = b>>8, bl = b&255;
136 if (ah < 64) ah *= 4; else ah = 255;
137 if (al < 64) al *= 4; else al = 255;
138 if (bh > ah) ah = bh;
139 if (bl > al) al = bl;
140 return ah*256+al;
144 extern PolygonEngine<unsigned short,Combiner,2> polygonEngine;
146 extern int outWidth, outHeight;
148 void allocOutput(int w,int h);
150 void coreInit();
151 void setStarSize(double size);
152 int coreGo();
153 void fade();
155 /* ui */
156 void interfaceInit();
157 void interfaceSyncToState();
158 void interfaceEnd();
159 bool interfaceGo();
161 enum SymbolID {
162 Speaker, Bulb,
163 Play, Pause, Stop, SkipFwd, SkipBack,
164 Handle, Pointer, Open, NoCD, Exit,
165 Zero, One, Two, Three, Four,
166 Five, Six, Seven, Eight, Nine,
167 Slider, Selector, Plug, Loop, Box, Bar,
168 Flame, Wave, Stars, Star, Diamond, Size, FgColor, BgColor,
169 Save, Reset, TrackSelect,
170 NotASymbol
173 /* State information */
175 extern SymbolID state;
176 extern int track, frames;
177 extern double trackProgress;
178 extern char **playList;
179 extern int playListLength, playListPosition;
180 extern SymbolID fadeMode;
181 extern bool pointsAreDiamonds;
182 extern double brightnessTwiddler;
183 extern double starSize;
184 extern double fgRedSlider, fgGreenSlider, bgRedSlider, bgGreenSlider;
186 extern double volume;
188 void setStateToDefaults();
189 void saveConfig();
191 void putString(char *string,int x,int y,int red,int blue);
193 /* sound */
194 enum SoundSource { SourceLine, SourceCD, SourcePipe, SourceESD };
196 void cdOpen(char *cdromName);
197 void cdClose(void);
198 void cdGetStatus(int &track, int &frames, SymbolID &state);
199 void cdPlay(int trackFrame, int endFrame=-1);
200 void cdStop(void);
201 void cdPause(void);
202 void cdResume(void);
203 void cdEject(void);
204 void cdCloseTray(void);
205 int cdGetTrackCount(void);
206 int cdGetTrackFrame(int track);
207 void openSound(SoundSource sound, int downFactor, char *dspName, char *mixerName);
208 void closeSound();
209 void setupMixer(double &loudness);
210 void setVolume(double loudness);
211 int getNextFragment(void);