2009-09-17 13:01:21 +00:00
|
|
|
/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
|
|
|
|
|
|
|
|
|
/*
|
2012-09-09 16:57:42 +01:00
|
|
|
Rubber Band Library
|
2009-09-17 13:01:21 +00:00
|
|
|
An audio time-stretching and pitch-shifting library.
|
2023-01-10 11:10:06 +00:00
|
|
|
Copyright 2007-2023 Particular Programs Ltd.
|
2012-09-09 16:57:42 +01:00
|
|
|
|
2009-09-17 13:01:21 +00:00
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
|
modify it under the terms of the GNU General Public License as
|
|
|
|
|
published by the Free Software Foundation; either version 2 of the
|
|
|
|
|
License, or (at your option) any later version. See the file
|
|
|
|
|
COPYING included with this distribution for more information.
|
2012-09-09 16:57:42 +01:00
|
|
|
|
|
|
|
|
Alternatively, if you have a valid commercial licence for the
|
|
|
|
|
Rubber Band Library obtained by agreement with the copyright
|
|
|
|
|
holders, you may redistribute and/or modify it under the terms
|
|
|
|
|
described in that licence.
|
|
|
|
|
|
|
|
|
|
If you wish to distribute code using the Rubber Band Library
|
|
|
|
|
under terms other than those of the GNU General Public License,
|
|
|
|
|
you must obtain a valid commercial licence before doing so.
|
2009-09-17 13:01:21 +00:00
|
|
|
*/
|
|
|
|
|
|
2021-02-10 11:07:33 +00:00
|
|
|
#ifndef RUBBERBAND_SYSUTILS_H
|
|
|
|
|
#define RUBBERBAND_SYSUTILS_H
|
2009-09-17 13:01:21 +00:00
|
|
|
|
2015-01-28 21:01:25 +00:00
|
|
|
#ifdef __clang__
|
2020-01-16 11:28:47 +00:00
|
|
|
# define R__ __restrict__
|
2015-01-28 21:01:25 +00:00
|
|
|
#else
|
2020-01-16 11:28:47 +00:00
|
|
|
# ifdef __GNUC__
|
|
|
|
|
# define R__ __restrict__
|
|
|
|
|
# endif
|
2015-01-28 21:01:25 +00:00
|
|
|
#endif
|
2009-09-17 13:01:21 +00:00
|
|
|
|
2021-03-05 10:31:00 +00:00
|
|
|
#ifdef _MSC_VER
|
|
|
|
|
# if _MSC_VER < 1800
|
|
|
|
|
# include "float_cast/float_cast.h"
|
|
|
|
|
# endif
|
|
|
|
|
# ifndef R__
|
|
|
|
|
# define R__ __restrict
|
|
|
|
|
# endif
|
|
|
|
|
#endif
|
|
|
|
|
|
2009-09-17 13:01:21 +00:00
|
|
|
#ifndef R__
|
2020-01-16 11:28:47 +00:00
|
|
|
# define R__
|
2009-09-17 13:01:21 +00:00
|
|
|
#endif
|
|
|
|
|
|
2023-12-15 20:32:57 +00:00
|
|
|
#ifdef _MSC_VER
|
|
|
|
|
#pragma warning(disable:4127; disable:4244; disable:4267)
|
|
|
|
|
#else
|
2023-12-15 20:14:51 +00:00
|
|
|
#pragma GCC diagnostic ignored "-Wconversion"
|
|
|
|
|
#pragma clang diagnostic ignored "-Wconversion"
|
2023-12-15 20:32:57 +00:00
|
|
|
#endif
|
2023-12-15 20:14:51 +00:00
|
|
|
|
2022-06-15 17:22:32 +01:00
|
|
|
#ifdef __clang__
|
|
|
|
|
# define RTENTRY__ __attribute__((annotate("realtime")))
|
|
|
|
|
#else
|
|
|
|
|
# define RTENTRY__
|
|
|
|
|
#endif
|
|
|
|
|
|
2020-12-10 09:25:28 +00:00
|
|
|
#if defined(_MSC_VER)
|
2020-01-16 11:28:47 +00:00
|
|
|
# include <malloc.h>
|
|
|
|
|
# include <process.h>
|
|
|
|
|
# define alloca _alloca
|
|
|
|
|
# define getpid _getpid
|
2011-01-07 21:46:36 +00:00
|
|
|
#else
|
2020-01-16 11:28:47 +00:00
|
|
|
# if defined(__MINGW32__)
|
|
|
|
|
# include <malloc.h>
|
|
|
|
|
# elif defined(__GNUC__)
|
|
|
|
|
# ifndef alloca
|
|
|
|
|
# define alloca __builtin_alloca
|
|
|
|
|
# endif
|
|
|
|
|
# elif defined(HAVE_ALLOCA_H)
|
|
|
|
|
# include <alloca.h>
|
|
|
|
|
# else
|
|
|
|
|
# ifndef __USE_MISC
|
|
|
|
|
# define __USE_MISC
|
|
|
|
|
# endif
|
|
|
|
|
# include <stdlib.h>
|
|
|
|
|
# endif
|
2012-09-09 16:57:42 +01:00
|
|
|
#endif
|
2009-09-17 13:01:21 +00:00
|
|
|
|
2020-12-10 09:25:28 +00:00
|
|
|
#if defined(_MSC_VER) && _MSC_VER < 1700
|
2020-01-16 11:28:47 +00:00
|
|
|
# define uint8_t unsigned __int8
|
|
|
|
|
# define uint16_t unsigned __int16
|
|
|
|
|
# define uint32_t unsigned __int32
|
2020-12-10 09:25:28 +00:00
|
|
|
#elif defined(_MSC_VER)
|
2020-01-16 11:28:47 +00:00
|
|
|
# define ssize_t long
|
|
|
|
|
# include <stdint.h>
|
2012-09-09 16:57:42 +01:00
|
|
|
#else
|
2020-01-16 11:28:47 +00:00
|
|
|
# include <stdint.h>
|
2012-09-09 16:57:42 +01:00
|
|
|
#endif
|
2009-09-17 13:01:21 +00:00
|
|
|
|
|
|
|
|
#include <math.h>
|
|
|
|
|
|
|
|
|
|
namespace RubberBand {
|
|
|
|
|
|
2022-06-21 10:25:08 +01:00
|
|
|
#ifdef PROCESS_SAMPLE_TYPE
|
|
|
|
|
typedef PROCESS_SAMPLE_TYPE process_t;
|
|
|
|
|
#else
|
|
|
|
|
typedef double process_t;
|
|
|
|
|
#endif
|
|
|
|
|
|
2009-09-17 13:01:21 +00:00
|
|
|
extern const char *system_get_platform_tag();
|
|
|
|
|
extern bool system_is_multiprocessor();
|
|
|
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
|
struct timeval { long tv_sec; long tv_usec; };
|
|
|
|
|
void gettimeofday(struct timeval *p, void *tz);
|
2020-01-16 11:28:47 +00:00
|
|
|
#endif // _WIN32
|
2009-09-17 13:01:21 +00:00
|
|
|
|
|
|
|
|
} // end namespace
|
|
|
|
|
|
|
|
|
|
// The following should be functions in the RubberBand namespace, really
|
|
|
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
|
|
2011-11-25 11:11:59 +00:00
|
|
|
namespace RubberBand {
|
|
|
|
|
extern void system_memorybarrier();
|
|
|
|
|
}
|
|
|
|
|
#define MBARRIER() RubberBand::system_memorybarrier()
|
|
|
|
|
|
2020-01-16 11:28:47 +00:00
|
|
|
#else // !_WIN32
|
2009-09-17 13:01:21 +00:00
|
|
|
|
2010-03-24 09:44:51 +00:00
|
|
|
#include <stdio.h>
|
2009-09-17 13:01:21 +00:00
|
|
|
|
2011-11-25 11:11:59 +00:00
|
|
|
#ifdef __APPLE__
|
2020-01-16 11:28:47 +00:00
|
|
|
# if defined __MAC_10_12
|
|
|
|
|
# define MBARRIER() __sync_synchronize()
|
|
|
|
|
# else
|
|
|
|
|
# include <libkern/OSAtomic.h>
|
|
|
|
|
# define MBARRIER() OSMemoryBarrier()
|
|
|
|
|
# endif
|
2011-11-25 11:11:59 +00:00
|
|
|
#else
|
2020-01-16 11:28:47 +00:00
|
|
|
# if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)
|
|
|
|
|
# define MBARRIER() __sync_synchronize()
|
|
|
|
|
# else
|
2011-11-25 11:11:59 +00:00
|
|
|
namespace RubberBand {
|
|
|
|
|
extern void system_memorybarrier();
|
|
|
|
|
}
|
2020-01-16 11:28:47 +00:00
|
|
|
# define MBARRIER() ::RubberBand::system_memorybarrier()
|
|
|
|
|
# endif
|
2011-11-25 11:11:59 +00:00
|
|
|
#endif
|
|
|
|
|
|
2020-01-16 11:28:47 +00:00
|
|
|
#endif // !_WIN32
|
2009-09-17 13:01:21 +00:00
|
|
|
|
2012-09-09 16:57:42 +01:00
|
|
|
#ifdef NO_THREADING
|
2020-01-16 11:28:47 +00:00
|
|
|
# undef MBARRIER
|
|
|
|
|
# define MBARRIER()
|
|
|
|
|
#endif // NO_THREADING
|
2011-12-09 18:18:32 +00:00
|
|
|
|
2009-09-17 13:01:21 +00:00
|
|
|
#endif
|
2020-01-16 11:28:47 +00:00
|
|
|
|