mirror of
https://github.com/haya3218/SDfmL.git
synced 2024-08-14 23:57:09 +00:00
Add new stuff ig?
This commit is contained in:
parent
7d12a4273e
commit
db68d1dae3
9 changed files with 496 additions and 0 deletions
37
DOCUMENTATION.md
Normal file
37
DOCUMENTATION.md
Normal file
|
@ -0,0 +1,37 @@
|
|||
# What the shit is this
|
||||
|
||||
A wrapper build around SDL2, some of its libraries, and SoLoud to make a lot of stuff
|
||||
more easier to use.
|
||||
|
||||
Stuff like:
|
||||
- Rendering functions
|
||||
- Object system
|
||||
- Sound
|
||||
- Configuration
|
||||
- and most possibly, more.... idk.
|
||||
- Less dll binary clutter!
|
||||
|
||||
# How the shit to use it den
|
||||
|
||||
Currently, it only supports MSVC, but you could probably tweak CMakeLists.txt to be able to use
|
||||
MingW, or GCC.
|
||||
|
||||
## Requirements
|
||||
- CMake, to build the damn thing
|
||||
- SDL2 and SDL_ttf 2.0, duh
|
||||
- SoLoud (static library)
|
||||
- A VC++ (MSVC) compiler that atleast supports C++ std 17
|
||||
|
||||
To use it (in windows atleast),
|
||||
|
||||
- Get SDL2 and SDL_ttf 2.0, and put em on the respective x86 and x64 folders.
|
||||
You know how to place them. It's fucking common sense.
|
||||
- [SoLoud.](https://sol.gfxile.net/soloud/index.html) Follow GENie instructions and build as a static library.
|
||||
- If you are gonna be using the OpenMPT module, you'll need the libopenmpt dll in your exe directory as well.
|
||||
- Prebuilt binaries (with OpenMPT) are [here.](https://cdn.discordapp.com/attachments/872338952483381258/942267595824967690/fixed.7z)
|
||||
- Clone the dam repo somewhere on ur machine.
|
||||
- Go to where you cloned it, and run `cmake -B build -DCMAKE_BUILD_TYPE=Release`
|
||||
- After successfully making the build files, run `cmake --build --config Release` to build it without the use of VStudio.
|
||||
- If everything worked well, congratulations! You have just compiled a shitty program.
|
||||
|
||||
`src/Main.cpp` should contain example code with some explanations.
|
58
LICENSING.md
Normal file
58
LICENSING.md
Normal file
|
@ -0,0 +1,58 @@
|
|||
# Licensing
|
||||
|
||||
The sole libraries themselves (SDL, SoLoud) are under the zLib/LibPNG licenses ofc, so you'll have to deal with that
|
||||
|
||||
stb_image is under the Public Domain/MIT.
|
||||
|
||||
TinySoundfont and toml11 are under the MIT License.
|
||||
|
||||
## SDfmL license
|
||||
|
||||
This library is dual-licensed between DBAD and MIT license.
|
||||
|
||||
This means:
|
||||
- I do not care about what you do about this goddam library.
|
||||
- You can sell it, butcher it, burn it, whatever.
|
||||
- Just make sure to not be a dick :)
|
||||
|
||||
MIT is also there *juuuuust* incase your boss aint want that DBAD.
|
||||
|
||||
### DON'T BE A DICK PUBLIC LICENSE
|
||||
|
||||
[Source](https://github.com/philsturgeon/dbad)
|
||||
|
||||
> Version 1.2, February 2021
|
||||
|
||||
> Copyright (C) 2022 Haya, the bitchass
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim or modified copies of this license document.
|
||||
|
||||
> DON'T BE A DICK PUBLIC LICENSE
|
||||
> TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
1. Do whatever you like with the original work, just don't be a dick.
|
||||
|
||||
Being a dick includes - but is not limited to - the following instances:
|
||||
|
||||
1a. Outright copyright infringement - Don't just copy the original work/works and change the name.
|
||||
1b. Selling the unmodified original with no work done what-so-ever, that's REALLY being a dick.
|
||||
1c. Modifying the original work to contain hidden harmful content. That would make you a PROPER dick.
|
||||
|
||||
2. If you become rich through modifications, related works/services, or supporting the original work,
|
||||
share the love. Only a dick would make loads off this work and not buy the original work's
|
||||
creator(s) a pint.
|
||||
|
||||
3. Code is provided with no warranty. Using somebody else's code and bitching when it goes wrong makes
|
||||
you a DONKEY dick. Fix the problem yourself. A non-dick would submit the fix back or submit a [bug report](https://www.chiark.greenend.org.uk/~sgtatham/bugs.html).
|
||||
|
||||
4. If you use code, calling it your own would make you a ROYAL dick. [How to cite a repo](https://academia.stackexchange.com/questions/14010/how-do-you-cite-a-github-repository). Alternatively, even just a comment giving attribution to where you found the code would be OK.
|
||||
|
||||
### MIT License
|
||||
|
||||
> Copyright (C) 2022 Haya, the bitchass
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
BIN
bin/data/solarbeams.xm
Normal file
BIN
bin/data/solarbeams.xm
Normal file
Binary file not shown.
BIN
lib/libraries.7z
Normal file
BIN
lib/libraries.7z
Normal file
Binary file not shown.
70
src/SoLoud/soloud_ay.h
Normal file
70
src/SoLoud/soloud_ay.h
Normal file
|
@ -0,0 +1,70 @@
|
|||
/*
|
||||
AY module for SoLoud audio engine
|
||||
Copyright (c) 2020 Jari Komppa
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
*/
|
||||
|
||||
#ifndef AY_H
|
||||
#define AY_H
|
||||
|
||||
#include "soloud.h"
|
||||
|
||||
class ChipPlayer;
|
||||
|
||||
namespace SoLoud
|
||||
{
|
||||
class Ay;
|
||||
class File;
|
||||
class AyInstance : public AudioSourceInstance
|
||||
{
|
||||
public:
|
||||
Ay *mParent;
|
||||
ChipPlayer *mChip;
|
||||
int mPos;
|
||||
|
||||
AyInstance(Ay *aParent);
|
||||
~AyInstance();
|
||||
virtual unsigned int getAudio(float *aBuffer, unsigned int aSamplesToRead, unsigned int aBufferSize);
|
||||
virtual bool hasEnded();
|
||||
virtual result rewind();
|
||||
virtual float getInfo(unsigned int aInfoKey);
|
||||
};
|
||||
|
||||
class Ay : public AudioSource
|
||||
{
|
||||
public:
|
||||
bool mYm;
|
||||
int mChipspeed;
|
||||
int mCpuspeed;
|
||||
int mLooppos;
|
||||
int mLength;
|
||||
unsigned short* mOps;
|
||||
public:
|
||||
Ay();
|
||||
~Ay();
|
||||
result load(const char *aFilename);
|
||||
result loadFile(File *aFile);
|
||||
result loadMem(const unsigned char* aMem, unsigned int aLength, bool aCopy, bool aTakeOwnership);
|
||||
virtual AudioSourceInstance *createInstance();
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
71
src/SoLoud/soloud_duckfilter.h
Normal file
71
src/SoLoud/soloud_duckfilter.h
Normal file
|
@ -0,0 +1,71 @@
|
|||
/*
|
||||
SoLoud audio engine
|
||||
Copyright (c) 2013-2021 Jari Komppa
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
*/
|
||||
|
||||
#ifndef SOLOUD_DUCKFILTER_H
|
||||
#define SOLOUD_DUCKFILTER_H
|
||||
|
||||
#include "soloud.h"
|
||||
|
||||
namespace SoLoud
|
||||
{
|
||||
class DuckFilter;
|
||||
|
||||
class DuckFilterInstance : public FilterInstance
|
||||
{
|
||||
handle mListenTo;
|
||||
Soloud* mSoloud;
|
||||
float mCurrentLevel;
|
||||
public:
|
||||
virtual void filter(float *aBuffer, unsigned int aSamples, unsigned int aBufferSize, unsigned int aChannels, float aSamplerate, time aTime);
|
||||
virtual ~DuckFilterInstance();
|
||||
DuckFilterInstance(DuckFilter *aParent);
|
||||
};
|
||||
|
||||
class DuckFilter : public Filter
|
||||
{
|
||||
public:
|
||||
enum FILTERATTRIBUTE
|
||||
{
|
||||
WET = 0,
|
||||
ONRAMP,
|
||||
OFFRAMP,
|
||||
LEVEL
|
||||
};
|
||||
Soloud* mSoloud;
|
||||
float mOnRamp;
|
||||
float mOffRamp;
|
||||
float mLevel;
|
||||
handle mListenTo;
|
||||
virtual int getParamCount();
|
||||
virtual const char* getParamName(unsigned int aParamIndex);
|
||||
virtual unsigned int getParamType(unsigned int aParamIndex);
|
||||
virtual float getParamMax(unsigned int aParamIndex);
|
||||
virtual float getParamMin(unsigned int aParamIndex);
|
||||
virtual FilterInstance *createInstance();
|
||||
DuckFilter();
|
||||
result setParams(Soloud* aSoloud, handle aListenTo, float aOnRamp = 0.1f, float aOffRamp = 0.5f, float aLevel = 0.1f);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
82
src/SoLoud/soloud_eqfilter.h
Normal file
82
src/SoLoud/soloud_eqfilter.h
Normal file
|
@ -0,0 +1,82 @@
|
|||
/*
|
||||
SoLoud audio engine
|
||||
Copyright (c) 2013-2020 Jari Komppa
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
*/
|
||||
|
||||
#ifndef SOLOUD_EQFILTER_H
|
||||
#define SOLOUD_EQFILTER_H
|
||||
|
||||
#include "soloud.h"
|
||||
#include "soloud_fftfilter.h"
|
||||
|
||||
namespace SoLoud
|
||||
{
|
||||
class EqFilter;
|
||||
|
||||
class EqFilterInstance : public FFTFilterInstance
|
||||
{
|
||||
enum FILTERATTRIBUTE
|
||||
{
|
||||
WET = 0,
|
||||
BAND1 = 1,
|
||||
BAND2 = 2,
|
||||
BAND3 = 3,
|
||||
BAND4 = 4,
|
||||
BAND5 = 5,
|
||||
BAND6 = 6,
|
||||
BAND7 = 7,
|
||||
BAND8 = 8
|
||||
};
|
||||
EqFilter *mParent;
|
||||
public:
|
||||
virtual void fftFilterChannel(float *aFFTBuffer, unsigned int aSamples, float aSamplerate, time aTime, unsigned int aChannel, unsigned int aChannels);
|
||||
EqFilterInstance(EqFilter *aParent);
|
||||
};
|
||||
|
||||
class EqFilter : public FFTFilter
|
||||
{
|
||||
public:
|
||||
enum FILTERATTRIBUTE
|
||||
{
|
||||
WET = 0,
|
||||
BAND1 = 1,
|
||||
BAND2 = 2,
|
||||
BAND3 = 3,
|
||||
BAND4 = 4,
|
||||
BAND5 = 5,
|
||||
BAND6 = 6,
|
||||
BAND7 = 7,
|
||||
BAND8 = 8
|
||||
};
|
||||
virtual int getParamCount();
|
||||
virtual const char* getParamName(unsigned int aParamIndex);
|
||||
virtual unsigned int getParamType(unsigned int aParamIndex);
|
||||
virtual float getParamMax(unsigned int aParamIndex);
|
||||
virtual float getParamMin(unsigned int aParamIndex);
|
||||
float mVolume[8];
|
||||
result setParam(unsigned int aBand, float aVolume);
|
||||
virtual FilterInstance *createInstance();
|
||||
EqFilter();
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
63
src/SoLoud/soloud_modplug.h
Normal file
63
src/SoLoud/soloud_modplug.h
Normal file
|
@ -0,0 +1,63 @@
|
|||
/*
|
||||
libmodplug module for SoLoud audio engine, fixed
|
||||
Copyright (c) 2014 Jari Komppa, 2022 haya
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
*/
|
||||
|
||||
#ifndef MODPLUG_H
|
||||
#define MODPLUG_H
|
||||
|
||||
#include "soloud.h"
|
||||
|
||||
namespace SoLoud
|
||||
{
|
||||
class Modplug;
|
||||
class File;
|
||||
|
||||
class ModplugInstance : public AudioSourceInstance
|
||||
{
|
||||
Modplug *mParent;
|
||||
void *mModplugfile;
|
||||
int mPlaying;
|
||||
|
||||
public:
|
||||
ModplugInstance(Modplug *aParent);
|
||||
virtual ~ModplugInstance();
|
||||
virtual void getAudio(float *aBuffer, unsigned int aSamples);
|
||||
virtual bool hasEnded();
|
||||
virtual void mpInit(Modplug *aParent);
|
||||
};
|
||||
|
||||
class Modplug : public AudioSource
|
||||
{
|
||||
public:
|
||||
char *mData;
|
||||
unsigned int mDataLen;
|
||||
Modplug();
|
||||
virtual ~Modplug();
|
||||
result load(const char* aFilename);
|
||||
result loadMem(unsigned char *aMem, unsigned int aLength, bool aCopy = false, bool aTakeOwnership = true);
|
||||
result loadFile(File *aFile);
|
||||
virtual AudioSourceInstance *createInstance();
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
115
src/SoLoud/zx7decompress.h
Normal file
115
src/SoLoud/zx7decompress.h
Normal file
|
@ -0,0 +1,115 @@
|
|||
/*
|
||||
* zx7 decompress by Jari Komppa, under public domain / unlicense
|
||||
*
|
||||
* Heavily based on zx7 decompressor by Einar Saukas.
|
||||
* Einar Saukas requests that you mention the use of dx7, but
|
||||
* this is not enforced by any way.
|
||||
*
|
||||
* Note that compressor has a different license!
|
||||
*/
|
||||
|
||||
#ifndef ZX7DECOMPRESS_H
|
||||
#define ZX7DECOMPRESS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct zx7_io
|
||||
{
|
||||
unsigned char* input_data;
|
||||
unsigned char* output_data;
|
||||
size_t input_index;
|
||||
size_t output_index;
|
||||
int bit_mask;
|
||||
int bit_value;
|
||||
};
|
||||
|
||||
static int zx7_read_byte(struct zx7_io *io) {
|
||||
return io->input_data[io->input_index++];
|
||||
}
|
||||
|
||||
static int zx7_read_bit(struct zx7_io *io) {
|
||||
io->bit_mask >>= 1;
|
||||
if (io->bit_mask == 0) {
|
||||
io->bit_mask = 128;
|
||||
io->bit_value = zx7_read_byte(io);
|
||||
}
|
||||
return io->bit_value & io->bit_mask ? 1 : 0;
|
||||
}
|
||||
|
||||
static int zx7_read_elias_gamma(struct zx7_io *io) {
|
||||
int i = 0;
|
||||
int value = 0;
|
||||
|
||||
while (!zx7_read_bit(io)) {
|
||||
i++;
|
||||
}
|
||||
if (i > 15) {
|
||||
return -1;
|
||||
}
|
||||
value = 1;
|
||||
while (i--) {
|
||||
value = value << 1 | zx7_read_bit(io);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
static int zx7_read_offset(struct zx7_io *io) {
|
||||
int value = 0;
|
||||
int i = 0;
|
||||
|
||||
value = zx7_read_byte(io);
|
||||
if (value < 128) {
|
||||
return value;
|
||||
} else {
|
||||
i = zx7_read_bit(io);
|
||||
i = i << 1 | zx7_read_bit(io);
|
||||
i = i << 1 | zx7_read_bit(io);
|
||||
i = i << 1 | zx7_read_bit(io);
|
||||
return (value & 127 | i << 7) + 128;
|
||||
}
|
||||
}
|
||||
|
||||
static void zx7_write_byte(struct zx7_io *io, int value) {
|
||||
io->output_data[io->output_index++] = value;
|
||||
}
|
||||
|
||||
static void zx7_write_bytes(struct zx7_io *io, int offset, int length) {
|
||||
int i;
|
||||
while (length-- > 0) {
|
||||
i = io->output_index - offset;
|
||||
zx7_write_byte(io, io->output_data[i]);
|
||||
}
|
||||
}
|
||||
|
||||
static int zx7_decompress(unsigned char *input_data, unsigned char *output_data) {
|
||||
struct zx7_io io;
|
||||
int length;
|
||||
|
||||
io.input_data = input_data;
|
||||
io.output_data = output_data;
|
||||
io.input_index = 0;
|
||||
io.output_index = 0;
|
||||
io.bit_mask = 0;
|
||||
io.bit_value = 0;
|
||||
|
||||
zx7_write_byte(&io, zx7_read_byte(&io));
|
||||
while (1) {
|
||||
if (!zx7_read_bit(&io)) {
|
||||
zx7_write_byte(&io, zx7_read_byte(&io));
|
||||
} else {
|
||||
length = zx7_read_elias_gamma(&io) + 1;
|
||||
if (length == 0) {
|
||||
return io.input_index;
|
||||
}
|
||||
zx7_write_bytes(&io, zx7_read_offset(&io) + 1, length);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // ZX7DECOMPRESS_H
|
Loading…
Reference in a new issue