1 /* Copyright (C) 2010-2020 The RetroArch team
3 * ---------------------------------------------------------------------------------------
4 * The following license statement only applies to this file (audio_mix.h).
5 * ---------------------------------------------------------------------------------------
7 * Permission is hereby granted, free of charge,
8 * to any person obtaining a copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation the rights to
10 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
11 * and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
16 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
19 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 #ifndef __LIBRETRO_SDK_AUDIO_MIX_H__
24 #define __LIBRETRO_SDK_AUDIO_MIX_H__
26 #include <retro_common_api.h>
36 #include <formats/rwav.h>
37 #include <audio/audio_resampler.h>
45 int16_t *upsample_buf;
47 float *float_resample_buf;
48 int16_t *resample_buf;
49 const retro_resampler_t *resampler;
59 #define audio_mix_volume audio_mix_volume_SSE2
61 void audio_mix_volume_SSE2(float *out,
62 const float *in, float vol, size_t samples);
64 #define audio_mix_volume audio_mix_volume_C
67 void audio_mix_volume_C(float *dst, const float *src, float vol, size_t samples);
69 void audio_mix_free_chunk(audio_chunk_t *chunk);
71 audio_chunk_t* audio_mix_load_wav_file(const char *path, int sample_rate,
72 const char *resampler_ident, enum resampler_quality quality);
74 size_t audio_mix_get_chunk_num_samples(audio_chunk_t *chunk);
77 * audio_mix_get_chunk_sample:
78 * @chunk : audio chunk instance
79 * @channel : channel of the sample (0=left, 1=right)
80 * @index : index of the sample
82 * Get a sample from an audio chunk.
84 * Returns: A signed 16-bit audio sample, (if necessary) resampled into the desired output rate.
86 int16_t audio_mix_get_chunk_sample(audio_chunk_t *chunk, unsigned channel, size_t sample);
88 int16_t* audio_mix_get_chunk_samples(audio_chunk_t *chunk);
90 int audio_mix_get_chunk_num_channels(audio_chunk_t *chunk);