1
0
mirror of https://github.com/RPCS3/soundtouch.git synced 2024-11-08 20:12:27 +01:00

Fixed c++ function name mangling issue in SoundTouch.dll compilation

This commit is contained in:
oparviai 2014-04-06 18:06:50 +00:00
parent 099a6240eb
commit 0715880b1f
4 changed files with 121 additions and 118 deletions

View File

@ -738,6 +738,7 @@ submitted bugfixes since SoundTouch v1.3.1: </p>
<li> David Clark</li> <li> David Clark</li>
<li> Patrick Colis</li> <li> Patrick Colis</li>
<li> Miquel Colon</li> <li> Miquel Colon</li>
<li> Sandro Cumerlato</li>
<li> Justin Frankel</li> <li> Justin Frankel</li>
<li> Jason Garland</li> <li> Jason Garland</li>
<li> Takashi Iwai</li> <li> Takashi Iwai</li>
@ -745,9 +746,6 @@ submitted bugfixes since SoundTouch v1.3.1: </p>
<li> Paulo Pizarro</li> <li> Paulo Pizarro</li>
<li> Blaise Potard</li> <li> Blaise Potard</li>
<li> RJ Ryan</li> <li> RJ Ryan</li>
<li> Patrick Colis </li>
<li> Miquel Colon </li>
<li> Sandro Cumerlato</li>
<li> Justin Frankel </li> <li> Justin Frankel </li>
<li> Jason Garland </li> <li> Jason Garland </li>
<li> Masa H. </li> <li> Masa H. </li>
@ -761,7 +759,6 @@ submitted bugfixes since SoundTouch v1.3.1: </p>
<li> John Sheehy</li> <li> John Sheehy</li>
<li> Tim Shuttleworth</li> <li> Tim Shuttleworth</li>
<li> John Stumpo</li> <li> John Stumpo</li>
<li> Tim Shuttleworth</li>
<li> Katja Vetter</li> <li> Katja Vetter</li>
</ul> </ul>
<p>Moral greetings to all other contributors and users also!</p> <p>Moral greetings to all other contributors and users also!</p>

View File

