2 |
* * |
* * |
3 |
* libgig - C++ cross-platform Gigasampler format file access library * |
* libgig - C++ cross-platform Gigasampler format file access library * |
4 |
* * |
* * |
5 |
* Copyright (C) 2003-2016 by Christian Schoenebeck * |
* Copyright (C) 2003-2019 by Christian Schoenebeck * |
6 |
* <cuse@users.sourceforge.net> * |
* <cuse@users.sourceforge.net> * |
7 |
* * |
* * |
8 |
* This library is free software; you can redistribute it and/or modify * |
* This library is free software; you can redistribute it and/or modify * |
36 |
# define DEBUG 0 |
# define DEBUG 0 |
37 |
#endif |
#endif |
38 |
|
|
39 |
|
#ifndef OVERRIDE |
40 |
|
# if defined(__cplusplus) && __cplusplus >= 201103L |
41 |
|
# define OVERRIDE override |
42 |
|
# else |
43 |
|
# define OVERRIDE |
44 |
|
# endif |
45 |
|
#endif |
46 |
|
|
47 |
#include <string> |
#include <string> |
48 |
#include <list> |
#include <list> |
49 |
#include <map> |
#include <map> |
50 |
#include <set> |
#include <set> |
51 |
|
#include <vector> |
52 |
#include <iostream> |
#include <iostream> |
53 |
|
#include <stdarg.h> |
54 |
|
|
55 |
#ifdef HAVE_CONFIG_H |
#ifdef HAVE_CONFIG_H |
56 |
# include <config.h> |
# include <config.h> |
63 |
# include <unistd.h> |
# include <unistd.h> |
64 |
#endif // POSIX |
#endif // POSIX |
65 |
|
|
66 |
#ifdef _MSC_VER |
#if defined _MSC_VER && _MSC_VER < 1600 |
67 |
// Visual C++ 2008 doesn't have stdint.h |
// Visual C++ 2008 doesn't have stdint.h |
68 |
typedef __int8 int8_t; |
typedef __int8 int8_t; |
69 |
typedef __int16 int16_t; |
typedef __int16 int16_t; |
78 |
#endif |
#endif |
79 |
|
|
80 |
#ifdef WIN32 |
#ifdef WIN32 |
81 |
|
# if (_WIN32 && !_WIN64) || (__GNUC__ && !(__x86_64__ || __ppc64__)) /* if 32 bit windows compilation */ |
82 |
|
# if _WIN32_WINNT < 0x0501 |
83 |
|
# undef _WIN32_WINNT |
84 |
|
# define _WIN32_WINNT 0x0501 /* Win XP (no service pack): required for 32 bit compilation for GetFileSizeEx() to be declared by windows.h */ |
85 |
|
# endif |
86 |
|
# endif |
87 |
# include <windows.h> |
# include <windows.h> |
88 |
typedef unsigned int uint; |
typedef unsigned int uint; |
89 |
#endif // WIN32 |
#endif // WIN32 |
160 |
typedef uint64_t file_offset_t; |
typedef uint64_t file_offset_t; |
161 |
|
|
162 |
/** Whether file stream is open in read or in read/write mode. */ |
/** Whether file stream is open in read or in read/write mode. */ |
163 |
typedef enum { |
enum stream_mode_t { |
164 |
stream_mode_read = 0, |
stream_mode_read = 0, |
165 |
stream_mode_read_write = 1, |
stream_mode_read_write = 1, |
166 |
stream_mode_closed = 2 |
stream_mode_closed = 2 |
167 |
} stream_mode_t; |
}; |
168 |
|
|
169 |
/** Current state of the file stream. */ |
/** Current state of the file stream. */ |
170 |
typedef enum { |
enum stream_state_t { |
171 |
stream_ready = 0, |
stream_ready = 0, |
172 |
stream_end_reached = 1, |
stream_end_reached = 1, |
173 |
stream_closed = 2 |
stream_closed = 2 |
174 |
} stream_state_t; |
}; |
175 |
|
|
176 |
/** File stream position dependent to these relations. */ |
/** File stream position dependent to these relations. */ |
177 |
typedef enum { |
enum stream_whence_t { |
178 |
stream_start = 0, |
stream_start = 0, |
179 |
stream_curpos = 1, |
stream_curpos = 1, |
180 |
stream_backward = 2, |
stream_backward = 2, |
181 |
stream_end = 3 |
stream_end = 3 |
182 |
} stream_whence_t; |
}; |
183 |
|
|
184 |
/** Alignment of data bytes in memory (system dependant). */ |
/** Alignment of data bytes in memory (system dependant). */ |
185 |
typedef enum { |
enum endian_t { |
186 |
endian_little = 0, |
endian_little = 0, |
187 |
endian_big = 1, |
endian_big = 1, |
188 |
endian_native = 2 |
endian_native = 2 |
189 |
} endian_t; |
}; |
190 |
|
|
191 |
/** General RIFF chunk structure of a RIFF file. */ |
/** General RIFF chunk structure of a RIFF file. */ |
192 |
enum layout_t { |
enum layout_t { |
220 |
float __range_min; ///< Only for internal usage, do not modify! |
float __range_min; ///< Only for internal usage, do not modify! |
221 |
float __range_max; ///< Only for internal usage, do not modify! |
float __range_max; ///< Only for internal usage, do not modify! |
222 |
progress_t(); |
progress_t(); |
223 |
|
std::vector<progress_t> subdivide(int iSubtasks); |
224 |
}; |
}; |
225 |
|
|
226 |
/** @brief Ordinary RIFF Chunk |
/** @brief Ordinary RIFF Chunk |
315 |
Chunk* GetNextSubChunk(); |
Chunk* GetNextSubChunk(); |
316 |
List* GetFirstSubList(); |
List* GetFirstSubList(); |
317 |
List* GetNextSubList(); |
List* GetNextSubList(); |
318 |
unsigned int CountSubChunks(); |
size_t CountSubChunks(); |
319 |
unsigned int CountSubChunks(uint32_t ChunkID); |
size_t CountSubChunks(uint32_t ChunkID); |
320 |
unsigned int CountSubLists(); |
size_t CountSubLists(); |
321 |
unsigned int CountSubLists(uint32_t ListType); |
size_t CountSubLists(uint32_t ListType); |
322 |
Chunk* AddSubChunk(uint32_t uiChunkID, file_offset_t ullBodySize); |
Chunk* AddSubChunk(uint32_t uiChunkID, file_offset_t ullBodySize); |
323 |
List* AddSubList(uint32_t uiListType); |
List* AddSubList(uint32_t uiListType); |
324 |
void DeleteSubChunk(Chunk* pSubChunk); |
void DeleteSubChunk(Chunk* pSubChunk); |
418 |
public: |
public: |
419 |
String Message; |
String Message; |
420 |
|
|
421 |
Exception(String Message) { Exception::Message = Message; } |
Exception(String format, ...); |
422 |
|
Exception(String format, va_list arg); |
423 |
void PrintMessage(); |
void PrintMessage(); |
424 |
virtual ~Exception() {} |
virtual ~Exception() {} |
425 |
|
|
426 |
|
protected: |
427 |
|
Exception(); |
428 |
|
static String assemble(String format, va_list arg); |
429 |
}; |
}; |
430 |
|
|
431 |
String libraryName(); |
String libraryName(); |