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
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…
Add table
Add a link
Reference in a new issue