Mercurial > hg > dmlib
annotate minijss/jss.h @ 2298:b5abfff07ca9
Add new DMGrowBuf helper functions dmGrowBufCopyOffsSize() and
dmGrowBufConstCopyOffsSize().
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 04 Jul 2019 10:54:16 +0300 |
parents | aa3738b121d1 |
children | d6b9410f1b1b |
rev | line source |
---|---|
0 | 1 /* |
2 * miniJSS - Main header file | |
3 * Programmed and designed by Matti 'ccr' Hamalainen | |
1163 | 4 * (C) Copyright 2006-2015 Tecnic Software productions (TNSP) |
0 | 5 */ |
6 #ifndef JSS_H | |
7 #define JSS_H | |
8 | |
9 #include "dmlib.h" | |
10 | |
358 | 11 #ifdef __cplusplus |
12 extern "C" { | |
13 #endif | |
14 | |
0 | 15 |
16 /* Locking | |
17 */ | |
18 #ifdef JSS_SUP_THREADS | |
19 # define JSS_LOCK(Q) dmMutexLock((Q)->mutex) | |
20 # define JSS_UNLOCK(Q) dmMutexUnlock((Q)->mutex) | |
21 #else | |
22 # warning DANGER! JSS threads support not included! | |
23 # define JSS_LOCK(Q) | |
24 # define JSS_UNLOCK(Q) | |
25 #endif | |
26 | |
27 | |
28 // Global settings | |
29 #define jsetNChannels (64) // Max number of channels | |
30 #define jsetNotSet (-1) // A global "not set" constant | |
31 #define jsetMinVol (0) | |
32 #define jsetMaxVol (255) | |
33 | |
34 // Sample instrument flags | |
35 #define jsfLooped (0x01) // Is sample looped | |
36 #define jsfBiDi (0x02) // Bi-directional loop? | |
37 #define jsf16bit (0x04) // 16-bit? | |
44
064d1d1d5b0f
Add new functions, jssConvertSampleFromFP() and jssConvertSampleToFP().
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
38 |
0 | 39 #define JSFSET(a, b) do { a |= b; } while (0) |
40 #define JSFUNSET(a, b) do { a &= (0xff ^ b); } while (0) | |
41 | |
42 // Panning position | |
43 #define jchPanLeft (0x00) // Leftmost pan | |
44 #define jchPanMiddle (0x80) // Center pan | |
45 #define jchPanRight (0xff) // Rightmost pan | |
46 | |
47 // Audio formats | |
48 enum | |
49 { | |
50 JSS_AUDIO_U8, // 8-bit formats | |
51 JSS_AUDIO_S8, | |
52 JSS_AUDIO_U16, // 16-bit formats | |
53 JSS_AUDIO_S16, | |
54 JSS_AUDIO_U32, // 32-bit (24+padding) | |
55 JSS_AUDIO_S32 | |
56 } JSS_AUDIO_FMT; | |
57 | |
58 | |
59 enum | |
60 { | |
61 JSS_AUDIO_MONO = 1, | |
62 JSS_AUDIO_STEREO = 2 | |
63 } JSS_AUDIO_CHANNELS; | |
64 | |
65 | |
66 /* System initialization and shutdown | |
67 */ | |
68 int jssInit(void); // Initialization. Call before anything else! | |
69 int jssClose(void); // Shutdown. Do not call ANY JSS routines after this! | |
70 | |
71 | |
72 /* Error handling routines and related variables | |
73 */ | |
1133
2af228303727
#ifdef out code that is not needed or used if JSS_LIGHT is defined.
Matti Hamalainen <ccr@tnsp.org>
parents:
658
diff
changeset
|
74 #ifndef JSS_LIGHT |
0 | 75 extern BOOL jssWarningIsFatal, // if TRUE, warnings are considered fatal -> function returns |
76 jssErrorIsFatal; // if FALSE, error is considered non-fatal. this may cause strange problems. | |
77 | |
520 | 78 extern void (*jssError)(int code, const char *filename, int linen, const char *fmt, ...); |
79 extern void (*jssWarning)(int code, const char *filename, int linen, const char *fmt, ...); | |
0 | 80 #endif |
81 | |
82 | |
83 /* If JSS_LIGHT is NOT defined, we add code for verbose error-, warning- | |
84 * and debug-messages. Otherwise use a macro stub. | |
85 */ | |
86 #ifndef JSS_LIGHT | |
1134
d0898867ec4c
Various fixes for issues reported by clang static analyzer.
Matti Hamalainen <ccr@tnsp.org>
parents:
1133
diff
changeset
|
87 # define JSSERROR(MEVAL, MRET, ...) do { jssError(MEVAL, __FILE__, (int) __LINE__, __VA_ARGS__); return MRET; } while (0) |
0 | 88 # define JSSWARNING(MEVAL, MRET, ...) do { jssWarning(MEVAL, __FILE__, (int) __LINE__, __VA_ARGS__); if (jssWarningIsFatal) return MRET; } while (0) |
89 # ifdef JSS_DEBUG | |
90 # define JSSDEBUG(...) do { fprintf(stderr, "[%s:%d]: ", __FILE__, (int) __LINE__); fprintf(stderr, __VA_ARGS__); } while (0) | |
91 # else | |
92 # define JSSDEBUG(...) do { } while (0) | |
93 # endif // NDEBUG | |
94 #else | |
1136
2cb0955b50f6
Oops, duped a macro argument name. Fixed.
Matti Hamalainen <ccr@tnsp.org>
parents:
1134
diff
changeset
|
95 # define JSSERROR(MEVAL, MRET, ...) return MRET |
0 | 96 # define JSSWARNING(MEVAL, MRET, ...) do { } while (0) |
97 # define JSSDEBUG(...) do { } while (0) | |
98 #endif // JSS_LIGHT | |
99 | |
100 | |
358 | 101 #ifdef __cplusplus |
102 } | |
103 #endif | |
104 | |
0 | 105 #endif // JSS_H |