Browse Source
libretro-common: update
libretro-common: update
Signed-off-by: Mahyar Koshkouei <mahyar.koshkouei@gmail.com>master
Mahyar Koshkouei
6 years ago
205 changed files with 1514 additions and 540 deletions
-
4libretro-common/audio/audio_mix.c
-
405libretro-common/audio/audio_mixer.c
-
2libretro-common/audio/conversion/float_to_s16.c
-
2libretro-common/audio/conversion/float_to_s16_neon.S
-
2libretro-common/audio/conversion/float_to_s16_neon.c
-
2libretro-common/audio/conversion/s16_to_float.c
-
2libretro-common/audio/conversion/s16_to_float_neon.S
-
2libretro-common/audio/conversion/s16_to_float_neon.c
-
2libretro-common/audio/dsp_filter.c
-
7libretro-common/audio/dsp_filters/Tremolo.dsp
-
7libretro-common/audio/dsp_filters/Vibrato.dsp
-
2libretro-common/audio/dsp_filters/fft/fft.c
-
2libretro-common/audio/dsp_filters/fft/fft.h
-
84libretro-common/audio/dsp_filters/reverb.c
-
133libretro-common/audio/dsp_filters/tremolo.c
-
169libretro-common/audio/dsp_filters/vibrato.c
-
2libretro-common/audio/resampler/audio_resampler.c
-
2libretro-common/audio/resampler/drivers/nearest_resampler.c
-
2libretro-common/audio/resampler/drivers/null_resampler.c
-
2libretro-common/audio/resampler/drivers/sinc_resampler.c
-
2libretro-common/audio/resampler/drivers/sinc_resampler_neon.S
-
2libretro-common/compat/compat_fnmatch.c
-
2libretro-common/compat/compat_getopt.c
-
2libretro-common/compat/compat_posix_string.c
-
7libretro-common/compat/compat_snprintf.c
-
2libretro-common/compat/compat_strcasestr.c
-
2libretro-common/compat/compat_strl.c
-
25libretro-common/compat/fopen_utf8.c
-
2libretro-common/dynamic/dylib.c
-
2libretro-common/encodings/encoding_crc32.c
-
2libretro-common/encodings/encoding_utf.c
-
10libretro-common/features/features_cpu.c
-
6libretro-common/file/archive_file.c
-
2libretro-common/file/archive_file_7z.c
-
22libretro-common/file/archive_file_zlib.c
-
4libretro-common/file/config_file.c
-
2libretro-common/file/config_file_userdata.c
-
12libretro-common/file/file_path.c
-
2libretro-common/file/nbio/nbio_intf.c
-
2libretro-common/file/nbio/nbio_linux.c
-
2libretro-common/file/nbio/nbio_stdio.c
-
2libretro-common/file/nbio/nbio_unixmmap.c
-
2libretro-common/file/nbio/nbio_windowsmmap.c
-
10libretro-common/file/retro_dirent.c
-
2libretro-common/formats/bmp/rbmp.c
-
2libretro-common/formats/bmp/rbmp_encode.c
-
2libretro-common/formats/image_texture.c
-
2libretro-common/formats/image_transfer.c
-
2libretro-common/formats/jpeg/rjpeg.c
-
2libretro-common/formats/json/jsonsax.c
-
0libretro-common/formats/libchdr/libchdr_bitstream.c
-
0libretro-common/formats/libchdr/libchdr_cdrom.c
-
204libretro-common/formats/libchdr/libchdr_chd.c
-
3libretro-common/formats/libchdr/libchdr_flac.c
-
3libretro-common/formats/libchdr/libchdr_huffman.c
-
2libretro-common/formats/png/rpng.c
-
2libretro-common/formats/png/rpng_encode.c
-
2libretro-common/formats/png/rpng_internal.h
-
2libretro-common/formats/tga/rtga.c
-
2libretro-common/formats/wav/rwav.c
-
2libretro-common/formats/xml/rxml.c
-
2libretro-common/formats/xml/test/rxml_test.c
-
2libretro-common/gfx/gl_capabilities.c
-
2libretro-common/gfx/scaler/pixconv.c
-
6libretro-common/gfx/scaler/scaler.c
-
2libretro-common/gfx/scaler/scaler_filter.c
-
2libretro-common/gfx/scaler/scaler_int.c
-
4libretro-common/glsm/glsm.c
-
2libretro-common/glsym/glsym_gl.c
-
2libretro-common/glsym/rglgen.c
-
2libretro-common/hash/rhash.c
-
2libretro-common/include/audio/audio_mix.h
-
8libretro-common/include/audio/audio_mixer.h
-
2libretro-common/include/audio/audio_resampler.h
-
2libretro-common/include/audio/conversion/float_to_s16.h
-
2libretro-common/include/audio/conversion/s16_to_float.h
-
2libretro-common/include/audio/dsp_filter.h
-
2libretro-common/include/boolean.h
-
2libretro-common/include/clamping.h
-
2libretro-common/include/compat/apple_compat.h
-
2libretro-common/include/compat/fnmatch.h
-
30libretro-common/include/compat/fopen_utf8.h
-
2libretro-common/include/compat/getopt.h
-
2libretro-common/include/compat/intrinsics.h
-
2libretro-common/include/compat/msvc.h
-
2libretro-common/include/compat/posix_string.h
-
2libretro-common/include/compat/strcasestr.h
-
2libretro-common/include/compat/strl.h
-
2libretro-common/include/dynamic/dylib.h
-
2libretro-common/include/encodings/crc32.h
-
2libretro-common/include/encodings/utf.h
-
2libretro-common/include/encodings/win32.h
-
2libretro-common/include/fastcpy.h
-
2libretro-common/include/features/features_cpu.h
-
4libretro-common/include/file/archive_file.h
-
2libretro-common/include/file/config_file.h
-
2libretro-common/include/file/config_file_userdata.h
-
8libretro-common/include/file/file_path.h
-
2libretro-common/include/file/nbio.h
-
2libretro-common/include/filters.h
@ -0,0 +1,7 @@ |
|||
filters = 1 |
|||
filter0 = tremolo |
|||
|
|||
# Defaults. |
|||
#tremolo_frequency = 4.0 |
|||
#tremolo_depth = 0.9 |
|||
|
@ -0,0 +1,7 @@ |
|||
filters = 1 |
|||
filter0 = vibrato |
|||
|
|||
# Defaults. |
|||
#vibrato_frequency = 5.0 |
|||
#vibrato_depth = 0.5 |
|||
|
@ -0,0 +1,133 @@ |
|||
/* Copyright (C) 2010-2017 The RetroArch team |
|||
* |
|||
* --------------------------------------------------------------------------------------- |
|||
* The following license statement only applies to this file (tremolo.c). |
|||
* --------------------------------------------------------------------------------------- |
|||
* |
|||
* 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. |
|||
*/ |
|||
|
|||
#include <math.h> |
|||
#include <stdlib.h> |
|||
#include <string.h> |
|||
|
|||
#include <retro_miscellaneous.h> |
|||
#include <libretro_dspfilter.h> |
|||
#include <string/stdstring.h> |
|||
|
|||
#define sqr(a) ((a) * (a)) |
|||
|
|||
struct tremolo_core |
|||
{ |
|||
float freq; |
|||
float depth; |
|||
float* wavetable; |
|||
int index; |
|||
int maxindex; |
|||
}; |
|||
|
|||
struct tremolo |
|||
{ |
|||
struct tremolo_core left, right; |
|||
}; |
|||
|
|||
static void tremolo_free(void *data) |
|||
{ |
|||
struct tremolo *tre = (struct tremolo*)data; |
|||
free(tre->left.wavetable); |
|||
free(tre->right.wavetable); |
|||
free(data); |
|||
} |
|||
|
|||
static void tremolocore_init(struct tremolo_core *core,float depth,int samplerate,float freq) |
|||
{ |
|||
const double offset = 1. - depth / 2.; |
|||
unsigned i; |
|||
double env; |
|||
core->index = 0; |
|||
core->maxindex = samplerate/freq; |
|||
core->wavetable = malloc(core->maxindex*sizeof(float)); |
|||
memset(core->wavetable, 0, core->maxindex * sizeof(float)); |
|||
for (i = 0; i < core->maxindex; i++) { |
|||
env = freq * i / samplerate; |
|||
env = sin((M_PI*2) * fmod(env + 0.25, 1.0)); |
|||
core->wavetable[i] = env * (1 - fabs(offset)) + offset; |
|||
} |
|||
} |
|||
|
|||
float tremolocore_core(struct tremolo_core *core,float in) |
|||
{ |
|||
core->index = core->index % core->maxindex; |
|||
return in * core->wavetable[core->index++]; |
|||
} |
|||
|
|||
static void tremolo_process(void *data, struct dspfilter_output *output, |
|||
const struct dspfilter_input *input) |
|||
{ |
|||
unsigned i; |
|||
float *out; |
|||
struct tremolo *tre = (struct tremolo*)data; |
|||
|
|||
output->samples = input->samples; |
|||
output->frames = input->frames; |
|||
out = output->samples; |
|||
|
|||
for (i = 0; i < input->frames; i++, out += 2) |
|||
{ |
|||
float in[2] = { out[0], out[1] }; |
|||
|
|||
out[0] = tremolocore_core(&tre->left, in[0]); |
|||
out[1] = tremolocore_core(&tre->right, in[1]); |
|||
} |
|||
} |
|||
|
|||
static void *tremolo_init(const struct dspfilter_info *info, |
|||
const struct dspfilter_config *config, void *userdata) |
|||
{ |
|||
float freq, depth; |
|||
struct tremolo *tre = (struct tremolo*)calloc(1, sizeof(*tre)); |
|||
if (!tre) |
|||
return NULL; |
|||
|
|||
config->get_float(userdata, "freq", &freq,4.0f); |
|||
config->get_float(userdata, "depth", &depth, 0.9f); |
|||
tremolocore_init(&tre->left,depth,info->input_rate,freq); |
|||
tremolocore_init(&tre->right,depth,info->input_rate,freq); |
|||
return tre; |
|||
} |
|||
|
|||
static const struct dspfilter_implementation tremolo_plug = { |
|||
tremolo_init, |
|||
tremolo_process, |
|||
tremolo_free, |
|||
|
|||
DSPFILTER_API_VERSION, |
|||
"Tremolo", |
|||
"tremolo", |
|||
}; |
|||
|
|||
#ifdef HAVE_FILTERS_BUILTIN |
|||
#define dspfilter_get_implementation tremolo_dspfilter_get_implementation |
|||
#endif |
|||
|
|||
const struct dspfilter_implementation *dspfilter_get_implementation(dspfilter_simd_mask_t mask) |
|||
{ |
|||
(void)mask; |
|||
return &tremolo_plug; |
|||
} |
|||
|
|||
#undef dspfilter_get_implementation |
|||
|
@ -0,0 +1,169 @@ |
|||
/* Copyright (C) 2010-2017 The RetroArch team |
|||
* |
|||
* --------------------------------------------------------------------------------------- |
|||
* The following license statement only applies to this file (vibrato.c). |
|||
* --------------------------------------------------------------------------------------- |
|||
* |
|||
* 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. |
|||
*/ |
|||
|
|||
#include <math.h> |
|||
#include <stdlib.h> |
|||
#include <string.h> |
|||
|
|||
#include <retro_miscellaneous.h> |
|||
#include <libretro_dspfilter.h> |
|||
#include <string/stdstring.h> |
|||
|
|||
#define sqr(a) ((a) * (a)) |
|||
|
|||
|
|||
const float BASE_DELAY_SEC = 0.002; // 2 ms |
|||
const float VIBRATO_FREQUENCY_DEFAULT_HZ = 2; |
|||
const float VIBRATO_FREQUENCY_MAX_HZ = 14; |
|||
const float VIBRATO_DEPTH_DEFAULT_PERCENT = 50; |
|||
const int add_delay = 3; |
|||
|
|||
float hermite_interp(float x, float *y) |
|||
{ |
|||
float c0, c1, c2, c3; |
|||
c0 = y[1]; |
|||
c1 = (1.0 / 2.0)*(y[2] - y[0]); |
|||
c2 = (y[0] - (5.0 / 2.0)*y[1]) + (2.0*y[2] - (1.0 / 2.0)*y[3]); |
|||
c3 = (1.0 / 2.0)*(y[3] - y[0]) + (3.0 / 2.0)*(y[1] - y[2]); |
|||
return ((c3*x + c2)*x + c1)*x + c0; |
|||
} |
|||
|
|||
struct vibrato_core |
|||
{ |
|||
float freq; |
|||
float samplerate; |
|||
int phase; |
|||
float depth; |
|||
float* buffer; |
|||
int writeindex; |
|||
int size; |
|||
}; |
|||
|
|||
struct vibrato |
|||
{ |
|||
struct vibrato_core left, right; |
|||
}; |
|||
|
|||
static void vibrato_free(void *data) |
|||
{ |
|||
struct vibrato *vib = (struct vibrato*)data; |
|||
free(vib->left.buffer); |
|||
free(vib->right.buffer); |
|||
free(data); |
|||
} |
|||
|
|||
static void vibratocore_init(struct vibrato_core *core,float depth,int samplerate,float freq) |
|||
{ |
|||
core->size = BASE_DELAY_SEC * samplerate * 2; |
|||
core->buffer = malloc((core->size + add_delay)*sizeof(float)); |
|||
memset(core->buffer, 0, (core->size + add_delay) * sizeof(float)); |
|||
core->samplerate = samplerate; |
|||
core->freq = freq; |
|||
core->depth = depth; |
|||
core->phase = 0; |
|||
core->writeindex = 0; |
|||
} |
|||
|
|||
float vibratocore_core(struct vibrato_core *core,float in) |
|||
{ |
|||
float M = core->freq / core->samplerate; |
|||
int maxphase = core->samplerate / core->freq; |
|||
float lfo = sin(M * 2. * M_PI * core->phase++); |
|||
core->phase = core->phase % maxphase; |
|||
lfo = (lfo + 1) * 1.; // transform from [-1; 1] to [0; 1] |
|||
int maxdelay = BASE_DELAY_SEC * core->samplerate; |
|||
float delay = lfo * core->depth * maxdelay; |
|||
delay += add_delay; |
|||
float readindex = core->writeindex - 1 - delay; |
|||
while (readindex < 0)readindex += core->size; |
|||
while (readindex >= core->size)readindex -= core->size; |
|||
int ipart = (int)readindex; // integer part of the delay |
|||
float fpart = readindex - ipart; // fractional part of the delay |
|||
float value = hermite_interp(fpart, &(core->buffer[ipart])); |
|||
core->buffer[core->writeindex] = in; |
|||
if (core->writeindex < add_delay){ |
|||
core->buffer[core->size + core->writeindex] = in; |
|||
} |
|||
core->writeindex++; |
|||
if (core->writeindex == core->size) { |
|||
core->writeindex = 0; |
|||
} |
|||
return value; |
|||
} |
|||
|
|||
static void vibrato_process(void *data, struct dspfilter_output *output, |
|||
const struct dspfilter_input *input) |
|||
{ |
|||
unsigned i; |
|||
float *out; |
|||
struct vibrato *vib = (struct vibrato*)data; |
|||
|
|||
output->samples = input->samples; |
|||
output->frames = input->frames; |
|||
out = output->samples; |
|||
|
|||
for (i = 0; i < input->frames; i++, out += 2) |
|||
{ |
|||
float in[2] = { out[0], out[1] }; |
|||
|
|||
out[0] = vibratocore_core(&vib->left, in[0]); |
|||
out[1] = vibratocore_core(&vib->right, in[1]); |
|||
} |
|||
} |
|||
|
|||
static void *vibrato_init(const struct dspfilter_info *info, |
|||
const struct dspfilter_config *config, void *userdata) |
|||
{ |
|||
float freq, depth; |
|||
struct vibrato *vib = (struct vibrato*)calloc(1, sizeof(*vib)); |
|||
if (!vib) |
|||
return NULL; |
|||
|
|||
config->get_float(userdata, "freq", &freq,5.0f); |
|||
config->get_float(userdata, "depth", &depth, 0.5f); |
|||
vibratocore_init(&vib->left,depth,info->input_rate,freq); |
|||
vibratocore_init(&vib->right,depth,info->input_rate,freq); |
|||
return vib; |
|||
} |
|||
|
|||
static const struct dspfilter_implementation vibrato_plug = { |
|||
vibrato_init, |
|||
vibrato_process, |
|||
vibrato_free, |
|||
|
|||
DSPFILTER_API_VERSION, |
|||
"Vibrato", |
|||
"vibrato", |
|||
}; |
|||
|
|||
#ifdef HAVE_FILTERS_BUILTIN |
|||
#define dspfilter_get_implementation vibrato_dspfilter_get_implementation |
|||
#endif |
|||
|
|||
const struct dspfilter_implementation *dspfilter_get_implementation(dspfilter_simd_mask_t mask) |
|||
{ |
|||
(void)mask; |
|||
return &vibrato_plug; |
|||
} |
|||
|
|||
#undef dspfilter_get_implementation |
|||
|
@ -1,13 +1,33 @@ |
|||
#ifndef __FOPEN_UTF8_H |
|||
#define __FOPEN_UTF8_H |
|||
/* Copyright (C) 2010-2018 The RetroArch team |
|||
* |
|||
* --------------------------------------------------------------------------------------- |
|||
* The following license statement only applies to this file (fopen_utf8.h). |
|||
* --------------------------------------------------------------------------------------- |
|||
* |
|||
* 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. |
|||
*/ |
|||
|
|||
#include <stdio.h> |
|||
#ifndef __LIBRETRO_SDK_COMPAT_FOPEN_UTF8_H |
|||
#define __LIBRETRO_SDK_COMPAT_FOPEN_UTF8_H |
|||
|
|||
#ifdef _WIN32 |
|||
/* defined to error rather than fopen_utf8, to make it clear to everyone reading the code that not worrying about utf16 is fine */ |
|||
/* Defined to error rather than fopen_utf8, to make it clear to everyone reading the code that not worrying about utf16 is fine */ |
|||
/* TODO: enable */ |
|||
/* #define fopen (use fopen_utf8 instead) */ |
|||
FILE* fopen_utf8(const char * filename, const char * mode); |
|||
void *fopen_utf8(const char * filename, const char * mode); |
|||
#else |
|||
#define fopen_utf8 fopen |
|||
#endif |
|||
|
Some files were not shown because too many files changed in this diff
Write
Preview
Loading…
Cancel
Save
Reference in new issue