0
|
1 /*
|
|
2 * miniJSS - Main header file
|
|
3 * Programmed and designed by Matti 'ccr' Hamalainen
|
|
4 * (C) Copyright 2006-2007 Tecnic Software productions (TNSP)
|
|
5 */
|
|
6 #ifndef JSS_H
|
|
7 #define JSS_H
|
|
8
|
|
9 #include "dmlib.h"
|
|
10
|
|
11
|
|
12 /* Locking
|
|
13 */
|
|
14 #ifdef JSS_SUP_THREADS
|
|
15 # define JSS_LOCK(Q) dmMutexLock((Q)->mutex)
|
|
16 # define JSS_UNLOCK(Q) dmMutexUnlock((Q)->mutex)
|
|
17 #else
|
|
18 # warning DANGER! JSS threads support not included!
|
|
19 # define JSS_LOCK(Q)
|
|
20 # define JSS_UNLOCK(Q)
|
|
21 #endif
|
|
22
|
|
23
|
|
24 // Global settings
|
|
25 #define jsetNChannels (64) // Max number of channels
|
|
26 #define jsetNotSet (-1) // A global "not set" constant
|
|
27 #define jsetMinVol (0)
|
|
28 #define jsetMaxVol (255)
|
|
29
|
|
30 // Sample instrument flags
|
|
31 #define jsfLooped (0x01) // Is sample looped
|
|
32 #define jsfBiDi (0x02) // Bi-directional loop?
|
|
33 #define jsf16bit (0x04) // 16-bit?
|
|
34 #define JSFSET(a, b) do { a |= b; } while (0)
|
|
35 #define JSFUNSET(a, b) do { a &= (0xff ^ b); } while (0)
|
|
36
|
|
37 // Panning position
|
|
38 #define jchPanLeft (0x00) // Leftmost pan
|
|
39 #define jchPanMiddle (0x80) // Center pan
|
|
40 #define jchPanRight (0xff) // Rightmost pan
|
|
41
|
|
42 // Audio formats
|
|
43 enum
|
|
44 {
|
|
45 JSS_AUDIO_U8, // 8-bit formats
|
|
46 JSS_AUDIO_S8,
|
|
47 JSS_AUDIO_U16, // 16-bit formats
|
|
48 JSS_AUDIO_S16,
|
|
49 JSS_AUDIO_U32, // 32-bit (24+padding)
|
|
50 JSS_AUDIO_S32
|
|
51 } JSS_AUDIO_FMT;
|
|
52
|
|
53
|
|
54 enum
|
|
55 {
|
|
56 JSS_AUDIO_MONO = 1,
|
|
57 JSS_AUDIO_STEREO = 2
|
|
58 } JSS_AUDIO_CHANNELS;
|
|
59
|
|
60
|
|
61 /* System initialization and shutdown
|
|
62 */
|
|
63 int jssInit(void); // Initialization. Call before anything else!
|
|
64 int jssClose(void); // Shutdown. Do not call ANY JSS routines after this!
|
|
65
|
|
66
|
|
67 /* Error handling routines and related variables
|
|
68 */
|
|
69 extern BOOL jssWarningIsFatal, // if TRUE, warnings are considered fatal -> function returns
|
|
70 jssErrorIsFatal; // if FALSE, error is considered non-fatal. this may cause strange problems.
|
|
71
|
|
72 #ifndef JSS_LIGHT
|
|
73 extern void (*jssError)(int code, char *filename, int linen, char *fmt, ...);
|
|
74 extern void (*jssWarning)(int code, char *filename, int linen, char *fmt, ...);
|
|
75 #endif
|
|
76
|
|
77
|
|
78 /* If JSS_LIGHT is NOT defined, we add code for verbose error-, warning-
|
|
79 * and debug-messages. Otherwise use a macro stub.
|
|
80 */
|
|
81 #ifndef JSS_LIGHT
|
|
82 # define JSSERROR(MEVAL, MRET, ...) do { jssError(MEVAL, __FILE__, (int) __LINE__, __VA_ARGS__); if (jssErrorIsFatal) return MRET; } while (0)
|
|
83 # define JSSWARNING(MEVAL, MRET, ...) do { jssWarning(MEVAL, __FILE__, (int) __LINE__, __VA_ARGS__); if (jssWarningIsFatal) return MRET; } while (0)
|
|
84 # ifdef JSS_DEBUG
|
|
85 # define JSSDEBUG(...) do { fprintf(stderr, "[%s:%d]: ", __FILE__, (int) __LINE__); fprintf(stderr, __VA_ARGS__); } while (0)
|
|
86 # else
|
|
87 # define JSSDEBUG(...) do { } while (0)
|
|
88 # endif // NDEBUG
|
|
89 #else
|
|
90 # define JSSERROR(MEVAL, MRET, ...) do { return MRET; } while (0)
|
|
91 # define JSSWARNING(MEVAL, MRET, ...) do { } while (0)
|
|
92 # define JSSDEBUG(...) do { } while (0)
|
|
93 #endif // JSS_LIGHT
|
|
94
|
|
95
|
|
96 #endif // JSS_H
|