~ubuntu-branches/ubuntu/hoary/kdemultimedia/hoary

« back to all changes in this revision

Viewing changes to kscd/kscdmagic/syna.h

  • Committer: Bazaar Package Importer
  • Author(s): Martin Schulze
  • Date: 2003-01-22 15:00:51 UTC
  • Revision ID: james.westby@ubuntu.com-20030122150051-uihwkdoxf15mi1tn
Tags: upstream-2.2.2
ImportĀ upstreamĀ versionĀ 2.2.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
   $Id: syna.h,v 1.8 2000/08/11 15:44:48 faure Exp $
 
3
 
 
4
   Synaesthesia - program to display sound graphically
 
5
   Copyright (C) 1997  Paul Francis Harrison
 
6
 
 
7
  This program is free software; you can redistribute it and/or modify it
 
8
  under the terms of the GNU General Public License as published by the
 
9
  Free Software Foundation; either version 2 of the License, or (at your
 
10
  option) any later version.
 
11
 
 
12
  This program is distributed in the hope that it will be useful, but
 
13
  WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
15
  General Public License for more details.
 
16
 
 
17
  You should have received a copy of the GNU General Public License along
 
18
  with this program; if not, write to the Free Software Foundation, Inc.,
 
19
  675 Mass Ave, Cambridge, MA 02139, USA.
 
20
 
 
21
  The author may be contacted at:
 
22
    phar6@student.monash.edu.au
 
23
  or
 
24
    27 Bond St., Mt. Waverley, 3149, Melbourne, Australia
 
25
*/
 
26
 
 
27
#ifndef __SYNA_H__
 
28
#define __SYNA_H__
 
29
 
 
30
 
 
31
#if defined(__linux__) || defined(__svr4__) || defined(__osf__)
 
32
 
 
33
void error(const char *str, bool syscall=false); //Display error and exit
 
34
void warning(const char *str, bool syscall=false); //Display error
 
35
 
 
36
//void error(char *str,bool syscall=false);
 
37
inline void attempt(int x, const char *y, bool syscall=false) { if (x == -1) error(y,syscall); }  
 
38
 
 
39
//void warning(char *str,bool syscall=false);
 
40
inline void attemptNoDie(int x, const char *y, bool syscall=false) { if (x == -1) warning(y,syscall); } 
 
41
 
 
42
#include "polygon.h"
 
43
#include "magicconf.h"
 
44
 
 
45
/***************************************/
 
46
 
 
47
 
 
48
#define PROGNAME "kscdmagic"
 
49
 
 
50
 
 
51
#ifdef __FreeBSD__
 
52
 
 
53
 
 
54
typedef unsigned short sampleType;
 
55
 
 
56
#else
 
57
 
 
58
typedef short sampleType;
 
59
 
 
60
#ifndef __linux__
 
61
 
 
62
#warning This target has not been tested!
 
63
 
 
64
#endif
 
65
#endif
 
66
 
 
67
#ifdef __osf__
 
68
#include <machine/endian.h>
 
69
#else
 
70
#include <endian.h>
 
71
#endif
 
72
#if BYTE_ORDER == BIG_ENDIAN
 
73
#define BIGENDIAN
 
74
#else
 
75
#define LITTLEENDIAN
 
76
#endif
 
77
 
 
78
 
 
79
#define n (1<<m)
 
80
#define recSize (1<<m-overlap)
 
81
 
 
82
/* core */
 
83
extern volatile sampleType *data;
 
84
//extern unsigned char *output, *lastOutput, *lastLastOutput;
 
85
extern Bitmap<unsigned short> outputBmp, lastOutputBmp, lastLastOutputBmp;
 
86
#define ucoutput ((unsigned char*)outputBmp.data)
 
87
#define lastOutput ((unsigned char*)lastOutputBmp.data)
 
88
#define lastLastOutput ((unsigned char*)lastLastOutputBmp.data)
 
89
 
 
90
inline unsigned short combiner(unsigned short a,unsigned short b) {
 
91
  //Not that i want to give the compiler a hint or anything...
 
92
  unsigned char ah = a>>8, al = a&255, bh = b>>8, bl = b&255;
 
93
  if (ah < 64) ah *= 4; else ah = 255;
 
94
  if (al < 64) al *= 4; else al = 255;
 
95
  if (bh > ah) ah = bh;
 
96
  if (bl > al) al = bl;
 
97
  return ah*256+al;
 
98
}
 
99
 
 
100
extern PolygonEngine<unsigned short,combiner,2> polygonEngine;
 
101
 
 
102
extern int outWidth, outHeight;
 
103
 
 
104
void allocOutput(int w,int h);
 
105
 
 
106
void coreInit();
 
107
void setStarSize(double size);
 
108
int coreGo();
 
109
void fade();
 
110
 
 
111
/* *wrap */
 
112
void screenInit(int xHint,int yHint,int widthHint,int heightHint);
 
113
void screenSetPalette(unsigned char *palette);
 
114
void screenEnd(void);
 
115
void screenShow(void);
 
116
int sizeUpdate(void);
 
117
 
 
118
void inputUpdate(int &mouseX,int &mouseY,int &mouseButtons,char &keyHit);
 
119
 
 
120
/* ui */
 
121
void interfaceInit();
 
122
void interfaceSyncToState();
 
123
void interfaceEnd();
 
124
bool interfaceGo();
 
125
 
 
126
enum SymbolID {
 
127
  Speaker, Bulb,
 
128
  Play, Pause, Stop, SkipFwd, SkipBack,
 
129
  Handle, Pointer, Open, NoCD, Exit,
 
130
  Zero, One, Two, Three, Four,
 
131
  Five, Six, Seven, Eight, Nine,
 
132
  Slider, Selector, Plug, Loop, Box, Bar,
 
133
  Flame, Wave, Stars, Star, Diamond, Size, FgColor, BgColor,
 
134
  Save, Reset, TrackSelect,
 
135
  NotASymbol
 
136
};
 
137
 
 
138
/* State information */
 
139
 
 
140
extern SymbolID state;
 
141
extern int track, frames;
 
142
extern double trackProgress;
 
143
extern char **playList;
 
144
extern int playListLength, playListPosition;
 
145
extern SymbolID fadeMode;
 
146
extern bool pointsAreDiamonds;
 
147
extern double brightnessTwiddler; 
 
148
extern double starSize; 
 
149
extern double fgRedSlider, fgGreenSlider, bgRedSlider, bgGreenSlider;
 
150
 
 
151
extern double volume; 
 
152
 
 
153
void setStateToDefaults();
 
154
void saveConfig();
 
155
 
 
156
void putString(char *string,int x,int y,int red,int blue);
 
157
 
 
158
/* sound */
 
159
enum SoundSource { SourceLine, SourceCD, SourcePipe };
 
160
 
 
161
void cdOpen(char *cdromName);
 
162
void cdClose(void);
 
163
void cdGetStatus(int &track, int &frames, SymbolID &state);
 
164
void cdPlay(int trackFrame, int endFrame=-1); 
 
165
void cdStop(void);
 
166
void cdPause(void);
 
167
void cdResume(void);
 
168
void cdEject(void);
 
169
void cdCloseTray(void);
 
170
int cdGetTrackCount(void);
 
171
int cdGetTrackFrame(int track);
 
172
void openSound(SoundSource sound, int downFactor, const char *dspName, char *mixerName);
 
173
void closeSound();
 
174
void setupMixer(double &loudness);
 
175
void setVolume(double loudness);
 
176
int getNextFragment(void);
 
177
 
 
178
 
 
179
#endif // linux || svr4
 
180
#endif // __SYNA_H__