@ -68,7 +68,7 @@ typedef struct
#define STMAGIC 0x1770C001 #define STMAGIC 0x1770C001
SOUNDTOUCHDLL_API HANDLE __stdcall soundtouch_createInstance() SOUNDTOUCHDLL_API HANDLE __cdecl soundtouch_createInstance()
{ {
STHANDLE *tmp = new STHANDLE; STHANDLE *tmp = new STHANDLE;
@ -86,7 +86,7 @@ SOUNDTOUCHDLL_API HANDLE __stdcall soundtouch_createInstance()
} }
SOUNDTOUCHDLL_API void __stdcall soundtouch_destroyInstance(HANDLE h) SOUNDTOUCHDLL_API void __cdecl soundtouch_destroyInstance(HANDLE h)
{ {
/* /*
STHANDLE *sth = (STHANDLE*)h; STHANDLE *sth = (STHANDLE*)h;
@ -103,7 +103,7 @@ SOUNDTOUCHDLL_API void __stdcall soundtouch_destroyInstance(HANDLE h)
/// Get SoundTouch library version string /// Get SoundTouch library version string
SOUNDTOUCHDLL_API const char *__stdcall soundtouch_getVersionString() SOUNDTOUCHDLL_API const char *__cdecl soundtouch_getVersionString()
{ {
return SoundTouch::getVersionString(); return SoundTouch::getVersionString();
} }
@ -111,7 +111,7 @@ SOUNDTOUCHDLL_API const char *__stdcall soundtouch_getVersionString()
/// Get SoundTouch library version string - alternative function for /// Get SoundTouch library version string - alternative function for
/// environments that can't properly handle character string as return value /// environments that can't properly handle character string as return value
SOUNDTOUCHDLL_API void __stdcall soundtouch_getVersionString2(char* versionString, int bufferSize) SOUNDTOUCHDLL_API void __cdecl soundtouch_getVersionString2(char* versionString, int bufferSize)
{ {
strncpy(versionString, SoundTouch::getVersionString(), bufferSize - 1); strncpy(versionString, SoundTouch::getVersionString(), bufferSize - 1);
versionString[bufferSize - 1] = 0; versionString[bufferSize - 1] = 0;
@ -119,14 +119,14 @@ SOUNDTOUCHDLL_API void __stdcall soundtouch_getVersionString2(char* versionStrin
/// Get SoundTouch library version Id /// Get SoundTouch library version Id
SOUNDTOUCHDLL_API uint __stdcall soundtouch_getVersionId() SOUNDTOUCHDLL_API uint __cdecl soundtouch_getVersionId()
{ {
return SoundTouch::getVersionId(); return SoundTouch::getVersionId();
} }
/// Sets new rate control value. Normal rate = 1.0, smaller values /// Sets new rate control value. Normal rate = 1.0, smaller values
/// represent slower rate, larger faster rates. /// represent slower rate, larger faster rates.
SOUNDTOUCHDLL_API void __stdcall soundtouch_setRate(HANDLE h, float newRate) SOUNDTOUCHDLL_API void __cdecl soundtouch_setRate(HANDLE h, float newRate)
{ {
STHANDLE *sth = (STHANDLE*)h; STHANDLE *sth = (STHANDLE*)h;
if (sth->dwMagic != STMAGIC) return; if (sth->dwMagic != STMAGIC) return;
@ -137,7 +137,7 @@ SOUNDTOUCHDLL_API void __stdcall soundtouch_setRate(HANDLE h, float newRate)
/// Sets new tempo control value. Normal tempo = 1.0, smaller values /// Sets new tempo control value. Normal tempo = 1.0, smaller values
/// represent slower tempo, larger faster tempo. /// represent slower tempo, larger faster tempo.
SOUNDTOUCHDLL_API void __stdcall soundtouch_setTempo(HANDLE h, float newTempo) SOUNDTOUCHDLL_API void __cdecl soundtouch_setTempo(HANDLE h, float newTempo)
{ {
STHANDLE *sth = (STHANDLE*)h; STHANDLE *sth = (STHANDLE*)h;
if (sth->dwMagic != STMAGIC) return; if (sth->dwMagic != STMAGIC) return;
@ -147,7 +147,7 @@ SOUNDTOUCHDLL_API void __stdcall soundtouch_setTempo(HANDLE h, float newTempo)
/// Sets new rate control value as a difference in percents compared /// Sets new rate control value as a difference in percents compared
/// to the original rate (-50 .. +100 %) /// to the original rate (-50 .. +100 %)
SOUNDTOUCHDLL_API void __stdcall soundtouch_setRateChange(HANDLE h, float newRate) SOUNDTOUCHDLL_API void __cdecl soundtouch_setRateChange(HANDLE h, float newRate)
{ {
STHANDLE *sth = (STHANDLE*)h; STHANDLE *sth = (STHANDLE*)h;
if (sth->dwMagic != STMAGIC) return; if (sth->dwMagic != STMAGIC) return;
@ -157,7 +157,7 @@ SOUNDTOUCHDLL_API void __stdcall soundtouch_setRateChange(HANDLE h, float newRat
/// Sets new tempo control value as a difference in percents compared /// Sets new tempo control value as a difference in percents compared
/// to the original tempo (-50 .. +100 %) /// to the original tempo (-50 .. +100 %)
SOUNDTOUCHDLL_API void __stdcall soundtouch_setTempoChange(HANDLE h, float newTempo) SOUNDTOUCHDLL_API void __cdecl soundtouch_setTempoChange(HANDLE h, float newTempo)
{ {
STHANDLE *sth = (STHANDLE*)h; STHANDLE *sth = (STHANDLE*)h;
if (sth->dwMagic != STMAGIC) return; if (sth->dwMagic != STMAGIC) return;
@ -167,7 +167,7 @@ SOUNDTOUCHDLL_API void __stdcall soundtouch_setTempoChange(HANDLE h, float newTe
/// Sets new pitch control value. Original pitch = 1.0, smaller values /// Sets new pitch control value. Original pitch = 1.0, smaller values
/// represent lower pitches, larger values higher pitch. /// represent lower pitches, larger values higher pitch.
SOUNDTOUCHDLL_API void __stdcall soundtouch_setPitch(HANDLE h, float newPitch) SOUNDTOUCHDLL_API void __cdecl soundtouch_setPitch(HANDLE h, float newPitch)
{ {
STHANDLE *sth = (STHANDLE*)h; STHANDLE *sth = (STHANDLE*)h;
if (sth->dwMagic != STMAGIC) return; if (sth->dwMagic != STMAGIC) return;
@ -177,7 +177,7 @@ SOUNDTOUCHDLL_API void __stdcall soundtouch_setPitch(HANDLE h, float newPitch)
/// Sets pitch change in octaves compared to the original pitch /// Sets pitch change in octaves compared to the original pitch
/// (-1.00 .. +1.00) /// (-1.00 .. +1.00)
SOUNDTOUCHDLL_API void __stdcall soundtouch_setPitchOctaves(HANDLE h, float newPitch) SOUNDTOUCHDLL_API void __cdecl soundtouch_setPitchOctaves(HANDLE h, float newPitch)
{ {
STHANDLE *sth = (STHANDLE*)h; STHANDLE *sth = (STHANDLE*)h;
if (sth->dwMagic != STMAGIC) return; if (sth->dwMagic != STMAGIC) return;
@ -187,7 +187,7 @@ SOUNDTOUCHDLL_API void __stdcall soundtouch_setPitchOctaves(HANDLE h, float newP
/// Sets pitch change in semi-tones compared to the original pitch /// Sets pitch change in semi-tones compared to the original pitch
/// (-12 .. +12) /// (-12 .. +12)
SOUNDTOUCHDLL_API void __stdcall soundtouch_setPitchSemiTones(HANDLE h, float newPitch) SOUNDTOUCHDLL_API void __cdecl soundtouch_setPitchSemiTones(HANDLE h, float newPitch)
{ {
STHANDLE *sth = (STHANDLE*)h; STHANDLE *sth = (STHANDLE*)h;
if (sth->dwMagic != STMAGIC) return; if (sth->dwMagic != STMAGIC) return;
@ -197,7 +197,7 @@ SOUNDTOUCHDLL_API void __stdcall soundtouch_setPitchSemiTones(HANDLE h, float ne
/// Sets the number of channels, 1 = mono, 2 = stereo /// Sets the number of channels, 1 = mono, 2 = stereo
SOUNDTOUCHDLL_API void __stdcall soundtouch_setChannels(HANDLE h, uint numChannels) SOUNDTOUCHDLL_API void __cdecl soundtouch_setChannels(HANDLE h, uint numChannels)
{ {
STHANDLE *sth = (STHANDLE*)h; STHANDLE *sth = (STHANDLE*)h;
if (sth->dwMagic != STMAGIC) return; if (sth->dwMagic != STMAGIC) return;
@ -206,7 +206,7 @@ SOUNDTOUCHDLL_API void __stdcall soundtouch_setChannels(HANDLE h, uint numChanne
} }
/// Sets sample rate. /// Sets sample rate.
SOUNDTOUCHDLL_API void __stdcall soundtouch_setSampleRate(HANDLE h, uint srate) SOUNDTOUCHDLL_API void __cdecl soundtouch_setSampleRate(HANDLE h, uint srate)
{ {
STHANDLE *sth = (STHANDLE*)h; STHANDLE *sth = (STHANDLE*)h;
if (sth->dwMagic != STMAGIC) return; if (sth->dwMagic != STMAGIC) return;
@ -221,7 +221,7 @@ SOUNDTOUCHDLL_API void __stdcall soundtouch_setSampleRate(HANDLE h, uint srate)
/// stream. This function may introduce additional blank samples in the end /// stream. This function may introduce additional blank samples in the end
/// of the sound stream, and thus it's not recommended to call this function /// of the sound stream, and thus it's not recommended to call this function
/// in the middle of a sound stream. /// in the middle of a sound stream.
SOUNDTOUCHDLL_API void __stdcall soundtouch_flush(HANDLE h) SOUNDTOUCHDLL_API void __cdecl soundtouch_flush(HANDLE h)
{ {
STHANDLE *sth = (STHANDLE*)h; STHANDLE *sth = (STHANDLE*)h;
if (sth->dwMagic != STMAGIC) return; if (sth->dwMagic != STMAGIC) return;
@ -232,7 +232,7 @@ SOUNDTOUCHDLL_API void __stdcall soundtouch_flush(HANDLE h)
/// Adds 'numSamples' pcs of samples from the 'samples' memory position into /// Adds 'numSamples' pcs of samples from the 'samples' memory position into
/// the input of the object. Notice that sample rate _has_to_ be set before /// the input of the object. Notice that sample rate _has_to_ be set before
/// calling this function, otherwise throws a runtime_error exception. /// calling this function, otherwise throws a runtime_error exception.
SOUNDTOUCHDLL_API void __stdcall soundtouch_putSamples(HANDLE h, SOUNDTOUCHDLL_API void __cdecl soundtouch_putSamples(HANDLE h,
const SAMPLETYPE *samples, ///< Pointer to sample buffer. const SAMPLETYPE *samples, ///< Pointer to sample buffer.
uint numSamples ///< Number of samples in buffer. Notice uint numSamples ///< Number of samples in buffer. Notice
///< that in case of stereo-sound a single sample ///< that in case of stereo-sound a single sample
@ -247,7 +247,7 @@ SOUNDTOUCHDLL_API void __stdcall soundtouch_putSamples(HANDLE h,
/// Clears all the samples in the object's output and internal processing /// Clears all the samples in the object's output and internal processing
/// buffers. /// buffers.
SOUNDTOUCHDLL_API void __stdcall soundtouch_clear(HANDLE h) SOUNDTOUCHDLL_API void __cdecl soundtouch_clear(HANDLE h)
{ {
STHANDLE *sth = (STHANDLE*)h; STHANDLE *sth = (STHANDLE*)h;
if (sth->dwMagic != STMAGIC) return; if (sth->dwMagic != STMAGIC) return;
@ -259,7 +259,7 @@ SOUNDTOUCHDLL_API void __stdcall soundtouch_clear(HANDLE h)
/// 'SETTING_...' defines for available setting ID's. /// 'SETTING_...' defines for available setting ID's.
/// ///
/// \return 'TRUE' if the setting was succesfully changed /// \return 'TRUE' if the setting was succesfully changed
SOUNDTOUCHDLL_API BOOL __stdcall soundtouch_setSetting(HANDLE h, SOUNDTOUCHDLL_API BOOL __cdecl soundtouch_setSetting(HANDLE h,
int settingId, ///< Setting ID number. see SETTING_... defines. int settingId, ///< Setting ID number. see SETTING_... defines.
int value ///< New setting value. int value ///< New setting value.
) )
@ -274,7 +274,7 @@ SOUNDTOUCHDLL_API BOOL __stdcall soundtouch_setSetting(HANDLE h,
/// 'SETTING_...' defines for available setting ID's. /// 'SETTING_...' defines for available setting ID's.
/// ///
/// \return the setting value. /// \return the setting value.
SOUNDTOUCHDLL_API int __stdcall soundtouch_getSetting(HANDLE h, SOUNDTOUCHDLL_API int __cdecl soundtouch_getSetting(HANDLE h,
int settingId ///< Setting ID number, see SETTING_... defines. int settingId ///< Setting ID number, see SETTING_... defines.
) )
{ {
@ -286,7 +286,7 @@ SOUNDTOUCHDLL_API int __stdcall soundtouch_getSetting(HANDLE h,
/// Returns number of samples currently unprocessed. /// Returns number of samples currently unprocessed.
SOUNDTOUCHDLL_API uint __stdcall soundtouch_numUnprocessedSamples(HANDLE h) SOUNDTOUCHDLL_API uint __cdecl soundtouch_numUnprocessedSamples(HANDLE h)
{ {
STHANDLE *sth = (STHANDLE*)h; STHANDLE *sth = (STHANDLE*)h;
if (sth->dwMagic != STMAGIC) return 0; if (sth->dwMagic != STMAGIC) return 0;
@ -300,7 +300,7 @@ SOUNDTOUCHDLL_API uint __stdcall soundtouch_numUnprocessedSamples(HANDLE h)
/// ///
/// Used to reduce the number of samples in the buffer when accessing the sample buffer directly /// Used to reduce the number of samples in the buffer when accessing the sample buffer directly
/// with 'ptrBegin' function. /// with 'ptrBegin' function.
SOUNDTOUCHDLL_API uint __stdcall soundtouch_receiveSamples(HANDLE h, SOUNDTOUCHDLL_API uint __cdecl soundtouch_receiveSamples(HANDLE h,
SAMPLETYPE *outBuffer, ///< Buffer where to copy output samples. SAMPLETYPE *outBuffer, ///< Buffer where to copy output samples.
uint maxSamples ///< How many samples to receive at max. uint maxSamples ///< How many samples to receive at max.
) )
@ -319,7 +319,7 @@ SOUNDTOUCHDLL_API uint __stdcall soundtouch_receiveSamples(HANDLE h,
} }
/// Returns number of samples currently available. /// Returns number of samples currently available.
SOUNDTOUCHDLL_API uint __stdcall soundtouch_numSamples(HANDLE h) SOUNDTOUCHDLL_API uint __cdecl soundtouch_numSamples(HANDLE h)
{ {
STHANDLE *sth = (STHANDLE*)h; STHANDLE *sth = (STHANDLE*)h;
if (sth->dwMagic != STMAGIC) return 0; if (sth->dwMagic != STMAGIC) return 0;
@ -329,7 +329,7 @@ SOUNDTOUCHDLL_API uint __stdcall soundtouch_numSamples(HANDLE h)
/// Returns nonzero if there aren't any samples available for outputting. /// Returns nonzero if there aren't any samples available for outputting.
SOUNDTOUCHDLL_API int __stdcall soundtouch_isEmpty(HANDLE h) SOUNDTOUCHDLL_API int __cdecl soundtouch_isEmpty(HANDLE h)
{ {
STHANDLE *sth = (STHANDLE*)h; STHANDLE *sth = (STHANDLE*)h;
if (sth->dwMagic != STMAGIC) return -1; if (sth->dwMagic != STMAGIC) return -1;

View File

@ -38,67 +38,75 @@
#define _SoundTouchDLL_h_ #define _SoundTouchDLL_h_
#ifdef __cplusplus #ifdef __cplusplus
extern "C" {
#ifdef DLL_EXPORTS
#define SOUNDTOUCHDLL_API extern "C" __declspec(dllexport)
#else
#define SOUNDTOUCHDLL_API extern "C" __declspec(dllimport)
#endif #endif
#else
#ifdef DLL_EXPORTS #ifdef DLL_EXPORTS
#define SOUNDTOUCHDLL_API __declspec(dllexport) #define SOUNDTOUCHDLL_API __declspec(dllexport)
#else #else
#define SOUNDTOUCHDLL_API __declspec(dllimport) #define SOUNDTOUCHDLL_API __declspec(dllimport)
#endif #endif
#endif // __cplusplus
typedef void * HANDLE; typedef void * HANDLE;
/// Create a new instance of SoundTouch processor. /// Create a new instance of SoundTouch processor.
SOUNDTOUCHDLL_API HANDLE __stdcall soundtouch_createInstance(); SOUNDTOUCHDLL_API HANDLE __cdecl soundtouch_createInstance();
/// Destroys a SoundTouch processor instance. /// Destroys a SoundTouch processor instance.
SOUNDTOUCHDLL_API void __stdcall soundtouch_destroyInstance(HANDLE h); SOUNDTOUCHDLL_API void __cdecl soundtouch_destroyInstance(HANDLE h);
/// Get SoundTouch library version string /// Get SoundTouch library version string
SOUNDTOUCHDLL_API const char *__stdcall soundtouch_getVersionString(); SOUNDTOUCHDLL_API const char *__cdecl soundtouch_getVersionString();
/// Get SoundTouch library version string - alternative function for /// Get SoundTouch library version string - alternative function for
/// environments that can't properly handle character string as return value /// environments that can't properly handle character string as return value
SOUNDTOUCHDLL_API void __stdcall soundtouch_getVersionString2(char* versionString, int bufferSize); SOUNDTOUCHDLL_API void __cdecl soundtouch_getVersionString2(char* versionString, int bufferSize);
/// Get SoundTouch library version Id /// Get SoundTouch library version Id
SOUNDTOUCHDLL_API unsigned int __stdcall soundtouch_getVersionId(); SOUNDTOUCHDLL_API unsigned int __cdecl soundtouch_getVersionId();
/// Sets new rate control value. Normal rate = 1.0, smaller values /// Sets new rate control value. Normal rate = 1.0, smaller values
/// represent slower rate, larger faster rates. /// represent slower rate, larger faster rates.
SOUNDTOUCHDLL_API void __stdcall soundtouch_setRate(HANDLE h, float newRate); SOUNDTOUCHDLL_API void __cdecl soundtouch_setRate(HANDLE h, float newRate);
/// Sets new tempo control value. Normal tempo = 1.0, smaller values /// Sets new tempo control value. Normal tempo = 1.0, smaller values
/// represent slower tempo, larger faster tempo. /// represent slower tempo, larger faster tempo.
SOUNDTOUCHDLL_API void __stdcall soundtouch_setTempo(HANDLE h, float newTempo); SOUNDTOUCHDLL_API void __cdecl soundtouch_setTempo(HANDLE h, float newTempo);
/// Sets new rate control value as a difference in percents compared /// Sets new rate control value as a difference in percents compared
/// to the original rate (-50 .. +100 %); /// to the original rate (-50 .. +100 %);
SOUNDTOUCHDLL_API void __stdcall soundtouch_setRateChange(HANDLE h, float newRate); SOUNDTOUCHDLL_API void __cdecl soundtouch_setRateChange(HANDLE h, float newRate);
/// Sets new tempo control value as a difference in percents compared /// Sets new tempo control value as a difference in percents compared
/// to the original tempo (-50 .. +100 %); /// to the original tempo (-50 .. +100 %);
SOUNDTOUCHDLL_API void __stdcall soundtouch_setTempoChange(HANDLE h, float newTempo); SOUNDTOUCHDLL_API void __cdecl soundtouch_setTempoChange(HANDLE h, float newTempo);
/// Sets new pitch control value. Original pitch = 1.0, smaller values /// Sets new pitch control value. Original pitch = 1.0, smaller values
/// represent lower pitches, larger values higher pitch. /// represent lower pitches, larger values higher pitch.
SOUNDTOUCHDLL_API void __stdcall soundtouch_setPitch(HANDLE h, float newPitch); SOUNDTOUCHDLL_API void __cdecl soundtouch_setPitch(HANDLE h, float newPitch);
/// Sets pitch change in octaves compared to the original pitch /// Sets pitch change in octaves compared to the original pitch
/// (-1.00 .. +1.00); /// (-1.00 .. +1.00);
SOUNDTOUCHDLL_API void __stdcall soundtouch_setPitchOctaves(HANDLE h, float newPitch); SOUNDTOUCHDLL_API void __cdecl soundtouch_setPitchOctaves(HANDLE h, float newPitch);
/// Sets pitch change in semi-tones compared to the original pitch /// Sets pitch change in semi-tones compared to the original pitch
/// (-12 .. +12); /// (-12 .. +12);
SOUNDTOUCHDLL_API void __stdcall soundtouch_setPitchSemiTones(HANDLE h, float newPitch); SOUNDTOUCHDLL_API void __cdecl soundtouch_setPitchSemiTones(HANDLE h, float newPitch);
/// Sets the number of channels, 1 = mono, 2 = stereo /// Sets the number of channels, 1 = mono, 2 = stereo
SOUNDTOUCHDLL_API void __stdcall soundtouch_setChannels(HANDLE h, unsigned int numChannels); SOUNDTOUCHDLL_API void __cdecl soundtouch_setChannels(HANDLE h, unsigned int numChannels);
/// Sets sample rate. /// Sets sample rate.
SOUNDTOUCHDLL_API void __stdcall soundtouch_setSampleRate(HANDLE h, unsigned int srate); SOUNDTOUCHDLL_API void __cdecl soundtouch_setSampleRate(HANDLE h, unsigned int srate);
/// Flushes the last samples from the processing pipeline to the output. /// Flushes the last samples from the processing pipeline to the output.
/// Clears also the internal processing buffers. /// Clears also the internal processing buffers.
@ -107,12 +115,12 @@ SOUNDTOUCHDLL_API void __stdcall soundtouch_setSampleRate(HANDLE h, unsigned int
/// stream. This function may introduce additional blank samples in the end /// stream. This function may introduce additional blank samples in the end
/// of the sound stream, and thus it's not recommended to call this function /// of the sound stream, and thus it's not recommended to call this function
/// in the middle of a sound stream. /// in the middle of a sound stream.
SOUNDTOUCHDLL_API void __stdcall soundtouch_flush(HANDLE h); SOUNDTOUCHDLL_API void __cdecl soundtouch_flush(HANDLE h);
/// Adds 'numSamples' pcs of samples from the 'samples' memory position into /// Adds 'numSamples' pcs of samples from the 'samples' memory position into
/// the input of the object. Notice that sample rate _has_to_ be set before /// the input of the object. Notice that sample rate _has_to_ be set before
/// calling this function, otherwise throws a runtime_error exception. /// calling this function, otherwise throws a runtime_error exception.
SOUNDTOUCHDLL_API void __stdcall soundtouch_putSamples(HANDLE h, SOUNDTOUCHDLL_API void __cdecl soundtouch_putSamples(HANDLE h,
const float *samples, ///< Pointer to sample buffer. const float *samples, ///< Pointer to sample buffer.
unsigned int numSamples ///< Number of samples in buffer. Notice unsigned int numSamples ///< Number of samples in buffer. Notice
///< that in case of stereo-sound a single sample ///< that in case of stereo-sound a single sample
@ -121,13 +129,13 @@ SOUNDTOUCHDLL_API void __stdcall soundtouch_putSamples(HANDLE h,
/// Clears all the samples in the object's output and internal processing /// Clears all the samples in the object's output and internal processing
/// buffers. /// buffers.
SOUNDTOUCHDLL_API void __stdcall soundtouch_clear(HANDLE h); SOUNDTOUCHDLL_API void __cdecl soundtouch_clear(HANDLE h);
/// Changes a setting controlling the processing system behaviour. See the /// Changes a setting controlling the processing system behaviour. See the
/// 'SETTING_...' defines for available setting ID's. /// 'SETTING_...' defines for available setting ID's.
/// ///
/// \return 'TRUE' if the setting was succesfully changed /// \return 'TRUE' if the setting was succesfully changed
SOUNDTOUCHDLL_API BOOL __stdcall soundtouch_setSetting(HANDLE h, SOUNDTOUCHDLL_API BOOL __cdecl soundtouch_setSetting(HANDLE h,
int settingId, ///< Setting ID number. see SETTING_... defines. int settingId, ///< Setting ID number. see SETTING_... defines.
int value ///< New setting value. int value ///< New setting value.
); );
@ -136,33 +144,29 @@ SOUNDTOUCHDLL_API BOOL __stdcall soundtouch_setSetting(HANDLE h,
/// 'SETTING_...' defines for available setting ID's. /// 'SETTING_...' defines for available setting ID's.
/// ///
/// \return the setting value. /// \return the setting value.
SOUNDTOUCHDLL_API int __stdcall soundtouch_getSetting(HANDLE h, SOUNDTOUCHDLL_API int __cdecl soundtouch_getSetting(HANDLE h,
int settingId ///< Setting ID number, see SETTING_... defines. int settingId ///< Setting ID number, see SETTING_... defines.
); );
/// Returns number of samples currently unprocessed. /// Returns number of samples currently unprocessed.
SOUNDTOUCHDLL_API unsigned int __stdcall soundtouch_numUnprocessedSamples(HANDLE h); SOUNDTOUCHDLL_API unsigned int __cdecl soundtouch_numUnprocessedSamples(HANDLE h);
/// Adjusts book-keeping so that given number of samples are removed from beginning of the /// Adjusts book-keeping so that given number of samples are removed from beginning of the
/// sample buffer without copying them anywhere. /// sample buffer without copying them anywhere.
/// ///
/// Used to reduce the number of samples in the buffer when accessing the sample buffer directly /// Used to reduce the number of samples in the buffer when accessing the sample buffer directly
/// with 'ptrBegin' function. /// with 'ptrBegin' function.
SOUNDTOUCHDLL_API unsigned int __stdcall soundtouch_receiveSamples(HANDLE h, SOUNDTOUCHDLL_API unsigned int __cdecl soundtouch_receiveSamples(HANDLE h,
float *outBuffer, ///< Buffer where to copy output samples. float *outBuffer, ///< Buffer where to copy output samples.
unsigned int maxSamples ///< How many samples to receive at max. unsigned int maxSamples ///< How many samples to receive at max.
); );
/// Returns number of samples currently available. /// Returns number of samples currently available.
SOUNDTOUCHDLL_API unsigned int __stdcall soundtouch_numSamples(HANDLE h); SOUNDTOUCHDLL_API unsigned int __cdecl soundtouch_numSamples(HANDLE h);
/// Returns nonzero if there aren't any samples available for outputting. /// Returns nonzero if there aren't any samples available for outputting.
SOUNDTOUCHDLL_API int __stdcall soundtouch_isEmpty(HANDLE h); SOUNDTOUCHDLL_API int __cdecl soundtouch_isEmpty(HANDLE h);
#ifdef __cplusplus
}
#endif
#endif // _SoundTouchDLL_h_ #endif // _SoundTouchDLL_h_

View File

@ -6,6 +6,8 @@ unit SoundTouchDLL;
// //
// Module Author : Christian Budde // Module Author : Christian Budde
// //
// 2014-01-12 fixes by Sandro Cumerlato <sandro.cumerlato 'at' gmail.com>
//
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// //
// $Id$ // $Id$
@ -42,51 +44,53 @@ type
TSoundTouchHandle = THandle; TSoundTouchHandle = THandle;
// Create a new instance of SoundTouch processor. // Create a new instance of SoundTouch processor.
TSoundTouchCreateInstance = function : TSoundTouchHandle; stdcall; TSoundTouchCreateInstance = function : TSoundTouchHandle; cdecl;
// Destroys a SoundTouch processor instance. // Destroys a SoundTouch processor instance.
TSoundTouchDestroyInstance = procedure (Handle: TSoundTouchHandle); stdcall; TSoundTouchDestroyInstance = procedure (Handle: TSoundTouchHandle); cdecl;
// Get SoundTouch library version string // Get SoundTouch library version string
TSoundTouchGetVersionString = function : PChar; stdcall; TSoundTouchGetVersionString = function : PAnsiChar; cdecl;
// Get SoundTouch library version string 2
TSoundTouchGetVersionString2 = procedure(VersionString : PAnsiChar; BufferSize : Integer); cdecl;
// Get SoundTouch library version Id // Get SoundTouch library version Id
TSoundTouchGetVersionId = function : Cardinal; stdcall; TSoundTouchGetVersionId = function : Cardinal; cdecl;
// Sets new rate control value. Normal rate = 1.0, smaller values // Sets new rate control value. Normal rate = 1.0, smaller values
// represent slower rate, larger faster rates. // represent slower rate, larger faster rates.
TSoundTouchSetRate = procedure (Handle: TSoundTouchHandle; newRate: Single); stdcall; TSoundTouchSetRate = procedure (Handle: TSoundTouchHandle; NewRate: Single); cdecl;
// Sets new tempo control value. Normal tempo = 1.0, smaller values // Sets new tempo control value. Normal tempo = 1.0, smaller values
// represent slower tempo, larger faster tempo. // represent slower tempo, larger faster tempo.
TSoundTouchSetTempo = procedure (Handle: TSoundTouchHandle; newTempo: Single); stdcall; TSoundTouchSetTempo = procedure (Handle: TSoundTouchHandle; NewTempo: Single); cdecl;
// Sets new rate control value as a difference in percents compared // Sets new rate control value as a difference in percents compared
// to the original rate (-50 .. +100 %); // to the original rate (-50 .. +100 %);
TSoundTouchSetRateChange = procedure (Handle: TSoundTouchHandle; newRate: Single); stdcall; TSoundTouchSetRateChange = procedure (Handle: TSoundTouchHandle; NewRate: Single); cdecl;
// Sets new tempo control value as a difference in percents compared // Sets new tempo control value as a difference in percents compared
// to the original tempo (-50 .. +100 %); // to the original tempo (-50 .. +100 %);
TSoundTouchSetTempoChange = procedure (Handle: TSoundTouchHandle; newTempo: Single); stdcall; TSoundTouchSetTempoChange = procedure (Handle: TSoundTouchHandle; NewTempo: Single); cdecl;
// Sets new pitch control value. Original pitch = 1.0, smaller values // Sets new pitch control value. Original pitch = 1.0, smaller values
// represent lower pitches, larger values higher pitch. // represent lower pitches, larger values higher pitch.
TSoundTouchSetPitch = procedure (Handle: TSoundTouchHandle; newPitch: Single); stdcall; TSoundTouchSetPitch = procedure (Handle: TSoundTouchHandle; NewPitch: Single); cdecl;
// Sets pitch change in octaves compared to the original pitch // Sets pitch change in octaves compared to the original pitch
// (-1.00 .. +1.00); // (-1.00 .. +1.00);
TSoundTouchSetPitchOctaves = procedure (Handle: TSoundTouchHandle; newPitch: Single); stdcall; TSoundTouchSetPitchOctaves = procedure (Handle: TSoundTouchHandle; NewPitch: Single); cdecl;
// Sets pitch change in semi-tones compared to the original pitch // Sets pitch change in semi-tones compared to the original pitch
// (-12 .. +12); // (-12 .. +12);
TSoundTouchSetPitchSemiTones = procedure (Handle: TSoundTouchHandle; newPitch: Single); stdcall; TSoundTouchSetPitchSemiTones = procedure (Handle: TSoundTouchHandle; NewPitch: Single); cdecl;
// Sets the number of channels, 1 = mono, 2 = stereo // Sets the number of channels, 1 = mono, 2 = stereo
TSoundTouchSetChannels = procedure (Handle: TSoundTouchHandle; numChannels: Cardinal); stdcall; TSoundTouchSetChannels = procedure (Handle: TSoundTouchHandle; NumChannels: Cardinal); cdecl;
// Sets sample rate. // Sets sample rate.
TSoundTouchSetSampleRate = procedure (Handle: TSoundTouchHandle; SampleRate: Cardinal); stdcall; TSoundTouchSetSampleRate = procedure (Handle: TSoundTouchHandle; SampleRate: Cardinal); cdecl;
// Flushes the last samples from the processing pipeline to the output. // Flushes the last samples from the processing pipeline to the output.
// Clears also the internal processing buffers. // Clears also the internal processing buffers.
@ -95,7 +99,7 @@ type
// stream. This function may introduce additional blank samples in the end // stream. This function may introduce additional blank samples in the end
// of the sound stream, and thus it // of the sound stream, and thus it
// in the middle of a sound stream. // in the middle of a sound stream.
TSoundTouchFlush = procedure (Handle: TSoundTouchHandle); stdcall; TSoundTouchFlush = procedure (Handle: TSoundTouchHandle); cdecl;
// Adds 'numSamples' pcs of samples from the 'samples' memory position into // Adds 'numSamples' pcs of samples from the 'samples' memory position into
// the input of the object. Notice that sample rate _has_to_ be set before // the input of the object. Notice that sample rate _has_to_ be set before
@ -105,11 +109,11 @@ type
NumSamples: Cardinal //< Number of samples in buffer. Notice NumSamples: Cardinal //< Number of samples in buffer. Notice
//< that in case of stereo-sound a single sample //< that in case of stereo-sound a single sample
//< contains data for both channels. //< contains data for both channels.
); stdcall; ); cdecl;
// Clears all the samples in the object's output and internal processing // Clears all the samples in the object's output and internal processing
// buffers. // buffers.
TSoundTouchClear = procedure (Handle: TSoundTouchHandle); stdcall; TSoundTouchClear = procedure (Handle: TSoundTouchHandle); cdecl;
// Changes a setting controlling the processing system behaviour. See the // Changes a setting controlling the processing system behaviour. See the
// 'SETTING_...' defines for available setting ID's. // 'SETTING_...' defines for available setting ID's.
@ -118,19 +122,18 @@ type
TSoundTouchSetSetting = function (Handle: TSoundTouchHandle; TSoundTouchSetSetting = function (Handle: TSoundTouchHandle;
SettingId: Integer; //< Setting ID number. see SETTING_... defines. SettingId: Integer; //< Setting ID number. see SETTING_... defines.
Value: Integer //< New setting value. Value: Integer //< New setting value.
): Boolean; stdcall; ): Boolean; cdecl;
// Reads a setting controlling the processing system behaviour. See the // Reads a setting controlling the processing system behaviour. See the
// 'SETTING_...' defines for available setting ID's. // 'SETTING_...' defines for available setting ID's.
// //
// \return the setting value. // \return the setting value.
TSoundTouchGetSetting = function (Handle: TSoundTouchHandle; TSoundTouchGetSetting = function (Handle: TSoundTouchHandle;
settingId: Integer //< Setting ID number, see SETTING_... defines. SettingId: Integer //< Setting ID number, see SETTING_... defines.
): Integer; stdcall; ): Integer; cdecl;
// Returns number of samples currently unprocessed. // Returns number of samples currently unprocessed.
TSoundTouchNumUnprocessedSamples = function (Handle: TSoundTouchHandle): Cardinal; stdcall; TSoundTouchNumUnprocessedSamples = function (Handle: TSoundTouchHandle): Cardinal; cdecl;
// Adjusts book-keeping so that given number of samples are removed from beginning of the // Adjusts book-keeping so that given number of samples are removed from beginning of the
// sample buffer without copying them anywhere. // sample buffer without copying them anywhere.
@ -138,20 +141,21 @@ type
// Used to reduce the number of samples in the buffer when accessing the sample buffer directly // Used to reduce the number of samples in the buffer when accessing the sample buffer directly
// with 'ptrBegin' function. // with 'ptrBegin' function.
TSoundTouchReceiveSamples = function (Handle: TSoundTouchHandle; TSoundTouchReceiveSamples = function (Handle: TSoundTouchHandle;
outBuffer: PSingle; //< Buffer where to copy output samples. OutBuffer: PSingle; //< Buffer where to copy output samples.
maxSamples: Integer //< How many samples to receive at max. MaxSamples: Integer //< How many samples to receive at max.
): Cardinal; stdcall; ): Cardinal; cdecl;
// Returns number of samples currently available. // Returns number of samples currently available.
TSoundTouchNumSamples = function (Handle: TSoundTouchHandle): Cardinal; stdcall; TSoundTouchNumSamples = function (Handle: TSoundTouchHandle): Cardinal; cdecl;
// Returns nonzero if there aren't any samples available for outputting. // Returns nonzero if there aren't any samples available for outputting.
TSoundTouchIsEmpty = function (Handle: TSoundTouchHandle): Integer; stdcall; TSoundTouchIsEmpty = function (Handle: TSoundTouchHandle): Integer; cdecl;
var var
SoundTouchCreateInstance : TSoundTouchCreateInstance; SoundTouchCreateInstance : TSoundTouchCreateInstance;
SoundTouchDestroyInstance : TSoundTouchDestroyInstance; SoundTouchDestroyInstance : TSoundTouchDestroyInstance;
SoundTouchGetVersionString : TSoundTouchGetVersionString; SoundTouchGetVersionString : TSoundTouchGetVersionString;
SoundTouchGetVersionString2 : TSoundTouchGetVersionString2;
SoundTouchGetVersionId : TSoundTouchGetVersionId; SoundTouchGetVersionId : TSoundTouchGetVersionId;
SoundTouchSetRate : TSoundTouchSetRate; SoundTouchSetRate : TSoundTouchSetRate;
SoundTouchSetTempo : TSoundTouchSetTempo; SoundTouchSetTempo : TSoundTouchSetTempo;
@ -210,10 +214,10 @@ type
procedure Clear; virtual; procedure Clear; virtual;
procedure PutSamples(const Samples: PSingle; const NumSamples: Cardinal); procedure PutSamples(const Samples: PSingle; const NumSamples: Cardinal);
function ReceiveSamples(const outBuffer: PSingle; const maxSamples: Integer): Cardinal; function ReceiveSamples(const OutBuffer: PSingle; const MaxSamples: Integer): Cardinal;
function SetSetting(const SettingId: Integer; const Value: Integer): Boolean; function SetSetting(const SettingId: Integer; const Value: Integer): Boolean;
function GetSetting(const settingId: Integer): Integer; function GetSetting(const SettingId: Integer): Integer;
property VersionString: string read GetVersionString; property VersionString: string read GetVersionString;
property VersionID: Cardinal read GetVersionId; property VersionID: Cardinal read GetVersionId;
@ -233,15 +237,12 @@ type
implementation implementation
uses
SysUtils;
{ TSoundTouch } { TSoundTouch }
constructor TSoundTouch.Create; constructor TSoundTouch.Create;
begin begin
inherited; inherited;
FHandle := SoundTouchCreateInstance; FHandle := SoundTouchCreateInstance();
FRate := 1; FRate := 1;
FTempo := 1; FTempo := 1;
FPitch := 1; FPitch := 1;
@ -299,12 +300,12 @@ end;
class function TSoundTouch.GetVersionId: Cardinal; class function TSoundTouch.GetVersionId: Cardinal;
begin begin
result := SoundTouchGetVersionId; result := SoundTouchGetVersionId();
end; end;
class function TSoundTouch.GetVersionString: string; class function TSoundTouch.GetVersionString: string;
begin begin
result := StrPas(SoundTouchGetVersionString); result := StrPas(SoundTouchGetVersionString());
end; end;
procedure TSoundTouch.SetChannels(const Value: Cardinal); procedure TSoundTouch.SetChannels(const Value: Cardinal);
@ -347,10 +348,10 @@ begin
SoundTouchSetRate(FHandle, FRate); SoundTouchSetRate(FHandle, FRate);
end; end;
function TSoundTouch.ReceiveSamples(const outBuffer: PSingle; function TSoundTouch.ReceiveSamples(const OutBuffer: PSingle;
const maxSamples: Integer): Cardinal; const MaxSamples: Integer): Cardinal;
begin begin
result := SoundTouchReceiveSamples(FHandle, outBuffer, maxSamples); result := SoundTouchReceiveSamples(FHandle, OutBuffer, MaxSamples);
end; end;
procedure TSoundTouch.SetPitchChange(const Value: Single); procedure TSoundTouch.SetPitchChange(const Value: Single);
@ -419,35 +420,36 @@ end;
var var
SoundTouchLibHandle: HINST; SoundTouchLibHandle: HINST;
SoundTouchDLL: PAnsiChar = 'SoundTouch.DLL'; SoundTouchDLLFile: PAnsiChar = 'SoundTouch.dll';
procedure InitDLL; procedure InitDLL;
begin begin
SoundTouchLibHandle := LoadLibrary(SoundTouchDLL); SoundTouchLibHandle := LoadLibrary(SoundTouchDLLFile);
if SoundTouchLibHandle <> 0 then if SoundTouchLibHandle <> 0 then
try try
SoundTouchCreateInstance := GetProcAddress(SoundTouchLibHandle, PAnsiChar( 2)); //'soundtouch_createInstance'); Pointer(SoundTouchCreateInstance) := GetProcAddress(SoundTouchLibHandle, 'soundtouch_createInstance');
SoundTouchDestroyInstance := GetProcAddress(SoundTouchLibHandle, PAnsiChar( 3)); //'soundtouch_destroyInstance'); Pointer(SoundTouchDestroyInstance) := GetProcAddress(SoundTouchLibHandle, 'soundtouch_destroyInstance');
SoundTouchGetVersionString := GetProcAddress(SoundTouchLibHandle, PAnsiChar( 7)); //'soundtouch_getVersionString'); Pointer(SoundTouchGetVersionString) := GetProcAddress(SoundTouchLibHandle, 'soundtouch_getVersionString');
SoundTouchGetVersionId := GetProcAddress(SoundTouchLibHandle, PAnsiChar( 6)); //'soundtouch_getVersionId'); Pointer(SoundTouchGetVersionString2) := GetProcAddress(SoundTouchLibHandle, 'soundtouch_getVersionString2');
SoundTouchSetRate := GetProcAddress(SoundTouchLibHandle, PAnsiChar(17)); //'soundtouch_setRate'); Pointer(SoundTouchGetVersionId) := GetProcAddress(SoundTouchLibHandle, 'soundtouch_getVersionId');
SoundTouchSetTempo := GetProcAddress(SoundTouchLibHandle, PAnsiChar(21)); //'soundtouch_setTempo'); Pointer(SoundTouchSetRate) := GetProcAddress(SoundTouchLibHandle, 'soundtouch_setRate');
SoundTouchSetRateChange := GetProcAddress(SoundTouchLibHandle, PAnsiChar(18)); //'soundtouch_setRateChange'); Pointer(SoundTouchSetTempo) := GetProcAddress(SoundTouchLibHandle, 'soundtouch_setTempo');
SoundTouchSetTempoChange := GetProcAddress(SoundTouchLibHandle, PAnsiChar(22)); //'soundtouch_setTempoChange'); Pointer(SoundTouchSetRateChange) := GetProcAddress(SoundTouchLibHandle, 'soundtouch_setRateChange');
SoundTouchSetPitch := GetProcAddress(SoundTouchLibHandle, PAnsiChar(14)); //'soundtouch_setPitch'); Pointer(SoundTouchSetTempoChange) := GetProcAddress(SoundTouchLibHandle, 'soundtouch_setTempoChange');
SoundTouchSetPitchOctaves := GetProcAddress(SoundTouchLibHandle, PAnsiChar(15)); //'soundtouch_setPitchOctaves'); Pointer(SoundTouchSetPitch) := GetProcAddress(SoundTouchLibHandle, 'soundtouch_setPitch');
SoundTouchSetPitchSemiTones := GetProcAddress(SoundTouchLibHandle, PAnsiChar(16)); //'soundtouch_setPitchSemiTones'); Pointer(SoundTouchSetPitchOctaves) := GetProcAddress(SoundTouchLibHandle, 'soundtouch_setPitchOctaves');
SoundTouchSetChannels := GetProcAddress(SoundTouchLibHandle, PAnsiChar(13)); //'soundtouch_setChannels'); Pointer(SoundTouchSetPitchSemiTones) := GetProcAddress(SoundTouchLibHandle, 'soundtouch_setPitchSemiTones');
SoundTouchSetSampleRate := GetProcAddress(SoundTouchLibHandle, PAnsiChar(19)); //'soundtouch_setSampleRate'); Pointer(SoundTouchSetChannels) := GetProcAddress(SoundTouchLibHandle, 'soundtouch_setChannels');
SoundTouchFlush := GetProcAddress(SoundTouchLibHandle, PAnsiChar(4)); //'soundtouch_flush'); Pointer(SoundTouchSetSampleRate) := GetProcAddress(SoundTouchLibHandle, 'soundtouch_setSampleRate');
SoundTouchPutSamples := GetProcAddress(SoundTouchLibHandle, PAnsiChar(11)); //'soundtouch_putSamples'); Pointer(SoundTouchFlush) := GetProcAddress(SoundTouchLibHandle, 'soundtouch_flush');
SoundTouchClear := GetProcAddress(SoundTouchLibHandle, PAnsiChar(1)); //'soundtouch_clear'); Pointer(SoundTouchPutSamples) := GetProcAddress(SoundTouchLibHandle, 'soundtouch_putSamples');
SoundTouchSetSetting := GetProcAddress(SoundTouchLibHandle, PAnsiChar(20)); //'soundtouch_SetSetting'); Pointer(SoundTouchClear) := GetProcAddress(SoundTouchLibHandle, 'soundtouch_clear');
SoundTouchGetSetting := GetProcAddress(SoundTouchLibHandle, PAnsiChar(5)); //'soundtouch_setSetting'); Pointer(SoundTouchSetSetting) := GetProcAddress(SoundTouchLibHandle, 'soundtouch_SetSetting');
SoundTouchNumUnprocessedSamples := GetProcAddress(SoundTouchLibHandle, PAnsiChar(10)); //'soundtouch_numUnprocessedSamples'); Pointer(SoundTouchGetSetting) := GetProcAddress(SoundTouchLibHandle, 'soundtouch_setSetting');
SoundTouchReceiveSamples := GetProcAddress(SoundTouchLibHandle, PAnsiChar(12)); //'soundtouch_receiveSamples'); Pointer(SoundTouchNumUnprocessedSamples) := GetProcAddress(SoundTouchLibHandle, 'soundtouch_numUnprocessedSamples');
SoundTouchNumSamples := GetProcAddress(SoundTouchLibHandle, PAnsiChar(9)); //'soundtouch_numSamples'); Pointer(SoundTouchReceiveSamples) := GetProcAddress(SoundTouchLibHandle, 'soundtouch_receiveSamples');
SoundTouchIsEmpty := GetProcAddress(SoundTouchLibHandle, PAnsiChar(8)); //'soundtouch_isEmpty'); Pointer(SoundTouchNumSamples) := GetProcAddress(SoundTouchLibHandle, 'soundtouch_numSamples');
Pointer(SoundTouchIsEmpty) := GetProcAddress(SoundTouchLibHandle, 'soundtouch_isEmpty');
except except
FreeLibrary(SoundTouchLibHandle); FreeLibrary(SoundTouchLibHandle);