/* Generated by Cython 0.29.21 */

#define PY_SSIZE_T_CLEAN
#include "Python.h"
#ifndef Py_PYTHON_H
    #error Python headers needed to compile C extensions, please install development version of Python.
#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000)
    #error Cython requires Python 2.6+ or Python 3.3+.
#else
#define CYTHON_ABI "0_29_21"
#define CYTHON_HEX_VERSION 0x001D15F0
#define CYTHON_FUTURE_DIVISION 1
#include <stddef.h>
#ifndef offsetof
  #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
#endif
#if !defined(WIN32) && !defined(MS_WINDOWS)
  #ifndef __stdcall
    #define __stdcall
  #endif
  #ifndef __cdecl
    #define __cdecl
  #endif
  #ifndef __fastcall
    #define __fastcall
  #endif
#endif
#ifndef DL_IMPORT
  #define DL_IMPORT(t) t
#endif
#ifndef DL_EXPORT
  #define DL_EXPORT(t) t
#endif
#define __PYX_COMMA ,
#ifndef HAVE_LONG_LONG
  #if PY_VERSION_HEX >= 0x02070000
    #define HAVE_LONG_LONG
  #endif
#endif
#ifndef PY_LONG_LONG
  #define PY_LONG_LONG LONG_LONG
#endif
#ifndef Py_HUGE_VAL
  #define Py_HUGE_VAL HUGE_VAL
#endif
#ifdef PYPY_VERSION
  #define CYTHON_COMPILING_IN_PYPY 1
  #define CYTHON_COMPILING_IN_PYSTON 0
  #define CYTHON_COMPILING_IN_CPYTHON 0
  #undef CYTHON_USE_TYPE_SLOTS
  #define CYTHON_USE_TYPE_SLOTS 0
  #undef CYTHON_USE_PYTYPE_LOOKUP
  #define CYTHON_USE_PYTYPE_LOOKUP 0
  #if PY_VERSION_HEX < 0x03050000
    #undef CYTHON_USE_ASYNC_SLOTS
    #define CYTHON_USE_ASYNC_SLOTS 0
  #elif !defined(CYTHON_USE_ASYNC_SLOTS)
    #define CYTHON_USE_ASYNC_SLOTS 1
  #endif
  #undef CYTHON_USE_PYLIST_INTERNALS
  #define CYTHON_USE_PYLIST_INTERNALS 0
  #undef CYTHON_USE_UNICODE_INTERNALS
  #define CYTHON_USE_UNICODE_INTERNALS 0
  #undef CYTHON_USE_UNICODE_WRITER
  #define CYTHON_USE_UNICODE_WRITER 0
  #undef CYTHON_USE_PYLONG_INTERNALS
  #define CYTHON_USE_PYLONG_INTERNALS 0
  #undef CYTHON_AVOID_BORROWED_REFS
  #define CYTHON_AVOID_BORROWED_REFS 1
  #undef CYTHON_ASSUME_SAFE_MACROS
  #define CYTHON_ASSUME_SAFE_MACROS 0
  #undef CYTHON_UNPACK_METHODS
  #define CYTHON_UNPACK_METHODS 0
  #undef CYTHON_FAST_THREAD_STATE
  #define CYTHON_FAST_THREAD_STATE 0
  #undef CYTHON_FAST_PYCALL
  #define CYTHON_FAST_PYCALL 0
  #undef CYTHON_PEP489_MULTI_PHASE_INIT
  #define CYTHON_PEP489_MULTI_PHASE_INIT 0
  #undef CYTHON_USE_TP_FINALIZE
  #define CYTHON_USE_TP_FINALIZE 0
  #undef CYTHON_USE_DICT_VERSIONS
  #define CYTHON_USE_DICT_VERSIONS 0
  #undef CYTHON_USE_EXC_INFO_STACK
  #define CYTHON_USE_EXC_INFO_STACK 0
#elif defined(PYSTON_VERSION)
  #define CYTHON_COMPILING_IN_PYPY 0
  #define CYTHON_COMPILING_IN_PYSTON 1
  #define CYTHON_COMPILING_IN_CPYTHON 0
  #ifndef CYTHON_USE_TYPE_SLOTS
    #define CYTHON_USE_TYPE_SLOTS 1
  #endif
  #undef CYTHON_USE_PYTYPE_LOOKUP
  #define CYTHON_USE_PYTYPE_LOOKUP 0
  #undef CYTHON_USE_ASYNC_SLOTS
  #define CYTHON_USE_ASYNC_SLOTS 0
  #undef CYTHON_USE_PYLIST_INTERNALS
  #define CYTHON_USE_PYLIST_INTERNALS 0
  #ifndef CYTHON_USE_UNICODE_INTERNALS
    #define CYTHON_USE_UNICODE_INTERNALS 1
  #endif
  #undef CYTHON_USE_UNICODE_WRITER
  #define CYTHON_USE_UNICODE_WRITER 0
  #undef CYTHON_USE_PYLONG_INTERNALS
  #define CYTHON_USE_PYLONG_INTERNALS 0
  #ifndef CYTHON_AVOID_BORROWED_REFS
    #define CYTHON_AVOID_BORROWED_REFS 0
  #endif
  #ifndef CYTHON_ASSUME_SAFE_MACROS
    #define CYTHON_ASSUME_SAFE_MACROS 1
  #endif
  #ifndef CYTHON_UNPACK_METHODS
    #define CYTHON_UNPACK_METHODS 1
  #endif
  #undef CYTHON_FAST_THREAD_STATE
  #define CYTHON_FAST_THREAD_STATE 0
  #undef CYTHON_FAST_PYCALL
  #define CYTHON_FAST_PYCALL 0
  #undef CYTHON_PEP489_MULTI_PHASE_INIT
  #define CYTHON_PEP489_MULTI_PHASE_INIT 0
  #undef CYTHON_USE_TP_FINALIZE
  #define CYTHON_USE_TP_FINALIZE 0
  #undef CYTHON_USE_DICT_VERSIONS
  #define CYTHON_USE_DICT_VERSIONS 0
  #undef CYTHON_USE_EXC_INFO_STACK
  #define CYTHON_USE_EXC_INFO_STACK 0
#else
  #define CYTHON_COMPILING_IN_PYPY 0
  #define CYTHON_COMPILING_IN_PYSTON 0
  #define CYTHON_COMPILING_IN_CPYTHON 1
  #ifndef CYTHON_USE_TYPE_SLOTS
    #define CYTHON_USE_TYPE_SLOTS 1
  #endif
  #if PY_VERSION_HEX < 0x02070000
    #undef CYTHON_USE_PYTYPE_LOOKUP
    #define CYTHON_USE_PYTYPE_LOOKUP 0
  #elif !defined(CYTHON_USE_PYTYPE_LOOKUP)
    #define CYTHON_USE_PYTYPE_LOOKUP 1
  #endif
  #if PY_MAJOR_VERSION < 3
    #undef CYTHON_USE_ASYNC_SLOTS
    #define CYTHON_USE_ASYNC_SLOTS 0
  #elif !defined(CYTHON_USE_ASYNC_SLOTS)
    #define CYTHON_USE_ASYNC_SLOTS 1
  #endif
  #if PY_VERSION_HEX < 0x02070000
    #undef CYTHON_USE_PYLONG_INTERNALS
    #define CYTHON_USE_PYLONG_INTERNALS 0
  #elif !defined(CYTHON_USE_PYLONG_INTERNALS)
    #define CYTHON_USE_PYLONG_INTERNALS 1
  #endif
  #ifndef CYTHON_USE_PYLIST_INTERNALS
    #define CYTHON_USE_PYLIST_INTERNALS 1
  #endif
  #ifndef CYTHON_USE_UNICODE_INTERNALS
    #define CYTHON_USE_UNICODE_INTERNALS 1
  #endif
  #if PY_VERSION_HEX < 0x030300F0
    #undef CYTHON_USE_UNICODE_WRITER
    #define CYTHON_USE_UNICODE_WRITER 0
  #elif !defined(CYTHON_USE_UNICODE_WRITER)
    #define CYTHON_USE_UNICODE_WRITER 1
  #endif
  #ifndef CYTHON_AVOID_BORROWED_REFS
    #define CYTHON_AVOID_BORROWED_REFS 0
  #endif
  #ifndef CYTHON_ASSUME_SAFE_MACROS
    #define CYTHON_ASSUME_SAFE_MACROS 1
  #endif
  #ifndef CYTHON_UNPACK_METHODS
    #define CYTHON_UNPACK_METHODS 1
  #endif
  #ifndef CYTHON_FAST_THREAD_STATE
    #define CYTHON_FAST_THREAD_STATE 1
  #endif
  #ifndef CYTHON_FAST_PYCALL
    #define CYTHON_FAST_PYCALL 1
  #endif
  #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
    #define CYTHON_PEP489_MULTI_PHASE_INIT (PY_VERSION_HEX >= 0x03050000)
  #endif
  #ifndef CYTHON_USE_TP_FINALIZE
    #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1)
  #endif
  #ifndef CYTHON_USE_DICT_VERSIONS
    #define CYTHON_USE_DICT_VERSIONS (PY_VERSION_HEX >= 0x030600B1)
  #endif
  #ifndef CYTHON_USE_EXC_INFO_STACK
    #define CYTHON_USE_EXC_INFO_STACK (PY_VERSION_HEX >= 0x030700A3)
  #endif
#endif
#if !defined(CYTHON_FAST_PYCCALL)
#define CYTHON_FAST_PYCCALL  (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1)
#endif
#if CYTHON_USE_PYLONG_INTERNALS
  #include "longintrepr.h"
  #undef SHIFT
  #undef BASE
  #undef MASK
  #ifdef SIZEOF_VOID_P
    enum { __pyx_check_sizeof_voidp = 1 / (int)(SIZEOF_VOID_P == sizeof(void*)) };
  #endif
#endif
#ifndef __has_attribute
  #define __has_attribute(x) 0
#endif
#ifndef __has_cpp_attribute
  #define __has_cpp_attribute(x) 0
#endif
#ifndef CYTHON_RESTRICT
  #if defined(__GNUC__)
    #define CYTHON_RESTRICT __restrict__
  #elif defined(_MSC_VER) && _MSC_VER >= 1400
    #define CYTHON_RESTRICT __restrict
  #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
    #define CYTHON_RESTRICT restrict
  #else
    #define CYTHON_RESTRICT
  #endif
#endif
#ifndef CYTHON_UNUSED
# if defined(__GNUC__)
#   if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
#     define CYTHON_UNUSED __attribute__ ((__unused__))
#   else
#     define CYTHON_UNUSED
#   endif
# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
#   define CYTHON_UNUSED __attribute__ ((__unused__))
# else
#   define CYTHON_UNUSED
# endif
#endif
#ifndef CYTHON_MAYBE_UNUSED_VAR
#  if defined(__cplusplus)
     template<class T> void CYTHON_MAYBE_UNUSED_VAR( const T& ) { }
#  else
#    define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x)
#  endif
#endif
#ifndef CYTHON_NCP_UNUSED
# if CYTHON_COMPILING_IN_CPYTHON
#  define CYTHON_NCP_UNUSED
# else
#  define CYTHON_NCP_UNUSED CYTHON_UNUSED
# endif
#endif
#define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
#ifdef _MSC_VER
    #ifndef _MSC_STDINT_H_
        #if _MSC_VER < 1300
           typedef unsigned char     uint8_t;
           typedef unsigned int      uint32_t;
        #else
           typedef unsigned __int8   uint8_t;
           typedef unsigned __int32  uint32_t;
        #endif
    #endif
#else
   #include <stdint.h>
#endif
#ifndef CYTHON_FALLTHROUGH
  #if defined(__cplusplus) && __cplusplus >= 201103L
    #if __has_cpp_attribute(fallthrough)
      #define CYTHON_FALLTHROUGH [[fallthrough]]
    #elif __has_cpp_attribute(clang::fallthrough)
      #define CYTHON_FALLTHROUGH [[clang::fallthrough]]
    #elif __has_cpp_attribute(gnu::fallthrough)
      #define CYTHON_FALLTHROUGH [[gnu::fallthrough]]
    #endif
  #endif
  #ifndef CYTHON_FALLTHROUGH
    #if __has_attribute(fallthrough)
      #define CYTHON_FALLTHROUGH __attribute__((fallthrough))
    #else
      #define CYTHON_FALLTHROUGH
    #endif
  #endif
  #if defined(__clang__ ) && defined(__apple_build_version__)
    #if __apple_build_version__ < 7000000
      #undef  CYTHON_FALLTHROUGH
      #define CYTHON_FALLTHROUGH
    #endif
  #endif
#endif

#ifndef CYTHON_INLINE
  #if defined(__clang__)
    #define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
  #elif defined(__GNUC__)
    #define CYTHON_INLINE __inline__
  #elif defined(_MSC_VER)
    #define CYTHON_INLINE __inline
  #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
    #define CYTHON_INLINE inline
  #else
    #define CYTHON_INLINE
  #endif
#endif

#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag)
  #define Py_OptimizeFlag 0
#endif
#define __PYX_BUILD_PY_SSIZE_T "n"
#define CYTHON_FORMAT_SSIZE_T "z"
#if PY_MAJOR_VERSION < 3
  #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
  #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
          PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
  #define __Pyx_DefaultClassType PyClass_Type
#else
  #define __Pyx_BUILTIN_MODULE_NAME "builtins"
#if PY_VERSION_HEX >= 0x030800A4 && PY_VERSION_HEX < 0x030800B2
  #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
          PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
#else
  #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
          PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
#endif
  #define __Pyx_DefaultClassType PyType_Type
#endif
#ifndef Py_TPFLAGS_CHECKTYPES
  #define Py_TPFLAGS_CHECKTYPES 0
#endif
#ifndef Py_TPFLAGS_HAVE_INDEX
  #define Py_TPFLAGS_HAVE_INDEX 0
#endif
#ifndef Py_TPFLAGS_HAVE_NEWBUFFER
  #define Py_TPFLAGS_HAVE_NEWBUFFER 0
#endif
#ifndef Py_TPFLAGS_HAVE_FINALIZE
  #define Py_TPFLAGS_HAVE_FINALIZE 0
#endif
#ifndef METH_STACKLESS
  #define METH_STACKLESS 0
#endif
#if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL)
  #ifndef METH_FASTCALL
     #define METH_FASTCALL 0x80
  #endif
  typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs);
  typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args,
                                                          Py_ssize_t nargs, PyObject *kwnames);
#else
  #define __Pyx_PyCFunctionFast _PyCFunctionFast
  #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords
#endif
#if CYTHON_FAST_PYCCALL
#define __Pyx_PyFastCFunction_Check(func)\
    ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)))))
#else
#define __Pyx_PyFastCFunction_Check(func) 0
#endif
#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
  #define PyObject_Malloc(s)   PyMem_Malloc(s)
  #define PyObject_Free(p)     PyMem_Free(p)
  #define PyObject_Realloc(p)  PyMem_Realloc(p)
#endif
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030400A1
  #define PyMem_RawMalloc(n)           PyMem_Malloc(n)
  #define PyMem_RawRealloc(p, n)       PyMem_Realloc(p, n)
  #define PyMem_RawFree(p)             PyMem_Free(p)
#endif
#if CYTHON_COMPILING_IN_PYSTON
  #define __Pyx_PyCode_HasFreeVars(co)  PyCode_HasFreeVars(co)
  #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno)
#else
  #define __Pyx_PyCode_HasFreeVars(co)  (PyCode_GetNumFree(co) > 0)
  #define __Pyx_PyFrame_SetLineNumber(frame, lineno)  (frame)->f_lineno = (lineno)
#endif
#if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000
  #define __Pyx_PyThreadState_Current PyThreadState_GET()
#elif PY_VERSION_HEX >= 0x03060000
  #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet()
#elif PY_VERSION_HEX >= 0x03000000
  #define __Pyx_PyThreadState_Current PyThreadState_GET()
#else
  #define __Pyx_PyThreadState_Current _PyThreadState_Current
#endif
#if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT)
#include "pythread.h"
#define Py_tss_NEEDS_INIT 0
typedef int Py_tss_t;
static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) {
  *key = PyThread_create_key();
  return 0;
}
static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) {
  Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t));
  *key = Py_tss_NEEDS_INIT;
  return key;
}
static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) {
  PyObject_Free(key);
}
static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) {
  return *key != Py_tss_NEEDS_INIT;
}
static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) {
  PyThread_delete_key(*key);
  *key = Py_tss_NEEDS_INIT;
}
static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) {
  return PyThread_set_key_value(*key, value);
}
static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) {
  return PyThread_get_key_value(*key);
}
#endif
#if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized)
#define __Pyx_PyDict_NewPresized(n)  ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n))
#else
#define __Pyx_PyDict_NewPresized(n)  PyDict_New()
#endif
#if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION
  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_TrueDivide(x,y)
  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceTrueDivide(x,y)
#else
  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_Divide(x,y)
  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceDivide(x,y)
#endif
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS
#define __Pyx_PyDict_GetItemStr(dict, name)  _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash)
#else
#define __Pyx_PyDict_GetItemStr(dict, name)  PyDict_GetItem(dict, name)
#endif
#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
  #define CYTHON_PEP393_ENABLED 1
  #define __Pyx_PyUnicode_READY(op)       (likely(PyUnicode_IS_READY(op)) ?\
                                              0 : _PyUnicode_Ready((PyObject *)(op)))
  #define __Pyx_PyUnicode_GET_LENGTH(u)   PyUnicode_GET_LENGTH(u)
  #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
  #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u)   PyUnicode_MAX_CHAR_VALUE(u)
  #define __Pyx_PyUnicode_KIND(u)         PyUnicode_KIND(u)
  #define __Pyx_PyUnicode_DATA(u)         PyUnicode_DATA(u)
  #define __Pyx_PyUnicode_READ(k, d, i)   PyUnicode_READ(k, d, i)
  #define __Pyx_PyUnicode_WRITE(k, d, i, ch)  PyUnicode_WRITE(k, d, i, ch)
  #if defined(PyUnicode_IS_READY) && defined(PyUnicode_GET_SIZE)
  #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
  #else
  #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != PyUnicode_GET_LENGTH(u))
  #endif
#else
  #define CYTHON_PEP393_ENABLED 0
  #define PyUnicode_1BYTE_KIND  1
  #define PyUnicode_2BYTE_KIND  2
  #define PyUnicode_4BYTE_KIND  4
  #define __Pyx_PyUnicode_READY(op)       (0)
  #define __Pyx_PyUnicode_GET_LENGTH(u)   PyUnicode_GET_SIZE(u)
  #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
  #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u)   ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111)
  #define __Pyx_PyUnicode_KIND(u)         (sizeof(Py_UNICODE))
  #define __Pyx_PyUnicode_DATA(u)         ((void*)PyUnicode_AS_UNICODE(u))
  #define __Pyx_PyUnicode_READ(k, d, i)   ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
  #define __Pyx_PyUnicode_WRITE(k, d, i, ch)  (((void)(k)), ((Py_UNICODE*)d)[i] = ch)
  #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != PyUnicode_GET_SIZE(u))
#endif
#if CYTHON_COMPILING_IN_PYPY
  #define __Pyx_PyUnicode_Concat(a, b)      PyNumber_Add(a, b)
  #define __Pyx_PyUnicode_ConcatSafe(a, b)  PyNumber_Add(a, b)
#else
  #define __Pyx_PyUnicode_Concat(a, b)      PyUnicode_Concat(a, b)
  #define __Pyx_PyUnicode_ConcatSafe(a, b)  ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\
      PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
#endif
#if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
  #define PyUnicode_Contains(u, s)  PySequence_Contains(u, s)
#endif
#if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check)
  #define PyByteArray_Check(obj)  PyObject_TypeCheck(obj, &PyByteArray_Type)
#endif
#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format)
  #define PyObject_Format(obj, fmt)  PyObject_CallMethod(obj, "__format__", "O", fmt)
#endif
#define __Pyx_PyString_FormatSafe(a, b)   ((unlikely((a) == Py_None || (PyString_Check(b) && !PyString_CheckExact(b)))) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
#define __Pyx_PyUnicode_FormatSafe(a, b)  ((unlikely((a) == Py_None || (PyUnicode_Check(b) && !PyUnicode_CheckExact(b)))) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
#if PY_MAJOR_VERSION >= 3
  #define __Pyx_PyString_Format(a, b)  PyUnicode_Format(a, b)
#else
  #define __Pyx_PyString_Format(a, b)  PyString_Format(a, b)
#endif
#if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII)
  #define PyObject_ASCII(o)            PyObject_Repr(o)
#endif
#if PY_MAJOR_VERSION >= 3
  #define PyBaseString_Type            PyUnicode_Type
  #define PyStringObject               PyUnicodeObject
  #define PyString_Type                PyUnicode_Type
  #define PyString_Check               PyUnicode_Check
  #define PyString_CheckExact          PyUnicode_CheckExact
#ifndef PyObject_Unicode
  #define PyObject_Unicode             PyObject_Str
#endif
#endif
#if PY_MAJOR_VERSION >= 3
  #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
  #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
#else
  #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
  #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
#endif
#ifndef PySet_CheckExact
  #define PySet_CheckExact(obj)        (Py_TYPE(obj) == &PySet_Type)
#endif
#if PY_VERSION_HEX >= 0x030900A4
  #define __Pyx_SET_REFCNT(obj, refcnt) Py_SET_REFCNT(obj, refcnt)
  #define __Pyx_SET_SIZE(obj, size) Py_SET_SIZE(obj, size)
#else
  #define __Pyx_SET_REFCNT(obj, refcnt) Py_REFCNT(obj) = (refcnt)
  #define __Pyx_SET_SIZE(obj, size) Py_SIZE(obj) = (size)
#endif
#if CYTHON_ASSUME_SAFE_MACROS
  #define __Pyx_PySequence_SIZE(seq)  Py_SIZE(seq)
#else
  #define __Pyx_PySequence_SIZE(seq)  PySequence_Size(seq)
#endif
#if PY_MAJOR_VERSION >= 3
  #define PyIntObject                  PyLongObject
  #define PyInt_Type                   PyLong_Type
  #define PyInt_Check(op)              PyLong_Check(op)
  #define PyInt_CheckExact(op)         PyLong_CheckExact(op)
  #define PyInt_FromString             PyLong_FromString
  #define PyInt_FromUnicode            PyLong_FromUnicode
  #define PyInt_FromLong               PyLong_FromLong
  #define PyInt_FromSize_t             PyLong_FromSize_t
  #define PyInt_FromSsize_t            PyLong_FromSsize_t
  #define PyInt_AsLong                 PyLong_AsLong
  #define PyInt_AS_LONG                PyLong_AS_LONG
  #define PyInt_AsSsize_t              PyLong_AsSsize_t
  #define PyInt_AsUnsignedLongMask     PyLong_AsUnsignedLongMask
  #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
  #define PyNumber_Int                 PyNumber_Long
#endif
#if PY_MAJOR_VERSION >= 3
  #define PyBoolObject                 PyLongObject
#endif
#if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
  #ifndef PyUnicode_InternFromString
    #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
  #endif
#endif
#if PY_VERSION_HEX < 0x030200A4
  typedef long Py_hash_t;
  #define __Pyx_PyInt_FromHash_t PyInt_FromLong
  #define __Pyx_PyInt_AsHash_t   PyInt_AsLong
#else
  #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
  #define __Pyx_PyInt_AsHash_t   PyInt_AsSsize_t
#endif
#if PY_MAJOR_VERSION >= 3
  #define __Pyx_PyMethod_New(func, self, klass) ((self) ? ((void)(klass), PyMethod_New(func, self)) : __Pyx_NewRef(func))
#else
  #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
#endif
#if CYTHON_USE_ASYNC_SLOTS
  #if PY_VERSION_HEX >= 0x030500B1
    #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
    #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
  #else
    #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
  #endif
#else
  #define __Pyx_PyType_AsAsync(obj) NULL
#endif
#ifndef __Pyx_PyAsyncMethodsStruct
    typedef struct {
        unaryfunc am_await;
        unaryfunc am_aiter;
        unaryfunc am_anext;
    } __Pyx_PyAsyncMethodsStruct;
#endif

#if defined(WIN32) || defined(MS_WINDOWS)
  #define _USE_MATH_DEFINES
#endif
#include <math.h>
#ifdef NAN
#define __PYX_NAN() ((float) NAN)
#else
static CYTHON_INLINE float __PYX_NAN() {
  float value;
  memset(&value, 0xFF, sizeof(value));
  return value;
}
#endif
#if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
#define __Pyx_truncl trunc
#else
#define __Pyx_truncl truncl
#endif

#define __PYX_MARK_ERR_POS(f_index, lineno) \
    { __pyx_filename = __pyx_f[f_index]; (void)__pyx_filename; __pyx_lineno = lineno; (void)__pyx_lineno; __pyx_clineno = __LINE__; (void)__pyx_clineno; }
#define __PYX_ERR(f_index, lineno, Ln_error) \
    { __PYX_MARK_ERR_POS(f_index, lineno) goto Ln_error; }

#ifndef __PYX_EXTERN_C
  #ifdef __cplusplus
    #define __PYX_EXTERN_C extern "C"
  #else
    #define __PYX_EXTERN_C extern
  #endif
#endif

#define __PYX_HAVE__mpfmc__core__audio__track_sound_loop
#define __PYX_HAVE_API__mpfmc__core__audio__track_sound_loop
/* Early includes */
#include <string.h>
#include <stdio.h>
#include "stdio.h"
#include "SDL.h"
#include "sdl2_helper.h"
#include "SDL_mixer.h"
#include "gst/gst.h"
#include "glib.h"
#include "gstreamer_helper.h"
#ifdef _OPENMP
#include <omp.h>
#endif /* _OPENMP */

#if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS)
#define CYTHON_WITHOUT_ASSERTIONS
#endif

typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding;
                const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;

#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
#define __PYX_DEFAULT_STRING_ENCODING_IS_UTF8 1
#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT (PY_MAJOR_VERSION >= 3 && __PYX_DEFAULT_STRING_ENCODING_IS_UTF8)
#define __PYX_DEFAULT_STRING_ENCODING "utf-8"
#define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
#define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
#define __Pyx_uchar_cast(c) ((unsigned char)c)
#define __Pyx_long_cast(x) ((long)x)
#define __Pyx_fits_Py_ssize_t(v, type, is_signed)  (\
    (sizeof(type) < sizeof(Py_ssize_t))  ||\
    (sizeof(type) > sizeof(Py_ssize_t) &&\
          likely(v < (type)PY_SSIZE_T_MAX ||\
                 v == (type)PY_SSIZE_T_MAX)  &&\
          (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
                                v == (type)PY_SSIZE_T_MIN)))  ||\
    (sizeof(type) == sizeof(Py_ssize_t) &&\
          (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
                               v == (type)PY_SSIZE_T_MAX)))  )
static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t limit) {
    return (size_t) i < (size_t) limit;
}
#if defined (__cplusplus) && __cplusplus >= 201103L
    #include <cstdlib>
    #define __Pyx_sst_abs(value) std::abs(value)
#elif SIZEOF_INT >= SIZEOF_SIZE_T
    #define __Pyx_sst_abs(value) abs(value)
#elif SIZEOF_LONG >= SIZEOF_SIZE_T
    #define __Pyx_sst_abs(value) labs(value)
#elif defined (_MSC_VER)
    #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value))
#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
    #define __Pyx_sst_abs(value) llabs(value)
#elif defined (__GNUC__)
    #define __Pyx_sst_abs(value) __builtin_llabs(value)
#else
    #define __Pyx_sst_abs(value) ((value<0) ? -value : value)
#endif
static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*);
static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
#define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
#define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
#define __Pyx_PyBytes_FromString        PyBytes_FromString
#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
#if PY_MAJOR_VERSION < 3
    #define __Pyx_PyStr_FromString        __Pyx_PyBytes_FromString
    #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
#else
    #define __Pyx_PyStr_FromString        __Pyx_PyUnicode_FromString
    #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
#endif
#define __Pyx_PyBytes_AsWritableString(s)     ((char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsWritableSString(s)    ((signed char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsWritableUString(s)    ((unsigned char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsString(s)     ((const char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsSString(s)    ((const signed char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsUString(s)    ((const unsigned char*) PyBytes_AS_STRING(s))
#define __Pyx_PyObject_AsWritableString(s)    ((char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsWritableSString(s)    ((signed char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsWritableUString(s)    ((unsigned char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsSString(s)    ((const signed char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsUString(s)    ((const unsigned char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_FromCString(s)  __Pyx_PyObject_FromString((const char*)s)
#define __Pyx_PyBytes_FromCString(s)   __Pyx_PyBytes_FromString((const char*)s)
#define __Pyx_PyByteArray_FromCString(s)   __Pyx_PyByteArray_FromString((const char*)s)
#define __Pyx_PyStr_FromCString(s)     __Pyx_PyStr_FromString((const char*)s)
#define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) {
    const Py_UNICODE *u_end = u;
    while (*u_end++) ;
    return (size_t)(u_end - u - 1);
}
#define __Pyx_PyUnicode_FromUnicode(u)       PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
#define __Pyx_PyUnicode_AsUnicode            PyUnicode_AsUnicode
#define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
#define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b);
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject*);
static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
#define __Pyx_PySequence_Tuple(obj)\
    (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj))
static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
#if CYTHON_ASSUME_SAFE_MACROS
#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
#else
#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
#endif
#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
#if PY_MAJOR_VERSION >= 3
#define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
#else
#define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
#endif
#define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x))
#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
static int __Pyx_sys_getdefaultencoding_not_ascii;
static int __Pyx_init_sys_getdefaultencoding_params(void) {
    PyObject* sys;
    PyObject* default_encoding = NULL;
    PyObject* ascii_chars_u = NULL;
    PyObject* ascii_chars_b = NULL;
    const char* default_encoding_c;
    sys = PyImport_ImportModule("sys");
    if (!sys) goto bad;
    default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
    Py_DECREF(sys);
    if (!default_encoding) goto bad;
    default_encoding_c = PyBytes_AsString(default_encoding);
    if (!default_encoding_c) goto bad;
    if (strcmp(default_encoding_c, "ascii") == 0) {
        __Pyx_sys_getdefaultencoding_not_ascii = 0;
    } else {
        char ascii_chars[128];
        int c;
        for (c = 0; c < 128; c++) {
            ascii_chars[c] = c;
        }
        __Pyx_sys_getdefaultencoding_not_ascii = 1;
        ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
        if (!ascii_chars_u) goto bad;
        ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
        if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
            PyErr_Format(
                PyExc_ValueError,
                "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
                default_encoding_c);
            goto bad;
        }
        Py_DECREF(ascii_chars_u);
        Py_DECREF(ascii_chars_b);
    }
    Py_DECREF(default_encoding);
    return 0;
bad:
    Py_XDECREF(default_encoding);
    Py_XDECREF(ascii_chars_u);
    Py_XDECREF(ascii_chars_b);
    return -1;
}
#endif
#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
#else
#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
static char* __PYX_DEFAULT_STRING_ENCODING;
static int __Pyx_init_sys_getdefaultencoding_params(void) {
    PyObject* sys;
    PyObject* default_encoding = NULL;
    char* default_encoding_c;
    sys = PyImport_ImportModule("sys");
    if (!sys) goto bad;
    default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
    Py_DECREF(sys);
    if (!default_encoding) goto bad;
    default_encoding_c = PyBytes_AsString(default_encoding);
    if (!default_encoding_c) goto bad;
    __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c) + 1);
    if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
    strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
    Py_DECREF(default_encoding);
    return 0;
bad:
    Py_XDECREF(default_encoding);
    return -1;
}
#endif
#endif


/* Test for GCC > 2.95 */
#if defined(__GNUC__)     && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
  #define likely(x)   __builtin_expect(!!(x), 1)
  #define unlikely(x) __builtin_expect(!!(x), 0)
#else /* !__GNUC__ or GCC < 2.95 */
  #define likely(x)   (x)
  #define unlikely(x) (x)
#endif /* __GNUC__ */
static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }

static PyObject *__pyx_m = NULL;
static PyObject *__pyx_d;
static PyObject *__pyx_b;
static PyObject *__pyx_cython_runtime = NULL;
static PyObject *__pyx_empty_tuple;
static PyObject *__pyx_empty_bytes;
static PyObject *__pyx_empty_unicode;
static int __pyx_lineno;
static int __pyx_clineno = 0;
static const char * __pyx_cfilenm= __FILE__;
static const char *__pyx_filename;


static const char *__pyx_f[] = {
  "mpfmc\\core\\audio\\track_sound_loop.pyx",
  "stringsource",
  "mpfmc\\core\\audio\\sound_file.pxd",
};
/* ForceInitThreads.proto */
#ifndef __PYX_FORCE_INIT_THREADS
  #define __PYX_FORCE_INIT_THREADS 0
#endif

/* NoFastGil.proto */
#define __Pyx_PyGILState_Ensure PyGILState_Ensure
#define __Pyx_PyGILState_Release PyGILState_Release
#define __Pyx_FastGIL_Remember()
#define __Pyx_FastGIL_Forget()
#define __Pyx_FastGilFuncInit()


/*--- Type declarations ---*/
struct __pyx_obj_5mpfmc_4core_5audio_5track_Track;
struct __pyx_obj_5mpfmc_4core_5audio_10sound_file_SoundFile;
struct __pyx_obj_5mpfmc_4core_5audio_10sound_file_SoundMemoryFile;
struct __pyx_obj_5mpfmc_4core_5audio_10sound_file_SoundStreamingFile;
struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop;
struct __pyx_t_5mpfmc_4core_5audio_4sdl2_Sample16Bytes;
union __pyx_t_5mpfmc_4core_5audio_4sdl2_Sample16;
struct __pyx_t_5mpfmc_4core_5audio_4sdl2_AudioCallbackData;
typedef struct __pyx_t_5mpfmc_4core_5audio_4sdl2_AudioCallbackData __pyx_t_5mpfmc_4core_5audio_4sdl2_AudioCallbackData;

/* "mpfmc/core/audio/sdl2.pxd":231
 * # specific data structures used in the MPF media controller audio library:
 * 
 * cdef struct Sample16Bytes:             # <<<<<<<<<<<<<<
 *     # Structure that represents two bytes of a 16-bit sample.  This is used in
 *     # the union below (nested structs are not permitted in Cython so it is
 */
struct __pyx_t_5mpfmc_4core_5audio_4sdl2_Sample16Bytes {
  Uint8 byte0;
  Uint8 byte1;
};

/* "mpfmc/core/audio/sdl2.pxd":238
 *     Uint8 byte1
 * 
 * cdef union Sample16:             # <<<<<<<<<<<<<<
 *     # Union structure that represents a single 16-bit sample value.  A union is
 *     # utilized to make it easy to access the individual bytes in the sample.
 */
union __pyx_t_5mpfmc_4core_5audio_4sdl2_Sample16 {
  Sint16 value;
  struct __pyx_t_5mpfmc_4core_5audio_4sdl2_Sample16Bytes bytes;
};

/* "mpfmc/core/audio/sdl2.pxd":251
 * # ---------------------------------------------------------------------------
 * 
 * ctypedef struct AudioCallbackData:             # <<<<<<<<<<<<<<
 *     # A pointer to this struct is passed to the main audio callback function and
 *     # is the only way data is made available to the main audio thread.  Must not
 */
struct __pyx_t_5mpfmc_4core_5audio_4sdl2_AudioCallbackData {
  SDL_AudioFormat format;
  int sample_rate;
  int channels;
  Uint16 buffer_samples;
  Uint32 buffer_size;
  Uint16 bytes_per_control_point;
  Uint8 bytes_per_sample;
  double seconds_to_bytes_factor;
  Uint8 quick_fade_steps;
  Uint8 master_volume;
  Uint8 silence;
  Uint8 track_count;
  void **tracks;
  FILE *c_log_file;
};
struct __pyx_t_5mpfmc_4core_5audio_5track_TrackState;
typedef struct __pyx_t_5mpfmc_4core_5audio_5track_TrackState __pyx_t_5mpfmc_4core_5audio_5track_TrackState;

/* "mpfmc/core/audio/track.pxd":10
 * 
 * # The number of control points per audio buffer (sets control rate for ducking)
 * cdef enum:             # <<<<<<<<<<<<<<
 *     CONTROL_POINTS_PER_BUFFER = 8
 * 
 */
enum  {
  __pyx_e_5mpfmc_4core_5audio_5track_CONTROL_POINTS_PER_BUFFER = 8
};

/* "mpfmc/core/audio/track.pxd":13
 *     CONTROL_POINTS_PER_BUFFER = 8
 * 
 * cdef enum:             # <<<<<<<<<<<<<<
 *     MAX_SIMULTANEOUS_SOUNDS_DEFAULT = 8
 * 
 */
enum  {
  __pyx_e_5mpfmc_4core_5audio_5track_MAX_SIMULTANEOUS_SOUNDS_DEFAULT = 8
};

/* "mpfmc/core/audio/track.pxd":16
 *     MAX_SIMULTANEOUS_SOUNDS_DEFAULT = 8
 * 
 * cdef enum:             # <<<<<<<<<<<<<<
 *     MAX_SIMULTANEOUS_SOUNDS_LIMIT = 32
 * 
 */
enum  {
  __pyx_e_5mpfmc_4core_5audio_5track_MAX_SIMULTANEOUS_SOUNDS_LIMIT = 32
};

/* "mpfmc/core/audio/track.pxd":20
 * 
 * 
 * cdef enum TrackStatus:             # <<<<<<<<<<<<<<
 *     track_status_stopped = 0
 *     track_status_stopping = 1
 */
enum __pyx_t_5mpfmc_4core_5audio_5track_TrackStatus {
  __pyx_e_5mpfmc_4core_5audio_5track_track_status_stopped = 0,
  __pyx_e_5mpfmc_4core_5audio_5track_track_status_stopping = 1,
  __pyx_e_5mpfmc_4core_5audio_5track_track_status_playing = 2,
  __pyx_e_5mpfmc_4core_5audio_5track_track_status_pausing = 3,
  __pyx_e_5mpfmc_4core_5audio_5track_track_status_paused = 4
};

/* "mpfmc/core/audio/track.pxd":27
 *     track_status_paused = 4
 * 
 * ctypedef struct TrackState:             # <<<<<<<<<<<<<<
 *     # Common track state variables (for all track types)
 *     AudioCallbackData *callback_data
 */
struct __pyx_t_5mpfmc_4core_5audio_5track_TrackState {
  __pyx_t_5mpfmc_4core_5audio_4sdl2_AudioCallbackData *callback_data;
  void (*mix_callback_function)(__pyx_t_5mpfmc_4core_5audio_5track_TrackState *, Uint32, __pyx_t_5mpfmc_4core_5audio_4sdl2_AudioCallbackData *);
  void *type_state;
  enum __pyx_t_5mpfmc_4core_5audio_5track_TrackStatus status;
  int active;
  int number;
  Uint8 volume;
  Uint8 fade_volume_start;
  Uint8 fade_volume_target;
  Uint8 fade_volume_current;
  Uint32 fade_steps;
  Uint32 fade_steps_remaining;
  int buffer_size;
  Uint8 *buffer;
  GSList *notification_messages;
  int ducking_is_active;
  GArray *ducking_control_points;
};
struct __pyx_t_5mpfmc_4core_5audio_20notification_message_NotificationMessageDataLooping;
typedef struct __pyx_t_5mpfmc_4core_5audio_20notification_message_NotificationMessageDataLooping __pyx_t_5mpfmc_4core_5audio_20notification_message_NotificationMessageDataLooping;
struct __pyx_t_5mpfmc_4core_5audio_20notification_message_NotificationMessageDataMarker;
typedef struct __pyx_t_5mpfmc_4core_5audio_20notification_message_NotificationMessageDataMarker __pyx_t_5mpfmc_4core_5audio_20notification_message_NotificationMessageDataMarker;
struct __pyx_t_5mpfmc_4core_5audio_20notification_message_NotificationMessageSoundLoopSet;
typedef struct __pyx_t_5mpfmc_4core_5audio_20notification_message_NotificationMessageSoundLoopSet __pyx_t_5mpfmc_4core_5audio_20notification_message_NotificationMessageSoundLoopSet;
union __pyx_t_5mpfmc_4core_5audio_20notification_message_NotificationMessageData;
typedef union __pyx_t_5mpfmc_4core_5audio_20notification_message_NotificationMessageData __pyx_t_5mpfmc_4core_5audio_20notification_message_NotificationMessageData;
struct __pyx_t_5mpfmc_4core_5audio_20notification_message_NotificationMessageContainer;
typedef struct __pyx_t_5mpfmc_4core_5audio_20notification_message_NotificationMessageContainer __pyx_t_5mpfmc_4core_5audio_20notification_message_NotificationMessageContainer;

/* "mpfmc/core/audio/notification_message.pxd":10
 * # ---------------------------------------------------------------------------
 * 
 * cdef enum NotificationMessage:             # <<<<<<<<<<<<<<
 *     notification_sound_started = 1            # Notification that a sound has started playing
 *     notification_sound_stopped = 2            # Notification that a sound has stopped
 */
enum __pyx_t_5mpfmc_4core_5audio_20notification_message_NotificationMessage {
  __pyx_e_5mpfmc_4core_5audio_20notification_message_notification_sound_started = 1,
  __pyx_e_5mpfmc_4core_5audio_20notification_message_notification_sound_stopped = 2,
  __pyx_e_5mpfmc_4core_5audio_20notification_message_notification_sound_looping = 3,
  __pyx_e_5mpfmc_4core_5audio_20notification_message_notification_sound_marker = 4,
  __pyx_e_5mpfmc_4core_5audio_20notification_message_notification_sound_about_to_finish = 5,
  __pyx_e_5mpfmc_4core_5audio_20notification_message_notification_player_idle = 10,
  __pyx_e_5mpfmc_4core_5audio_20notification_message_notification_track_stopped = 0,
  __pyx_e_5mpfmc_4core_5audio_20notification_message_notification_track_paused = 21,
  __pyx_e_5mpfmc_4core_5audio_20notification_message_notification_sound_loop_set_started = 31,
  __pyx_e_5mpfmc_4core_5audio_20notification_message_notification_sound_loop_set_stopped = 32,
  __pyx_e_5mpfmc_4core_5audio_20notification_message_notification_sound_loop_set_looping = 33
};

/* "mpfmc/core/audio/notification_message.pxd":23
 *     notification_sound_loop_set_looping = 33  # Notification that a sound_loop_set is looping back to the beginning
 * 
 * ctypedef struct NotificationMessageDataLooping:             # <<<<<<<<<<<<<<
 *     int loop_count
 *     int loops_remaining
 */
struct __pyx_t_5mpfmc_4core_5audio_20notification_message_NotificationMessageDataLooping {
  int loop_count;
  int loops_remaining;
};

/* "mpfmc/core/audio/notification_message.pxd":27
 *     int loops_remaining
 * 
 * ctypedef struct NotificationMessageDataMarker:             # <<<<<<<<<<<<<<
 *     int id
 * 
 */
struct __pyx_t_5mpfmc_4core_5audio_20notification_message_NotificationMessageDataMarker {
  int id;
};

/* "mpfmc/core/audio/notification_message.pxd":30
 *     int id
 * 
 * ctypedef struct NotificationMessageSoundLoopSet:             # <<<<<<<<<<<<<<
 *     long id
 *     gpointer player
 */
struct __pyx_t_5mpfmc_4core_5audio_20notification_message_NotificationMessageSoundLoopSet {
  long id;
  gpointer player;
};

/* "mpfmc/core/audio/notification_message.pxd":35
 * 
 * 
 * ctypedef union NotificationMessageData:             # <<<<<<<<<<<<<<
 *     NotificationMessageDataLooping looping
 *     NotificationMessageDataMarker marker
 */
union __pyx_t_5mpfmc_4core_5audio_20notification_message_NotificationMessageData {
  __pyx_t_5mpfmc_4core_5audio_20notification_message_NotificationMessageDataLooping looping;
  __pyx_t_5mpfmc_4core_5audio_20notification_message_NotificationMessageDataMarker marker;
  __pyx_t_5mpfmc_4core_5audio_20notification_message_NotificationMessageSoundLoopSet sound_loop_set;
};

/* "mpfmc/core/audio/notification_message.pxd":40
 *     NotificationMessageSoundLoopSet sound_loop_set
 * 
 * ctypedef struct NotificationMessageContainer:             # <<<<<<<<<<<<<<
 *     NotificationMessage message
 *     Uint64 sound_id
 */
struct __pyx_t_5mpfmc_4core_5audio_20notification_message_NotificationMessageContainer {
  enum __pyx_t_5mpfmc_4core_5audio_20notification_message_NotificationMessage message;
  Uint64 sound_id;
  Uint64 sound_instance_id;
  int player;
  __pyx_t_5mpfmc_4core_5audio_20notification_message_NotificationMessageData data;
};
struct __pyx_t_5mpfmc_4core_5audio_10sound_file_SampleMemory;
typedef struct __pyx_t_5mpfmc_4core_5audio_10sound_file_SampleMemory __pyx_t_5mpfmc_4core_5audio_10sound_file_SampleMemory;
struct __pyx_t_5mpfmc_4core_5audio_10sound_file_SampleStream;
typedef struct __pyx_t_5mpfmc_4core_5audio_10sound_file_SampleStream __pyx_t_5mpfmc_4core_5audio_10sound_file_SampleStream;
union __pyx_t_5mpfmc_4core_5audio_10sound_file_SoundSampleData;
typedef union __pyx_t_5mpfmc_4core_5audio_10sound_file_SoundSampleData __pyx_t_5mpfmc_4core_5audio_10sound_file_SoundSampleData;
struct __pyx_t_5mpfmc_4core_5audio_10sound_file_SoundSample;
typedef struct __pyx_t_5mpfmc_4core_5audio_10sound_file_SoundSample __pyx_t_5mpfmc_4core_5audio_10sound_file_SoundSample;

/* "mpfmc/core/audio/sound_file.pxd":19
 *     gint null_buffer_count
 * 
 * cdef enum SoundType:             # <<<<<<<<<<<<<<
 *     sound_type_memory = 0
 *     sound_type_streaming = 1
 */
enum __pyx_t_5mpfmc_4core_5audio_10sound_file_SoundType {
  __pyx_e_5mpfmc_4core_5audio_10sound_file_sound_type_memory = 0,
  __pyx_e_5mpfmc_4core_5audio_10sound_file_sound_type_streaming = 1
};

/* "mpfmc/core/audio/sound_file.pxd":5
 * 
 * 
 * ctypedef struct SampleMemory:             # <<<<<<<<<<<<<<
 *     gpointer data
 *     gsize size
 */
struct __pyx_t_5mpfmc_4core_5audio_10sound_file_SampleMemory {
  gpointer data;
  gsize size;
};

/* "mpfmc/core/audio/sound_file.pxd":9
 *     gsize size
 * 
 * ctypedef struct SampleStream:             # <<<<<<<<<<<<<<
 *     GstElement *pipeline
 *     GstElement *sink
 */
struct __pyx_t_5mpfmc_4core_5audio_10sound_file_SampleStream {
  GstElement *pipeline;
  GstElement *sink;
  GstSample *sample;
  GstBuffer *buffer;
  GstMapInfo map_info;
  Uint32 map_buffer_pos;
  gboolean map_contains_valid_sample_data;
  gint null_buffer_count;
};

/* "mpfmc/core/audio/sound_file.pxd":23
 *     sound_type_streaming = 1
 * 
 * ctypedef union SoundSampleData:             # <<<<<<<<<<<<<<
 *     SampleMemory *memory
 *     SampleStream *stream
 */
union __pyx_t_5mpfmc_4core_5audio_10sound_file_SoundSampleData {
  __pyx_t_5mpfmc_4core_5audio_10sound_file_SampleMemory *memory;
  __pyx_t_5mpfmc_4core_5audio_10sound_file_SampleStream *stream;
};

/* "mpfmc/core/audio/sound_file.pxd":27
 *     SampleStream *stream
 * 
 * ctypedef struct SoundSample:             # <<<<<<<<<<<<<<
 *     SoundType type
 *     SoundSampleData data
 */
struct __pyx_t_5mpfmc_4core_5audio_10sound_file_SoundSample {
  enum __pyx_t_5mpfmc_4core_5audio_10sound_file_SoundType type;
  __pyx_t_5mpfmc_4core_5audio_10sound_file_SoundSampleData data;
  double duration;
  Uint32 size;
};
struct __pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopLayerSettings;
typedef struct __pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopLayerSettings __pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopLayerSettings;
struct __pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopSetPlayer;
typedef struct __pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopSetPlayer __pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopSetPlayer;
struct __pyx_t_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoopState;
typedef struct __pyx_t_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoopState __pyx_t_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoopState;

/* "mpfmc/core/audio/track_sound_loop.pxd":11
 * #    Sound Loop Track types
 * # ---------------------------------------------------------------------------
 * cdef enum:             # <<<<<<<<<<<<<<
 *     do_not_stop_loop = 0xFFFFFFFF
 * 
 */
enum  {
  __pyx_e_5mpfmc_4core_5audio_16track_sound_loop_do_not_stop_loop = 0xFFFFFFFF
};

/* "mpfmc/core/audio/track_sound_loop.pxd":14
 *     do_not_stop_loop = 0xFFFFFFFF
 * 
 * cdef enum LayerStatus:             # <<<<<<<<<<<<<<
 *     layer_stopped = 0
 *     layer_queued = 1
 */
enum __pyx_t_5mpfmc_4core_5audio_16track_sound_loop_LayerStatus {
  __pyx_e_5mpfmc_4core_5audio_16track_sound_loop_layer_stopped = 0,
  __pyx_e_5mpfmc_4core_5audio_16track_sound_loop_layer_queued = 1,
  __pyx_e_5mpfmc_4core_5audio_16track_sound_loop_layer_playing = 2,
  __pyx_e_5mpfmc_4core_5audio_16track_sound_loop_layer_fading_in = 3,
  __pyx_e_5mpfmc_4core_5audio_16track_sound_loop_layer_fading_out = 4
};

/* "mpfmc/core/audio/track_sound_loop.pxd":34
 *     GArray *markers
 * 
 * cdef enum SoundLoopSetPlayerStatus:             # <<<<<<<<<<<<<<
 *     # Enumeration of the possible sound loop set player status values.
 *     player_idle = 0
 */
enum __pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopSetPlayerStatus {
  __pyx_e_5mpfmc_4core_5audio_16track_sound_loop_player_idle = 0,
  __pyx_e_5mpfmc_4core_5audio_16track_sound_loop_player_delayed = 1,
  __pyx_e_5mpfmc_4core_5audio_16track_sound_loop_player_fading_in = 2,
  __pyx_e_5mpfmc_4core_5audio_16track_sound_loop_player_fading_out = 3,
  __pyx_e_5mpfmc_4core_5audio_16track_sound_loop_player_playing = 4
};

/* "mpfmc/core/audio/track_sound_loop.pxd":21
 *     layer_fading_out = 4
 * 
 * ctypedef struct SoundLoopLayerSettings:             # <<<<<<<<<<<<<<
 *     LayerStatus status
 *     SoundSample *sound
 */
struct __pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopLayerSettings {
  enum __pyx_t_5mpfmc_4core_5audio_16track_sound_loop_LayerStatus status;
  __pyx_t_5mpfmc_4core_5audio_10sound_file_SoundSample *sound;
  Uint8 volume;
  long sound_loop_set_id;
  Uint64 sound_id;
  Uint32 fade_in_steps;
  Uint32 fade_out_steps;
  Uint32 fade_steps_remaining;
  int looping;
  Uint8 marker_count;
  GArray *markers;
};

/* "mpfmc/core/audio/track_sound_loop.pxd":42
 *     player_playing = 4
 * 
 * ctypedef struct SoundLoopSetPlayer:             # <<<<<<<<<<<<<<
 *     SoundLoopSetPlayerStatus status
 *     Uint32 length
 */
struct __pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopSetPlayer {
  enum __pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopSetPlayerStatus status;
  Uint32 length;
  __pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopLayerSettings master_sound_layer;
  GSList *layers;
  Uint32 sample_pos;
  Uint32 stop_loop_samples_remaining;
  Uint32 start_delay_samples_remaining;
  float tempo;
};

/* "mpfmc/core/audio/track_sound_loop.pxd":52
 *     float tempo
 * 
 * ctypedef struct TrackSoundLoopState:             # <<<<<<<<<<<<<<
 *     # State variables for TrackSoundLoop tracks
 *     GSList *players
 */
struct __pyx_t_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoopState {
  GSList *players;
  __pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopSetPlayer *current;
};

/* "mpfmc/core/audio/track.pxd":51
 * #    Track base class
 * # ---------------------------------------------------------------------------
 * cdef class Track:             # <<<<<<<<<<<<<<
 * 
 *     cdef str _name
 */
struct __pyx_obj_5mpfmc_4core_5audio_5track_Track {
  PyObject_HEAD
  struct __pyx_vtabstruct_5mpfmc_4core_5audio_5track_Track *__pyx_vtab;
  PyObject *_name;
  int _number;
  PyObject *_events_when_stopped;
  PyObject *_events_when_played;
  PyObject *_events_when_paused;
  PyObject *mc;
  SDL_AudioDeviceID device_id;
  PyObject *log;
  __pyx_t_5mpfmc_4core_5audio_5track_TrackState *state;
};


/* "mpfmc/core/audio/sound_file.pxd":34
 * 
 * 
 * cdef class SoundFile:             # <<<<<<<<<<<<<<
 *     """SoundFile is the base class for wrapper classes used to manage sound sample data."""
 *     cdef str file_name
 */
struct __pyx_obj_5mpfmc_4core_5audio_10sound_file_SoundFile {
  PyObject_HEAD
  PyObject *file_name;
  __pyx_t_5mpfmc_4core_5audio_4sdl2_AudioCallbackData *callback_data;
  __pyx_t_5mpfmc_4core_5audio_10sound_file_SoundSample sample;
  PyObject *log;
};


/* "mpfmc/core/audio/sound_file.pxd":42
 * 
 * 
 * cdef class SoundMemoryFile(SoundFile):             # <<<<<<<<<<<<<<
 *     """SoundMemoryFile is a wrapper class to manage sound sample data stored
 *     in memory."""
 */
struct __pyx_obj_5mpfmc_4core_5audio_10sound_file_SoundMemoryFile {
  struct __pyx_obj_5mpfmc_4core_5audio_10sound_file_SoundFile __pyx_base;
  int _loaded_using_sdl;
};


/* "mpfmc/core/audio/sound_file.pxd":48
 * 
 * 
 * cdef class SoundStreamingFile(SoundFile):             # <<<<<<<<<<<<<<
 *     """SoundStreamingFile is a wrapper class to manage streaming sound sample data."""
 *     cdef GstElement *pipeline
 */
struct __pyx_obj_5mpfmc_4core_5audio_10sound_file_SoundStreamingFile {
  struct __pyx_obj_5mpfmc_4core_5audio_10sound_file_SoundFile __pyx_base;
  GstElement *pipeline;
  GstElement *source;
  GstElement *convert;
  GstElement *resample;
  GstElement *sink;
  GstBus *bus;
  gulong bus_message_handler_id;
};


/* "mpfmc/core/audio/track_sound_loop.pyx":21
 * #    TrackSoundLoop class
 * # ---------------------------------------------------------------------------
 * cdef class TrackSoundLoop(Track):             # <<<<<<<<<<<<<<
 *     """
 *     Live Loop track class
 */
struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop {
  struct __pyx_obj_5mpfmc_4core_5audio_5track_Track __pyx_base;
  __pyx_t_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoopState *type_state;
  long _sound_loop_set_counter;
  PyObject *_active_sound_loop_sets;
};



/* "mpfmc/core/audio/track.pxd":51
 * #    Track base class
 * # ---------------------------------------------------------------------------
 * cdef class Track:             # <<<<<<<<<<<<<<
 * 
 *     cdef str _name
 */

struct __pyx_vtabstruct_5mpfmc_4core_5audio_5track_Track {
  __pyx_t_5mpfmc_4core_5audio_5track_TrackState *(*get_state)(struct __pyx_obj_5mpfmc_4core_5audio_5track_Track *);
  void (*mix_track_to_output)(__pyx_t_5mpfmc_4core_5audio_5track_TrackState *, __pyx_t_5mpfmc_4core_5audio_4sdl2_AudioCallbackData *, Uint8 *, Uint32);
  void (*mix_audio)(Uint8 *, Uint8 const *, Uint32, int);
  void (*mix_audio_stereo)(Uint8 *, Uint8 const *, Uint32, int, int);
  void (*apply_volume)(Uint8 *, Uint8 const *, Uint32, int);
  void (*apply_volume_stereo)(Uint8 *, Uint8 const *, Uint32, int, int);
};
static struct __pyx_vtabstruct_5mpfmc_4core_5audio_5track_Track *__pyx_vtabptr_5mpfmc_4core_5audio_5track_Track;


/* "mpfmc/core/audio/track_sound_loop.pyx":21
 * #    TrackSoundLoop class
 * # ---------------------------------------------------------------------------
 * cdef class TrackSoundLoop(Track):             # <<<<<<<<<<<<<<
 *     """
 *     Live Loop track class
 */

struct __pyx_vtabstruct_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop {
  struct __pyx_vtabstruct_5mpfmc_4core_5audio_5track_Track __pyx_base;
  PyObject *(*process_notification_message)(struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *, __pyx_t_5mpfmc_4core_5audio_20notification_message_NotificationMessageContainer *);
  PyObject *(*_apply_layer_settings)(struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *, __pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopLayerSettings *, PyObject *);
  PyObject *(*_initialize_player)(struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *, __pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopSetPlayer *);
  PyObject *(*_delete_player)(struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *, __pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopSetPlayer *);
  PyObject *(*_delete_player_layers)(struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *, __pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopSetPlayer *);
  PyObject *(*_cancel_all_delayed_players)(struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *);
  PyObject *(*_fade_out_all_players)(struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *, Uint32);
  Uint32 (*_round_sample_pos_up_to_interval)(struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *, Uint32, Uint32, int);
  void (*mix_playing_sounds)(__pyx_t_5mpfmc_4core_5audio_5track_TrackState *, Uint32, __pyx_t_5mpfmc_4core_5audio_4sdl2_AudioCallbackData *);
};
static struct __pyx_vtabstruct_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *__pyx_vtabptr_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop;
static CYTHON_INLINE Uint32 __pyx_f_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop__round_sample_pos_up_to_interval(struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *, Uint32, Uint32, int);

/* --- Runtime support code (head) --- */
/* Refnanny.proto */
#ifndef CYTHON_REFNANNY
  #define CYTHON_REFNANNY 0
#endif
#if CYTHON_REFNANNY
  typedef struct {
    void (*INCREF)(void*, PyObject*, int);
    void (*DECREF)(void*, PyObject*, int);
    void (*GOTREF)(void*, PyObject*, int);
    void (*GIVEREF)(void*, PyObject*, int);
    void* (*SetupContext)(const char*, int, const char*);
    void (*FinishContext)(void**);
  } __Pyx_RefNannyAPIStruct;
  static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
  static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
  #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
#ifdef WITH_THREAD
  #define __Pyx_RefNannySetupContext(name, acquire_gil)\
          if (acquire_gil) {\
              PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
              __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
              PyGILState_Release(__pyx_gilstate_save);\
          } else {\
              __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
          }
#else
  #define __Pyx_RefNannySetupContext(name, acquire_gil)\
          __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
#endif
  #define __Pyx_RefNannyFinishContext()\
          __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
  #define __Pyx_INCREF(r)  __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_DECREF(r)  __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_GOTREF(r)  __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_XINCREF(r)  do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
  #define __Pyx_XDECREF(r)  do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
  #define __Pyx_XGOTREF(r)  do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
  #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
#else
  #define __Pyx_RefNannyDeclarations
  #define __Pyx_RefNannySetupContext(name, acquire_gil)
  #define __Pyx_RefNannyFinishContext()
  #define __Pyx_INCREF(r) Py_INCREF(r)
  #define __Pyx_DECREF(r) Py_DECREF(r)
  #define __Pyx_GOTREF(r)
  #define __Pyx_GIVEREF(r)
  #define __Pyx_XINCREF(r) Py_XINCREF(r)
  #define __Pyx_XDECREF(r) Py_XDECREF(r)
  #define __Pyx_XGOTREF(r)
  #define __Pyx_XGIVEREF(r)
#endif
#define __Pyx_XDECREF_SET(r, v) do {\
        PyObject *tmp = (PyObject *) r;\
        r = v; __Pyx_XDECREF(tmp);\
    } while (0)
#define __Pyx_DECREF_SET(r, v) do {\
        PyObject *tmp = (PyObject *) r;\
        r = v; __Pyx_DECREF(tmp);\
    } while (0)
#define __Pyx_CLEAR(r)    do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
#define __Pyx_XCLEAR(r)   do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)

/* PyObjectGetAttrStr.proto */
#if CYTHON_USE_TYPE_SLOTS
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name);
#else
#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
#endif

/* GetBuiltinName.proto */
static PyObject *__Pyx_GetBuiltinName(PyObject *name);

/* RaiseArgTupleInvalid.proto */
static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
    Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);

/* RaiseDoubleKeywords.proto */
static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);

/* ParseKeywords.proto */
static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\
    PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\
    const char* function_name);

/* ArgTypeTest.proto */
#define __Pyx_ArgTypeTest(obj, type, none_allowed, name, exact)\
    ((likely((Py_TYPE(obj) == type) | (none_allowed && (obj == Py_None)))) ? 1 :\
        __Pyx__ArgTypeTest(obj, type, name, exact))
static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact);

/* PyObjectCall.proto */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
#else
#define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
#endif

/* PyFunctionFastCall.proto */
#if CYTHON_FAST_PYCALL
#define __Pyx_PyFunction_FastCall(func, args, nargs)\
    __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL)
#if 1 || PY_VERSION_HEX < 0x030600B1
static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs);
#else
#define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs)
#endif
#define __Pyx_BUILD_ASSERT_EXPR(cond)\
    (sizeof(char [1 - 2*!(cond)]) - 1)
#ifndef Py_MEMBER_SIZE
#define Py_MEMBER_SIZE(type, member) sizeof(((type *)0)->member)
#endif
  static size_t __pyx_pyframe_localsplus_offset = 0;
  #include "frameobject.h"
  #define __Pxy_PyFrame_Initialize_Offsets()\
    ((void)__Pyx_BUILD_ASSERT_EXPR(sizeof(PyFrameObject) == offsetof(PyFrameObject, f_localsplus) + Py_MEMBER_SIZE(PyFrameObject, f_localsplus)),\
     (void)(__pyx_pyframe_localsplus_offset = ((size_t)PyFrame_Type.tp_basicsize) - Py_MEMBER_SIZE(PyFrameObject, f_localsplus)))
  #define __Pyx_PyFrame_GetLocalsplus(frame)\
    (assert(__pyx_pyframe_localsplus_offset), (PyObject **)(((char *)(frame)) + __pyx_pyframe_localsplus_offset))
#endif

/* PyCFunctionFastCall.proto */
#if CYTHON_FAST_PYCCALL
static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs);
#else
#define __Pyx_PyCFunction_FastCall(func, args, nargs)  (assert(0), NULL)
#endif

/* PyDictVersioning.proto */
#if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
#define __PYX_DICT_VERSION_INIT  ((PY_UINT64_T) -1)
#define __PYX_GET_DICT_VERSION(dict)  (((PyDictObject*)(dict))->ma_version_tag)
#define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)\
    (version_var) = __PYX_GET_DICT_VERSION(dict);\
    (cache_var) = (value);
#define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) {\
    static PY_UINT64_T __pyx_dict_version = 0;\
    static PyObject *__pyx_dict_cached_value = NULL;\
    if (likely(__PYX_GET_DICT_VERSION(DICT) == __pyx_dict_version)) {\
        (VAR) = __pyx_dict_cached_value;\
    } else {\
        (VAR) = __pyx_dict_cached_value = (LOOKUP);\
        __pyx_dict_version = __PYX_GET_DICT_VERSION(DICT);\
    }\
}
static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj);
static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj);
static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version);
#else
#define __PYX_GET_DICT_VERSION(dict)  (0)
#define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)
#define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP)  (VAR) = (LOOKUP);
#endif

/* GetModuleGlobalName.proto */
#if CYTHON_USE_DICT_VERSIONS
#define __Pyx_GetModuleGlobalName(var, name)  {\
    static PY_UINT64_T __pyx_dict_version = 0;\
    static PyObject *__pyx_dict_cached_value = NULL;\
    (var) = (likely(__pyx_dict_version == __PYX_GET_DICT_VERSION(__pyx_d))) ?\
        (likely(__pyx_dict_cached_value) ? __Pyx_NewRef(__pyx_dict_cached_value) : __Pyx_GetBuiltinName(name)) :\
        __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
}
#define __Pyx_GetModuleGlobalNameUncached(var, name)  {\
    PY_UINT64_T __pyx_dict_version;\
    PyObject *__pyx_dict_cached_value;\
    (var) = __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
}
static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value);
#else
#define __Pyx_GetModuleGlobalName(var, name)  (var) = __Pyx__GetModuleGlobalName(name)
#define __Pyx_GetModuleGlobalNameUncached(var, name)  (var) = __Pyx__GetModuleGlobalName(name)
static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name);
#endif

/* PyObjectCallMethO.proto */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
#endif

/* PyObjectCallOneArg.proto */
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);

/* PyObjectCall2Args.proto */
static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2);

/* PyThreadStateGet.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_PyThreadState_declare  PyThreadState *__pyx_tstate;
#define __Pyx_PyThreadState_assign  __pyx_tstate = __Pyx_PyThreadState_Current;
#define __Pyx_PyErr_Occurred()  __pyx_tstate->curexc_type
#else
#define __Pyx_PyThreadState_declare
#define __Pyx_PyThreadState_assign
#define __Pyx_PyErr_Occurred()  PyErr_Occurred()
#endif

/* PyErrFetchRestore.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL)
#define __Pyx_ErrRestoreWithState(type, value, tb)  __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
#define __Pyx_ErrFetchWithState(type, value, tb)    __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
#define __Pyx_ErrRestore(type, value, tb)  __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
#define __Pyx_ErrFetch(type, value, tb)    __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
#if CYTHON_COMPILING_IN_CPYTHON
#define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL))
#else
#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
#endif
#else
#define __Pyx_PyErr_Clear() PyErr_Clear()
#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
#define __Pyx_ErrRestoreWithState(type, value, tb)  PyErr_Restore(type, value, tb)
#define __Pyx_ErrFetchWithState(type, value, tb)  PyErr_Fetch(type, value, tb)
#define __Pyx_ErrRestoreInState(tstate, type, value, tb)  PyErr_Restore(type, value, tb)
#define __Pyx_ErrFetchInState(tstate, type, value, tb)  PyErr_Fetch(type, value, tb)
#define __Pyx_ErrRestore(type, value, tb)  PyErr_Restore(type, value, tb)
#define __Pyx_ErrFetch(type, value, tb)  PyErr_Fetch(type, value, tb)
#endif

/* WriteUnraisableException.proto */
static void __Pyx_WriteUnraisable(const char *name, int clineno,
                                  int lineno, const char *filename,
                                  int full_traceback, int nogil);

/* py_dict_keys.proto */
static CYTHON_INLINE PyObject* __Pyx_PyDict_Keys(PyObject* d);

/* UnpackUnboundCMethod.proto */
typedef struct {
    PyObject *type;
    PyObject **method_name;
    PyCFunction func;
    PyObject *method;
    int flag;
} __Pyx_CachedCFunction;

/* CallUnboundCMethod0.proto */
static PyObject* __Pyx__CallUnboundCMethod0(__Pyx_CachedCFunction* cfunc, PyObject* self);
#if CYTHON_COMPILING_IN_CPYTHON
#define __Pyx_CallUnboundCMethod0(cfunc, self)\
    (likely((cfunc)->func) ?\
        (likely((cfunc)->flag == METH_NOARGS) ?  (*((cfunc)->func))(self, NULL) :\
         (PY_VERSION_HEX >= 0x030600B1 && likely((cfunc)->flag == METH_FASTCALL) ?\
            (PY_VERSION_HEX >= 0x030700A0 ?\
                (*(__Pyx_PyCFunctionFast)(void*)(PyCFunction)(cfunc)->func)(self, &__pyx_empty_tuple, 0) :\
                (*(__Pyx_PyCFunctionFastWithKeywords)(void*)(PyCFunction)(cfunc)->func)(self, &__pyx_empty_tuple, 0, NULL)) :\
          (PY_VERSION_HEX >= 0x030700A0 && (cfunc)->flag == (METH_FASTCALL | METH_KEYWORDS) ?\
            (*(__Pyx_PyCFunctionFastWithKeywords)(void*)(PyCFunction)(cfunc)->func)(self, &__pyx_empty_tuple, 0, NULL) :\
            (likely((cfunc)->flag == (METH_VARARGS | METH_KEYWORDS)) ?  ((*(PyCFunctionWithKeywords)(void*)(PyCFunction)(cfunc)->func)(self, __pyx_empty_tuple, NULL)) :\
               ((cfunc)->flag == METH_VARARGS ?  (*((cfunc)->func))(self, __pyx_empty_tuple) :\
               __Pyx__CallUnboundCMethod0(cfunc, self)))))) :\
        __Pyx__CallUnboundCMethod0(cfunc, self))
#else
#define __Pyx_CallUnboundCMethod0(cfunc, self)  __Pyx__CallUnboundCMethod0(cfunc, self)
#endif

/* PySequenceContains.proto */
static CYTHON_INLINE int __Pyx_PySequence_ContainsTF(PyObject* item, PyObject* seq, int eq) {
    int result = PySequence_Contains(seq, item);
    return unlikely(result < 0) ? result : (result == (eq == Py_EQ));
}

/* DictGetItem.proto */
#if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY
static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key);
#define __Pyx_PyObject_Dict_GetItem(obj, name)\
    (likely(PyDict_CheckExact(obj)) ?\
     __Pyx_PyDict_GetItem(obj, name) : PyObject_GetItem(obj, name))
#else
#define __Pyx_PyDict_GetItem(d, key) PyObject_GetItem(d, key)
#define __Pyx_PyObject_Dict_GetItem(obj, name)  PyObject_GetItem(obj, name)
#endif

/* PyObjectCallNoArg.proto */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func);
#else
#define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL)
#endif

/* GetItemInt.proto */
#define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
    (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
    __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\
    (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\
               __Pyx_GetItemInt_Generic(o, to_py_func(i))))
#define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
    (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
    __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
    (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL))
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
                                                              int wraparound, int boundscheck);
#define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
    (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
    __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
    (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL))
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
                                                              int wraparound, int boundscheck);
static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j);
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
                                                     int is_list, int wraparound, int boundscheck);

/* dict_setdefault.proto */
static CYTHON_INLINE PyObject *__Pyx_PyDict_SetDefault(PyObject *d, PyObject *key, PyObject *default_value, int is_safe_type);

/* CallUnboundCMethod2.proto */
static PyObject* __Pyx__CallUnboundCMethod2(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg1, PyObject* arg2);
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030600B1
static CYTHON_INLINE PyObject *__Pyx_CallUnboundCMethod2(__Pyx_CachedCFunction *cfunc, PyObject *self, PyObject *arg1, PyObject *arg2);
#else
#define __Pyx_CallUnboundCMethod2(cfunc, self, arg1, arg2)  __Pyx__CallUnboundCMethod2(cfunc, self, arg1, arg2)
#endif

/* ObjectGetItem.proto */
#if CYTHON_USE_TYPE_SLOTS
static CYTHON_INLINE PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key);
#else
#define __Pyx_PyObject_GetItem(obj, key)  PyObject_GetItem(obj, key)
#endif

/* IncludeStringH.proto */
#include <string.h>

/* BytesEquals.proto */
static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals);

/* UnicodeEquals.proto */
static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals);

/* PyDictContains.proto */
static CYTHON_INLINE int __Pyx_PyDict_ContainsTF(PyObject* item, PyObject* dict, int eq) {
    int result = PyDict_Contains(dict, item);
    return unlikely(result < 0) ? result : (result == (eq == Py_EQ));
}

/* ExtTypeTest.proto */
static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type);

/* ListAppend.proto */
#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) {
    PyListObject* L = (PyListObject*) list;
    Py_ssize_t len = Py_SIZE(list);
    if (likely(L->allocated > len) & likely(len > (L->allocated >> 1))) {
        Py_INCREF(x);
        PyList_SET_ITEM(list, len, x);
        __Pyx_SET_SIZE(list, len + 1);
        return 0;
    }
    return PyList_Append(list, x);
}
#else
#define __Pyx_PyList_Append(L,x) PyList_Append(L,x)
#endif

/* dict_getitem_default.proto */
static PyObject* __Pyx_PyDict_GetItemDefault(PyObject* d, PyObject* key, PyObject* default_value);

/* CallUnboundCMethod1.proto */
static PyObject* __Pyx__CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg);
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg);
#else
#define __Pyx_CallUnboundCMethod1(cfunc, self, arg)  __Pyx__CallUnboundCMethod1(cfunc, self, arg)
#endif

/* GetTopmostException.proto */
#if CYTHON_USE_EXC_INFO_STACK
static _PyErr_StackItem * __Pyx_PyErr_GetTopmostException(PyThreadState *tstate);
#endif

/* SaveResetException.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_ExceptionSave(type, value, tb)  __Pyx__ExceptionSave(__pyx_tstate, type, value, tb)
static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
#define __Pyx_ExceptionReset(type, value, tb)  __Pyx__ExceptionReset(__pyx_tstate, type, value, tb)
static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
#else
#define __Pyx_ExceptionSave(type, value, tb)   PyErr_GetExcInfo(type, value, tb)
#define __Pyx_ExceptionReset(type, value, tb)  PyErr_SetExcInfo(type, value, tb)
#endif

/* PyErrExceptionMatches.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err)
static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err);
#else
#define __Pyx_PyErr_ExceptionMatches(err)  PyErr_ExceptionMatches(err)
#endif

/* GetException.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_GetException(type, value, tb)  __Pyx__GetException(__pyx_tstate, type, value, tb)
static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
#else
static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb);
#endif

/* RaiseException.proto */
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);

/* None.proto */
static CYTHON_INLINE int __Pyx_div_int(int, int);

/* UnaryNegOverflows.proto */
#define UNARY_NEG_WOULD_OVERFLOW(x)\
        (((x) < 0) & ((unsigned long)(x) == 0-(unsigned long)(x)))

/* CallNextTpDealloc.proto */
static void __Pyx_call_next_tp_dealloc(PyObject* obj, destructor current_tp_dealloc);

/* CallNextTpTraverse.proto */
static int __Pyx_call_next_tp_traverse(PyObject* obj, visitproc v, void *a, traverseproc current_tp_traverse);

/* CallNextTpClear.proto */
static void __Pyx_call_next_tp_clear(PyObject* obj, inquiry current_tp_dealloc);

/* TypeImport.proto */
#ifndef __PYX_HAVE_RT_ImportType_proto
#define __PYX_HAVE_RT_ImportType_proto
enum __Pyx_ImportType_CheckSize {
   __Pyx_ImportType_CheckSize_Error = 0,
   __Pyx_ImportType_CheckSize_Warn = 1,
   __Pyx_ImportType_CheckSize_Ignore = 2
};
static PyTypeObject *__Pyx_ImportType(PyObject* module, const char *module_name, const char *class_name, size_t size, enum __Pyx_ImportType_CheckSize check_size);
#endif

/* GetVTable.proto */
static void* __Pyx_GetVtable(PyObject *dict);

/* PyObject_GenericGetAttrNoDict.proto */
#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name);
#else
#define __Pyx_PyObject_GenericGetAttrNoDict PyObject_GenericGetAttr
#endif

/* PyObject_GenericGetAttr.proto */
#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name);
#else
#define __Pyx_PyObject_GenericGetAttr PyObject_GenericGetAttr
#endif

/* SetVTable.proto */
static int __Pyx_SetVtable(PyObject *dict, void *vtable);

/* PyObjectGetAttrStrNoError.proto */
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name);

/* SetupReduce.proto */
static int __Pyx_setup_reduce(PyObject* type_obj);

/* Import.proto */
static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);

/* ImportFrom.proto */
static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name);

/* GetNameInClass.proto */
#define __Pyx_GetNameInClass(var, nmspace, name)  (var) = __Pyx__GetNameInClass(nmspace, name)
static PyObject *__Pyx__GetNameInClass(PyObject *nmspace, PyObject *name);

/* CLineInTraceback.proto */
#ifdef CYTHON_CLINE_IN_TRACEBACK
#define __Pyx_CLineForTraceback(tstate, c_line)  (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0)
#else
static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line);
#endif

/* CodeObjectCache.proto */
typedef struct {
    PyCodeObject* code_object;
    int code_line;
} __Pyx_CodeObjectCacheEntry;
struct __Pyx_CodeObjectCache {
    int count;
    int max_count;
    __Pyx_CodeObjectCacheEntry* entries;
};
static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
static PyCodeObject *__pyx_find_code_object(int code_line);
static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);

/* AddTraceback.proto */
static void __Pyx_AddTraceback(const char *funcname, int c_line,
                               int py_line, const char *filename);

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value);

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum____pyx_t_5mpfmc_4core_5audio_20notification_message_NotificationMessage(enum __pyx_t_5mpfmc_4core_5audio_20notification_message_NotificationMessage value);

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_Uint64(Uint64 value);

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_Uint16(Uint16 value);

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum____pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopSetPlayerStatus(enum __pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopSetPlayerStatus value);

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum____pyx_t_5mpfmc_4core_5audio_16track_sound_loop_LayerStatus(enum __pyx_t_5mpfmc_4core_5audio_16track_sound_loop_LayerStatus value);

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_gsize(gsize value);

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_Uint8(Uint8 value);

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_Uint32(Uint32 value);

/* CIntFromPy.proto */
static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);

/* CIntFromPy.proto */
static CYTHON_INLINE Uint32 __Pyx_PyInt_As_Uint32(PyObject *);

/* CIntFromPy.proto */
static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);

/* CIntFromPy.proto */
static CYTHON_INLINE Uint64 __Pyx_PyInt_As_Uint64(PyObject *);

/* CIntFromPy.proto */
static CYTHON_INLINE Uint8 __Pyx_PyInt_As_Uint8(PyObject *);

/* CIntFromPy.proto */
static CYTHON_INLINE guint __Pyx_PyInt_As_guint(PyObject *);

/* FastTypeChecks.proto */
#if CYTHON_COMPILING_IN_CPYTHON
#define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type)
static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b);
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type);
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2);
#else
#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
#define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type)
#define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2))
#endif
#define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)

/* CheckBinaryVersion.proto */
static int __Pyx_check_binary_version(void);

/* FunctionExport.proto */
static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig);

/* InitStrings.proto */
static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);

static PyObject *__pyx_f_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_process_notification_message(struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *__pyx_v_self, __pyx_t_5mpfmc_4core_5audio_20notification_message_NotificationMessageContainer *__pyx_v_notification_message); /* proto*/
static PyObject *__pyx_f_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop__apply_layer_settings(struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *__pyx_v_self, __pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopLayerSettings *__pyx_v_layer, PyObject *__pyx_v_layer_settings); /* proto*/
static PyObject *__pyx_f_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop__initialize_player(CYTHON_UNUSED struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *__pyx_v_self, __pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopSetPlayer *__pyx_v_player); /* proto*/
static PyObject *__pyx_f_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop__delete_player(struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *__pyx_v_self, __pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopSetPlayer *__pyx_v_player); /* proto*/
static PyObject *__pyx_f_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop__delete_player_layers(CYTHON_UNUSED struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *__pyx_v_self, __pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopSetPlayer *__pyx_v_player); /* proto*/
static PyObject *__pyx_f_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop__cancel_all_delayed_players(struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *__pyx_v_self); /* proto*/
static PyObject *__pyx_f_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop__fade_out_all_players(struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *__pyx_v_self, Uint32 __pyx_v_fade_steps); /* proto*/
static CYTHON_INLINE Uint32 __pyx_f_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop__round_sample_pos_up_to_interval(CYTHON_UNUSED struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *__pyx_v_self, Uint32 __pyx_v_sample_pos, Uint32 __pyx_v_interval, int __pyx_v_bytes_per_sample_frame); /* proto*/
static void __pyx_f_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_mix_playing_sounds(__pyx_t_5mpfmc_4core_5audio_5track_TrackState *__pyx_v_track, Uint32 __pyx_v_buffer_length, __pyx_t_5mpfmc_4core_5audio_4sdl2_AudioCallbackData *__pyx_v_callback_data); /* proto*/

/* Module declarations from 'libc.string' */

/* Module declarations from 'libc.stdio' */

/* Module declarations from 'cpython.mem' */

/* Module declarations from 'cython' */

/* Module declarations from 'mpfmc.core.audio.sdl2' */

/* Module declarations from 'mpfmc.core.audio.gstreamer' */

/* Module declarations from 'mpfmc.core.audio.track' */
static PyTypeObject *__pyx_ptype_5mpfmc_4core_5audio_5track_Track = 0;

/* Module declarations from 'mpfmc.core.audio.inline' */
static CYTHON_INLINE float __pyx_f_5mpfmc_4core_5audio_6inline_in_out_quad(float); /*proto*/

/* Module declarations from 'mpfmc.core.audio.notification_message' */
static CYTHON_INLINE __pyx_t_5mpfmc_4core_5audio_20notification_message_NotificationMessageContainer *__pyx_f_5mpfmc_4core_5audio_20notification_message__create_notification_message(void); /*proto*/
static CYTHON_INLINE void __pyx_f_5mpfmc_4core_5audio_20notification_message_send_sound_marker_notification(int, Uint64, Uint64, __pyx_t_5mpfmc_4core_5audio_5track_TrackState *, int); /*proto*/
static CYTHON_INLINE void __pyx_f_5mpfmc_4core_5audio_20notification_message_send_sound_loop_set_started_notification(int, Uint64, gpointer, __pyx_t_5mpfmc_4core_5audio_5track_TrackState *); /*proto*/
static CYTHON_INLINE void __pyx_f_5mpfmc_4core_5audio_20notification_message_send_sound_loop_set_stopped_notification(int, Uint64, gpointer, __pyx_t_5mpfmc_4core_5audio_5track_TrackState *); /*proto*/
static CYTHON_INLINE void __pyx_f_5mpfmc_4core_5audio_20notification_message_send_sound_loop_set_looping_notification(int, Uint64, gpointer, __pyx_t_5mpfmc_4core_5audio_5track_TrackState *); /*proto*/

/* Module declarations from 'mpfmc.core.audio.sound_file' */
static PyTypeObject *__pyx_ptype_5mpfmc_4core_5audio_10sound_file_SoundFile = 0;
static PyTypeObject *__pyx_ptype_5mpfmc_4core_5audio_10sound_file_SoundMemoryFile = 0;
static PyTypeObject *__pyx_ptype_5mpfmc_4core_5audio_10sound_file_SoundStreamingFile = 0;

/* Module declarations from 'mpfmc.core.audio.track_sound_loop' */
static PyTypeObject *__pyx_ptype_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop = 0;
static CYTHON_INLINE __pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopLayerSettings *__pyx_f_5mpfmc_4core_5audio_16track_sound_loop__create_sound_loop_layer_settings(void); /*proto*/
static Uint32 __pyx_f_5mpfmc_4core_5audio_16track_sound_loop_get_player_sound_samples(__pyx_t_5mpfmc_4core_5audio_5track_TrackState *, __pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopSetPlayer *, Uint32, Uint32, __pyx_t_5mpfmc_4core_5audio_4sdl2_AudioCallbackData *); /*proto*/
#define __Pyx_MODULE_NAME "mpfmc.core.audio.track_sound_loop"
extern int __pyx_module_is_main_mpfmc__core__audio__track_sound_loop;
int __pyx_module_is_main_mpfmc__core__audio__track_sound_loop = 0;

/* Implementation of 'mpfmc.core.audio.track_sound_loop' */
static PyObject *__pyx_builtin_staticmethod;
static PyObject *__pyx_builtin_super;
static PyObject *__pyx_builtin_range;
static PyObject *__pyx_builtin_round;
static PyObject *__pyx_builtin_KeyError;
static PyObject *__pyx_builtin_TypeError;
static const char __pyx_k_id[] = "id";
static const char __pyx_k_mc[] = "mc";
static const char __pyx_k_get[] = "get";
static const char __pyx_k_now[] = "now";
static const char __pyx_k_ceil[] = "ceil";
static const char __pyx_k_idle[] = "idle";
static const char __pyx_k_info[] = "info";
static const char __pyx_k_init[] = "__init__";
static const char __pyx_k_keys[] = "keys";
static const char __pyx_k_main[] = "__main__";
static const char __pyx_k_math[] = "math";
static const char __pyx_k_name[] = "name";
static const char __pyx_k_play[] = "play";
static const char __pyx_k_test[] = "__test__";
static const char __pyx_k_time[] = "time";
static const char __pyx_k_Track[] = "Track.";
static const char __pyx_k_debug[] = "debug";
static const char __pyx_k_error[] = "error";
static const char __pyx_k_layer[] = "layer";
static const char __pyx_k_range[] = "range";
static const char __pyx_k_round[] = "round";
static const char __pyx_k_sound[] = "sound";
static const char __pyx_k_super[] = "super";
static const char __pyx_k_tempo[] = "tempo";
static const char __pyx_k_track[] = "track";
static const char __pyx_k_events[] = "events";
static const char __pyx_k_format[] = "format";
static const char __pyx_k_import[] = "__import__";
static const char __pyx_k_layers[] = "layers";
static const char __pyx_k_length[] = "length";
static const char __pyx_k_loaded[] = "loaded";
static const char __pyx_k_name_2[] = "__name__";
static const char __pyx_k_number[] = "number";
static const char __pyx_k_queued[] = "queued";
static const char __pyx_k_reduce[] = "__reduce__";
static const char __pyx_k_sounds[] = "sounds";
static const char __pyx_k_status[] = "status";
static const char __pyx_k_timing[] = "timing";
static const char __pyx_k_volume[] = "volume";
static const char __pyx_k_context[] = "context";
static const char __pyx_k_delayed[] = "delayed";
static const char __pyx_k_fade_in[] = "fade_in";
static const char __pyx_k_logging[] = "logging";
static const char __pyx_k_looping[] = "looping";
static const char __pyx_k_markers[] = "markers";
static const char __pyx_k_playing[] = "playing";
static const char __pyx_k_stopped[] = "stopped";
static const char __pyx_k_unknown[] = "unknown";
static const char __pyx_k_warning[] = "warning";
static const char __pyx_k_KeyError[] = "KeyError";
static const char __pyx_k_fade_out[] = "fade_out";
static const char __pyx_k_getstate[] = "__getstate__";
static const char __pyx_k_interval[] = "interval";
static const char __pyx_k_loop_end[] = "loop_end";
static const char __pyx_k_setstate[] = "__setstate__";
static const char __pyx_k_sound_id[] = "sound_id";
static const char __pyx_k_start_at[] = "start_at";
static const char __pyx_k_TypeError[] = "TypeError";
static const char __pyx_k_container[] = "container";
static const char __pyx_k_fading_in[] = "fading in";
static const char __pyx_k_getLogger[] = "getLogger";
static const char __pyx_k_marker_id[] = "marker_id";
static const char __pyx_k_reduce_ex[] = "__reduce_ex__";
static const char __pyx_k_track_num[] = "track_num";
static const char __pyx_k_fading_out[] = "fading out";
static const char __pyx_k_max_layers[] = "max_layers";
static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__";
static const char __pyx_k_sample_pos[] = "sample_pos";
static const char __pyx_k_setdefault[] = "setdefault";
static const char __pyx_k_sound_loop[] = "sound_loop";
static const char __pyx_k_buffer_size[] = "buffer_size";
static const char __pyx_k_synchronize[] = "synchronize";
static const char __pyx_k_marker_count[] = "marker_count";
static const char __pyx_k_sound_length[] = "sound_length";
static const char __pyx_k_sounds_by_id[] = "sounds_by_id";
static const char __pyx_k_staticmethod[] = "staticmethod";
static const char __pyx_k_fade_in_steps[] = "fade_in_steps";
static const char __pyx_k_initial_state[] = "initial_state";
static const char __pyx_k_reduce_cython[] = "__reduce_cython__";
static const char __pyx_k_status_values[] = "status_values";
static const char __pyx_k_TrackSoundLoop[] = ".TrackSoundLoop.";
static const char __pyx_k_fade_out_steps[] = "fade_out_steps";
static const char __pyx_k_sound_instance[] = "sound_instance";
static const char __pyx_k_sound_loop_set[] = "sound_loop_set";
static const char __pyx_k_Track_SoundLoop[] = "<Track.{}.SoundLoop.{}>";
static const char __pyx_k_mode_end_action[] = "mode_end_action";
static const char __pyx_k_player_settings[] = "player_settings";
static const char __pyx_k_setstate_cython[] = "__setstate_cython__";
static const char __pyx_k_DO_NOT_STOP_LOOP[] = "DO NOT STOP LOOP";
static const char __pyx_k_TrackSoundLoop_2[] = "TrackSoundLoop";
static const char __pyx_k_fade_out_seconds[] = "fade_out_seconds";
static const char __pyx_k_Created_Track_d_s[] = "Created Track %d %s";
static const char __pyx_k_sound_loop_set_id[] = "sound_loop_set_id";
static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback";
static const char __pyx_k_events_when_played[] = "events_when_played";
static const char __pyx_k_next_beat_interval[] = "next_beat_interval";
static const char __pyx_k_next_time_interval[] = "next_time_interval";
static const char __pyx_k_audio_callback_data[] = "audio_callback_data";
static const char __pyx_k_events_when_looping[] = "events_when_looping";
static const char __pyx_k_events_when_stopped[] = "events_when_stopped";
static const char __pyx_k_fade_steps_remaining[] = "fade_steps_remaining";
static const char __pyx_k_layer_status_to_text[] = "layer_status_to_text";
static const char __pyx_k_post_mc_native_event[] = "post_mc_native_event";
static const char __pyx_k_player_status_to_text[] = "player_status_to_text";
static const char __pyx_k_stop_loop_samples_remaining[] = "stop_loop_samples_remaining";
static const char __pyx_k_start_delay_samples_remaining[] = "start_delay_samples_remaining";
static const char __pyx_k_Could_not_retrieve_settings_for[] = "Could not retrieve settings for a sound loop set (id: %d) Notification will be discarded.";
static const char __pyx_k_Processing_notification_message[] = "Processing notification message %d for sound instance (id: %d)";
static const char __pyx_k_Received_a_notification_message[] = "Received a notification message for a sound loop set (id: %d) that is no longer active. Notification will be discarded.";
static const char __pyx_k_Stopping_current_sound_loop_set[] = "Stopping current sound loop set";
static const char __pyx_k_stop_looping_layer_Stop_looping[] = "stop_looping_layer - Stop looping layer %d of the currently playing sound_loop_set.";
static const char __pyx_k_Illegal_layer_value_in_call_to_p[] = "Illegal layer value in call to play_layer (must be > 0).";
static const char __pyx_k_Illegal_layer_value_in_call_to_s[] = "Illegal layer value in call to stop_layer (must be > 0).";
static const char __pyx_k_Jumping_to_f_seconds_playback_po[] = "Jumping to %f seconds playback position in current sound loop set";
static const char __pyx_k_Removing_sound_loop_set_settings[] = "Removing sound_loop_set settings %d from active list";
static const char __pyx_k_Stopping_looping_current_sound_l[] = "Stopping looping current sound loop set";
static const char __pyx_k_The_current_sound_loop_set_layer[] = "The current sound loop set layer is already playing: play_layers has no effect";
static const char __pyx_k_The_specified_layer_could_not_be[] = "The specified layer could not be found in the current sound loop set: play_layers has no effect";
static const char __pyx_k_There_are_no_layers_defined_in_t[] = "There are no layers defined in the current sound loop set: play_layers has no effect";
static const char __pyx_k_Unable_to_jump_to_specified_play[] = "Unable to jump to specified playback position - no sound loop set is currently playing.";
static const char __pyx_k_Unable_to_play_layer_no_sound_lo[] = "Unable to play layer - no sound loop set is currently playing.";
static const char __pyx_k_Unable_to_stop_layer_no_sound_lo[] = "Unable to stop layer - no sound loop set is currently playing.";
static const char __pyx_k_Unable_to_stop_looping_sound_loo[] = "Unable to stop looping sound loop set - no sound loop set is currently playing.";
static const char __pyx_k_Unable_to_stop_sound_loop_set_no[] = "Unable to stop sound loop set - no sound loop set is currently playing.";
static const char __pyx_k_Unknown_timing_value_specified_s[] = "Unknown timing value specified: %s";
static const char __pyx_k_mpfmc_core_audio_track_sound_loo[] = "mpfmc\\core\\audio\\track_sound_loop.pyx";
static const char __pyx_k_play_layer_Play_layer_d_of_the_c[] = "play_layer - Play layer %d of the currently playing sound_loop_set (fade-in = %f sec).";
static const char __pyx_k_play_sound_loop_set_Preparing_so[] = "play_sound_loop_set - Preparing sound_loop_set '%s' for playback.";
static const char __pyx_k_play_sound_loop_set_sound_s_in_s[] = "play_sound_loop_set - sound %s in sound_loop_set could not be located, could not play loop set";
static const char __pyx_k_self_state_self_type_state_canno[] = "self.state,self.type_state cannot be converted to a Python object for pickling";
static const char __pyx_k_stop_layer_Stop_layer_d_of_the_c[] = "stop_layer - Stop layer %d of the currently playing sound_loop_set (fade-out = %f sec).";
static const char __pyx_k_Received_a_notification_message_2[] = "Received a notification message for a sound (id: %d) that does not exist. Notification will be discarded.";
static const char __pyx_k_Illegal_layer_value_in_call_to_s_2[] = "Illegal layer value in call to stop_looping_layer (must be > 0).";
static const char __pyx_k_The_current_sound_loop_set_layer_2[] = "The current sound loop set layer is already stopped: stop_layers has no effect";
static const char __pyx_k_The_current_sound_loop_set_layer_3[] = "The current sound loop set layer is already stopped: stop_looping_layers has no effect";
static const char __pyx_k_The_specified_layer_could_not_be_2[] = "The specified layer could not be found in the current sound loop set: stop_layers has no effect";
static const char __pyx_k_The_specified_layer_could_not_be_3[] = "The specified layer could not be found in the current sound loop set: stop_looping_layers has no effect";
static const char __pyx_k_There_are_no_layers_defined_in_t_2[] = "There are no layers defined in the current sound loop set: stop_layers has no effect";
static const char __pyx_k_There_are_no_layers_defined_in_t_3[] = "There are no layers defined in the current sound loop set: stop_looping_layers has no effect";
static const char __pyx_k_mpfmc_core_audio_track_sound_loo_2[] = "mpfmc.core.audio.track_sound_loop";
static const char __pyx_k_play_sound_loop_set_sound_s_in_s_2[] = "play_sound_loop_set - sound %s in sound_loop_set was not loaded, could not play loop set";
static PyObject *__pyx_kp_u_Could_not_retrieve_settings_for;
static PyObject *__pyx_kp_u_Created_Track_d_s;
static PyObject *__pyx_kp_u_DO_NOT_STOP_LOOP;
static PyObject *__pyx_kp_u_Illegal_layer_value_in_call_to_p;
static PyObject *__pyx_kp_u_Illegal_layer_value_in_call_to_s;
static PyObject *__pyx_kp_u_Illegal_layer_value_in_call_to_s_2;
static PyObject *__pyx_kp_u_Jumping_to_f_seconds_playback_po;
static PyObject *__pyx_n_s_KeyError;
static PyObject *__pyx_kp_u_Processing_notification_message;
static PyObject *__pyx_kp_u_Received_a_notification_message;
static PyObject *__pyx_kp_u_Received_a_notification_message_2;
static PyObject *__pyx_kp_u_Removing_sound_loop_set_settings;
static PyObject *__pyx_kp_u_Stopping_current_sound_loop_set;
static PyObject *__pyx_kp_u_Stopping_looping_current_sound_l;
static PyObject *__pyx_kp_u_The_current_sound_loop_set_layer;
static PyObject *__pyx_kp_u_The_current_sound_loop_set_layer_2;
static PyObject *__pyx_kp_u_The_current_sound_loop_set_layer_3;
static PyObject *__pyx_kp_u_The_specified_layer_could_not_be;
static PyObject *__pyx_kp_u_The_specified_layer_could_not_be_2;
static PyObject *__pyx_kp_u_The_specified_layer_could_not_be_3;
static PyObject *__pyx_kp_u_There_are_no_layers_defined_in_t;
static PyObject *__pyx_kp_u_There_are_no_layers_defined_in_t_2;
static PyObject *__pyx_kp_u_There_are_no_layers_defined_in_t_3;
static PyObject *__pyx_kp_u_Track;
static PyObject *__pyx_kp_u_TrackSoundLoop;
static PyObject *__pyx_n_s_TrackSoundLoop_2;
static PyObject *__pyx_kp_u_Track_SoundLoop;
static PyObject *__pyx_n_s_TypeError;
static PyObject *__pyx_kp_u_Unable_to_jump_to_specified_play;
static PyObject *__pyx_kp_u_Unable_to_play_layer_no_sound_lo;
static PyObject *__pyx_kp_u_Unable_to_stop_layer_no_sound_lo;
static PyObject *__pyx_kp_u_Unable_to_stop_looping_sound_loo;
static PyObject *__pyx_kp_u_Unable_to_stop_sound_loop_set_no;
static PyObject *__pyx_kp_u_Unknown_timing_value_specified_s;
static PyObject *__pyx_n_s_audio_callback_data;
static PyObject *__pyx_n_s_buffer_size;
static PyObject *__pyx_n_s_ceil;
static PyObject *__pyx_n_s_cline_in_traceback;
static PyObject *__pyx_n_s_container;
static PyObject *__pyx_n_s_context;
static PyObject *__pyx_n_u_context;
static PyObject *__pyx_n_s_debug;
static PyObject *__pyx_n_u_delayed;
static PyObject *__pyx_n_s_error;
static PyObject *__pyx_n_u_events;
static PyObject *__pyx_n_u_events_when_looping;
static PyObject *__pyx_n_u_events_when_played;
static PyObject *__pyx_n_u_events_when_stopped;
static PyObject *__pyx_n_s_fade_in;
static PyObject *__pyx_n_u_fade_in;
static PyObject *__pyx_n_u_fade_in_steps;
static PyObject *__pyx_n_s_fade_out;
static PyObject *__pyx_n_u_fade_out;
static PyObject *__pyx_n_s_fade_out_seconds;
static PyObject *__pyx_n_u_fade_out_steps;
static PyObject *__pyx_n_u_fade_steps_remaining;
static PyObject *__pyx_kp_u_fading_in;
static PyObject *__pyx_kp_u_fading_out;
static PyObject *__pyx_n_s_format;
static PyObject *__pyx_n_s_get;
static PyObject *__pyx_n_s_getLogger;
static PyObject *__pyx_n_s_getstate;
static PyObject *__pyx_n_s_id;
static PyObject *__pyx_n_u_idle;
static PyObject *__pyx_n_s_import;
static PyObject *__pyx_n_s_info;
static PyObject *__pyx_n_s_init;
static PyObject *__pyx_n_u_initial_state;
static PyObject *__pyx_n_u_interval;
static PyObject *__pyx_n_s_keys;
static PyObject *__pyx_n_s_layer;
static PyObject *__pyx_n_s_layer_status_to_text;
static PyObject *__pyx_n_u_layers;
static PyObject *__pyx_n_u_length;
static PyObject *__pyx_n_s_loaded;
static PyObject *__pyx_n_s_logging;
static PyObject *__pyx_n_u_loop_end;
static PyObject *__pyx_n_u_looping;
static PyObject *__pyx_n_s_main;
static PyObject *__pyx_n_s_marker_count;
static PyObject *__pyx_n_u_marker_count;
static PyObject *__pyx_n_s_marker_id;
static PyObject *__pyx_n_s_markers;
static PyObject *__pyx_n_s_math;
static PyObject *__pyx_n_s_max_layers;
static PyObject *__pyx_n_s_mc;
static PyObject *__pyx_n_u_mode_end_action;
static PyObject *__pyx_kp_s_mpfmc_core_audio_track_sound_loo;
static PyObject *__pyx_n_s_mpfmc_core_audio_track_sound_loo_2;
static PyObject *__pyx_n_s_name;
static PyObject *__pyx_n_s_name_2;
static PyObject *__pyx_n_u_next_beat_interval;
static PyObject *__pyx_n_u_next_time_interval;
static PyObject *__pyx_n_u_now;
static PyObject *__pyx_n_s_number;
static PyObject *__pyx_n_u_play;
static PyObject *__pyx_kp_u_play_layer_Play_layer_d_of_the_c;
static PyObject *__pyx_kp_u_play_sound_loop_set_Preparing_so;
static PyObject *__pyx_kp_u_play_sound_loop_set_sound_s_in_s;
static PyObject *__pyx_kp_u_play_sound_loop_set_sound_s_in_s_2;
static PyObject *__pyx_n_s_player_settings;
static PyObject *__pyx_n_s_player_status_to_text;
static PyObject *__pyx_n_u_playing;
static PyObject *__pyx_n_s_post_mc_native_event;
static PyObject *__pyx_n_s_pyx_vtable;
static PyObject *__pyx_n_u_queued;
static PyObject *__pyx_n_s_range;
static PyObject *__pyx_n_s_reduce;
static PyObject *__pyx_n_s_reduce_cython;
static PyObject *__pyx_n_s_reduce_ex;
static PyObject *__pyx_n_s_round;
static PyObject *__pyx_n_u_sample_pos;
static PyObject *__pyx_kp_s_self_state_self_type_state_canno;
static PyObject *__pyx_n_s_setdefault;
static PyObject *__pyx_n_s_setstate;
static PyObject *__pyx_n_s_setstate_cython;
static PyObject *__pyx_n_s_sound;
static PyObject *__pyx_n_u_sound;
static PyObject *__pyx_n_u_sound_id;
static PyObject *__pyx_n_s_sound_instance;
static PyObject *__pyx_n_u_sound_length;
static PyObject *__pyx_n_u_sound_loop;
static PyObject *__pyx_n_s_sound_loop_set;
static PyObject *__pyx_n_u_sound_loop_set_id;
static PyObject *__pyx_n_s_sounds;
static PyObject *__pyx_n_s_sounds_by_id;
static PyObject *__pyx_n_u_start_at;
static PyObject *__pyx_n_u_start_delay_samples_remaining;
static PyObject *__pyx_n_s_staticmethod;
static PyObject *__pyx_n_s_status;
static PyObject *__pyx_n_u_status;
static PyObject *__pyx_n_s_status_values;
static PyObject *__pyx_kp_u_stop_layer_Stop_layer_d_of_the_c;
static PyObject *__pyx_n_u_stop_loop_samples_remaining;
static PyObject *__pyx_kp_u_stop_looping_layer_Stop_looping;
static PyObject *__pyx_n_u_stopped;
static PyObject *__pyx_n_s_super;
static PyObject *__pyx_n_u_synchronize;
static PyObject *__pyx_n_u_tempo;
static PyObject *__pyx_n_s_test;
static PyObject *__pyx_n_s_time;
static PyObject *__pyx_n_u_time;
static PyObject *__pyx_n_s_timing;
static PyObject *__pyx_n_u_timing;
static PyObject *__pyx_n_s_track;
static PyObject *__pyx_n_s_track_num;
static PyObject *__pyx_n_u_unknown;
static PyObject *__pyx_n_s_volume;
static PyObject *__pyx_n_u_volume;
static PyObject *__pyx_n_s_warning;
static int __pyx_pf_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop___init__(struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *__pyx_v_self, PyObject *__pyx_v_mc, PyObject *__pyx_v_audio_callback_data, PyObject *__pyx_v_name, int __pyx_v_track_num, int __pyx_v_buffer_size, CYTHON_UNUSED int __pyx_v_max_layers, float __pyx_v_volume); /* proto */
static void __pyx_pf_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_2__dealloc__(struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_4__repr__(struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_4type___get__(CYTHON_UNUSED struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_25supports_in_memory_sounds___get__(CYTHON_UNUSED struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_25supports_streaming_sounds___get__(CYTHON_UNUSED struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_6stop_all_sounds(struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *__pyx_v_self, CYTHON_UNUSED float __pyx_v_fade_out_seconds); /* proto */
static PyObject *__pyx_pf_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_8stop_sound(CYTHON_UNUSED struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_sound, CYTHON_UNUSED PyObject *__pyx_v_fade_out); /* proto */
static PyObject *__pyx_pf_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_10stop_sound_instance(CYTHON_UNUSED struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_sound_instance, CYTHON_UNUSED PyObject *__pyx_v_fade_out); /* proto */
static PyObject *__pyx_pf_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_12stop_sound_looping(CYTHON_UNUSED struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_sound); /* proto */
static PyObject *__pyx_pf_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_14stop_sound_instance_looping(CYTHON_UNUSED struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_sound_instance); /* proto */
static PyObject *__pyx_pf_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_16process(struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_18play_sound_loop_set(struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *__pyx_v_self, PyObject *__pyx_v_sound_loop_set, PyObject *__pyx_v_context, PyObject *__pyx_v_player_settings); /* proto */
static PyObject *__pyx_pf_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_20stop_current_sound_loop_set(struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *__pyx_v_self, PyObject *__pyx_v_fade_out); /* proto */
static PyObject *__pyx_pf_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_22jump_to_time_current_sound_loop_set(struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *__pyx_v_self, PyObject *__pyx_v_time); /* proto */
static PyObject *__pyx_pf_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_24stop_looping_current_sound_loop_set(struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_26play_layer(struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *__pyx_v_self, int __pyx_v_layer, float __pyx_v_fade_in, PyObject *__pyx_v_timing, PyObject *__pyx_v_volume); /* proto */
static PyObject *__pyx_pf_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_28stop_layer(struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *__pyx_v_self, int __pyx_v_layer, float __pyx_v_fade_out); /* proto */
static PyObject *__pyx_pf_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_30stop_looping_layer(struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *__pyx_v_self, int __pyx_v_layer); /* proto */
static PyObject *__pyx_pf_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_32get_status(struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_34player_status_to_text(int __pyx_v_status); /* proto */
static PyObject *__pyx_pf_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_36layer_status_to_text(int __pyx_v_status); /* proto */
static PyObject *__pyx_pf_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_38__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_40__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_tp_new_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static __Pyx_CachedCFunction __pyx_umethod_PyDict_Type_get = {0, &__pyx_n_s_get, 0, 0, 0};
static __Pyx_CachedCFunction __pyx_umethod_PyDict_Type_keys = {0, &__pyx_n_s_keys, 0, 0, 0};
static __Pyx_CachedCFunction __pyx_umethod_PyDict_Type_setdefault = {0, &__pyx_n_s_setdefault, 0, 0, 0};
static PyObject *__pyx_float_0_0;
static PyObject *__pyx_float_60_0;
static PyObject *__pyx_int_0;
static PyObject *__pyx_int_1;
static PyObject *__pyx_tuple_;
static PyObject *__pyx_tuple__2;
static PyObject *__pyx_tuple__3;
static PyObject *__pyx_tuple__5;
static PyObject *__pyx_codeobj__4;
static PyObject *__pyx_codeobj__6;
/* Late includes */

/* "mpfmc/core/audio/track_sound_loop.pyx":26
 *     """
 * 
 *     def __init__(self, object mc, object audio_callback_data, str name, int track_num, int buffer_size,             # <<<<<<<<<<<<<<
 *                  int max_layers=8,
 *                  float volume=1.0):
 */

/* Python wrapper */
static int __pyx_pw_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop___init__[] = "\n        Constructor\n        Args:\n            mc: The media controller app\n            audio_callback_data: The AudioCallbackData struct wrapped in a PyCapsule\n            name: The track name\n            track_num: The track number\n            buffer_size: The length of the track audio buffer in bytes\n            max_layers: The maximum number of sounds that can be played simultaneously\n                on the track\n            volume: The track volume (0.0 to 1.0)\n        ";
#if CYTHON_COMPILING_IN_CPYTHON
struct wrapperbase __pyx_wrapperbase_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop___init__;
#endif
static int __pyx_pw_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_mc = 0;
  PyObject *__pyx_v_audio_callback_data = 0;
  PyObject *__pyx_v_name = 0;
  int __pyx_v_track_num;
  int __pyx_v_buffer_size;
  CYTHON_UNUSED int __pyx_v_max_layers;
  float __pyx_v_volume;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_mc,&__pyx_n_s_audio_callback_data,&__pyx_n_s_name,&__pyx_n_s_track_num,&__pyx_n_s_buffer_size,&__pyx_n_s_max_layers,&__pyx_n_s_volume,0};
    PyObject* values[7] = {0,0,0,0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_mc)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_audio_callback_data)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 5, 7, 1); __PYX_ERR(0, 26, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_name)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 5, 7, 2); __PYX_ERR(0, 26, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_track_num)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 5, 7, 3); __PYX_ERR(0, 26, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_buffer_size)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 5, 7, 4); __PYX_ERR(0, 26, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_max_layers);
          if (value) { values[5] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_volume);
          if (value) { values[6] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 26, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_mc = values[0];
    __pyx_v_audio_callback_data = values[1];
    __pyx_v_name = ((PyObject*)values[2]);
    __pyx_v_track_num = __Pyx_PyInt_As_int(values[3]); if (unlikely((__pyx_v_track_num == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 26, __pyx_L3_error)
    __pyx_v_buffer_size = __Pyx_PyInt_As_int(values[4]); if (unlikely((__pyx_v_buffer_size == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 26, __pyx_L3_error)
    if (values[5]) {
      __pyx_v_max_layers = __Pyx_PyInt_As_int(values[5]); if (unlikely((__pyx_v_max_layers == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 27, __pyx_L3_error)
    } else {
      __pyx_v_max_layers = ((int)8);
    }
    if (values[6]) {
      __pyx_v_volume = __pyx_PyFloat_AsFloat(values[6]); if (unlikely((__pyx_v_volume == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 28, __pyx_L3_error)
    } else {
      __pyx_v_volume = ((float)1.0);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 5, 7, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 26, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mpfmc.core.audio.track_sound_loop.TrackSoundLoop.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_name), (&PyUnicode_Type), 1, "name", 1))) __PYX_ERR(0, 26, __pyx_L1_error)
  __pyx_r = __pyx_pf_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop___init__(((struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *)__pyx_v_self), __pyx_v_mc, __pyx_v_audio_callback_data, __pyx_v_name, __pyx_v_track_num, __pyx_v_buffer_size, __pyx_v_max_layers, __pyx_v_volume);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop___init__(struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *__pyx_v_self, PyObject *__pyx_v_mc, PyObject *__pyx_v_audio_callback_data, PyObject *__pyx_v_name, int __pyx_v_track_num, int __pyx_v_buffer_size, CYTHON_UNUSED int __pyx_v_max_layers, float __pyx_v_volume) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "mpfmc/core/audio/track_sound_loop.pyx":42
 *         """
 *         # IMPORTANT: Call super class init function to allocate track state memory!
 *         super().__init__(mc, audio_callback_data, name, track_num, buffer_size, volume)             # <<<<<<<<<<<<<<
 * 
 *         self.log = logging.getLogger("Track." + str(track_num) + ".TrackSoundLoop." + name)
 */
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 42, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_ptype_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop));
  __Pyx_GIVEREF(((PyObject *)__pyx_ptype_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_ptype_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop));
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_v_self));
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_super, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 42, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_init); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 42, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_track_num); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 42, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_buffer_size); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 42, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = PyFloat_FromDouble(__pyx_v_volume); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 42, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = NULL;
  __pyx_t_7 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
      __pyx_t_7 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[7] = {__pyx_t_6, __pyx_v_mc, __pyx_v_audio_callback_data, __pyx_v_name, __pyx_t_3, __pyx_t_4, __pyx_t_5};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_7, 6+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 42, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[7] = {__pyx_t_6, __pyx_v_mc, __pyx_v_audio_callback_data, __pyx_v_name, __pyx_t_3, __pyx_t_4, __pyx_t_5};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_7, 6+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 42, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else
  #endif
  {
    __pyx_t_8 = PyTuple_New(6+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 42, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    if (__pyx_t_6) {
      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __pyx_t_6 = NULL;
    }
    __Pyx_INCREF(__pyx_v_mc);
    __Pyx_GIVEREF(__pyx_v_mc);
    PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_v_mc);
    __Pyx_INCREF(__pyx_v_audio_callback_data);
    __Pyx_GIVEREF(__pyx_v_audio_callback_data);
    PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_v_audio_callback_data);
    __Pyx_INCREF(__pyx_v_name);
    __Pyx_GIVEREF(__pyx_v_name);
    PyTuple_SET_ITEM(__pyx_t_8, 2+__pyx_t_7, __pyx_v_name);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_8, 3+__pyx_t_7, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_8, 4+__pyx_t_7, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_8, 5+__pyx_t_7, __pyx_t_5);
    __pyx_t_3 = 0;
    __pyx_t_4 = 0;
    __pyx_t_5 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_8, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 42, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "mpfmc/core/audio/track_sound_loop.pyx":44
 *         super().__init__(mc, audio_callback_data, name, track_num, buffer_size, volume)
 * 
 *         self.log = logging.getLogger("Track." + str(track_num) + ".TrackSoundLoop." + name)             # <<<<<<<<<<<<<<
 * 
 *         SDL_LockAudio()
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_logging); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 44, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_getLogger); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 44, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_track_num); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 44, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_5 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyUnicode_Type)), __pyx_t_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 44, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyUnicode_Concat(__pyx_kp_u_Track, __pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 44, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyUnicode_Concat(__pyx_t_2, __pyx_kp_u_TrackSoundLoop); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 44, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyUnicode_ConcatSafe(__pyx_t_5, __pyx_v_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 44, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_8);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_8, function);
    }
  }
  __pyx_t_1 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_5, __pyx_t_2) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 44, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.log);
  __Pyx_DECREF(__pyx_v_self->__pyx_base.log);
  __pyx_v_self->__pyx_base.log = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "mpfmc/core/audio/track_sound_loop.pyx":46
 *         self.log = logging.getLogger("Track." + str(track_num) + ".TrackSoundLoop." + name)
 * 
 *         SDL_LockAudio()             # <<<<<<<<<<<<<<
 * 
 *         # Set track type specific settings
 */
  SDL_LockAudio();

  /* "mpfmc/core/audio/track_sound_loop.pyx":49
 * 
 *         # Set track type specific settings
 *         self.state.mix_callback_function = TrackSoundLoop.mix_playing_sounds             # <<<<<<<<<<<<<<
 * 
 *         # Allocate memory for the specific track type state struct (TrackSoundLoopState)
 */
  __pyx_v_self->__pyx_base.state->mix_callback_function = __pyx_f_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_mix_playing_sounds;

  /* "mpfmc/core/audio/track_sound_loop.pyx":52
 * 
 *         # Allocate memory for the specific track type state struct (TrackSoundLoopState)
 *         self.type_state = <TrackSoundLoopState*> PyMem_Malloc(sizeof(TrackSoundLoopState))             # <<<<<<<<<<<<<<
 *         self.state.type_state = <void*>self.type_state
 * 
 */
  __pyx_v_self->type_state = ((__pyx_t_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoopState *)PyMem_Malloc((sizeof(__pyx_t_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoopState))));

  /* "mpfmc/core/audio/track_sound_loop.pyx":53
 *         # Allocate memory for the specific track type state struct (TrackSoundLoopState)
 *         self.type_state = <TrackSoundLoopState*> PyMem_Malloc(sizeof(TrackSoundLoopState))
 *         self.state.type_state = <void*>self.type_state             # <<<<<<<<<<<<<<
 * 
 *         # Initialize track specific state structures
 */
  __pyx_v_self->__pyx_base.state->type_state = ((void *)__pyx_v_self->type_state);

  /* "mpfmc/core/audio/track_sound_loop.pyx":56
 * 
 *         # Initialize track specific state structures
 *         self.type_state.players = NULL             # <<<<<<<<<<<<<<
 *         self.type_state.current = NULL
 * 
 */
  __pyx_v_self->type_state->players = NULL;

  /* "mpfmc/core/audio/track_sound_loop.pyx":57
 *         # Initialize track specific state structures
 *         self.type_state.players = NULL
 *         self.type_state.current = NULL             # <<<<<<<<<<<<<<
 * 
 *         self._sound_loop_set_counter = 0
 */
  __pyx_v_self->type_state->current = NULL;

  /* "mpfmc/core/audio/track_sound_loop.pyx":59
 *         self.type_state.current = NULL
 * 
 *         self._sound_loop_set_counter = 0             # <<<<<<<<<<<<<<
 *         self._active_sound_loop_sets = dict()
 * 
 */
  __pyx_v_self->_sound_loop_set_counter = 0;

  /* "mpfmc/core/audio/track_sound_loop.pyx":60
 * 
 *         self._sound_loop_set_counter = 0
 *         self._active_sound_loop_sets = dict()             # <<<<<<<<<<<<<<
 * 
 *         self.log.debug("Created Track %d %s", self.number, self.name)
 */
  __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 60, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->_active_sound_loop_sets);
  __Pyx_DECREF(__pyx_v_self->_active_sound_loop_sets);
  __pyx_v_self->_active_sound_loop_sets = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "mpfmc/core/audio/track_sound_loop.pyx":62
 *         self._active_sound_loop_sets = dict()
 * 
 *         self.log.debug("Created Track %d %s", self.number, self.name)             # <<<<<<<<<<<<<<
 * 
 *         SDL_UnlockAudio()
 */
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->__pyx_base.log, __pyx_n_s_debug); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 62, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_number); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 62, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_name); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 62, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_4 = NULL;
  __pyx_t_7 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_8);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_8, function);
      __pyx_t_7 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_8)) {
    PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_kp_u_Created_Track_d_s, __pyx_t_2, __pyx_t_5};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 62, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) {
    PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_kp_u_Created_Track_d_s, __pyx_t_2, __pyx_t_5};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 62, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else
  #endif
  {
    __pyx_t_3 = PyTuple_New(3+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 62, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    if (__pyx_t_4) {
      __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); __pyx_t_4 = NULL;
    }
    __Pyx_INCREF(__pyx_kp_u_Created_Track_d_s);
    __Pyx_GIVEREF(__pyx_kp_u_Created_Track_d_s);
    PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_7, __pyx_kp_u_Created_Track_d_s);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_7, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_3, 2+__pyx_t_7, __pyx_t_5);
    __pyx_t_2 = 0;
    __pyx_t_5 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 62, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "mpfmc/core/audio/track_sound_loop.pyx":64
 *         self.log.debug("Created Track %d %s", self.number, self.name)
 * 
 *         SDL_UnlockAudio()             # <<<<<<<<<<<<<<
 * 
 *     def __dealloc__(self):
 */
  SDL_UnlockAudio();

  /* "mpfmc/core/audio/track_sound_loop.pyx":26
 *     """
 * 
 *     def __init__(self, object mc, object audio_callback_data, str name, int track_num, int buffer_size,             # <<<<<<<<<<<<<<
 *                  int max_layers=8,
 *                  float volume=1.0):
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("mpfmc.core.audio.track_sound_loop.TrackSoundLoop.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mpfmc/core/audio/track_sound_loop.pyx":66
 *         SDL_UnlockAudio()
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         """Destructor"""
 * 
 */

/* Python wrapper */
static void __pyx_pw_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_3__dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pw_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_3__dealloc__(PyObject *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
  __pyx_pf_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_2__dealloc__(((struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

static void __pyx_pf_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_2__dealloc__(struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *__pyx_v_self) {
  GSList *__pyx_v_iterator;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  GSList *__pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__dealloc__", 0);

  /* "mpfmc/core/audio/track_sound_loop.pyx":69
 *         """Destructor"""
 * 
 *         SDL_LockAudio()             # <<<<<<<<<<<<<<
 * 
 *         # Free the specific track type state and other allocated memory
 */
  SDL_LockAudio();

  /* "mpfmc/core/audio/track_sound_loop.pyx":72
 * 
 *         # Free the specific track type state and other allocated memory
 *         if self.type_state != NULL:             # <<<<<<<<<<<<<<
 * 
 *             if self.type_state.players != NULL:
 */
  __pyx_t_1 = ((__pyx_v_self->type_state != NULL) != 0);
  if (__pyx_t_1) {

    /* "mpfmc/core/audio/track_sound_loop.pyx":74
 *         if self.type_state != NULL:
 * 
 *             if self.type_state.players != NULL:             # <<<<<<<<<<<<<<
 *                 iterator = self.type_state.players
 *                 while iterator != NULL:
 */
    __pyx_t_1 = ((__pyx_v_self->type_state->players != NULL) != 0);
    if (__pyx_t_1) {

      /* "mpfmc/core/audio/track_sound_loop.pyx":75
 * 
 *             if self.type_state.players != NULL:
 *                 iterator = self.type_state.players             # <<<<<<<<<<<<<<
 *                 while iterator != NULL:
 *                     self._delete_player_layers(<SoundLoopSetPlayer*>iterator.data)
 */
      __pyx_t_2 = __pyx_v_self->type_state->players;
      __pyx_v_iterator = __pyx_t_2;

      /* "mpfmc/core/audio/track_sound_loop.pyx":76
 *             if self.type_state.players != NULL:
 *                 iterator = self.type_state.players
 *                 while iterator != NULL:             # <<<<<<<<<<<<<<
 *                     self._delete_player_layers(<SoundLoopSetPlayer*>iterator.data)
 *                     g_slice_free1(sizeof(SoundLoopSetPlayer), iterator.data)
 */
      while (1) {
        __pyx_t_1 = ((__pyx_v_iterator != NULL) != 0);
        if (!__pyx_t_1) break;

        /* "mpfmc/core/audio/track_sound_loop.pyx":77
 *                 iterator = self.type_state.players
 *                 while iterator != NULL:
 *                     self._delete_player_layers(<SoundLoopSetPlayer*>iterator.data)             # <<<<<<<<<<<<<<
 *                     g_slice_free1(sizeof(SoundLoopSetPlayer), iterator.data)
 *                     iterator = iterator.next
 */
        __pyx_t_3 = ((struct __pyx_vtabstruct_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *)__pyx_v_self->__pyx_base.__pyx_vtab)->_delete_player_layers(__pyx_v_self, ((__pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopSetPlayer *)__pyx_v_iterator->data)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 77, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

        /* "mpfmc/core/audio/track_sound_loop.pyx":78
 *                 while iterator != NULL:
 *                     self._delete_player_layers(<SoundLoopSetPlayer*>iterator.data)
 *                     g_slice_free1(sizeof(SoundLoopSetPlayer), iterator.data)             # <<<<<<<<<<<<<<
 *                     iterator = iterator.next
 * 
 */
        g_slice_free1((sizeof(__pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopSetPlayer)), __pyx_v_iterator->data);

        /* "mpfmc/core/audio/track_sound_loop.pyx":79
 *                     self._delete_player_layers(<SoundLoopSetPlayer*>iterator.data)
 *                     g_slice_free1(sizeof(SoundLoopSetPlayer), iterator.data)
 *                     iterator = iterator.next             # <<<<<<<<<<<<<<
 * 
 *                 g_slist_free(self.type_state.players)
 */
        __pyx_t_2 = __pyx_v_iterator->next;
        __pyx_v_iterator = __pyx_t_2;
      }

      /* "mpfmc/core/audio/track_sound_loop.pyx":81
 *                     iterator = iterator.next
 * 
 *                 g_slist_free(self.type_state.players)             # <<<<<<<<<<<<<<
 *                 self.type_state.players = NULL
 * 
 */
      g_slist_free(__pyx_v_self->type_state->players);

      /* "mpfmc/core/audio/track_sound_loop.pyx":82
 * 
 *                 g_slist_free(self.type_state.players)
 *                 self.type_state.players = NULL             # <<<<<<<<<<<<<<
 * 
 *             PyMem_Free(self.type_state)
 */
      __pyx_v_self->type_state->players = NULL;

      /* "mpfmc/core/audio/track_sound_loop.pyx":74
 *         if self.type_state != NULL:
 * 
 *             if self.type_state.players != NULL:             # <<<<<<<<<<<<<<
 *                 iterator = self.type_state.players
 *                 while iterator != NULL:
 */
    }

    /* "mpfmc/core/audio/track_sound_loop.pyx":84
 *                 self.type_state.players = NULL
 * 
 *             PyMem_Free(self.type_state)             # <<<<<<<<<<<<<<
 *             self.type_state = NULL
 *             if self.state != NULL:
 */
    PyMem_Free(__pyx_v_self->type_state);

    /* "mpfmc/core/audio/track_sound_loop.pyx":85
 * 
 *             PyMem_Free(self.type_state)
 *             self.type_state = NULL             # <<<<<<<<<<<<<<
 *             if self.state != NULL:
 *                 self.state.type_state = NULL
 */
    __pyx_v_self->type_state = NULL;

    /* "mpfmc/core/audio/track_sound_loop.pyx":86
 *             PyMem_Free(self.type_state)
 *             self.type_state = NULL
 *             if self.state != NULL:             # <<<<<<<<<<<<<<
 *                 self.state.type_state = NULL
 * 
 */
    __pyx_t_1 = ((__pyx_v_self->__pyx_base.state != NULL) != 0);
    if (__pyx_t_1) {

      /* "mpfmc/core/audio/track_sound_loop.pyx":87
 *             self.type_state = NULL
 *             if self.state != NULL:
 *                 self.state.type_state = NULL             # <<<<<<<<<<<<<<
 * 
 *         SDL_UnlockAudio()
 */
      __pyx_v_self->__pyx_base.state->type_state = NULL;

      /* "mpfmc/core/audio/track_sound_loop.pyx":86
 *             PyMem_Free(self.type_state)
 *             self.type_state = NULL
 *             if self.state != NULL:             # <<<<<<<<<<<<<<
 *                 self.state.type_state = NULL
 * 
 */
    }

    /* "mpfmc/core/audio/track_sound_loop.pyx":72
 * 
 *         # Free the specific track type state and other allocated memory
 *         if self.type_state != NULL:             # <<<<<<<<<<<<<<
 * 
 *             if self.type_state.players != NULL:
 */
  }

  /* "mpfmc/core/audio/track_sound_loop.pyx":89
 *                 self.state.type_state = NULL
 * 
 *         SDL_UnlockAudio()             # <<<<<<<<<<<<<<
 * 
 *     def __repr__(self):
 */
  SDL_UnlockAudio();

  /* "mpfmc/core/audio/track_sound_loop.pyx":66
 *         SDL_UnlockAudio()
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         """Destructor"""
 * 
 */

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_WriteUnraisable("mpfmc.core.audio.track_sound_loop.TrackSoundLoop.__dealloc__", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
}

/* "mpfmc/core/audio/track_sound_loop.pyx":91
 *         SDL_UnlockAudio()
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return '<Track.{}.SoundLoop.{}>'.format(self.number, self.name)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_5__repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_5__repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_4__repr__(((struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_4__repr__(struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__repr__", 0);

  /* "mpfmc/core/audio/track_sound_loop.pyx":92
 * 
 *     def __repr__(self):
 *         return '<Track.{}.SoundLoop.{}>'.format(self.number, self.name)             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_Track_SoundLoop, __pyx_n_s_format); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 92, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_number); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 92, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_name); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 92, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = NULL;
  __pyx_t_6 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
      __pyx_t_6 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_3, __pyx_t_4};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 92, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_3, __pyx_t_4};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 92, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else
  #endif
  {
    __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 92, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    if (__pyx_t_5) {
      __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_4);
    __pyx_t_3 = 0;
    __pyx_t_4 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 92, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "mpfmc/core/audio/track_sound_loop.pyx":91
 *         SDL_UnlockAudio()
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return '<Track.{}.SoundLoop.{}>'.format(self.number, self.name)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("mpfmc.core.audio.track_sound_loop.TrackSoundLoop.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mpfmc/core/audio/track_sound_loop.pyx":95
 * 
 *     @property
 *     def type(self):             # <<<<<<<<<<<<<<
 *         return "sound_loop"
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_4type_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_4type_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_4type___get__(((struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_4type___get__(CYTHON_UNUSED struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "mpfmc/core/audio/track_sound_loop.pyx":96
 *     @property
 *     def type(self):
 *         return "sound_loop"             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_n_u_sound_loop);
  __pyx_r = __pyx_n_u_sound_loop;
  goto __pyx_L0;

  /* "mpfmc/core/audio/track_sound_loop.pyx":95
 * 
 *     @property
 *     def type(self):             # <<<<<<<<<<<<<<
 *         return "sound_loop"
 * 
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mpfmc/core/audio/track_sound_loop.pyx":99
 * 
 *     @property
 *     def supports_in_memory_sounds(self):             # <<<<<<<<<<<<<<
 *         """Return whether or not track accepts in-memory sounds"""
 *         return True
 */

/* Python wrapper */
static PyObject *__pyx_pw_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_25supports_in_memory_sounds_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_25supports_in_memory_sounds_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_25supports_in_memory_sounds___get__(((struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_25supports_in_memory_sounds___get__(CYTHON_UNUSED struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "mpfmc/core/audio/track_sound_loop.pyx":101
 *     def supports_in_memory_sounds(self):
 *         """Return whether or not track accepts in-memory sounds"""
 *         return True             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(Py_True);
  __pyx_r = Py_True;
  goto __pyx_L0;

  /* "mpfmc/core/audio/track_sound_loop.pyx":99
 * 
 *     @property
 *     def supports_in_memory_sounds(self):             # <<<<<<<<<<<<<<
 *         """Return whether or not track accepts in-memory sounds"""
 *         return True
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mpfmc/core/audio/track_sound_loop.pyx":104
 * 
 *     @property
 *     def supports_streaming_sounds(self):             # <<<<<<<<<<<<<<
 *         """Return whether or not track accepts streaming sounds"""
 *         return False
 */

/* Python wrapper */
static PyObject *__pyx_pw_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_25supports_streaming_sounds_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_25supports_streaming_sounds_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_25supports_streaming_sounds___get__(((struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_25supports_streaming_sounds___get__(CYTHON_UNUSED struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "mpfmc/core/audio/track_sound_loop.pyx":106
 *     def supports_streaming_sounds(self):
 *         """Return whether or not track accepts streaming sounds"""
 *         return False             # <<<<<<<<<<<<<<
 * 
 *     def stop_all_sounds(self, float fade_out_seconds = 0.0):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(Py_False);
  __pyx_r = Py_False;
  goto __pyx_L0;

  /* "mpfmc/core/audio/track_sound_loop.pyx":104
 * 
 *     @property
 *     def supports_streaming_sounds(self):             # <<<<<<<<<<<<<<
 *         """Return whether or not track accepts streaming sounds"""
 *         return False
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mpfmc/core/audio/track_sound_loop.pyx":108
 *         return False
 * 
 *     def stop_all_sounds(self, float fade_out_seconds = 0.0):             # <<<<<<<<<<<<<<
 *         """
 *         Stops all playing sounds immediately on the track.
 */

/* Python wrapper */
static PyObject *__pyx_pw_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_7stop_all_sounds(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_6stop_all_sounds[] = "TrackSoundLoop.stop_all_sounds(self, float fade_out_seconds=0.0)\n\n        Stops all playing sounds immediately on the track.\n        Args:\n            fade_out_seconds: The number of seconds to fade out the sounds before stopping\n        ";
static PyObject *__pyx_pw_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_7stop_all_sounds(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  CYTHON_UNUSED float __pyx_v_fade_out_seconds;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("stop_all_sounds (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_fade_out_seconds,0};
    PyObject* values[1] = {0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_fade_out_seconds);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "stop_all_sounds") < 0)) __PYX_ERR(0, 108, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    if (values[0]) {
      __pyx_v_fade_out_seconds = __pyx_PyFloat_AsFloat(values[0]); if (unlikely((__pyx_v_fade_out_seconds == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 108, __pyx_L3_error)
    } else {
      __pyx_v_fade_out_seconds = ((float)0.0);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("stop_all_sounds", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 108, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mpfmc.core.audio.track_sound_loop.TrackSoundLoop.stop_all_sounds", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_6stop_all_sounds(((struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *)__pyx_v_self), __pyx_v_fade_out_seconds);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_6stop_all_sounds(struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *__pyx_v_self, CYTHON_UNUSED float __pyx_v_fade_out_seconds) {
  GSList *__pyx_v_iterator;
  CYTHON_UNUSED __pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopSetPlayer *__pyx_v_player;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  GSList *__pyx_t_1;
  int __pyx_t_2;
  __Pyx_RefNannySetupContext("stop_all_sounds", 0);

  /* "mpfmc/core/audio/track_sound_loop.pyx":117
 *         cdef SoundLoopSetPlayer *player
 * 
 *         iterator = self.type_state.players             # <<<<<<<<<<<<<<
 *         while iterator != NULL:
 *             player = <SoundLoopSetPlayer*>iterator.data
 */
  __pyx_t_1 = __pyx_v_self->type_state->players;
  __pyx_v_iterator = __pyx_t_1;

  /* "mpfmc/core/audio/track_sound_loop.pyx":118
 * 
 *         iterator = self.type_state.players
 *         while iterator != NULL:             # <<<<<<<<<<<<<<
 *             player = <SoundLoopSetPlayer*>iterator.data
 *             # TODO: Stop player (calculate fade out if necessary)
 */
  while (1) {
    __pyx_t_2 = ((__pyx_v_iterator != NULL) != 0);
    if (!__pyx_t_2) break;

    /* "mpfmc/core/audio/track_sound_loop.pyx":119
 *         iterator = self.type_state.players
 *         while iterator != NULL:
 *             player = <SoundLoopSetPlayer*>iterator.data             # <<<<<<<<<<<<<<
 *             # TODO: Stop player (calculate fade out if necessary)
 * 
 */
    __pyx_v_player = ((__pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopSetPlayer *)__pyx_v_iterator->data);

    /* "mpfmc/core/audio/track_sound_loop.pyx":122
 *             # TODO: Stop player (calculate fade out if necessary)
 * 
 *             iterator = iterator.next             # <<<<<<<<<<<<<<
 * 
 *     def stop_sound(self, sound not None, fade_out=None):
 */
    __pyx_t_1 = __pyx_v_iterator->next;
    __pyx_v_iterator = __pyx_t_1;
  }

  /* "mpfmc/core/audio/track_sound_loop.pyx":108
 *         return False
 * 
 *     def stop_all_sounds(self, float fade_out_seconds = 0.0):             # <<<<<<<<<<<<<<
 *         """
 *         Stops all playing sounds immediately on the track.
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mpfmc/core/audio/track_sound_loop.pyx":124
 *             iterator = iterator.next
 * 
 *     def stop_sound(self, sound not None, fade_out=None):             # <<<<<<<<<<<<<<
 *         """
 *         Stops all instances of the specified sound immediately on the track. This function is not used
 */

/* Python wrapper */
static PyObject *__pyx_pw_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_9stop_sound(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_8stop_sound[] = "TrackSoundLoop.stop_sound(self, sound, fade_out=None)\n\n        Stops all instances of the specified sound immediately on the track. This function is not used\n        in the sound loop track, but is provided for compatibility in case the sound player is\n        mistakenly used against this track.\n        Args:\n            sound: The Sound to stop\n            fade_out: Optional amount of time (seconds) to fade out before stopping\n        ";
static PyObject *__pyx_pw_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_9stop_sound(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  CYTHON_UNUSED PyObject *__pyx_v_sound = 0;
  CYTHON_UNUSED PyObject *__pyx_v_fade_out = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("stop_sound (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_sound,&__pyx_n_s_fade_out,0};
    PyObject* values[2] = {0,0};
    values[1] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sound)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_fade_out);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "stop_sound") < 0)) __PYX_ERR(0, 124, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_sound = values[0];
    __pyx_v_fade_out = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("stop_sound", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 124, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mpfmc.core.audio.track_sound_loop.TrackSoundLoop.stop_sound", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(((PyObject *)__pyx_v_sound) == Py_None)) {
    PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "sound"); __PYX_ERR(0, 124, __pyx_L1_error)
  }
  __pyx_r = __pyx_pf_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_8stop_sound(((struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *)__pyx_v_self), __pyx_v_sound, __pyx_v_fade_out);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_8stop_sound(CYTHON_UNUSED struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_sound, CYTHON_UNUSED PyObject *__pyx_v_fade_out) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("stop_sound", 0);

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mpfmc/core/audio/track_sound_loop.pyx":135
 *         pass
 * 
 *     def stop_sound_instance(self, sound_instance not None, fade_out=None):             # <<<<<<<<<<<<<<
 *         """
 *         Stops the specified sound instance immediately on the track. This function is not used
 */

/* Python wrapper */
static PyObject *__pyx_pw_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_11stop_sound_instance(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_10stop_sound_instance[] = "TrackSoundLoop.stop_sound_instance(self, sound_instance, fade_out=None)\n\n        Stops the specified sound instance immediately on the track. This function is not used\n        in the sound loop track, but is provided for compatibility in case the sound player is\n        mistakenly used against this track.\n        Args:\n            sound_instance: The SoundInstance to stop\n            fade_out: Optional amount of time (seconds) to fade out before stopping\n        ";
static PyObject *__pyx_pw_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_11stop_sound_instance(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  CYTHON_UNUSED PyObject *__pyx_v_sound_instance = 0;
  CYTHON_UNUSED PyObject *__pyx_v_fade_out = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("stop_sound_instance (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_sound_instance,&__pyx_n_s_fade_out,0};
    PyObject* values[2] = {0,0};
    values[1] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sound_instance)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_fade_out);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "stop_sound_instance") < 0)) __PYX_ERR(0, 135, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_sound_instance = values[0];
    __pyx_v_fade_out = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("stop_sound_instance", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 135, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mpfmc.core.audio.track_sound_loop.TrackSoundLoop.stop_sound_instance", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(((PyObject *)__pyx_v_sound_instance) == Py_None)) {
    PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "sound_instance"); __PYX_ERR(0, 135, __pyx_L1_error)
  }
  __pyx_r = __pyx_pf_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_10stop_sound_instance(((struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *)__pyx_v_self), __pyx_v_sound_instance, __pyx_v_fade_out);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_10stop_sound_instance(CYTHON_UNUSED struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_sound_instance, CYTHON_UNUSED PyObject *__pyx_v_fade_out) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("stop_sound_instance", 0);

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mpfmc/core/audio/track_sound_loop.pyx":146
 *         pass
 * 
 *     def stop_sound_looping(self, sound not None):             # <<<<<<<<<<<<<<
 *         """
 *         Cancels looping for all instances of the specified sound on the track. This function is not used
 */

/* Python wrapper */
static PyObject *__pyx_pw_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_13stop_sound_looping(PyObject *__pyx_v_self, PyObject *__pyx_v_sound); /*proto*/
static char __pyx_doc_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_12stop_sound_looping[] = "TrackSoundLoop.stop_sound_looping(self, sound)\n\n        Cancels looping for all instances of the specified sound on the track. This function is not used\n        in the sound loop track, but is provided for compatibility in case the sound player is\n        mistakenly used against this track.\n        Args:\n            sound: The Sound to stop looping\n        ";
static PyObject *__pyx_pw_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_13stop_sound_looping(PyObject *__pyx_v_self, PyObject *__pyx_v_sound) {
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("stop_sound_looping (wrapper)", 0);
  if (unlikely(((PyObject *)__pyx_v_sound) == Py_None)) {
    PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "sound"); __PYX_ERR(0, 146, __pyx_L1_error)
  }
  __pyx_r = __pyx_pf_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_12stop_sound_looping(((struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *)__pyx_v_self), ((PyObject *)__pyx_v_sound));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_12stop_sound_looping(CYTHON_UNUSED struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_sound) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("stop_sound_looping", 0);

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mpfmc/core/audio/track_sound_loop.pyx":156
 *         pass
 * 
 *     def stop_sound_instance_looping(self, sound_instance not None):             # <<<<<<<<<<<<<<
 *         """
 *         Stops the specified sound instance on the track after the current loop iteration
 */

/* Python wrapper */
static PyObject *__pyx_pw_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_15stop_sound_instance_looping(PyObject *__pyx_v_self, PyObject *__pyx_v_sound_instance); /*proto*/
static char __pyx_doc_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_14stop_sound_instance_looping[] = "TrackSoundLoop.stop_sound_instance_looping(self, sound_instance)\n\n        Stops the specified sound instance on the track after the current loop iteration\n        has finished. This function is not used in the sound loop track, but is provided for compatibility\n        in case the sound player is mistakenly used against this track.\n        Args:\n            sound_instance: The Sound to stop\n        ";
static PyObject *__pyx_pw_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_15stop_sound_instance_looping(PyObject *__pyx_v_self, PyObject *__pyx_v_sound_instance) {
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("stop_sound_instance_looping (wrapper)", 0);
  if (unlikely(((PyObject *)__pyx_v_sound_instance) == Py_None)) {
    PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "sound_instance"); __PYX_ERR(0, 156, __pyx_L1_error)
  }
  __pyx_r = __pyx_pf_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_14stop_sound_instance_looping(((struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *)__pyx_v_self), ((PyObject *)__pyx_v_sound_instance));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_14stop_sound_instance_looping(CYTHON_UNUSED struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_sound_instance) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("stop_sound_instance_looping", 0);

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mpfmc/core/audio/track_sound_loop.pyx":166
 *         pass
 * 
 *     def process(self):             # <<<<<<<<<<<<<<
 *         """Processes track messages each tick."""
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_17process(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_16process[] = "TrackSoundLoop.process(self)\nProcesses track messages each tick.";
static PyObject *__pyx_pw_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_17process(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("process (wrapper)", 0);
  __pyx_r = __pyx_pf_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_16process(((struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_16process(struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *__pyx_v_self) {
  GSList *__pyx_v_iterator;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  GSList *__pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("process", 0);

  /* "mpfmc/core/audio/track_sound_loop.pyx":171
 *         # Lock the mutex to ensure no audio data is changed during the playback processing
 *         # (multi-threaded protection)
 *         SDL_LockAudio()             # <<<<<<<<<<<<<<
 * 
 *         # Process track notification messages
 */
  SDL_LockAudio();

  /* "mpfmc/core/audio/track_sound_loop.pyx":174
 * 
 *         # Process track notification messages
 *         if self.state.notification_messages != NULL:             # <<<<<<<<<<<<<<
 *             self.state.notification_messages = g_slist_reverse(self.state.notification_messages)
 *             iterator = self.state.notification_messages
 */
  __pyx_t_1 = ((__pyx_v_self->__pyx_base.state->notification_messages != NULL) != 0);
  if (__pyx_t_1) {

    /* "mpfmc/core/audio/track_sound_loop.pyx":175
 *         # Process track notification messages
 *         if self.state.notification_messages != NULL:
 *             self.state.notification_messages = g_slist_reverse(self.state.notification_messages)             # <<<<<<<<<<<<<<
 *             iterator = self.state.notification_messages
 *             while iterator != NULL:
 */
    __pyx_v_self->__pyx_base.state->notification_messages = g_slist_reverse(__pyx_v_self->__pyx_base.state->notification_messages);

    /* "mpfmc/core/audio/track_sound_loop.pyx":176
 *         if self.state.notification_messages != NULL:
 *             self.state.notification_messages = g_slist_reverse(self.state.notification_messages)
 *             iterator = self.state.notification_messages             # <<<<<<<<<<<<<<
 *             while iterator != NULL:
 *                 self.process_notification_message(<NotificationMessageContainer*>iterator.data)
 */
    __pyx_t_2 = __pyx_v_self->__pyx_base.state->notification_messages;
    __pyx_v_iterator = __pyx_t_2;

    /* "mpfmc/core/audio/track_sound_loop.pyx":177
 *             self.state.notification_messages = g_slist_reverse(self.state.notification_messages)
 *             iterator = self.state.notification_messages
 *             while iterator != NULL:             # <<<<<<<<<<<<<<
 *                 self.process_notification_message(<NotificationMessageContainer*>iterator.data)
 *                 g_slice_free1(sizeof(NotificationMessageContainer), iterator.data)
 */
    while (1) {
      __pyx_t_1 = ((__pyx_v_iterator != NULL) != 0);
      if (!__pyx_t_1) break;

      /* "mpfmc/core/audio/track_sound_loop.pyx":178
 *             iterator = self.state.notification_messages
 *             while iterator != NULL:
 *                 self.process_notification_message(<NotificationMessageContainer*>iterator.data)             # <<<<<<<<<<<<<<
 *                 g_slice_free1(sizeof(NotificationMessageContainer), iterator.data)
 *                 iterator = iterator.next
 */
      __pyx_t_3 = ((struct __pyx_vtabstruct_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *)__pyx_v_self->__pyx_base.__pyx_vtab)->process_notification_message(__pyx_v_self, ((__pyx_t_5mpfmc_4core_5audio_20notification_message_NotificationMessageContainer *)__pyx_v_iterator->data)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 178, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "mpfmc/core/audio/track_sound_loop.pyx":179
 *             while iterator != NULL:
 *                 self.process_notification_message(<NotificationMessageContainer*>iterator.data)
 *                 g_slice_free1(sizeof(NotificationMessageContainer), iterator.data)             # <<<<<<<<<<<<<<
 *                 iterator = iterator.next
 * 
 */
      g_slice_free1((sizeof(__pyx_t_5mpfmc_4core_5audio_20notification_message_NotificationMessageContainer)), __pyx_v_iterator->data);

      /* "mpfmc/core/audio/track_sound_loop.pyx":180
 *                 self.process_notification_message(<NotificationMessageContainer*>iterator.data)
 *                 g_slice_free1(sizeof(NotificationMessageContainer), iterator.data)
 *                 iterator = iterator.next             # <<<<<<<<<<<<<<
 * 
 *             g_slist_free(self.state.notification_messages)
 */
      __pyx_t_2 = __pyx_v_iterator->next;
      __pyx_v_iterator = __pyx_t_2;
    }

    /* "mpfmc/core/audio/track_sound_loop.pyx":182
 *                 iterator = iterator.next
 * 
 *             g_slist_free(self.state.notification_messages)             # <<<<<<<<<<<<<<
 *             self.state.notification_messages = NULL
 * 
 */
    g_slist_free(__pyx_v_self->__pyx_base.state->notification_messages);

    /* "mpfmc/core/audio/track_sound_loop.pyx":183
 * 
 *             g_slist_free(self.state.notification_messages)
 *             self.state.notification_messages = NULL             # <<<<<<<<<<<<<<
 * 
 *         # Unlock the mutex since we are done accessing the audio data
 */
    __pyx_v_self->__pyx_base.state->notification_messages = NULL;

    /* "mpfmc/core/audio/track_sound_loop.pyx":174
 * 
 *         # Process track notification messages
 *         if self.state.notification_messages != NULL:             # <<<<<<<<<<<<<<
 *             self.state.notification_messages = g_slist_reverse(self.state.notification_messages)
 *             iterator = self.state.notification_messages
 */
  }

  /* "mpfmc/core/audio/track_sound_loop.pyx":186
 * 
 *         # Unlock the mutex since we are done accessing the audio data
 *         SDL_UnlockAudio()             # <<<<<<<<<<<<<<
 * 
 *     cdef process_notification_message(self, NotificationMessageContainer *notification_message):
 */
  SDL_UnlockAudio();

  /* "mpfmc/core/audio/track_sound_loop.pyx":166
 *         pass
 * 
 *     def process(self):             # <<<<<<<<<<<<<<
 *         """Processes track messages each tick."""
 * 
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("mpfmc.core.audio.track_sound_loop.TrackSoundLoop.process", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mpfmc/core/audio/track_sound_loop.pyx":188
 *         SDL_UnlockAudio()
 * 
 *     cdef process_notification_message(self, NotificationMessageContainer *notification_message):             # <<<<<<<<<<<<<<
 *         """Process a notification message to this track"""
 * 
 */

static PyObject *__pyx_f_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_process_notification_message(struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *__pyx_v_self, __pyx_t_5mpfmc_4core_5audio_20notification_message_NotificationMessageContainer *__pyx_v_notification_message) {
  PyObject *__pyx_v_event = NULL;
  PyObject *__pyx_v_sound_loop_set_settings = NULL;
  __pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopSetPlayer *__pyx_v_player;
  PyObject *__pyx_v_sound = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  PyObject *(*__pyx_t_11)(PyObject *);
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("process_notification_message", 0);

  /* "mpfmc/core/audio/track_sound_loop.pyx":191
 *         """Process a notification message to this track"""
 * 
 *         if notification_message == NULL:             # <<<<<<<<<<<<<<
 *             return
 * 
 */
  __pyx_t_1 = ((__pyx_v_notification_message == NULL) != 0);
  if (__pyx_t_1) {

    /* "mpfmc/core/audio/track_sound_loop.pyx":192
 * 
 *         if notification_message == NULL:
 *             return             # <<<<<<<<<<<<<<
 * 
 *         SDL_LockAudio()
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "mpfmc/core/audio/track_sound_loop.pyx":191
 *         """Process a notification message to this track"""
 * 
 *         if notification_message == NULL:             # <<<<<<<<<<<<<<
 *             return
 * 
 */
  }

  /* "mpfmc/core/audio/track_sound_loop.pyx":194
 *             return
 * 
 *         SDL_LockAudio()             # <<<<<<<<<<<<<<
 * 
 *         # Check for track notification messages first (they do not need sound instance information)
 */
  SDL_LockAudio();

  /* "mpfmc/core/audio/track_sound_loop.pyx":197
 * 
 *         # Check for track notification messages first (they do not need sound instance information)
 *         if notification_message.message in (notification_track_stopped, notification_track_paused):             # <<<<<<<<<<<<<<
 *             if notification_message.message == notification_track_stopped:
 *                 # Trigger any events
 */
  switch (__pyx_v_notification_message->message) {
    case __pyx_e_5mpfmc_4core_5audio_20notification_message_notification_track_stopped:
    case __pyx_e_5mpfmc_4core_5audio_20notification_message_notification_track_paused:

    /* "mpfmc/core/audio/track_sound_loop.pyx":198
 *         # Check for track notification messages first (they do not need sound instance information)
 *         if notification_message.message in (notification_track_stopped, notification_track_paused):
 *             if notification_message.message == notification_track_stopped:             # <<<<<<<<<<<<<<
 *                 # Trigger any events
 *                 if self._events_when_stopped is not None:
 */
    switch (__pyx_v_notification_message->message) {
      case __pyx_e_5mpfmc_4core_5audio_20notification_message_notification_track_stopped:

      /* "mpfmc/core/audio/track_sound_loop.pyx":200
 *             if notification_message.message == notification_track_stopped:
 *                 # Trigger any events
 *                 if self._events_when_stopped is not None:             # <<<<<<<<<<<<<<
 *                     for event in self._events_when_stopped:
 *                         self.mc.post_mc_native_event(event, track=self._name)
 */
      __pyx_t_1 = (__pyx_v_self->__pyx_base._events_when_stopped != ((PyObject*)Py_None));
      __pyx_t_2 = (__pyx_t_1 != 0);
      if (__pyx_t_2) {

        /* "mpfmc/core/audio/track_sound_loop.pyx":201
 *                 # Trigger any events
 *                 if self._events_when_stopped is not None:
 *                     for event in self._events_when_stopped:             # <<<<<<<<<<<<<<
 *                         self.mc.post_mc_native_event(event, track=self._name)
 * 
 */
        if (unlikely(__pyx_v_self->__pyx_base._events_when_stopped == Py_None)) {
          PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
          __PYX_ERR(0, 201, __pyx_L1_error)
        }
        __pyx_t_3 = __pyx_v_self->__pyx_base._events_when_stopped; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0;
        for (;;) {
          if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_3)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_5 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_5); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 201, __pyx_L1_error)
          #else
          __pyx_t_5 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 201, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          #endif
          __Pyx_XDECREF_SET(__pyx_v_event, __pyx_t_5);
          __pyx_t_5 = 0;

          /* "mpfmc/core/audio/track_sound_loop.pyx":202
 *                 if self._events_when_stopped is not None:
 *                     for event in self._events_when_stopped:
 *                         self.mc.post_mc_native_event(event, track=self._name)             # <<<<<<<<<<<<<<
 * 
 *             elif notification_message.message == notification_track_paused:
 */
          __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->__pyx_base.mc, __pyx_n_s_post_mc_native_event); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 202, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 202, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_INCREF(__pyx_v_event);
          __Pyx_GIVEREF(__pyx_v_event);
          PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_event);
          __pyx_t_7 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 202, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_track, __pyx_v_self->__pyx_base._name) < 0) __PYX_ERR(0, 202, __pyx_L1_error)
          __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 202, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_8);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

          /* "mpfmc/core/audio/track_sound_loop.pyx":201
 *                 # Trigger any events
 *                 if self._events_when_stopped is not None:
 *                     for event in self._events_when_stopped:             # <<<<<<<<<<<<<<
 *                         self.mc.post_mc_native_event(event, track=self._name)
 * 
 */
        }
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

        /* "mpfmc/core/audio/track_sound_loop.pyx":200
 *             if notification_message.message == notification_track_stopped:
 *                 # Trigger any events
 *                 if self._events_when_stopped is not None:             # <<<<<<<<<<<<<<
 *                     for event in self._events_when_stopped:
 *                         self.mc.post_mc_native_event(event, track=self._name)
 */
      }

      /* "mpfmc/core/audio/track_sound_loop.pyx":198
 *         # Check for track notification messages first (they do not need sound instance information)
 *         if notification_message.message in (notification_track_stopped, notification_track_paused):
 *             if notification_message.message == notification_track_stopped:             # <<<<<<<<<<<<<<
 *                 # Trigger any events
 *                 if self._events_when_stopped is not None:
 */
      break;
      case __pyx_e_5mpfmc_4core_5audio_20notification_message_notification_track_paused:

      /* "mpfmc/core/audio/track_sound_loop.pyx":206
 *             elif notification_message.message == notification_track_paused:
 *                 # Trigger any events
 *                 if self._events_when_paused is not None:             # <<<<<<<<<<<<<<
 *                     for event in self._events_when_paused:
 *                         self.mc.post_mc_native_event(event, track=self._name)
 */
      __pyx_t_2 = (__pyx_v_self->__pyx_base._events_when_paused != ((PyObject*)Py_None));
      __pyx_t_1 = (__pyx_t_2 != 0);
      if (__pyx_t_1) {

        /* "mpfmc/core/audio/track_sound_loop.pyx":207
 *                 # Trigger any events
 *                 if self._events_when_paused is not None:
 *                     for event in self._events_when_paused:             # <<<<<<<<<<<<<<
 *                         self.mc.post_mc_native_event(event, track=self._name)
 *                 pass
 */
        if (unlikely(__pyx_v_self->__pyx_base._events_when_paused == Py_None)) {
          PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
          __PYX_ERR(0, 207, __pyx_L1_error)
        }
        __pyx_t_3 = __pyx_v_self->__pyx_base._events_when_paused; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0;
        for (;;) {
          if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_3)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_8 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_8); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 207, __pyx_L1_error)
          #else
          __pyx_t_8 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 207, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_8);
          #endif
          __Pyx_XDECREF_SET(__pyx_v_event, __pyx_t_8);
          __pyx_t_8 = 0;

          /* "mpfmc/core/audio/track_sound_loop.pyx":208
 *                 if self._events_when_paused is not None:
 *                     for event in self._events_when_paused:
 *                         self.mc.post_mc_native_event(event, track=self._name)             # <<<<<<<<<<<<<<
 *                 pass
 * 
 */
          __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->__pyx_base.mc, __pyx_n_s_post_mc_native_event); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 208, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_8);
          __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 208, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          __Pyx_INCREF(__pyx_v_event);
          __Pyx_GIVEREF(__pyx_v_event);
          PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_event);
          __pyx_t_6 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 208, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_track, __pyx_v_self->__pyx_base._name) < 0) __PYX_ERR(0, 208, __pyx_L1_error)
          __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_7, __pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 208, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

          /* "mpfmc/core/audio/track_sound_loop.pyx":207
 *                 # Trigger any events
 *                 if self._events_when_paused is not None:
 *                     for event in self._events_when_paused:             # <<<<<<<<<<<<<<
 *                         self.mc.post_mc_native_event(event, track=self._name)
 *                 pass
 */
        }
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

        /* "mpfmc/core/audio/track_sound_loop.pyx":206
 *             elif notification_message.message == notification_track_paused:
 *                 # Trigger any events
 *                 if self._events_when_paused is not None:             # <<<<<<<<<<<<<<
 *                     for event in self._events_when_paused:
 *                         self.mc.post_mc_native_event(event, track=self._name)
 */
      }

      /* "mpfmc/core/audio/track_sound_loop.pyx":204
 *                         self.mc.post_mc_native_event(event, track=self._name)
 * 
 *             elif notification_message.message == notification_track_paused:             # <<<<<<<<<<<<<<
 *                 # Trigger any events
 *                 if self._events_when_paused is not None:
 */
      break;
      default: break;
    }

    /* "mpfmc/core/audio/track_sound_loop.pyx":211
 *                 pass
 * 
 *             SDL_UnlockAudio()             # <<<<<<<<<<<<<<
 *             return
 * 
 */
    SDL_UnlockAudio();

    /* "mpfmc/core/audio/track_sound_loop.pyx":212
 * 
 *             SDL_UnlockAudio()
 *             return             # <<<<<<<<<<<<<<
 * 
 *         self.log.debug("Processing notification message %d for sound instance (id: %d)",
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "mpfmc/core/audio/track_sound_loop.pyx":197
 * 
 *         # Check for track notification messages first (they do not need sound instance information)
 *         if notification_message.message in (notification_track_stopped, notification_track_paused):             # <<<<<<<<<<<<<<
 *             if notification_message.message == notification_track_stopped:
 *                 # Trigger any events
 */
    break;
    default: break;
  }

  /* "mpfmc/core/audio/track_sound_loop.pyx":214
 *             return
 * 
 *         self.log.debug("Processing notification message %d for sound instance (id: %d)",             # <<<<<<<<<<<<<<
 *                        notification_message.message, notification_message.sound_instance_id)
 * 
 */
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->__pyx_base.log, __pyx_n_s_debug); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 214, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);

  /* "mpfmc/core/audio/track_sound_loop.pyx":215
 * 
 *         self.log.debug("Processing notification message %d for sound instance (id: %d)",
 *                        notification_message.message, notification_message.sound_instance_id)             # <<<<<<<<<<<<<<
 * 
 *         if notification_message.message in (notification_sound_loop_set_started, notification_sound_loop_set_stopped,
 */
  __pyx_t_6 = __Pyx_PyInt_From_enum____pyx_t_5mpfmc_4core_5audio_20notification_message_NotificationMessage(__pyx_v_notification_message->message); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 215, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = __Pyx_PyInt_From_Uint64(__pyx_v_notification_message->sound_instance_id); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 215, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_8 = NULL;
  __pyx_t_9 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_8)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_8);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
      __pyx_t_9 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_5)) {
    PyObject *__pyx_temp[4] = {__pyx_t_8, __pyx_kp_u_Processing_notification_message, __pyx_t_6, __pyx_t_7};
    __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 214, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
    PyObject *__pyx_temp[4] = {__pyx_t_8, __pyx_kp_u_Processing_notification_message, __pyx_t_6, __pyx_t_7};
    __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 214, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  } else
  #endif
  {
    __pyx_t_10 = PyTuple_New(3+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 214, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    if (__pyx_t_8) {
      __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_8); __pyx_t_8 = NULL;
    }
    __Pyx_INCREF(__pyx_kp_u_Processing_notification_message);
    __Pyx_GIVEREF(__pyx_kp_u_Processing_notification_message);
    PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_9, __pyx_kp_u_Processing_notification_message);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_9, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_10, 2+__pyx_t_9, __pyx_t_7);
    __pyx_t_6 = 0;
    __pyx_t_7 = 0;
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_10, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 214, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "mpfmc/core/audio/track_sound_loop.pyx":217
 *                        notification_message.message, notification_message.sound_instance_id)
 * 
 *         if notification_message.message in (notification_sound_loop_set_started, notification_sound_loop_set_stopped,             # <<<<<<<<<<<<<<
 *                                             notification_sound_loop_set_looping):
 * 
 */
  switch (__pyx_v_notification_message->message) {
    case __pyx_e_5mpfmc_4core_5audio_20notification_message_notification_sound_loop_set_started:
    case __pyx_e_5mpfmc_4core_5audio_20notification_message_notification_sound_loop_set_stopped:
    case __pyx_e_5mpfmc_4core_5audio_20notification_message_notification_sound_loop_set_looping:

    /* "mpfmc/core/audio/track_sound_loop.pyx":220
 *                                             notification_sound_loop_set_looping):
 * 
 *             if notification_message.data.sound_loop_set.id not in self._active_sound_loop_sets.keys():             # <<<<<<<<<<<<<<
 *                 self.log.warning("Received a notification message for a sound loop set (id: %d) "
 *                                  "that is no longer active. Notification will be discarded.",
 */
    __pyx_t_3 = __Pyx_PyInt_From_long(__pyx_v_notification_message->data.sound_loop_set.id); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 220, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    if (unlikely(__pyx_v_self->_active_sound_loop_sets == Py_None)) {
      PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "keys");
      __PYX_ERR(0, 220, __pyx_L1_error)
    }
    __pyx_t_5 = __Pyx_PyDict_Keys(__pyx_v_self->_active_sound_loop_sets); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 220, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_1 = (__Pyx_PySequence_ContainsTF(__pyx_t_3, __pyx_t_5, Py_NE)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 220, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_2 = (__pyx_t_1 != 0);
    if (__pyx_t_2) {

      /* "mpfmc/core/audio/track_sound_loop.pyx":221
 * 
 *             if notification_message.data.sound_loop_set.id not in self._active_sound_loop_sets.keys():
 *                 self.log.warning("Received a notification message for a sound loop set (id: %d) "             # <<<<<<<<<<<<<<
 *                                  "that is no longer active. Notification will be discarded.",
 *                                  notification_message.data.sound_loop_set.id)
 */
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->__pyx_base.log, __pyx_n_s_warning); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 221, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);

      /* "mpfmc/core/audio/track_sound_loop.pyx":223
 *                 self.log.warning("Received a notification message for a sound loop set (id: %d) "
 *                                  "that is no longer active. Notification will be discarded.",
 *                                  notification_message.data.sound_loop_set.id)             # <<<<<<<<<<<<<<
 *                 SDL_UnlockAudio()
 *                 return
 */
      __pyx_t_10 = __Pyx_PyInt_From_long(__pyx_v_notification_message->data.sound_loop_set.id); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 223, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_7 = NULL;
      __pyx_t_9 = 0;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_7)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_7);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
          __pyx_t_9 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_kp_u_Received_a_notification_message, __pyx_t_10};
        __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 221, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_kp_u_Received_a_notification_message, __pyx_t_10};
        __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 221, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      } else
      #endif
      {
        __pyx_t_6 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 221, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        if (__pyx_t_7) {
          __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_7); __pyx_t_7 = NULL;
        }
        __Pyx_INCREF(__pyx_kp_u_Received_a_notification_message);
        __Pyx_GIVEREF(__pyx_kp_u_Received_a_notification_message);
        PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_9, __pyx_kp_u_Received_a_notification_message);
        __Pyx_GIVEREF(__pyx_t_10);
        PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_9, __pyx_t_10);
        __pyx_t_10 = 0;
        __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 221, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

      /* "mpfmc/core/audio/track_sound_loop.pyx":224
 *                                  "that is no longer active. Notification will be discarded.",
 *                                  notification_message.data.sound_loop_set.id)
 *                 SDL_UnlockAudio()             # <<<<<<<<<<<<<<
 *                 return
 * 
 */
      SDL_UnlockAudio();

      /* "mpfmc/core/audio/track_sound_loop.pyx":225
 *                                  notification_message.data.sound_loop_set.id)
 *                 SDL_UnlockAudio()
 *                 return             # <<<<<<<<<<<<<<
 * 
 *             sound_loop_set_settings = self._active_sound_loop_sets[notification_message.data.sound_loop_set.id]
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_r = Py_None; __Pyx_INCREF(Py_None);
      goto __pyx_L0;

      /* "mpfmc/core/audio/track_sound_loop.pyx":220
 *                                             notification_sound_loop_set_looping):
 * 
 *             if notification_message.data.sound_loop_set.id not in self._active_sound_loop_sets.keys():             # <<<<<<<<<<<<<<
 *                 self.log.warning("Received a notification message for a sound loop set (id: %d) "
 *                                  "that is no longer active. Notification will be discarded.",
 */
    }

    /* "mpfmc/core/audio/track_sound_loop.pyx":227
 *                 return
 * 
 *             sound_loop_set_settings = self._active_sound_loop_sets[notification_message.data.sound_loop_set.id]             # <<<<<<<<<<<<<<
 *             if not sound_loop_set_settings:
 *                 self.log.warning("Could not retrieve settings for a sound loop set (id: %d) "
 */
    if (unlikely(__pyx_v_self->_active_sound_loop_sets == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(0, 227, __pyx_L1_error)
    }
    __pyx_t_5 = __Pyx_PyInt_From_long(__pyx_v_notification_message->data.sound_loop_set.id); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 227, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_3 = __Pyx_PyDict_GetItem(__pyx_v_self->_active_sound_loop_sets, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 227, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_v_sound_loop_set_settings = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "mpfmc/core/audio/track_sound_loop.pyx":228
 * 
 *             sound_loop_set_settings = self._active_sound_loop_sets[notification_message.data.sound_loop_set.id]
 *             if not sound_loop_set_settings:             # <<<<<<<<<<<<<<
 *                 self.log.warning("Could not retrieve settings for a sound loop set (id: %d) "
 *                                  "Notification will be discarded.",
 */
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_sound_loop_set_settings); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 228, __pyx_L1_error)
    __pyx_t_1 = ((!__pyx_t_2) != 0);
    if (__pyx_t_1) {

      /* "mpfmc/core/audio/track_sound_loop.pyx":229
 *             sound_loop_set_settings = self._active_sound_loop_sets[notification_message.data.sound_loop_set.id]
 *             if not sound_loop_set_settings:
 *                 self.log.warning("Could not retrieve settings for a sound loop set (id: %d) "             # <<<<<<<<<<<<<<
 *                                  "Notification will be discarded.",
 *                                  notification_message.data.sound_loop_set.id)
 */
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->__pyx_base.log, __pyx_n_s_warning); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 229, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);

      /* "mpfmc/core/audio/track_sound_loop.pyx":231
 *                 self.log.warning("Could not retrieve settings for a sound loop set (id: %d) "
 *                                  "Notification will be discarded.",
 *                                  notification_message.data.sound_loop_set.id)             # <<<<<<<<<<<<<<
 *                 SDL_UnlockAudio()
 *                 return
 */
      __pyx_t_6 = __Pyx_PyInt_From_long(__pyx_v_notification_message->data.sound_loop_set.id); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 231, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_10 = NULL;
      __pyx_t_9 = 0;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
        __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_5);
        if (likely(__pyx_t_10)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
          __Pyx_INCREF(__pyx_t_10);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_5, function);
          __pyx_t_9 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_5)) {
        PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_kp_u_Could_not_retrieve_settings_for, __pyx_t_6};
        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 229, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
        PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_kp_u_Could_not_retrieve_settings_for, __pyx_t_6};
        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 229, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      } else
      #endif
      {
        __pyx_t_7 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 229, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        if (__pyx_t_10) {
          __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_10); __pyx_t_10 = NULL;
        }
        __Pyx_INCREF(__pyx_kp_u_Could_not_retrieve_settings_for);
        __Pyx_GIVEREF(__pyx_kp_u_Could_not_retrieve_settings_for);
        PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_9, __pyx_kp_u_Could_not_retrieve_settings_for);
        __Pyx_GIVEREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_9, __pyx_t_6);
        __pyx_t_6 = 0;
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 229, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      }
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "mpfmc/core/audio/track_sound_loop.pyx":232
 *                                  "Notification will be discarded.",
 *                                  notification_message.data.sound_loop_set.id)
 *                 SDL_UnlockAudio()             # <<<<<<<<<<<<<<
 *                 return
 * 
 */
      SDL_UnlockAudio();

      /* "mpfmc/core/audio/track_sound_loop.pyx":233
 *                                  notification_message.data.sound_loop_set.id)
 *                 SDL_UnlockAudio()
 *                 return             # <<<<<<<<<<<<<<
 * 
 *             if notification_message.message == notification_sound_loop_set_started:
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_r = Py_None; __Pyx_INCREF(Py_None);
      goto __pyx_L0;

      /* "mpfmc/core/audio/track_sound_loop.pyx":228
 * 
 *             sound_loop_set_settings = self._active_sound_loop_sets[notification_message.data.sound_loop_set.id]
 *             if not sound_loop_set_settings:             # <<<<<<<<<<<<<<
 *                 self.log.warning("Could not retrieve settings for a sound loop set (id: %d) "
 *                                  "Notification will be discarded.",
 */
    }

    /* "mpfmc/core/audio/track_sound_loop.pyx":235
 *                 return
 * 
 *             if notification_message.message == notification_sound_loop_set_started:             # <<<<<<<<<<<<<<
 *                 if sound_loop_set_settings['events_when_played'] is not None:
 *                     for event in sound_loop_set_settings['events_when_played']:
 */
    switch (__pyx_v_notification_message->message) {
      case __pyx_e_5mpfmc_4core_5audio_20notification_message_notification_sound_loop_set_started:

      /* "mpfmc/core/audio/track_sound_loop.pyx":236
 * 
 *             if notification_message.message == notification_sound_loop_set_started:
 *                 if sound_loop_set_settings['events_when_played'] is not None:             # <<<<<<<<<<<<<<
 *                     for event in sound_loop_set_settings['events_when_played']:
 *                         self.mc.post_mc_native_event(event)
 */
      __pyx_t_3 = __Pyx_PyObject_Dict_GetItem(__pyx_v_sound_loop_set_settings, __pyx_n_u_events_when_played); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 236, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_1 = (__pyx_t_3 != Py_None);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_2 = (__pyx_t_1 != 0);
      if (__pyx_t_2) {

        /* "mpfmc/core/audio/track_sound_loop.pyx":237
 *             if notification_message.message == notification_sound_loop_set_started:
 *                 if sound_loop_set_settings['events_when_played'] is not None:
 *                     for event in sound_loop_set_settings['events_when_played']:             # <<<<<<<<<<<<<<
 *                         self.mc.post_mc_native_event(event)
 * 
 */
        __pyx_t_3 = __Pyx_PyObject_Dict_GetItem(__pyx_v_sound_loop_set_settings, __pyx_n_u_events_when_played); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 237, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        if (likely(PyList_CheckExact(__pyx_t_3)) || PyTuple_CheckExact(__pyx_t_3)) {
          __pyx_t_5 = __pyx_t_3; __Pyx_INCREF(__pyx_t_5); __pyx_t_4 = 0;
          __pyx_t_11 = NULL;
        } else {
          __pyx_t_4 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 237, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_11 = Py_TYPE(__pyx_t_5)->tp_iternext; if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 237, __pyx_L1_error)
        }
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        for (;;) {
          if (likely(!__pyx_t_11)) {
            if (likely(PyList_CheckExact(__pyx_t_5))) {
              if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_5)) break;
              #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
              __pyx_t_3 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 237, __pyx_L1_error)
              #else
              __pyx_t_3 = PySequence_ITEM(__pyx_t_5, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 237, __pyx_L1_error)
              __Pyx_GOTREF(__pyx_t_3);
              #endif
            } else {
              if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_5)) break;
              #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
              __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 237, __pyx_L1_error)
              #else
              __pyx_t_3 = PySequence_ITEM(__pyx_t_5, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 237, __pyx_L1_error)
              __Pyx_GOTREF(__pyx_t_3);
              #endif
            }
          } else {
            __pyx_t_3 = __pyx_t_11(__pyx_t_5);
            if (unlikely(!__pyx_t_3)) {
              PyObject* exc_type = PyErr_Occurred();
              if (exc_type) {
                if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
                else __PYX_ERR(0, 237, __pyx_L1_error)
              }
              break;
            }
            __Pyx_GOTREF(__pyx_t_3);
          }
          __Pyx_XDECREF_SET(__pyx_v_event, __pyx_t_3);
          __pyx_t_3 = 0;

          /* "mpfmc/core/audio/track_sound_loop.pyx":238
 *                 if sound_loop_set_settings['events_when_played'] is not None:
 *                     for event in sound_loop_set_settings['events_when_played']:
 *                         self.mc.post_mc_native_event(event)             # <<<<<<<<<<<<<<
 * 
 *             elif notification_message.message == notification_sound_loop_set_stopped:
 */
          __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->__pyx_base.mc, __pyx_n_s_post_mc_native_event); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 238, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          __pyx_t_6 = NULL;
          if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
            __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_7);
            if (likely(__pyx_t_6)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
              __Pyx_INCREF(__pyx_t_6);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_7, function);
            }
          }
          __pyx_t_3 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_6, __pyx_v_event) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_v_event);
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 238, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

          /* "mpfmc/core/audio/track_sound_loop.pyx":237
 *             if notification_message.message == notification_sound_loop_set_started:
 *                 if sound_loop_set_settings['events_when_played'] is not None:
 *                     for event in sound_loop_set_settings['events_when_played']:             # <<<<<<<<<<<<<<
 *                         self.mc.post_mc_native_event(event)
 * 
 */
        }
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

        /* "mpfmc/core/audio/track_sound_loop.pyx":236
 * 
 *             if notification_message.message == notification_sound_loop_set_started:
 *                 if sound_loop_set_settings['events_when_played'] is not None:             # <<<<<<<<<<<<<<
 *                     for event in sound_loop_set_settings['events_when_played']:
 *                         self.mc.post_mc_native_event(event)
 */
      }

      /* "mpfmc/core/audio/track_sound_loop.pyx":235
 *                 return
 * 
 *             if notification_message.message == notification_sound_loop_set_started:             # <<<<<<<<<<<<<<
 *                 if sound_loop_set_settings['events_when_played'] is not None:
 *                     for event in sound_loop_set_settings['events_when_played']:
 */
      break;
      case __pyx_e_5mpfmc_4core_5audio_20notification_message_notification_sound_loop_set_stopped:

      /* "mpfmc/core/audio/track_sound_loop.pyx":241
 * 
 *             elif notification_message.message == notification_sound_loop_set_stopped:
 *                 if sound_loop_set_settings['events_when_stopped'] is not None:             # <<<<<<<<<<<<<<
 *                     for event in sound_loop_set_settings['events_when_stopped']:
 *                         self.mc.post_mc_native_event(event)
 */
      __pyx_t_5 = __Pyx_PyObject_Dict_GetItem(__pyx_v_sound_loop_set_settings, __pyx_n_u_events_when_stopped); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 241, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_2 = (__pyx_t_5 != Py_None);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_1 = (__pyx_t_2 != 0);
      if (__pyx_t_1) {

        /* "mpfmc/core/audio/track_sound_loop.pyx":242
 *             elif notification_message.message == notification_sound_loop_set_stopped:
 *                 if sound_loop_set_settings['events_when_stopped'] is not None:
 *                     for event in sound_loop_set_settings['events_when_stopped']:             # <<<<<<<<<<<<<<
 *                         self.mc.post_mc_native_event(event)
 * 
 */
        __pyx_t_5 = __Pyx_PyObject_Dict_GetItem(__pyx_v_sound_loop_set_settings, __pyx_n_u_events_when_stopped); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 242, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        if (likely(PyList_CheckExact(__pyx_t_5)) || PyTuple_CheckExact(__pyx_t_5)) {
          __pyx_t_3 = __pyx_t_5; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0;
          __pyx_t_11 = NULL;
        } else {
          __pyx_t_4 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 242, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_11 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 242, __pyx_L1_error)
        }
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        for (;;) {
          if (likely(!__pyx_t_11)) {
            if (likely(PyList_CheckExact(__pyx_t_3))) {
              if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_3)) break;
              #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
              __pyx_t_5 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_5); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 242, __pyx_L1_error)
              #else
              __pyx_t_5 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 242, __pyx_L1_error)
              __Pyx_GOTREF(__pyx_t_5);
              #endif
            } else {
              if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
              #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
              __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_5); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 242, __pyx_L1_error)
              #else
              __pyx_t_5 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 242, __pyx_L1_error)
              __Pyx_GOTREF(__pyx_t_5);
              #endif
            }
          } else {
            __pyx_t_5 = __pyx_t_11(__pyx_t_3);
            if (unlikely(!__pyx_t_5)) {
              PyObject* exc_type = PyErr_Occurred();
              if (exc_type) {
                if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
                else __PYX_ERR(0, 242, __pyx_L1_error)
              }
              break;
            }
            __Pyx_GOTREF(__pyx_t_5);
          }
          __Pyx_XDECREF_SET(__pyx_v_event, __pyx_t_5);
          __pyx_t_5 = 0;

          /* "mpfmc/core/audio/track_sound_loop.pyx":243
 *                 if sound_loop_set_settings['events_when_stopped'] is not None:
 *                     for event in sound_loop_set_settings['events_when_stopped']:
 *                         self.mc.post_mc_native_event(event)             # <<<<<<<<<<<<<<
 * 
 *                 self.log.debug("Removing sound_loop_set settings %d from active list", notification_message.data.sound_loop_set.id)
 */
          __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->__pyx_base.mc, __pyx_n_s_post_mc_native_event); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 243, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          __pyx_t_6 = NULL;
          if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
            __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_7);
            if (likely(__pyx_t_6)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
              __Pyx_INCREF(__pyx_t_6);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_7, function);
            }
          }
          __pyx_t_5 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_6, __pyx_v_event) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_v_event);
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 243, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

          /* "mpfmc/core/audio/track_sound_loop.pyx":242
 *             elif notification_message.message == notification_sound_loop_set_stopped:
 *                 if sound_loop_set_settings['events_when_stopped'] is not None:
 *                     for event in sound_loop_set_settings['events_when_stopped']:             # <<<<<<<<<<<<<<
 *                         self.mc.post_mc_native_event(event)
 * 
 */
        }
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

        /* "mpfmc/core/audio/track_sound_loop.pyx":241
 * 
 *             elif notification_message.message == notification_sound_loop_set_stopped:
 *                 if sound_loop_set_settings['events_when_stopped'] is not None:             # <<<<<<<<<<<<<<
 *                     for event in sound_loop_set_settings['events_when_stopped']:
 *                         self.mc.post_mc_native_event(event)
 */
      }

      /* "mpfmc/core/audio/track_sound_loop.pyx":245
 *                         self.mc.post_mc_native_event(event)
 * 
 *                 self.log.debug("Removing sound_loop_set settings %d from active list", notification_message.data.sound_loop_set.id)             # <<<<<<<<<<<<<<
 *                 del self._active_sound_loop_sets[notification_message.data.sound_loop_set.id]
 * 
 */
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->__pyx_base.log, __pyx_n_s_debug); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 245, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_7 = __Pyx_PyInt_From_long(__pyx_v_notification_message->data.sound_loop_set.id); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 245, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_6 = NULL;
      __pyx_t_9 = 0;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
        __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
        if (likely(__pyx_t_6)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
          __Pyx_INCREF(__pyx_t_6);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_5, function);
          __pyx_t_9 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_5)) {
        PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_kp_u_Removing_sound_loop_set_settings, __pyx_t_7};
        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 245, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
        PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_kp_u_Removing_sound_loop_set_settings, __pyx_t_7};
        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 245, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      } else
      #endif
      {
        __pyx_t_10 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 245, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        if (__pyx_t_6) {
          __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_6); __pyx_t_6 = NULL;
        }
        __Pyx_INCREF(__pyx_kp_u_Removing_sound_loop_set_settings);
        __Pyx_GIVEREF(__pyx_kp_u_Removing_sound_loop_set_settings);
        PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_9, __pyx_kp_u_Removing_sound_loop_set_settings);
        __Pyx_GIVEREF(__pyx_t_7);
        PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_9, __pyx_t_7);
        __pyx_t_7 = 0;
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_10, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 245, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      }
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "mpfmc/core/audio/track_sound_loop.pyx":246
 * 
 *                 self.log.debug("Removing sound_loop_set settings %d from active list", notification_message.data.sound_loop_set.id)
 *                 del self._active_sound_loop_sets[notification_message.data.sound_loop_set.id]             # <<<<<<<<<<<<<<
 * 
 *                 # Remove and delete sound loop set player used to play this set
 */
      if (unlikely(__pyx_v_self->_active_sound_loop_sets == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        __PYX_ERR(0, 246, __pyx_L1_error)
      }
      __pyx_t_3 = __Pyx_PyInt_From_long(__pyx_v_notification_message->data.sound_loop_set.id); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 246, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      if (unlikely(PyDict_DelItem(__pyx_v_self->_active_sound_loop_sets, __pyx_t_3) < 0)) __PYX_ERR(0, 246, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "mpfmc/core/audio/track_sound_loop.pyx":249
 * 
 *                 # Remove and delete sound loop set player used to play this set
 *                 player = <SoundLoopSetPlayer*>notification_message.data.sound_loop_set.player             # <<<<<<<<<<<<<<
 *                 if player != NULL:
 *                     self._delete_player(player)
 */
      __pyx_v_player = ((__pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopSetPlayer *)__pyx_v_notification_message->data.sound_loop_set.player);

      /* "mpfmc/core/audio/track_sound_loop.pyx":250
 *                 # Remove and delete sound loop set player used to play this set
 *                 player = <SoundLoopSetPlayer*>notification_message.data.sound_loop_set.player
 *                 if player != NULL:             # <<<<<<<<<<<<<<
 *                     self._delete_player(player)
 *                     self.type_state.players = g_slist_remove(self.type_state.players, player)
 */
      __pyx_t_1 = ((__pyx_v_player != NULL) != 0);
      if (__pyx_t_1) {

        /* "mpfmc/core/audio/track_sound_loop.pyx":251
 *                 player = <SoundLoopSetPlayer*>notification_message.data.sound_loop_set.player
 *                 if player != NULL:
 *                     self._delete_player(player)             # <<<<<<<<<<<<<<
 *                     self.type_state.players = g_slist_remove(self.type_state.players, player)
 * 
 */
        __pyx_t_3 = ((struct __pyx_vtabstruct_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *)__pyx_v_self->__pyx_base.__pyx_vtab)->_delete_player(__pyx_v_self, __pyx_v_player); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 251, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

        /* "mpfmc/core/audio/track_sound_loop.pyx":252
 *                 if player != NULL:
 *                     self._delete_player(player)
 *                     self.type_state.players = g_slist_remove(self.type_state.players, player)             # <<<<<<<<<<<<<<
 * 
 *             elif notification_message.message == notification_sound_loop_set_looping:
 */
        __pyx_v_self->type_state->players = g_slist_remove(__pyx_v_self->type_state->players, __pyx_v_player);

        /* "mpfmc/core/audio/track_sound_loop.pyx":250
 *                 # Remove and delete sound loop set player used to play this set
 *                 player = <SoundLoopSetPlayer*>notification_message.data.sound_loop_set.player
 *                 if player != NULL:             # <<<<<<<<<<<<<<
 *                     self._delete_player(player)
 *                     self.type_state.players = g_slist_remove(self.type_state.players, player)
 */
      }

      /* "mpfmc/core/audio/track_sound_loop.pyx":240
 *                         self.mc.post_mc_native_event(event)
 * 
 *             elif notification_message.message == notification_sound_loop_set_stopped:             # <<<<<<<<<<<<<<
 *                 if sound_loop_set_settings['events_when_stopped'] is not None:
 *                     for event in sound_loop_set_settings['events_when_stopped']:
 */
      break;
      case __pyx_e_5mpfmc_4core_5audio_20notification_message_notification_sound_loop_set_looping:

      /* "mpfmc/core/audio/track_sound_loop.pyx":255
 * 
 *             elif notification_message.message == notification_sound_loop_set_looping:
 *                 if sound_loop_set_settings['events_when_looping'] is not None:             # <<<<<<<<<<<<<<
 *                     for event in sound_loop_set_settings['events_when_looping']:
 *                         self.mc.post_mc_native_event(event)
 */
      __pyx_t_3 = __Pyx_PyObject_Dict_GetItem(__pyx_v_sound_loop_set_settings, __pyx_n_u_events_when_looping); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 255, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_1 = (__pyx_t_3 != Py_None);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_2 = (__pyx_t_1 != 0);
      if (__pyx_t_2) {

        /* "mpfmc/core/audio/track_sound_loop.pyx":256
 *             elif notification_message.message == notification_sound_loop_set_looping:
 *                 if sound_loop_set_settings['events_when_looping'] is not None:
 *                     for event in sound_loop_set_settings['events_when_looping']:             # <<<<<<<<<<<<<<
 *                         self.mc.post_mc_native_event(event)
 * 
 */
        __pyx_t_3 = __Pyx_PyObject_Dict_GetItem(__pyx_v_sound_loop_set_settings, __pyx_n_u_events_when_looping); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 256, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        if (likely(PyList_CheckExact(__pyx_t_3)) || PyTuple_CheckExact(__pyx_t_3)) {
          __pyx_t_5 = __pyx_t_3; __Pyx_INCREF(__pyx_t_5); __pyx_t_4 = 0;
          __pyx_t_11 = NULL;
        } else {
          __pyx_t_4 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 256, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_11 = Py_TYPE(__pyx_t_5)->tp_iternext; if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 256, __pyx_L1_error)
        }
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        for (;;) {
          if (likely(!__pyx_t_11)) {
            if (likely(PyList_CheckExact(__pyx_t_5))) {
              if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_5)) break;
              #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
              __pyx_t_3 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 256, __pyx_L1_error)
              #else
              __pyx_t_3 = PySequence_ITEM(__pyx_t_5, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 256, __pyx_L1_error)
              __Pyx_GOTREF(__pyx_t_3);
              #endif
            } else {
              if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_5)) break;
              #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
              __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 256, __pyx_L1_error)
              #else
              __pyx_t_3 = PySequence_ITEM(__pyx_t_5, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 256, __pyx_L1_error)
              __Pyx_GOTREF(__pyx_t_3);
              #endif
            }
          } else {
            __pyx_t_3 = __pyx_t_11(__pyx_t_5);
            if (unlikely(!__pyx_t_3)) {
              PyObject* exc_type = PyErr_Occurred();
              if (exc_type) {
                if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
                else __PYX_ERR(0, 256, __pyx_L1_error)
              }
              break;
            }
            __Pyx_GOTREF(__pyx_t_3);
          }
          __Pyx_XDECREF_SET(__pyx_v_event, __pyx_t_3);
          __pyx_t_3 = 0;

          /* "mpfmc/core/audio/track_sound_loop.pyx":257
 *                 if sound_loop_set_settings['events_when_looping'] is not None:
 *                     for event in sound_loop_set_settings['events_when_looping']:
 *                         self.mc.post_mc_native_event(event)             # <<<<<<<<<<<<<<
 * 
 *         elif notification_message.message == notification_sound_marker:
 */
          __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->__pyx_base.mc, __pyx_n_s_post_mc_native_event); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 257, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_10);
          __pyx_t_7 = NULL;
          if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_10))) {
            __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_10);
            if (likely(__pyx_t_7)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
              __Pyx_INCREF(__pyx_t_7);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_10, function);
            }
          }
          __pyx_t_3 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_10, __pyx_t_7, __pyx_v_event) : __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_v_event);
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
          if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 257, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

          /* "mpfmc/core/audio/track_sound_loop.pyx":256
 *             elif notification_message.message == notification_sound_loop_set_looping:
 *                 if sound_loop_set_settings['events_when_looping'] is not None:
 *                     for event in sound_loop_set_settings['events_when_looping']:             # <<<<<<<<<<<<<<
 *                         self.mc.post_mc_native_event(event)
 * 
 */
        }
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

        /* "mpfmc/core/audio/track_sound_loop.pyx":255
 * 
 *             elif notification_message.message == notification_sound_loop_set_looping:
 *                 if sound_loop_set_settings['events_when_looping'] is not None:             # <<<<<<<<<<<<<<
 *                     for event in sound_loop_set_settings['events_when_looping']:
 *                         self.mc.post_mc_native_event(event)
 */
      }

      /* "mpfmc/core/audio/track_sound_loop.pyx":254
 *                     self.type_state.players = g_slist_remove(self.type_state.players, player)
 * 
 *             elif notification_message.message == notification_sound_loop_set_looping:             # <<<<<<<<<<<<<<
 *                 if sound_loop_set_settings['events_when_looping'] is not None:
 *                     for event in sound_loop_set_settings['events_when_looping']:
 */
      break;
      default: break;
    }

    /* "mpfmc/core/audio/track_sound_loop.pyx":217
 *                        notification_message.message, notification_message.sound_instance_id)
 * 
 *         if notification_message.message in (notification_sound_loop_set_started, notification_sound_loop_set_stopped,             # <<<<<<<<<<<<<<
 *                                             notification_sound_loop_set_looping):
 * 
 */
    break;
    case __pyx_e_5mpfmc_4core_5audio_20notification_message_notification_sound_marker:

    /* "mpfmc/core/audio/track_sound_loop.pyx":261
 *         elif notification_message.message == notification_sound_marker:
 * 
 *             if notification_message.sound_id not in self.mc.sounds_by_id.keys():             # <<<<<<<<<<<<<<
 *                 self.log.warning("Received a notification message for a sound (id: %d) "
 *                                  "that does not exist. Notification will be discarded.",
 */
    __pyx_t_5 = __Pyx_PyInt_From_Uint64(__pyx_v_notification_message->sound_id); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 261, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->__pyx_base.mc, __pyx_n_s_sounds_by_id); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 261, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_keys); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 261, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __pyx_t_10 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
      __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_7);
      if (likely(__pyx_t_10)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_10);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_7, function);
      }
    }
    __pyx_t_3 = (__pyx_t_10) ? __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_10) : __Pyx_PyObject_CallNoArg(__pyx_t_7);
    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 261, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_2 = (__Pyx_PySequence_ContainsTF(__pyx_t_5, __pyx_t_3, Py_NE)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 261, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_1 = (__pyx_t_2 != 0);
    if (__pyx_t_1) {

      /* "mpfmc/core/audio/track_sound_loop.pyx":262
 * 
 *             if notification_message.sound_id not in self.mc.sounds_by_id.keys():
 *                 self.log.warning("Received a notification message for a sound (id: %d) "             # <<<<<<<<<<<<<<
 *                                  "that does not exist. Notification will be discarded.",
 *                                  notification_message.sound_id)
 */
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->__pyx_base.log, __pyx_n_s_warning); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 262, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);

      /* "mpfmc/core/audio/track_sound_loop.pyx":264
 *                 self.log.warning("Received a notification message for a sound (id: %d) "
 *                                  "that does not exist. Notification will be discarded.",
 *                                  notification_message.sound_id)             # <<<<<<<<<<<<<<
 *                 SDL_UnlockAudio()
 *                 return
 */
      __pyx_t_7 = __Pyx_PyInt_From_Uint64(__pyx_v_notification_message->sound_id); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 264, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_10 = NULL;
      __pyx_t_9 = 0;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
        __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_5);
        if (likely(__pyx_t_10)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
          __Pyx_INCREF(__pyx_t_10);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_5, function);
          __pyx_t_9 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_5)) {
        PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_kp_u_Received_a_notification_message_2, __pyx_t_7};
        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 262, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
        PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_kp_u_Received_a_notification_message_2, __pyx_t_7};
        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 262, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      } else
      #endif
      {
        __pyx_t_6 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 262, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        if (__pyx_t_10) {
          __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_10); __pyx_t_10 = NULL;
        }
        __Pyx_INCREF(__pyx_kp_u_Received_a_notification_message_2);
        __Pyx_GIVEREF(__pyx_kp_u_Received_a_notification_message_2);
        PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_9, __pyx_kp_u_Received_a_notification_message_2);
        __Pyx_GIVEREF(__pyx_t_7);
        PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_9, __pyx_t_7);
        __pyx_t_7 = 0;
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 262, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "mpfmc/core/audio/track_sound_loop.pyx":265
 *                                  "that does not exist. Notification will be discarded.",
 *                                  notification_message.sound_id)
 *                 SDL_UnlockAudio()             # <<<<<<<<<<<<<<
 *                 return
 * 
 */
      SDL_UnlockAudio();

      /* "mpfmc/core/audio/track_sound_loop.pyx":266
 *                                  notification_message.sound_id)
 *                 SDL_UnlockAudio()
 *                 return             # <<<<<<<<<<<<<<
 * 
 *             # In a sound loop track, sound instances are not created when playing a loop sound.  The sound
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_r = Py_None; __Pyx_INCREF(Py_None);
      goto __pyx_L0;

      /* "mpfmc/core/audio/track_sound_loop.pyx":261
 *         elif notification_message.message == notification_sound_marker:
 * 
 *             if notification_message.sound_id not in self.mc.sounds_by_id.keys():             # <<<<<<<<<<<<<<
 *                 self.log.warning("Received a notification message for a sound (id: %d) "
 *                                  "that does not exist. Notification will be discarded.",
 */
    }

    /* "mpfmc/core/audio/track_sound_loop.pyx":271
 *             # asset is used directly and therefore we need to reference the sound asset by sound_id to
 *             # retrieve the marker events to send.
 *             sound = self.mc.sounds_by_id[notification_message.sound_id]             # <<<<<<<<<<<<<<
 * 
 *             # Send marker event(s)
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->__pyx_base.mc, __pyx_n_s_sounds_by_id); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 271, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = __Pyx_GetItemInt(__pyx_t_3, __pyx_v_notification_message->sound_id, Uint64, 0, __Pyx_PyInt_From_Uint64, 0, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 271, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_sound = __pyx_t_5;
    __pyx_t_5 = 0;

    /* "mpfmc/core/audio/track_sound_loop.pyx":274
 * 
 *             # Send marker event(s)
 *             if sound and 0 <= notification_message.data.marker.id < sound.marker_count:             # <<<<<<<<<<<<<<
 *                 if sound.markers[notification_message.data.marker.id]['events'] is not None:
 *                     for event in sound.markers[notification_message.data.marker.id]['events']:
 */
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_sound); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 274, __pyx_L1_error)
    if (__pyx_t_2) {
    } else {
      __pyx_t_1 = __pyx_t_2;
      goto __pyx_L24_bool_binop_done;
    }
    __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_notification_message->data.marker.id); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 274, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_3 = PyObject_RichCompare(__pyx_int_0, __pyx_t_5, Py_LE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 274, __pyx_L1_error)
    if (__Pyx_PyObject_IsTrue(__pyx_t_3)) {
      __Pyx_DECREF(__pyx_t_3);
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_sound, __pyx_n_s_marker_count); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 274, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_3 = PyObject_RichCompare(__pyx_t_5, __pyx_t_6, Py_LT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 274, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 274, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_1 = __pyx_t_2;
    __pyx_L24_bool_binop_done:;
    if (__pyx_t_1) {

      /* "mpfmc/core/audio/track_sound_loop.pyx":275
 *             # Send marker event(s)
 *             if sound and 0 <= notification_message.data.marker.id < sound.marker_count:
 *                 if sound.markers[notification_message.data.marker.id]['events'] is not None:             # <<<<<<<<<<<<<<
 *                     for event in sound.markers[notification_message.data.marker.id]['events']:
 *                         self.mc.post_mc_native_event(event,
 */
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_sound, __pyx_n_s_markers); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 275, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_5 = __Pyx_GetItemInt(__pyx_t_3, __pyx_v_notification_message->data.marker.id, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 275, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = __Pyx_PyObject_Dict_GetItem(__pyx_t_5, __pyx_n_u_events); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 275, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_1 = (__pyx_t_3 != Py_None);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_2 = (__pyx_t_1 != 0);
      if (__pyx_t_2) {

        /* "mpfmc/core/audio/track_sound_loop.pyx":276
 *             if sound and 0 <= notification_message.data.marker.id < sound.marker_count:
 *                 if sound.markers[notification_message.data.marker.id]['events'] is not None:
 *                     for event in sound.markers[notification_message.data.marker.id]['events']:             # <<<<<<<<<<<<<<
 *                         self.mc.post_mc_native_event(event,
 *                                                      sound_instance=sound,
 */
        __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_sound, __pyx_n_s_markers); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 276, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_5 = __Pyx_GetItemInt(__pyx_t_3, __pyx_v_notification_message->data.marker.id, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 276, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_3 = __Pyx_PyObject_Dict_GetItem(__pyx_t_5, __pyx_n_u_events); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 276, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        if (likely(PyList_CheckExact(__pyx_t_3)) || PyTuple_CheckExact(__pyx_t_3)) {
          __pyx_t_5 = __pyx_t_3; __Pyx_INCREF(__pyx_t_5); __pyx_t_4 = 0;
          __pyx_t_11 = NULL;
        } else {
          __pyx_t_4 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 276, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_11 = Py_TYPE(__pyx_t_5)->tp_iternext; if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 276, __pyx_L1_error)
        }
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        for (;;) {
          if (likely(!__pyx_t_11)) {
            if (likely(PyList_CheckExact(__pyx_t_5))) {
              if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_5)) break;
              #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
              __pyx_t_3 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 276, __pyx_L1_error)
              #else
              __pyx_t_3 = PySequence_ITEM(__pyx_t_5, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 276, __pyx_L1_error)
              __Pyx_GOTREF(__pyx_t_3);
              #endif
            } else {
              if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_5)) break;
              #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
              __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 276, __pyx_L1_error)
              #else
              __pyx_t_3 = PySequence_ITEM(__pyx_t_5, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 276, __pyx_L1_error)
              __Pyx_GOTREF(__pyx_t_3);
              #endif
            }
          } else {
            __pyx_t_3 = __pyx_t_11(__pyx_t_5);
            if (unlikely(!__pyx_t_3)) {
              PyObject* exc_type = PyErr_Occurred();
              if (exc_type) {
                if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
                else __PYX_ERR(0, 276, __pyx_L1_error)
              }
              break;
            }
            __Pyx_GOTREF(__pyx_t_3);
          }
          __Pyx_XDECREF_SET(__pyx_v_event, __pyx_t_3);
          __pyx_t_3 = 0;

          /* "mpfmc/core/audio/track_sound_loop.pyx":277
 *                 if sound.markers[notification_message.data.marker.id]['events'] is not None:
 *                     for event in sound.markers[notification_message.data.marker.id]['events']:
 *                         self.mc.post_mc_native_event(event,             # <<<<<<<<<<<<<<
 *                                                      sound_instance=sound,
 *                                                      marker_id=notification_message.data.marker.id)
 */
          __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->__pyx_base.mc, __pyx_n_s_post_mc_native_event); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 277, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 277, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_INCREF(__pyx_v_event);
          __Pyx_GIVEREF(__pyx_v_event);
          PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_event);

          /* "mpfmc/core/audio/track_sound_loop.pyx":278
 *                     for event in sound.markers[notification_message.data.marker.id]['events']:
 *                         self.mc.post_mc_native_event(event,
 *                                                      sound_instance=sound,             # <<<<<<<<<<<<<<
 *                                                      marker_id=notification_message.data.marker.id)
 * 
 */
          __pyx_t_7 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 278, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_sound_instance, __pyx_v_sound) < 0) __PYX_ERR(0, 278, __pyx_L1_error)

          /* "mpfmc/core/audio/track_sound_loop.pyx":279
 *                         self.mc.post_mc_native_event(event,
 *                                                      sound_instance=sound,
 *                                                      marker_id=notification_message.data.marker.id)             # <<<<<<<<<<<<<<
 * 
 *         SDL_UnlockAudio()
 */
          __pyx_t_10 = __Pyx_PyInt_From_int(__pyx_v_notification_message->data.marker.id); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 279, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_10);
          if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_marker_id, __pyx_t_10) < 0) __PYX_ERR(0, 278, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

          /* "mpfmc/core/audio/track_sound_loop.pyx":277
 *                 if sound.markers[notification_message.data.marker.id]['events'] is not None:
 *                     for event in sound.markers[notification_message.data.marker.id]['events']:
 *                         self.mc.post_mc_native_event(event,             # <<<<<<<<<<<<<<
 *                                                      sound_instance=sound,
 *                                                      marker_id=notification_message.data.marker.id)
 */
          __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 277, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_10);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

          /* "mpfmc/core/audio/track_sound_loop.pyx":276
 *             if sound and 0 <= notification_message.data.marker.id < sound.marker_count:
 *                 if sound.markers[notification_message.data.marker.id]['events'] is not None:
 *                     for event in sound.markers[notification_message.data.marker.id]['events']:             # <<<<<<<<<<<<<<
 *                         self.mc.post_mc_native_event(event,
 *                                                      sound_instance=sound,
 */
        }
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

        /* "mpfmc/core/audio/track_sound_loop.pyx":275
 *             # Send marker event(s)
 *             if sound and 0 <= notification_message.data.marker.id < sound.marker_count:
 *                 if sound.markers[notification_message.data.marker.id]['events'] is not None:             # <<<<<<<<<<<<<<
 *                     for event in sound.markers[notification_message.data.marker.id]['events']:
 *                         self.mc.post_mc_native_event(event,
 */
      }

      /* "mpfmc/core/audio/track_sound_loop.pyx":274
 * 
 *             # Send marker event(s)
 *             if sound and 0 <= notification_message.data.marker.id < sound.marker_count:             # <<<<<<<<<<<<<<
 *                 if sound.markers[notification_message.data.marker.id]['events'] is not None:
 *                     for event in sound.markers[notification_message.data.marker.id]['events']:
 */
    }

    /* "mpfmc/core/audio/track_sound_loop.pyx":259
 *                         self.mc.post_mc_native_event(event)
 * 
 *         elif notification_message.message == notification_sound_marker:             # <<<<<<<<<<<<<<
 * 
 *             if notification_message.sound_id not in self.mc.sounds_by_id.keys():
 */
    break;
    default: break;
  }

  /* "mpfmc/core/audio/track_sound_loop.pyx":281
 *                                                      marker_id=notification_message.data.marker.id)
 * 
 *         SDL_UnlockAudio()             # <<<<<<<<<<<<<<
 * 
 *     def play_sound_loop_set(self, dict sound_loop_set not None, str context=None, dict player_settings=None):
 */
  SDL_UnlockAudio();

  /* "mpfmc/core/audio/track_sound_loop.pyx":188
 *         SDL_UnlockAudio()
 * 
 *     cdef process_notification_message(self, NotificationMessageContainer *notification_message):             # <<<<<<<<<<<<<<
 *         """Process a notification message to this track"""
 * 
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("mpfmc.core.audio.track_sound_loop.TrackSoundLoop.process_notification_message", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_event);
  __Pyx_XDECREF(__pyx_v_sound_loop_set_settings);
  __Pyx_XDECREF(__pyx_v_sound);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mpfmc/core/audio/track_sound_loop.pyx":283
 *         SDL_UnlockAudio()
 * 
 *     def play_sound_loop_set(self, dict sound_loop_set not None, str context=None, dict player_settings=None):             # <<<<<<<<<<<<<<
 *         """
 *         Immediately play a sound loop set.
 */

/* Python wrapper */
static PyObject *__pyx_pw_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_19play_sound_loop_set(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_18play_sound_loop_set[] = "TrackSoundLoop.play_sound_loop_set(self, dict sound_loop_set, unicode context=None, dict player_settings=None)\n\n        Immediately play a sound loop set.\n\n        Args:\n            sound_loop_set: The sound_loop_set asset object to play.\n            context: The context from which the sound loop set is played.\n            player_settings: Settings to use for playback\n        ";
static PyObject *__pyx_pw_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_19play_sound_loop_set(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_sound_loop_set = 0;
  PyObject *__pyx_v_context = 0;
  PyObject *__pyx_v_player_settings = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("play_sound_loop_set (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_sound_loop_set,&__pyx_n_s_context,&__pyx_n_s_player_settings,0};
    PyObject* values[3] = {0,0,0};
    values[1] = ((PyObject*)Py_None);
    values[2] = ((PyObject*)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sound_loop_set)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_context);
          if (value) { values[1] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_player_settings);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "play_sound_loop_set") < 0)) __PYX_ERR(0, 283, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_sound_loop_set = ((PyObject*)values[0]);
    __pyx_v_context = ((PyObject*)values[1]);
    __pyx_v_player_settings = ((PyObject*)values[2]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("play_sound_loop_set", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 283, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mpfmc.core.audio.track_sound_loop.TrackSoundLoop.play_sound_loop_set", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_sound_loop_set), (&PyDict_Type), 0, "sound_loop_set", 1))) __PYX_ERR(0, 283, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_context), (&PyUnicode_Type), 1, "context", 1))) __PYX_ERR(0, 283, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_player_settings), (&PyDict_Type), 1, "player_settings", 1))) __PYX_ERR(0, 283, __pyx_L1_error)
  __pyx_r = __pyx_pf_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_18play_sound_loop_set(((struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *)__pyx_v_self), __pyx_v_sound_loop_set, __pyx_v_context, __pyx_v_player_settings);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_18play_sound_loop_set(struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *__pyx_v_self, PyObject *__pyx_v_sound_loop_set, PyObject *__pyx_v_context, PyObject *__pyx_v_player_settings) {
  __pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopSetPlayer *__pyx_v_player;
  __pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopSetPlayer *__pyx_v_existing_player;
  __pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopLayerSettings *__pyx_v_layer;
  int __pyx_v_bytes_per_sample_frame;
  int __pyx_v_player_already_playing;
  PyObject *__pyx_v_master_layer_settings = NULL;
  PyObject *__pyx_v_layer_settings = NULL;
  GSList *__pyx_v_iterator;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  float __pyx_t_9;
  Py_ssize_t __pyx_t_10;
  PyObject *(*__pyx_t_11)(PyObject *);
  Uint32 __pyx_t_12;
  GSList *__pyx_t_13;
  Uint8 __pyx_t_14;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("play_sound_loop_set", 0);
  __Pyx_INCREF(__pyx_v_player_settings);

  /* "mpfmc/core/audio/track_sound_loop.pyx":296
 *         cdef SoundLoopLayerSettings *layer
 *         cdef int bytes_per_sample_frame
 *         cdef bint player_already_playing = False             # <<<<<<<<<<<<<<
 * 
 *         self.log.debug("play_sound_loop_set - Preparing sound_loop_set '%s' for playback.", sound_loop_set)
 */
  __pyx_v_player_already_playing = 0;

  /* "mpfmc/core/audio/track_sound_loop.pyx":298
 *         cdef bint player_already_playing = False
 * 
 *         self.log.debug("play_sound_loop_set - Preparing sound_loop_set '%s' for playback.", sound_loop_set)             # <<<<<<<<<<<<<<
 * 
 *         if player_settings is None:
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->__pyx_base.log, __pyx_n_s_debug); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 298, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  __pyx_t_4 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
      __pyx_t_4 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_kp_u_play_sound_loop_set_Preparing_so, __pyx_v_sound_loop_set};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 298, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_kp_u_play_sound_loop_set_Preparing_so, __pyx_v_sound_loop_set};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 298, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  {
    __pyx_t_5 = PyTuple_New(2+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 298, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    if (__pyx_t_3) {
      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
    }
    __Pyx_INCREF(__pyx_kp_u_play_sound_loop_set_Preparing_so);
    __Pyx_GIVEREF(__pyx_kp_u_play_sound_loop_set_Preparing_so);
    PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, __pyx_kp_u_play_sound_loop_set_Preparing_so);
    __Pyx_INCREF(__pyx_v_sound_loop_set);
    __Pyx_GIVEREF(__pyx_v_sound_loop_set);
    PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_v_sound_loop_set);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 298, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "mpfmc/core/audio/track_sound_loop.pyx":300
 *         self.log.debug("play_sound_loop_set - Preparing sound_loop_set '%s' for playback.", sound_loop_set)
 * 
 *         if player_settings is None:             # <<<<<<<<<<<<<<
 *             player_settings = dict()
 * 
 */
  __pyx_t_6 = (__pyx_v_player_settings == ((PyObject*)Py_None));
  __pyx_t_7 = (__pyx_t_6 != 0);
  if (__pyx_t_7) {

    /* "mpfmc/core/audio/track_sound_loop.pyx":301
 * 
 *         if player_settings is None:
 *             player_settings = dict()             # <<<<<<<<<<<<<<
 * 
 *         # Determine settings (override sound loop set with player settings)
 */
    __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 301, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF_SET(__pyx_v_player_settings, ((PyObject*)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "mpfmc/core/audio/track_sound_loop.pyx":300
 *         self.log.debug("play_sound_loop_set - Preparing sound_loop_set '%s' for playback.", sound_loop_set)
 * 
 *         if player_settings is None:             # <<<<<<<<<<<<<<
 *             player_settings = dict()
 * 
 */
  }

  /* "mpfmc/core/audio/track_sound_loop.pyx":304
 * 
 *         # Determine settings (override sound loop set with player settings)
 *         player_settings.setdefault('fade_in', sound_loop_set['fade_in'])             # <<<<<<<<<<<<<<
 *         player_settings.setdefault('fade_out', sound_loop_set['fade_out'])
 *         player_settings.setdefault('start_at', 0)
 */
  if (unlikely(__pyx_v_player_settings == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "setdefault");
    __PYX_ERR(0, 304, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_PyDict_GetItem(__pyx_v_sound_loop_set, __pyx_n_u_fade_in); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 304, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyDict_SetDefault(__pyx_v_player_settings, __pyx_n_u_fade_in, __pyx_t_1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 304, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "mpfmc/core/audio/track_sound_loop.pyx":305
 *         # Determine settings (override sound loop set with player settings)
 *         player_settings.setdefault('fade_in', sound_loop_set['fade_in'])
 *         player_settings.setdefault('fade_out', sound_loop_set['fade_out'])             # <<<<<<<<<<<<<<
 *         player_settings.setdefault('start_at', 0)
 *         player_settings.setdefault('events_when_played', sound_loop_set['events_when_played'])
 */
  if (unlikely(__pyx_v_player_settings == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "setdefault");
    __PYX_ERR(0, 305, __pyx_L1_error)
  }
  __pyx_t_2 = __Pyx_PyDict_GetItem(__pyx_v_sound_loop_set, __pyx_n_u_fade_out); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 305, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyDict_SetDefault(__pyx_v_player_settings, __pyx_n_u_fade_out, __pyx_t_2, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 305, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "mpfmc/core/audio/track_sound_loop.pyx":306
 *         player_settings.setdefault('fade_in', sound_loop_set['fade_in'])
 *         player_settings.setdefault('fade_out', sound_loop_set['fade_out'])
 *         player_settings.setdefault('start_at', 0)             # <<<<<<<<<<<<<<
 *         player_settings.setdefault('events_when_played', sound_loop_set['events_when_played'])
 *         player_settings.setdefault('events_when_stopped', sound_loop_set['events_when_stopped'])
 */
  if (unlikely(__pyx_v_player_settings == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "setdefault");
    __PYX_ERR(0, 306, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_PyDict_SetDefault(__pyx_v_player_settings, __pyx_n_u_start_at, __pyx_int_0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 306, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "mpfmc/core/audio/track_sound_loop.pyx":307
 *         player_settings.setdefault('fade_out', sound_loop_set['fade_out'])
 *         player_settings.setdefault('start_at', 0)
 *         player_settings.setdefault('events_when_played', sound_loop_set['events_when_played'])             # <<<<<<<<<<<<<<
 *         player_settings.setdefault('events_when_stopped', sound_loop_set['events_when_stopped'])
 *         player_settings.setdefault('events_when_looping', sound_loop_set['events_when_looping'])
 */
  if (unlikely(__pyx_v_player_settings == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "setdefault");
    __PYX_ERR(0, 307, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_PyDict_GetItem(__pyx_v_sound_loop_set, __pyx_n_u_events_when_played); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 307, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyDict_SetDefault(__pyx_v_player_settings, __pyx_n_u_events_when_played, __pyx_t_1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 307, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "mpfmc/core/audio/track_sound_loop.pyx":308
 *         player_settings.setdefault('start_at', 0)
 *         player_settings.setdefault('events_when_played', sound_loop_set['events_when_played'])
 *         player_settings.setdefault('events_when_stopped', sound_loop_set['events_when_stopped'])             # <<<<<<<<<<<<<<
 *         player_settings.setdefault('events_when_looping', sound_loop_set['events_when_looping'])
 *         player_settings.setdefault('mode_end_action', sound_loop_set['mode_end_action'])
 */
  if (unlikely(__pyx_v_player_settings == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "setdefault");
    __PYX_ERR(0, 308, __pyx_L1_error)
  }
  __pyx_t_2 = __Pyx_PyDict_GetItem(__pyx_v_sound_loop_set, __pyx_n_u_events_when_stopped); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 308, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyDict_SetDefault(__pyx_v_player_settings, __pyx_n_u_events_when_stopped, __pyx_t_2, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 308, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "mpfmc/core/audio/track_sound_loop.pyx":309
 *         player_settings.setdefault('events_when_played', sound_loop_set['events_when_played'])
 *         player_settings.setdefault('events_when_stopped', sound_loop_set['events_when_stopped'])
 *         player_settings.setdefault('events_when_looping', sound_loop_set['events_when_looping'])             # <<<<<<<<<<<<<<
 *         player_settings.setdefault('mode_end_action', sound_loop_set['mode_end_action'])
 *         player_settings.setdefault('tempo', sound_loop_set['tempo'])
 */
  if (unlikely(__pyx_v_player_settings == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "setdefault");
    __PYX_ERR(0, 309, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_PyDict_GetItem(__pyx_v_sound_loop_set, __pyx_n_u_events_when_looping); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 309, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyDict_SetDefault(__pyx_v_player_settings, __pyx_n_u_events_when_looping, __pyx_t_1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 309, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "mpfmc/core/audio/track_sound_loop.pyx":310
 *         player_settings.setdefault('events_when_stopped', sound_loop_set['events_when_stopped'])
 *         player_settings.setdefault('events_when_looping', sound_loop_set['events_when_looping'])
 *         player_settings.setdefault('mode_end_action', sound_loop_set['mode_end_action'])             # <<<<<<<<<<<<<<
 *         player_settings.setdefault('tempo', sound_loop_set['tempo'])
 *         player_settings.setdefault('timing', 'loop_end')
 */
  if (unlikely(__pyx_v_player_settings == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "setdefault");
    __PYX_ERR(0, 310, __pyx_L1_error)
  }
  __pyx_t_2 = __Pyx_PyDict_GetItem(__pyx_v_sound_loop_set, __pyx_n_u_mode_end_action); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 310, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyDict_SetDefault(__pyx_v_player_settings, __pyx_n_u_mode_end_action, __pyx_t_2, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 310, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "mpfmc/core/audio/track_sound_loop.pyx":311
 *         player_settings.setdefault('events_when_looping', sound_loop_set['events_when_looping'])
 *         player_settings.setdefault('mode_end_action', sound_loop_set['mode_end_action'])
 *         player_settings.setdefault('tempo', sound_loop_set['tempo'])             # <<<<<<<<<<<<<<
 *         player_settings.setdefault('timing', 'loop_end')
 *         player_settings.setdefault('interval', 1)
 */
  if (unlikely(__pyx_v_player_settings == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "setdefault");
    __PYX_ERR(0, 311, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_PyDict_GetItem(__pyx_v_sound_loop_set, __pyx_n_u_tempo); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 311, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyDict_SetDefault(__pyx_v_player_settings, __pyx_n_u_tempo, __pyx_t_1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 311, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "mpfmc/core/audio/track_sound_loop.pyx":312
 *         player_settings.setdefault('mode_end_action', sound_loop_set['mode_end_action'])
 *         player_settings.setdefault('tempo', sound_loop_set['tempo'])
 *         player_settings.setdefault('timing', 'loop_end')             # <<<<<<<<<<<<<<
 *         player_settings.setdefault('interval', 1)
 *         player_settings.setdefault('synchronize', False)
 */
  if (unlikely(__pyx_v_player_settings == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "setdefault");
    __PYX_ERR(0, 312, __pyx_L1_error)
  }
  __pyx_t_2 = __Pyx_PyDict_SetDefault(__pyx_v_player_settings, __pyx_n_u_timing, __pyx_n_u_loop_end, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 312, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "mpfmc/core/audio/track_sound_loop.pyx":313
 *         player_settings.setdefault('tempo', sound_loop_set['tempo'])
 *         player_settings.setdefault('timing', 'loop_end')
 *         player_settings.setdefault('interval', 1)             # <<<<<<<<<<<<<<
 *         player_settings.setdefault('synchronize', False)
 *         player_settings['sound'] = sound_loop_set['sound']
 */
  if (unlikely(__pyx_v_player_settings == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "setdefault");
    __PYX_ERR(0, 313, __pyx_L1_error)
  }
  __pyx_t_2 = __Pyx_PyDict_SetDefault(__pyx_v_player_settings, __pyx_n_u_interval, __pyx_int_1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 313, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "mpfmc/core/audio/track_sound_loop.pyx":314
 *         player_settings.setdefault('timing', 'loop_end')
 *         player_settings.setdefault('interval', 1)
 *         player_settings.setdefault('synchronize', False)             # <<<<<<<<<<<<<<
 *         player_settings['sound'] = sound_loop_set['sound']
 *         player_settings['context'] = context
 */
  if (unlikely(__pyx_v_player_settings == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "setdefault");
    __PYX_ERR(0, 314, __pyx_L1_error)
  }
  __pyx_t_2 = __Pyx_PyDict_SetDefault(__pyx_v_player_settings, __pyx_n_u_synchronize, Py_False, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 314, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "mpfmc/core/audio/track_sound_loop.pyx":315
 *         player_settings.setdefault('interval', 1)
 *         player_settings.setdefault('synchronize', False)
 *         player_settings['sound'] = sound_loop_set['sound']             # <<<<<<<<<<<<<<
 *         player_settings['context'] = context
 * 
 */
  __pyx_t_2 = __Pyx_PyDict_GetItem(__pyx_v_sound_loop_set, __pyx_n_u_sound); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 315, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (unlikely(__pyx_v_player_settings == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 315, __pyx_L1_error)
  }
  if (unlikely(PyDict_SetItem(__pyx_v_player_settings, __pyx_n_u_sound, __pyx_t_2) < 0)) __PYX_ERR(0, 315, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "mpfmc/core/audio/track_sound_loop.pyx":316
 *         player_settings.setdefault('synchronize', False)
 *         player_settings['sound'] = sound_loop_set['sound']
 *         player_settings['context'] = context             # <<<<<<<<<<<<<<
 * 
 *         # print("play_sound_loop_set - player_settings:", player_settings)
 */
  if (unlikely(__pyx_v_player_settings == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 316, __pyx_L1_error)
  }
  if (unlikely(PyDict_SetItem(__pyx_v_player_settings, __pyx_n_u_context, __pyx_v_context) < 0)) __PYX_ERR(0, 316, __pyx_L1_error)

  /* "mpfmc/core/audio/track_sound_loop.pyx":320
 *         # print("play_sound_loop_set - player_settings:", player_settings)
 * 
 *         if player_settings['sound'] not in self.mc.sounds:             # <<<<<<<<<<<<<<
 *             self.log.error("play_sound_loop_set - sound %s in sound_loop_set could "
 *                            "not be located, could not play loop set", player_settings['sound'])
 */
  if (unlikely(__pyx_v_player_settings == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 320, __pyx_L1_error)
  }
  __pyx_t_2 = __Pyx_PyDict_GetItem(__pyx_v_player_settings, __pyx_n_u_sound); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 320, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->__pyx_base.mc, __pyx_n_s_sounds); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 320, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_7 = (__Pyx_PySequence_ContainsTF(__pyx_t_2, __pyx_t_1, Py_NE)); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 320, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_6 = (__pyx_t_7 != 0);
  if (__pyx_t_6) {

    /* "mpfmc/core/audio/track_sound_loop.pyx":321
 * 
 *         if player_settings['sound'] not in self.mc.sounds:
 *             self.log.error("play_sound_loop_set - sound %s in sound_loop_set could "             # <<<<<<<<<<<<<<
 *                            "not be located, could not play loop set", player_settings['sound'])
 *             return
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->__pyx_base.log, __pyx_n_s_error); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 321, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);

    /* "mpfmc/core/audio/track_sound_loop.pyx":322
 *         if player_settings['sound'] not in self.mc.sounds:
 *             self.log.error("play_sound_loop_set - sound %s in sound_loop_set could "
 *                            "not be located, could not play loop set", player_settings['sound'])             # <<<<<<<<<<<<<<
 *             return
 * 
 */
    if (unlikely(__pyx_v_player_settings == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(0, 322, __pyx_L1_error)
    }
    __pyx_t_5 = __Pyx_PyDict_GetItem(__pyx_v_player_settings, __pyx_n_u_sound); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 322, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_3 = NULL;
    __pyx_t_4 = 0;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
        __pyx_t_4 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_kp_u_play_sound_loop_set_sound_s_in_s, __pyx_t_5};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 321, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_kp_u_play_sound_loop_set_sound_s_in_s, __pyx_t_5};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 321, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else
    #endif
    {
      __pyx_t_8 = PyTuple_New(2+__pyx_t_4); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 321, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      if (__pyx_t_3) {
        __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_3); __pyx_t_3 = NULL;
      }
      __Pyx_INCREF(__pyx_kp_u_play_sound_loop_set_sound_s_in_s);
      __Pyx_GIVEREF(__pyx_kp_u_play_sound_loop_set_sound_s_in_s);
      PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_4, __pyx_kp_u_play_sound_loop_set_sound_s_in_s);
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_4, __pyx_t_5);
      __pyx_t_5 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_8, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 321, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "mpfmc/core/audio/track_sound_loop.pyx":323
 *             self.log.error("play_sound_loop_set - sound %s in sound_loop_set could "
 *                            "not be located, could not play loop set", player_settings['sound'])
 *             return             # <<<<<<<<<<<<<<
 * 
 *         if not self.mc.sounds[player_settings['sound']].loaded:
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "mpfmc/core/audio/track_sound_loop.pyx":320
 *         # print("play_sound_loop_set - player_settings:", player_settings)
 * 
 *         if player_settings['sound'] not in self.mc.sounds:             # <<<<<<<<<<<<<<
 *             self.log.error("play_sound_loop_set - sound %s in sound_loop_set could "
 *                            "not be located, could not play loop set", player_settings['sound'])
 */
  }

  /* "mpfmc/core/audio/track_sound_loop.pyx":325
 *             return
 * 
 *         if not self.mc.sounds[player_settings['sound']].loaded:             # <<<<<<<<<<<<<<
 *             self.log.error("play_sound_loop_set - sound %s in sound_loop_set was "
 *                            "not loaded, could not play loop set", player_settings['sound'])
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->__pyx_base.mc, __pyx_n_s_sounds); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 325, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (unlikely(__pyx_v_player_settings == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 325, __pyx_L1_error)
  }
  __pyx_t_2 = __Pyx_PyDict_GetItem(__pyx_v_player_settings, __pyx_n_u_sound); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 325, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_8 = __Pyx_PyObject_GetItem(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 325, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_loaded); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 325, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 325, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_7 = ((!__pyx_t_6) != 0);
  if (__pyx_t_7) {

    /* "mpfmc/core/audio/track_sound_loop.pyx":326
 * 
 *         if not self.mc.sounds[player_settings['sound']].loaded:
 *             self.log.error("play_sound_loop_set - sound %s in sound_loop_set was "             # <<<<<<<<<<<<<<
 *                            "not loaded, could not play loop set", player_settings['sound'])
 *             return
 */
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->__pyx_base.log, __pyx_n_s_error); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 326, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);

    /* "mpfmc/core/audio/track_sound_loop.pyx":327
 *         if not self.mc.sounds[player_settings['sound']].loaded:
 *             self.log.error("play_sound_loop_set - sound %s in sound_loop_set was "
 *                            "not loaded, could not play loop set", player_settings['sound'])             # <<<<<<<<<<<<<<
 *             return
 * 
 */
    if (unlikely(__pyx_v_player_settings == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(0, 327, __pyx_L1_error)
    }
    __pyx_t_1 = __Pyx_PyDict_GetItem(__pyx_v_player_settings, __pyx_n_u_sound); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 327, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = NULL;
    __pyx_t_4 = 0;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_8);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_8, function);
        __pyx_t_4 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_8)) {
      PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_kp_u_play_sound_loop_set_sound_s_in_s_2, __pyx_t_1};
      __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 326, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) {
      PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_kp_u_play_sound_loop_set_sound_s_in_s_2, __pyx_t_1};
      __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 326, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    } else
    #endif
    {
      __pyx_t_3 = PyTuple_New(2+__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 326, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      if (__pyx_t_5) {
        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_5); __pyx_t_5 = NULL;
      }
      __Pyx_INCREF(__pyx_kp_u_play_sound_loop_set_sound_s_in_s_2);
      __Pyx_GIVEREF(__pyx_kp_u_play_sound_loop_set_sound_s_in_s_2);
      PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_4, __pyx_kp_u_play_sound_loop_set_sound_s_in_s_2);
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_4, __pyx_t_1);
      __pyx_t_1 = 0;
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 326, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    }
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "mpfmc/core/audio/track_sound_loop.pyx":328
 *             self.log.error("play_sound_loop_set - sound %s in sound_loop_set was "
 *                            "not loaded, could not play loop set", player_settings['sound'])
 *             return             # <<<<<<<<<<<<<<
 * 
 *         SDL_LockAudio()
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "mpfmc/core/audio/track_sound_loop.pyx":325
 *             return
 * 
 *         if not self.mc.sounds[player_settings['sound']].loaded:             # <<<<<<<<<<<<<<
 *             self.log.error("play_sound_loop_set - sound %s in sound_loop_set was "
 *                            "not loaded, could not play loop set", player_settings['sound'])
 */
  }

  /* "mpfmc/core/audio/track_sound_loop.pyx":330
 *             return
 * 
 *         SDL_LockAudio()             # <<<<<<<<<<<<<<
 * 
 *         # Create new player
 */
  SDL_LockAudio();

  /* "mpfmc/core/audio/track_sound_loop.pyx":333
 * 
 *         # Create new player
 *         player = <SoundLoopSetPlayer*>g_slice_alloc0(sizeof(SoundLoopSetPlayer))             # <<<<<<<<<<<<<<
 *         self._initialize_player(player)
 * 
 */
  __pyx_v_player = ((__pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopSetPlayer *)g_slice_alloc0((sizeof(__pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopSetPlayer))));

  /* "mpfmc/core/audio/track_sound_loop.pyx":334
 *         # Create new player
 *         player = <SoundLoopSetPlayer*>g_slice_alloc0(sizeof(SoundLoopSetPlayer))
 *         self._initialize_player(player)             # <<<<<<<<<<<<<<
 * 
 *         self._sound_loop_set_counter += 1
 */
  __pyx_t_2 = ((struct __pyx_vtabstruct_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *)__pyx_v_self->__pyx_base.__pyx_vtab)->_initialize_player(__pyx_v_self, __pyx_v_player); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 334, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "mpfmc/core/audio/track_sound_loop.pyx":336
 *         self._initialize_player(player)
 * 
 *         self._sound_loop_set_counter += 1             # <<<<<<<<<<<<<<
 * 
 *         # Assign sound loop settings
 */
  __pyx_v_self->_sound_loop_set_counter = (__pyx_v_self->_sound_loop_set_counter + 1);

  /* "mpfmc/core/audio/track_sound_loop.pyx":340
 *         # Assign sound loop settings
 *         master_layer_settings = {
 *             "sound_loop_set_id": self._sound_loop_set_counter,             # <<<<<<<<<<<<<<
 *             "sound": sound_loop_set['sound'],
 *             "volume": sound_loop_set['volume'],
 */
  __pyx_t_2 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 340, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_8 = __Pyx_PyInt_From_long(__pyx_v_self->_sound_loop_set_counter); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 340, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_u_sound_loop_set_id, __pyx_t_8) < 0) __PYX_ERR(0, 340, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "mpfmc/core/audio/track_sound_loop.pyx":341
 *         master_layer_settings = {
 *             "sound_loop_set_id": self._sound_loop_set_counter,
 *             "sound": sound_loop_set['sound'],             # <<<<<<<<<<<<<<
 *             "volume": sound_loop_set['volume'],
 *             "initial_state": "play"
 */
  __pyx_t_8 = __Pyx_PyDict_GetItem(__pyx_v_sound_loop_set, __pyx_n_u_sound); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 341, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_u_sound, __pyx_t_8) < 0) __PYX_ERR(0, 340, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "mpfmc/core/audio/track_sound_loop.pyx":342
 *             "sound_loop_set_id": self._sound_loop_set_counter,
 *             "sound": sound_loop_set['sound'],
 *             "volume": sound_loop_set['volume'],             # <<<<<<<<<<<<<<
 *             "initial_state": "play"
 *         }
 */
  __pyx_t_8 = __Pyx_PyDict_GetItem(__pyx_v_sound_loop_set, __pyx_n_u_volume); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 342, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_u_volume, __pyx_t_8) < 0) __PYX_ERR(0, 340, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_u_initial_state, __pyx_n_u_play) < 0) __PYX_ERR(0, 340, __pyx_L1_error)
  __pyx_v_master_layer_settings = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "mpfmc/core/audio/track_sound_loop.pyx":346
 *         }
 * 
 *         self._apply_layer_settings(&player.master_sound_layer, master_layer_settings)             # <<<<<<<<<<<<<<
 * 
 *         # Determine master sound length
 */
  __pyx_t_2 = ((struct __pyx_vtabstruct_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *)__pyx_v_self->__pyx_base.__pyx_vtab)->_apply_layer_settings(__pyx_v_self, (&__pyx_v_player->master_sound_layer), __pyx_v_master_layer_settings); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 346, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "mpfmc/core/audio/track_sound_loop.pyx":349
 * 
 *         # Determine master sound length
 *         if player.master_sound_layer.sound != NULL:             # <<<<<<<<<<<<<<
 *             player.length = <Uint32>player.master_sound_layer.sound.data.memory.size
 *             player.tempo = player_settings['tempo']
 */
  __pyx_t_7 = ((__pyx_v_player->master_sound_layer.sound != NULL) != 0);
  if (__pyx_t_7) {

    /* "mpfmc/core/audio/track_sound_loop.pyx":350
 *         # Determine master sound length
 *         if player.master_sound_layer.sound != NULL:
 *             player.length = <Uint32>player.master_sound_layer.sound.data.memory.size             # <<<<<<<<<<<<<<
 *             player.tempo = player_settings['tempo']
 *         else:
 */
    __pyx_v_player->length = ((Uint32)__pyx_v_player->master_sound_layer.sound->data.memory->size);

    /* "mpfmc/core/audio/track_sound_loop.pyx":351
 *         if player.master_sound_layer.sound != NULL:
 *             player.length = <Uint32>player.master_sound_layer.sound.data.memory.size
 *             player.tempo = player_settings['tempo']             # <<<<<<<<<<<<<<
 *         else:
 *             player.length = 0
 */
    if (unlikely(__pyx_v_player_settings == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(0, 351, __pyx_L1_error)
    }
    __pyx_t_2 = __Pyx_PyDict_GetItem(__pyx_v_player_settings, __pyx_n_u_tempo); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 351, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_9 = __pyx_PyFloat_AsFloat(__pyx_t_2); if (unlikely((__pyx_t_9 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 351, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_player->tempo = __pyx_t_9;

    /* "mpfmc/core/audio/track_sound_loop.pyx":349
 * 
 *         # Determine master sound length
 *         if player.master_sound_layer.sound != NULL:             # <<<<<<<<<<<<<<
 *             player.length = <Uint32>player.master_sound_layer.sound.data.memory.size
 *             player.tempo = player_settings['tempo']
 */
    goto __pyx_L6;
  }

  /* "mpfmc/core/audio/track_sound_loop.pyx":353
 *             player.tempo = player_settings['tempo']
 *         else:
 *             player.length = 0             # <<<<<<<<<<<<<<
 *             player.sample_pos = 0
 *             player.status = player_idle
 */
  /*else*/ {
    __pyx_v_player->length = 0;

    /* "mpfmc/core/audio/track_sound_loop.pyx":354
 *         else:
 *             player.length = 0
 *             player.sample_pos = 0             # <<<<<<<<<<<<<<
 *             player.status = player_idle
 *             g_slice_free1(sizeof(SoundLoopSetPlayer), player)
 */
    __pyx_v_player->sample_pos = 0;

    /* "mpfmc/core/audio/track_sound_loop.pyx":355
 *             player.length = 0
 *             player.sample_pos = 0
 *             player.status = player_idle             # <<<<<<<<<<<<<<
 *             g_slice_free1(sizeof(SoundLoopSetPlayer), player)
 *             SDL_UnlockAudio()
 */
    __pyx_v_player->status = __pyx_e_5mpfmc_4core_5audio_16track_sound_loop_player_idle;

    /* "mpfmc/core/audio/track_sound_loop.pyx":356
 *             player.sample_pos = 0
 *             player.status = player_idle
 *             g_slice_free1(sizeof(SoundLoopSetPlayer), player)             # <<<<<<<<<<<<<<
 *             SDL_UnlockAudio()
 *             return
 */
    g_slice_free1((sizeof(__pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopSetPlayer)), __pyx_v_player);

    /* "mpfmc/core/audio/track_sound_loop.pyx":357
 *             player.status = player_idle
 *             g_slice_free1(sizeof(SoundLoopSetPlayer), player)
 *             SDL_UnlockAudio()             # <<<<<<<<<<<<<<
 *             return
 * 
 */
    SDL_UnlockAudio();

    /* "mpfmc/core/audio/track_sound_loop.pyx":358
 *             g_slice_free1(sizeof(SoundLoopSetPlayer), player)
 *             SDL_UnlockAudio()
 *             return             # <<<<<<<<<<<<<<
 * 
 *         # Setup sound loop set layers
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;
  }
  __pyx_L6:;

  /* "mpfmc/core/audio/track_sound_loop.pyx":361
 * 
 *         # Setup sound loop set layers
 *         for layer_settings in sound_loop_set['layers']:             # <<<<<<<<<<<<<<
 *             layer = _create_sound_loop_layer_settings()
 *             self._apply_layer_settings(layer, layer_settings)
 */
  __pyx_t_2 = __Pyx_PyDict_GetItem(__pyx_v_sound_loop_set, __pyx_n_u_layers); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 361, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) {
    __pyx_t_8 = __pyx_t_2; __Pyx_INCREF(__pyx_t_8); __pyx_t_10 = 0;
    __pyx_t_11 = NULL;
  } else {
    __pyx_t_10 = -1; __pyx_t_8 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 361, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_11 = Py_TYPE(__pyx_t_8)->tp_iternext; if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 361, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  for (;;) {
    if (likely(!__pyx_t_11)) {
      if (likely(PyList_CheckExact(__pyx_t_8))) {
        if (__pyx_t_10 >= PyList_GET_SIZE(__pyx_t_8)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_2 = PyList_GET_ITEM(__pyx_t_8, __pyx_t_10); __Pyx_INCREF(__pyx_t_2); __pyx_t_10++; if (unlikely(0 < 0)) __PYX_ERR(0, 361, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_8, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 361, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      } else {
        if (__pyx_t_10 >= PyTuple_GET_SIZE(__pyx_t_8)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_8, __pyx_t_10); __Pyx_INCREF(__pyx_t_2); __pyx_t_10++; if (unlikely(0 < 0)) __PYX_ERR(0, 361, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_8, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 361, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      }
    } else {
      __pyx_t_2 = __pyx_t_11(__pyx_t_8);
      if (unlikely(!__pyx_t_2)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 361, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    __Pyx_XDECREF_SET(__pyx_v_layer_settings, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "mpfmc/core/audio/track_sound_loop.pyx":362
 *         # Setup sound loop set layers
 *         for layer_settings in sound_loop_set['layers']:
 *             layer = _create_sound_loop_layer_settings()             # <<<<<<<<<<<<<<
 *             self._apply_layer_settings(layer, layer_settings)
 * 
 */
    __pyx_v_layer = __pyx_f_5mpfmc_4core_5audio_16track_sound_loop__create_sound_loop_layer_settings();

    /* "mpfmc/core/audio/track_sound_loop.pyx":363
 *         for layer_settings in sound_loop_set['layers']:
 *             layer = _create_sound_loop_layer_settings()
 *             self._apply_layer_settings(layer, layer_settings)             # <<<<<<<<<<<<<<
 * 
 *             # Layer fading is only set by events using the sound_loop_player
 */
    if (!(likely(PyDict_CheckExact(__pyx_v_layer_settings))||((__pyx_v_layer_settings) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_v_layer_settings)->tp_name), 0))) __PYX_ERR(0, 363, __pyx_L1_error)
    __pyx_t_2 = ((struct __pyx_vtabstruct_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *)__pyx_v_self->__pyx_base.__pyx_vtab)->_apply_layer_settings(__pyx_v_self, __pyx_v_layer, ((PyObject*)__pyx_v_layer_settings)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 363, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "mpfmc/core/audio/track_sound_loop.pyx":366
 * 
 *             # Layer fading is only set by events using the sound_loop_player
 *             layer.fade_in_steps = 0             # <<<<<<<<<<<<<<
 *             layer.fade_out_steps = 0
 *             layer.fade_steps_remaining = 0
 */
    __pyx_v_layer->fade_in_steps = 0;

    /* "mpfmc/core/audio/track_sound_loop.pyx":367
 *             # Layer fading is only set by events using the sound_loop_player
 *             layer.fade_in_steps = 0
 *             layer.fade_out_steps = 0             # <<<<<<<<<<<<<<
 *             layer.fade_steps_remaining = 0
 * 
 */
    __pyx_v_layer->fade_out_steps = 0;

    /* "mpfmc/core/audio/track_sound_loop.pyx":368
 *             layer.fade_in_steps = 0
 *             layer.fade_out_steps = 0
 *             layer.fade_steps_remaining = 0             # <<<<<<<<<<<<<<
 * 
 *             # Append layer
 */
    __pyx_v_layer->fade_steps_remaining = 0;

    /* "mpfmc/core/audio/track_sound_loop.pyx":371
 * 
 *             # Append layer
 *             player.layers = g_slist_append(player.layers, layer)             # <<<<<<<<<<<<<<
 * 
 *         # Calculate fading (done at control rate; need to calculate the number of steps over which to fade in/out)
 */
    __pyx_v_player->layers = g_slist_append(__pyx_v_player->layers, __pyx_v_layer);

    /* "mpfmc/core/audio/track_sound_loop.pyx":361
 * 
 *         # Setup sound loop set layers
 *         for layer_settings in sound_loop_set['layers']:             # <<<<<<<<<<<<<<
 *             layer = _create_sound_loop_layer_settings()
 *             self._apply_layer_settings(layer, layer_settings)
 */
  }
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "mpfmc/core/audio/track_sound_loop.pyx":374
 * 
 *         # Calculate fading (done at control rate; need to calculate the number of steps over which to fade in/out)
 *         player.master_sound_layer.fade_in_steps = player_settings['fade_in'] * self.state.callback_data.seconds_to_bytes_factor // self.state.callback_data.bytes_per_control_point             # <<<<<<<<<<<<<<
 *         player.master_sound_layer.fade_out_steps = player_settings['fade_out'] * self.state.callback_data.seconds_to_bytes_factor // self.state.callback_data.bytes_per_control_point
 *         player.master_sound_layer.fade_steps_remaining = player.master_sound_layer.fade_in_steps
 */
  if (unlikely(__pyx_v_player_settings == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 374, __pyx_L1_error)
  }
  __pyx_t_8 = __Pyx_PyDict_GetItem(__pyx_v_player_settings, __pyx_n_u_fade_in); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 374, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_2 = PyFloat_FromDouble(__pyx_v_self->__pyx_base.state->callback_data->seconds_to_bytes_factor); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 374, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyNumber_Multiply(__pyx_t_8, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 374, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyInt_From_Uint16(__pyx_v_self->__pyx_base.state->callback_data->bytes_per_control_point); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 374, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_8 = PyNumber_FloorDivide(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 374, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_12 = __Pyx_PyInt_As_Uint32(__pyx_t_8); if (unlikely((__pyx_t_12 == ((Uint32)-1)) && PyErr_Occurred())) __PYX_ERR(0, 374, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_v_player->master_sound_layer.fade_in_steps = __pyx_t_12;

  /* "mpfmc/core/audio/track_sound_loop.pyx":375
 *         # Calculate fading (done at control rate; need to calculate the number of steps over which to fade in/out)
 *         player.master_sound_layer.fade_in_steps = player_settings['fade_in'] * self.state.callback_data.seconds_to_bytes_factor // self.state.callback_data.bytes_per_control_point
 *         player.master_sound_layer.fade_out_steps = player_settings['fade_out'] * self.state.callback_data.seconds_to_bytes_factor // self.state.callback_data.bytes_per_control_point             # <<<<<<<<<<<<<<
 *         player.master_sound_layer.fade_steps_remaining = player.master_sound_layer.fade_in_steps
 * 
 */
  if (unlikely(__pyx_v_player_settings == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 375, __pyx_L1_error)
  }
  __pyx_t_8 = __Pyx_PyDict_GetItem(__pyx_v_player_settings, __pyx_n_u_fade_out); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 375, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_2 = PyFloat_FromDouble(__pyx_v_self->__pyx_base.state->callback_data->seconds_to_bytes_factor); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 375, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyNumber_Multiply(__pyx_t_8, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 375, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyInt_From_Uint16(__pyx_v_self->__pyx_base.state->callback_data->bytes_per_control_point); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 375, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_8 = PyNumber_FloorDivide(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 375, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_12 = __Pyx_PyInt_As_Uint32(__pyx_t_8); if (unlikely((__pyx_t_12 == ((Uint32)-1)) && PyErr_Occurred())) __PYX_ERR(0, 375, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_v_player->master_sound_layer.fade_out_steps = __pyx_t_12;

  /* "mpfmc/core/audio/track_sound_loop.pyx":376
 *         player.master_sound_layer.fade_in_steps = player_settings['fade_in'] * self.state.callback_data.seconds_to_bytes_factor // self.state.callback_data.bytes_per_control_point
 *         player.master_sound_layer.fade_out_steps = player_settings['fade_out'] * self.state.callback_data.seconds_to_bytes_factor // self.state.callback_data.bytes_per_control_point
 *         player.master_sound_layer.fade_steps_remaining = player.master_sound_layer.fade_in_steps             # <<<<<<<<<<<<<<
 * 
 *         # Determine if there are any other active players
 */
  __pyx_t_12 = __pyx_v_player->master_sound_layer.fade_in_steps;
  __pyx_v_player->master_sound_layer.fade_steps_remaining = __pyx_t_12;

  /* "mpfmc/core/audio/track_sound_loop.pyx":379
 * 
 *         # Determine if there are any other active players
 *         if self.type_state.players != NULL:             # <<<<<<<<<<<<<<
 *             iterator = self.type_state.players
 *             while iterator != NULL:
 */
  __pyx_t_7 = ((__pyx_v_self->type_state->players != NULL) != 0);
  if (__pyx_t_7) {

    /* "mpfmc/core/audio/track_sound_loop.pyx":380
 *         # Determine if there are any other active players
 *         if self.type_state.players != NULL:
 *             iterator = self.type_state.players             # <<<<<<<<<<<<<<
 *             while iterator != NULL:
 *                 existing_player = <SoundLoopSetPlayer*>iterator.data
 */
    __pyx_t_13 = __pyx_v_self->type_state->players;
    __pyx_v_iterator = __pyx_t_13;

    /* "mpfmc/core/audio/track_sound_loop.pyx":381
 *         if self.type_state.players != NULL:
 *             iterator = self.type_state.players
 *             while iterator != NULL:             # <<<<<<<<<<<<<<
 *                 existing_player = <SoundLoopSetPlayer*>iterator.data
 *                 if existing_player != NULL and existing_player.status != player_idle:
 */
    while (1) {
      __pyx_t_7 = ((__pyx_v_iterator != NULL) != 0);
      if (!__pyx_t_7) break;

      /* "mpfmc/core/audio/track_sound_loop.pyx":382
 *             iterator = self.type_state.players
 *             while iterator != NULL:
 *                 existing_player = <SoundLoopSetPlayer*>iterator.data             # <<<<<<<<<<<<<<
 *                 if existing_player != NULL and existing_player.status != player_idle:
 *                     player_already_playing = True
 */
      __pyx_v_existing_player = ((__pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopSetPlayer *)__pyx_v_iterator->data);

      /* "mpfmc/core/audio/track_sound_loop.pyx":383
 *             while iterator != NULL:
 *                 existing_player = <SoundLoopSetPlayer*>iterator.data
 *                 if existing_player != NULL and existing_player.status != player_idle:             # <<<<<<<<<<<<<<
 *                     player_already_playing = True
 *                     break
 */
      __pyx_t_6 = ((__pyx_v_existing_player != NULL) != 0);
      if (__pyx_t_6) {
      } else {
        __pyx_t_7 = __pyx_t_6;
        goto __pyx_L13_bool_binop_done;
      }
      __pyx_t_6 = ((__pyx_v_existing_player->status != __pyx_e_5mpfmc_4core_5audio_16track_sound_loop_player_idle) != 0);
      __pyx_t_7 = __pyx_t_6;
      __pyx_L13_bool_binop_done:;
      if (__pyx_t_7) {

        /* "mpfmc/core/audio/track_sound_loop.pyx":384
 *                 existing_player = <SoundLoopSetPlayer*>iterator.data
 *                 if existing_player != NULL and existing_player.status != player_idle:
 *                     player_already_playing = True             # <<<<<<<<<<<<<<
 *                     break
 *                 iterator = iterator.next
 */
        __pyx_v_player_already_playing = 1;

        /* "mpfmc/core/audio/track_sound_loop.pyx":385
 *                 if existing_player != NULL and existing_player.status != player_idle:
 *                     player_already_playing = True
 *                     break             # <<<<<<<<<<<<<<
 *                 iterator = iterator.next
 * 
 */
        goto __pyx_L11_break;

        /* "mpfmc/core/audio/track_sound_loop.pyx":383
 *             while iterator != NULL:
 *                 existing_player = <SoundLoopSetPlayer*>iterator.data
 *                 if existing_player != NULL and existing_player.status != player_idle:             # <<<<<<<<<<<<<<
 *                     player_already_playing = True
 *                     break
 */
      }

      /* "mpfmc/core/audio/track_sound_loop.pyx":386
 *                     player_already_playing = True
 *                     break
 *                 iterator = iterator.next             # <<<<<<<<<<<<<<
 * 
 *         if player_already_playing and self.type_state.current != NULL:
 */
      __pyx_t_13 = __pyx_v_iterator->next;
      __pyx_v_iterator = __pyx_t_13;
    }
    __pyx_L11_break:;

    /* "mpfmc/core/audio/track_sound_loop.pyx":379
 * 
 *         # Determine if there are any other active players
 *         if self.type_state.players != NULL:             # <<<<<<<<<<<<<<
 *             iterator = self.type_state.players
 *             while iterator != NULL:
 */
  }

  /* "mpfmc/core/audio/track_sound_loop.pyx":388
 *                 iterator = iterator.next
 * 
 *         if player_already_playing and self.type_state.current != NULL:             # <<<<<<<<<<<<<<
 * 
 *             # Determine if playing immediately or queuing until next loop
 */
  __pyx_t_6 = (__pyx_v_player_already_playing != 0);
  if (__pyx_t_6) {
  } else {
    __pyx_t_7 = __pyx_t_6;
    goto __pyx_L16_bool_binop_done;
  }
  __pyx_t_6 = ((__pyx_v_self->type_state->current != NULL) != 0);
  __pyx_t_7 = __pyx_t_6;
  __pyx_L16_bool_binop_done:;
  if (__pyx_t_7) {

    /* "mpfmc/core/audio/track_sound_loop.pyx":391
 * 
 *             # Determine if playing immediately or queuing until next loop
 *             if player_settings['timing'] == 'loop_end':             # <<<<<<<<<<<<<<
 *                 # Queue until the end of the current loop
 *                 player.status = player_delayed
 */
    if (unlikely(__pyx_v_player_settings == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(0, 391, __pyx_L1_error)
    }
    __pyx_t_8 = __Pyx_PyDict_GetItem(__pyx_v_player_settings, __pyx_n_u_timing); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 391, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_7 = (__Pyx_PyUnicode_Equals(__pyx_t_8, __pyx_n_u_loop_end, Py_EQ)); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 391, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (__pyx_t_7) {

      /* "mpfmc/core/audio/track_sound_loop.pyx":393
 *             if player_settings['timing'] == 'loop_end':
 *                 # Queue until the end of the current loop
 *                 player.status = player_delayed             # <<<<<<<<<<<<<<
 * 
 *                 # Ensure sample position starts on a sample frame boundary (audio distortion may occur if starting
 */
      __pyx_v_player->status = __pyx_e_5mpfmc_4core_5audio_16track_sound_loop_player_delayed;

      /* "mpfmc/core/audio/track_sound_loop.pyx":397
 *                 # Ensure sample position starts on a sample frame boundary (audio distortion may occur if starting
 *                 # in the middle of a sample frame)
 *                 bytes_per_sample_frame = self.state.callback_data.bytes_per_sample * self.state.callback_data.channels             # <<<<<<<<<<<<<<
 *                 player.sample_pos = bytes_per_sample_frame * ceil(player.sample_pos / bytes_per_sample_frame)
 * 
 */
      __pyx_v_bytes_per_sample_frame = (__pyx_v_self->__pyx_base.state->callback_data->bytes_per_sample * __pyx_v_self->__pyx_base.state->callback_data->channels);

      /* "mpfmc/core/audio/track_sound_loop.pyx":398
 *                 # in the middle of a sample frame)
 *                 bytes_per_sample_frame = self.state.callback_data.bytes_per_sample * self.state.callback_data.channels
 *                 player.sample_pos = bytes_per_sample_frame * ceil(player.sample_pos / bytes_per_sample_frame)             # <<<<<<<<<<<<<<
 * 
 *                 self.type_state.current.stop_loop_samples_remaining = self.type_state.current.length - self.type_state.current.sample_pos
 */
      __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_bytes_per_sample_frame); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 398, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_ceil); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 398, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      if (unlikely(__pyx_v_bytes_per_sample_frame == 0)) {
        PyErr_SetString(PyExc_ZeroDivisionError, "float division");
        __PYX_ERR(0, 398, __pyx_L1_error)
      }
      __pyx_t_1 = PyFloat_FromDouble((((double)__pyx_v_player->sample_pos) / ((double)__pyx_v_bytes_per_sample_frame))); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 398, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_5 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      __pyx_t_2 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_5, __pyx_t_1) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_1);
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 398, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = PyNumber_Multiply(__pyx_t_8, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 398, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_12 = __Pyx_PyInt_As_Uint32(__pyx_t_3); if (unlikely((__pyx_t_12 == ((Uint32)-1)) && PyErr_Occurred())) __PYX_ERR(0, 398, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_v_player->sample_pos = __pyx_t_12;

      /* "mpfmc/core/audio/track_sound_loop.pyx":400
 *                 player.sample_pos = bytes_per_sample_frame * ceil(player.sample_pos / bytes_per_sample_frame)
 * 
 *                 self.type_state.current.stop_loop_samples_remaining = self.type_state.current.length - self.type_state.current.sample_pos             # <<<<<<<<<<<<<<
 *                 player.start_delay_samples_remaining = self.type_state.current.stop_loop_samples_remaining
 * 
 */
      __pyx_v_self->type_state->current->stop_loop_samples_remaining = (__pyx_v_self->type_state->current->length - __pyx_v_self->type_state->current->sample_pos);

      /* "mpfmc/core/audio/track_sound_loop.pyx":401
 * 
 *                 self.type_state.current.stop_loop_samples_remaining = self.type_state.current.length - self.type_state.current.sample_pos
 *                 player.start_delay_samples_remaining = self.type_state.current.stop_loop_samples_remaining             # <<<<<<<<<<<<<<
 * 
 *             elif player_settings['timing'] == 'next_time_interval':
 */
      __pyx_t_12 = __pyx_v_self->type_state->current->stop_loop_samples_remaining;
      __pyx_v_player->start_delay_samples_remaining = __pyx_t_12;

      /* "mpfmc/core/audio/track_sound_loop.pyx":391
 * 
 *             # Determine if playing immediately or queuing until next loop
 *             if player_settings['timing'] == 'loop_end':             # <<<<<<<<<<<<<<
 *                 # Queue until the end of the current loop
 *                 player.status = player_delayed
 */
      goto __pyx_L18;
    }

    /* "mpfmc/core/audio/track_sound_loop.pyx":403
 *                 player.start_delay_samples_remaining = self.type_state.current.stop_loop_samples_remaining
 * 
 *             elif player_settings['timing'] == 'next_time_interval':             # <<<<<<<<<<<<<<
 *                 # Set currently playing sample to end at the next specified time interval multiple
 *                 player.status = player_delayed
 */
    if (unlikely(__pyx_v_player_settings == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(0, 403, __pyx_L1_error)
    }
    __pyx_t_3 = __Pyx_PyDict_GetItem(__pyx_v_player_settings, __pyx_n_u_timing); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 403, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_7 = (__Pyx_PyUnicode_Equals(__pyx_t_3, __pyx_n_u_next_time_interval, Py_EQ)); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 403, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (__pyx_t_7) {

      /* "mpfmc/core/audio/track_sound_loop.pyx":405
 *             elif player_settings['timing'] == 'next_time_interval':
 *                 # Set currently playing sample to end at the next specified time interval multiple
 *                 player.status = player_delayed             # <<<<<<<<<<<<<<
 * 
 *                 self.type_state.current.stop_loop_samples_remaining = self._round_sample_pos_up_to_interval(
 */
      __pyx_v_player->status = __pyx_e_5mpfmc_4core_5audio_16track_sound_loop_player_delayed;

      /* "mpfmc/core/audio/track_sound_loop.pyx":409
 *                 self.type_state.current.stop_loop_samples_remaining = self._round_sample_pos_up_to_interval(
 *                     self.type_state.current.sample_pos,
 *                     <Uint32> (self.state.callback_data.seconds_to_bytes_factor * player_settings['interval']),             # <<<<<<<<<<<<<<
 *                     self.state.callback_data.bytes_per_sample * self.state.callback_data.channels) - self.type_state.current.sample_pos
 * 
 */
      __pyx_t_3 = PyFloat_FromDouble(__pyx_v_self->__pyx_base.state->callback_data->seconds_to_bytes_factor); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 409, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      if (unlikely(__pyx_v_player_settings == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        __PYX_ERR(0, 409, __pyx_L1_error)
      }
      __pyx_t_2 = __Pyx_PyDict_GetItem(__pyx_v_player_settings, __pyx_n_u_interval); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 409, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_8 = PyNumber_Multiply(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 409, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_12 = __Pyx_PyInt_As_Uint32(__pyx_t_8); if (unlikely((__pyx_t_12 == ((Uint32)-1)) && PyErr_Occurred())) __PYX_ERR(0, 409, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

      /* "mpfmc/core/audio/track_sound_loop.pyx":407
 *                 player.status = player_delayed
 * 
 *                 self.type_state.current.stop_loop_samples_remaining = self._round_sample_pos_up_to_interval(             # <<<<<<<<<<<<<<
 *                     self.type_state.current.sample_pos,
 *                     <Uint32> (self.state.callback_data.seconds_to_bytes_factor * player_settings['interval']),
 */
      __pyx_v_self->type_state->current->stop_loop_samples_remaining = (__pyx_f_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop__round_sample_pos_up_to_interval(__pyx_v_self, __pyx_v_self->type_state->current->sample_pos, ((Uint32)__pyx_t_12), (__pyx_v_self->__pyx_base.state->callback_data->bytes_per_sample * __pyx_v_self->__pyx_base.state->callback_data->channels)) - __pyx_v_self->type_state->current->sample_pos);

      /* "mpfmc/core/audio/track_sound_loop.pyx":412
 *                     self.state.callback_data.bytes_per_sample * self.state.callback_data.channels) - self.type_state.current.sample_pos
 * 
 *                 player.start_delay_samples_remaining = self.type_state.current.stop_loop_samples_remaining             # <<<<<<<<<<<<<<
 * 
 *             elif player_settings['timing'] == 'next_beat_interval':
 */
      __pyx_t_12 = __pyx_v_self->type_state->current->stop_loop_samples_remaining;
      __pyx_v_player->start_delay_samples_remaining = __pyx_t_12;

      /* "mpfmc/core/audio/track_sound_loop.pyx":403
 *                 player.start_delay_samples_remaining = self.type_state.current.stop_loop_samples_remaining
 * 
 *             elif player_settings['timing'] == 'next_time_interval':             # <<<<<<<<<<<<<<
 *                 # Set currently playing sample to end at the next specified time interval multiple
 *                 player.status = player_delayed
 */
      goto __pyx_L18;
    }

    /* "mpfmc/core/audio/track_sound_loop.pyx":414
 *                 player.start_delay_samples_remaining = self.type_state.current.stop_loop_samples_remaining
 * 
 *             elif player_settings['timing'] == 'next_beat_interval':             # <<<<<<<<<<<<<<
 *                 # Set currently playing sample to end at the next specified beat interval multiple
 *                 player.status = player_delayed
 */
    if (unlikely(__pyx_v_player_settings == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(0, 414, __pyx_L1_error)
    }
    __pyx_t_8 = __Pyx_PyDict_GetItem(__pyx_v_player_settings, __pyx_n_u_timing); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 414, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_7 = (__Pyx_PyUnicode_Equals(__pyx_t_8, __pyx_n_u_next_beat_interval, Py_EQ)); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 414, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (__pyx_t_7) {

      /* "mpfmc/core/audio/track_sound_loop.pyx":416
 *             elif player_settings['timing'] == 'next_beat_interval':
 *                 # Set currently playing sample to end at the next specified beat interval multiple
 *                 player.status = player_delayed             # <<<<<<<<<<<<<<
 * 
 *                 self.type_state.current.stop_loop_samples_remaining = self._round_sample_pos_up_to_interval(
 */
      __pyx_v_player->status = __pyx_e_5mpfmc_4core_5audio_16track_sound_loop_player_delayed;

      /* "mpfmc/core/audio/track_sound_loop.pyx":420
 *                 self.type_state.current.stop_loop_samples_remaining = self._round_sample_pos_up_to_interval(
 *                     self.type_state.current.sample_pos,
 *                     <Uint32> (self.state.callback_data.seconds_to_bytes_factor * (             # <<<<<<<<<<<<<<
 *                             player_settings['interval'] * 60.0 / self.type_state.current.tempo)),
 *                     self.state.callback_data.bytes_per_sample * self.state.callback_data.channels) - self.type_state.current.sample_pos
 */
      __pyx_t_8 = PyFloat_FromDouble(__pyx_v_self->__pyx_base.state->callback_data->seconds_to_bytes_factor); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 420, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);

      /* "mpfmc/core/audio/track_sound_loop.pyx":421
 *                     self.type_state.current.sample_pos,
 *                     <Uint32> (self.state.callback_data.seconds_to_bytes_factor * (
 *                             player_settings['interval'] * 60.0 / self.type_state.current.tempo)),             # <<<<<<<<<<<<<<
 *                     self.state.callback_data.bytes_per_sample * self.state.callback_data.channels) - self.type_state.current.sample_pos
 * 
 */
      if (unlikely(__pyx_v_player_settings == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        __PYX_ERR(0, 421, __pyx_L1_error)
      }
      __pyx_t_2 = __Pyx_PyDict_GetItem(__pyx_v_player_settings, __pyx_n_u_interval); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 421, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = PyNumber_Multiply(__pyx_t_2, __pyx_float_60_0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 421, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = PyFloat_FromDouble(__pyx_v_self->type_state->current->tempo); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 421, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = __Pyx_PyNumber_Divide(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 421, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "mpfmc/core/audio/track_sound_loop.pyx":420
 *                 self.type_state.current.stop_loop_samples_remaining = self._round_sample_pos_up_to_interval(
 *                     self.type_state.current.sample_pos,
 *                     <Uint32> (self.state.callback_data.seconds_to_bytes_factor * (             # <<<<<<<<<<<<<<
 *                             player_settings['interval'] * 60.0 / self.type_state.current.tempo)),
 *                     self.state.callback_data.bytes_per_sample * self.state.callback_data.channels) - self.type_state.current.sample_pos
 */
      __pyx_t_2 = PyNumber_Multiply(__pyx_t_8, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 420, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_12 = __Pyx_PyInt_As_Uint32(__pyx_t_2); if (unlikely((__pyx_t_12 == ((Uint32)-1)) && PyErr_Occurred())) __PYX_ERR(0, 420, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "mpfmc/core/audio/track_sound_loop.pyx":418
 *                 player.status = player_delayed
 * 
 *                 self.type_state.current.stop_loop_samples_remaining = self._round_sample_pos_up_to_interval(             # <<<<<<<<<<<<<<
 *                     self.type_state.current.sample_pos,
 *                     <Uint32> (self.state.callback_data.seconds_to_bytes_factor * (
 */
      __pyx_v_self->type_state->current->stop_loop_samples_remaining = (__pyx_f_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop__round_sample_pos_up_to_interval(__pyx_v_self, __pyx_v_self->type_state->current->sample_pos, ((Uint32)__pyx_t_12), (__pyx_v_self->__pyx_base.state->callback_data->bytes_per_sample * __pyx_v_self->__pyx_base.state->callback_data->channels)) - __pyx_v_self->type_state->current->sample_pos);

      /* "mpfmc/core/audio/track_sound_loop.pyx":424
 *                     self.state.callback_data.bytes_per_sample * self.state.callback_data.channels) - self.type_state.current.sample_pos
 * 
 *                 player.start_delay_samples_remaining = self.type_state.current.stop_loop_samples_remaining             # <<<<<<<<<<<<<<
 * 
 *             else:
 */
      __pyx_t_12 = __pyx_v_self->type_state->current->stop_loop_samples_remaining;
      __pyx_v_player->start_delay_samples_remaining = __pyx_t_12;

      /* "mpfmc/core/audio/track_sound_loop.pyx":414
 *                 player.start_delay_samples_remaining = self.type_state.current.stop_loop_samples_remaining
 * 
 *             elif player_settings['timing'] == 'next_beat_interval':             # <<<<<<<<<<<<<<
 *                 # Set currently playing sample to end at the next specified beat interval multiple
 *                 player.status = player_delayed
 */
      goto __pyx_L18;
    }

    /* "mpfmc/core/audio/track_sound_loop.pyx":428
 *             else:
 *                 # 'timing' == 'now'
 *                 player.status = player_playing             # <<<<<<<<<<<<<<
 * 
 *                 # If no fade is set, use a quick fade-in
 */
    /*else*/ {
      __pyx_v_player->status = __pyx_e_5mpfmc_4core_5audio_16track_sound_loop_player_playing;

      /* "mpfmc/core/audio/track_sound_loop.pyx":432
 *                 # If no fade is set, use a quick fade-in
 *                 # (avoids pops & clicks)
 *                 if player.master_sound_layer.fade_steps_remaining == 0:             # <<<<<<<<<<<<<<
 *                     player.master_sound_layer.fade_in_steps = self.state.callback_data.quick_fade_steps
 *                     player.master_sound_layer.fade_steps_remaining = player.master_sound_layer.fade_in_steps
 */
      __pyx_t_7 = ((__pyx_v_player->master_sound_layer.fade_steps_remaining == 0) != 0);
      if (__pyx_t_7) {

        /* "mpfmc/core/audio/track_sound_loop.pyx":433
 *                 # (avoids pops & clicks)
 *                 if player.master_sound_layer.fade_steps_remaining == 0:
 *                     player.master_sound_layer.fade_in_steps = self.state.callback_data.quick_fade_steps             # <<<<<<<<<<<<<<
 *                     player.master_sound_layer.fade_steps_remaining = player.master_sound_layer.fade_in_steps
 * 
 */
        __pyx_t_14 = __pyx_v_self->__pyx_base.state->callback_data->quick_fade_steps;
        __pyx_v_player->master_sound_layer.fade_in_steps = __pyx_t_14;

        /* "mpfmc/core/audio/track_sound_loop.pyx":434
 *                 if player.master_sound_layer.fade_steps_remaining == 0:
 *                     player.master_sound_layer.fade_in_steps = self.state.callback_data.quick_fade_steps
 *                     player.master_sound_layer.fade_steps_remaining = player.master_sound_layer.fade_in_steps             # <<<<<<<<<<<<<<
 * 
 *                 if player.master_sound_layer.fade_steps_remaining > 0:
 */
        __pyx_t_12 = __pyx_v_player->master_sound_layer.fade_in_steps;
        __pyx_v_player->master_sound_layer.fade_steps_remaining = __pyx_t_12;

        /* "mpfmc/core/audio/track_sound_loop.pyx":432
 *                 # If no fade is set, use a quick fade-in
 *                 # (avoids pops & clicks)
 *                 if player.master_sound_layer.fade_steps_remaining == 0:             # <<<<<<<<<<<<<<
 *                     player.master_sound_layer.fade_in_steps = self.state.callback_data.quick_fade_steps
 *                     player.master_sound_layer.fade_steps_remaining = player.master_sound_layer.fade_in_steps
 */
      }

      /* "mpfmc/core/audio/track_sound_loop.pyx":436
 *                     player.master_sound_layer.fade_steps_remaining = player.master_sound_layer.fade_in_steps
 * 
 *                 if player.master_sound_layer.fade_steps_remaining > 0:             # <<<<<<<<<<<<<<
 *                     player.status = player_fading_in
 *                     self._fade_out_all_players(player.master_sound_layer.fade_in_steps)
 */
      __pyx_t_7 = ((__pyx_v_player->master_sound_layer.fade_steps_remaining > 0) != 0);
      if (__pyx_t_7) {

        /* "mpfmc/core/audio/track_sound_loop.pyx":437
 * 
 *                 if player.master_sound_layer.fade_steps_remaining > 0:
 *                     player.status = player_fading_in             # <<<<<<<<<<<<<<
 *                     self._fade_out_all_players(player.master_sound_layer.fade_in_steps)
 *                     # TODO: Should layers fade out as well? (Probably)
 */
        __pyx_v_player->status = __pyx_e_5mpfmc_4core_5audio_16track_sound_loop_player_fading_in;

        /* "mpfmc/core/audio/track_sound_loop.pyx":438
 *                 if player.master_sound_layer.fade_steps_remaining > 0:
 *                     player.status = player_fading_in
 *                     self._fade_out_all_players(player.master_sound_layer.fade_in_steps)             # <<<<<<<<<<<<<<
 *                     # TODO: Should layers fade out as well? (Probably)
 * 
 */
        __pyx_t_2 = ((struct __pyx_vtabstruct_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *)__pyx_v_self->__pyx_base.__pyx_vtab)->_fade_out_all_players(__pyx_v_self, __pyx_v_player->master_sound_layer.fade_in_steps); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 438, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

        /* "mpfmc/core/audio/track_sound_loop.pyx":436
 *                     player.master_sound_layer.fade_steps_remaining = player.master_sound_layer.fade_in_steps
 * 
 *                 if player.master_sound_layer.fade_steps_remaining > 0:             # <<<<<<<<<<<<<<
 *                     player.status = player_fading_in
 *                     self._fade_out_all_players(player.master_sound_layer.fade_in_steps)
 */
      }
    }
    __pyx_L18:;

    /* "mpfmc/core/audio/track_sound_loop.pyx":442
 * 
 *             # Cancel and remove all existing delayed players
 *             self._cancel_all_delayed_players()             # <<<<<<<<<<<<<<
 * 
 *             if player_settings['synchronize']:
 */
    __pyx_t_2 = ((struct __pyx_vtabstruct_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *)__pyx_v_self->__pyx_base.__pyx_vtab)->_cancel_all_delayed_players(__pyx_v_self); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 442, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "mpfmc/core/audio/track_sound_loop.pyx":444
 *             self._cancel_all_delayed_players()
 * 
 *             if player_settings['synchronize']:             # <<<<<<<<<<<<<<
 *                 player.sample_pos = self.type_state.current.sample_pos + self.type_state.current.stop_loop_samples_remaining
 * 
 */
    if (unlikely(__pyx_v_player_settings == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(0, 444, __pyx_L1_error)
    }
    __pyx_t_2 = __Pyx_PyDict_GetItem(__pyx_v_player_settings, __pyx_n_u_synchronize); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 444, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 444, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (__pyx_t_7) {

      /* "mpfmc/core/audio/track_sound_loop.pyx":445
 * 
 *             if player_settings['synchronize']:
 *                 player.sample_pos = self.type_state.current.sample_pos + self.type_state.current.stop_loop_samples_remaining             # <<<<<<<<<<<<<<
 * 
 *                 # Adjust sample position to within sample boundaries of synchronized loop
 */
      __pyx_v_player->sample_pos = (__pyx_v_self->type_state->current->sample_pos + __pyx_v_self->type_state->current->stop_loop_samples_remaining);

      /* "mpfmc/core/audio/track_sound_loop.pyx":448
 * 
 *                 # Adjust sample position to within sample boundaries of synchronized loop
 *                 while player.sample_pos > self.type_state.current.length:             # <<<<<<<<<<<<<<
 *                     player.sample_pos -= self.type_state.current.length
 *             else:
 */
      while (1) {
        __pyx_t_7 = ((__pyx_v_player->sample_pos > __pyx_v_self->type_state->current->length) != 0);
        if (!__pyx_t_7) break;

        /* "mpfmc/core/audio/track_sound_loop.pyx":449
 *                 # Adjust sample position to within sample boundaries of synchronized loop
 *                 while player.sample_pos > self.type_state.current.length:
 *                     player.sample_pos -= self.type_state.current.length             # <<<<<<<<<<<<<<
 *             else:
 *                 player.sample_pos = player_settings['start_at'] * self.state.callback_data.seconds_to_bytes_factor
 */
        __pyx_v_player->sample_pos = (__pyx_v_player->sample_pos - __pyx_v_self->type_state->current->length);
      }

      /* "mpfmc/core/audio/track_sound_loop.pyx":444
 *             self._cancel_all_delayed_players()
 * 
 *             if player_settings['synchronize']:             # <<<<<<<<<<<<<<
 *                 player.sample_pos = self.type_state.current.sample_pos + self.type_state.current.stop_loop_samples_remaining
 * 
 */
      goto __pyx_L21;
    }

    /* "mpfmc/core/audio/track_sound_loop.pyx":451
 *                     player.sample_pos -= self.type_state.current.length
 *             else:
 *                 player.sample_pos = player_settings['start_at'] * self.state.callback_data.seconds_to_bytes_factor             # <<<<<<<<<<<<<<
 * 
 *         else:
 */
    /*else*/ {
      if (unlikely(__pyx_v_player_settings == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        __PYX_ERR(0, 451, __pyx_L1_error)
      }
      __pyx_t_2 = __Pyx_PyDict_GetItem(__pyx_v_player_settings, __pyx_n_u_start_at); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 451, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->__pyx_base.state->callback_data->seconds_to_bytes_factor); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 451, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_8 = PyNumber_Multiply(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 451, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_12 = __Pyx_PyInt_As_Uint32(__pyx_t_8); if (unlikely((__pyx_t_12 == ((Uint32)-1)) && PyErr_Occurred())) __PYX_ERR(0, 451, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_v_player->sample_pos = __pyx_t_12;
    }
    __pyx_L21:;

    /* "mpfmc/core/audio/track_sound_loop.pyx":388
 *                 iterator = iterator.next
 * 
 *         if player_already_playing and self.type_state.current != NULL:             # <<<<<<<<<<<<<<
 * 
 *             # Determine if playing immediately or queuing until next loop
 */
    goto __pyx_L15;
  }

  /* "mpfmc/core/audio/track_sound_loop.pyx":456
 *             # 'timing' value is ignored when there are no other sound loops playing (playback
 *             # begins right away)
 *             player.master_sound_layer.fade_steps_remaining = 0             # <<<<<<<<<<<<<<
 *             player.sample_pos = player_settings['start_at'] * self.state.callback_data.seconds_to_bytes_factor
 *             player.status = player_playing
 */
  /*else*/ {
    __pyx_v_player->master_sound_layer.fade_steps_remaining = 0;

    /* "mpfmc/core/audio/track_sound_loop.pyx":457
 *             # begins right away)
 *             player.master_sound_layer.fade_steps_remaining = 0
 *             player.sample_pos = player_settings['start_at'] * self.state.callback_data.seconds_to_bytes_factor             # <<<<<<<<<<<<<<
 *             player.status = player_playing
 * 
 */
    if (unlikely(__pyx_v_player_settings == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(0, 457, __pyx_L1_error)
    }
    __pyx_t_8 = __Pyx_PyDict_GetItem(__pyx_v_player_settings, __pyx_n_u_start_at); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 457, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->__pyx_base.state->callback_data->seconds_to_bytes_factor); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 457, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyNumber_Multiply(__pyx_t_8, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 457, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_12 = __Pyx_PyInt_As_Uint32(__pyx_t_2); if (unlikely((__pyx_t_12 == ((Uint32)-1)) && PyErr_Occurred())) __PYX_ERR(0, 457, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_player->sample_pos = __pyx_t_12;

    /* "mpfmc/core/audio/track_sound_loop.pyx":458
 *             player.master_sound_layer.fade_steps_remaining = 0
 *             player.sample_pos = player_settings['start_at'] * self.state.callback_data.seconds_to_bytes_factor
 *             player.status = player_playing             # <<<<<<<<<<<<<<
 * 
 *         # Ensure sample position starts on a sample frame boundary (audio distortion may occur if starting
 */
    __pyx_v_player->status = __pyx_e_5mpfmc_4core_5audio_16track_sound_loop_player_playing;
  }
  __pyx_L15:;

  /* "mpfmc/core/audio/track_sound_loop.pyx":462
 *         # Ensure sample position starts on a sample frame boundary (audio distortion may occur if starting
 *         # in the middle of a sample frame)
 *         bytes_per_sample_frame = self.state.callback_data.bytes_per_sample * self.state.callback_data.channels             # <<<<<<<<<<<<<<
 *         player.sample_pos = bytes_per_sample_frame * ceil(player.sample_pos / bytes_per_sample_frame)
 * 
 */
  __pyx_v_bytes_per_sample_frame = (__pyx_v_self->__pyx_base.state->callback_data->bytes_per_sample * __pyx_v_self->__pyx_base.state->callback_data->channels);

  /* "mpfmc/core/audio/track_sound_loop.pyx":463
 *         # in the middle of a sample frame)
 *         bytes_per_sample_frame = self.state.callback_data.bytes_per_sample * self.state.callback_data.channels
 *         player.sample_pos = bytes_per_sample_frame * ceil(player.sample_pos / bytes_per_sample_frame)             # <<<<<<<<<<<<<<
 * 
 *         # Adjust new player playing position to ensure it is within the sample
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_bytes_per_sample_frame); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 463, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_ceil); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 463, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (unlikely(__pyx_v_bytes_per_sample_frame == 0)) {
    PyErr_SetString(PyExc_ZeroDivisionError, "float division");
    __PYX_ERR(0, 463, __pyx_L1_error)
  }
  __pyx_t_3 = PyFloat_FromDouble((((double)__pyx_v_player->sample_pos) / ((double)__pyx_v_bytes_per_sample_frame))); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 463, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_8);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_8, function);
    }
  }
  __pyx_t_1 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_5, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 463, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_8 = PyNumber_Multiply(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 463, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_12 = __Pyx_PyInt_As_Uint32(__pyx_t_8); if (unlikely((__pyx_t_12 == ((Uint32)-1)) && PyErr_Occurred())) __PYX_ERR(0, 463, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_v_player->sample_pos = __pyx_t_12;

  /* "mpfmc/core/audio/track_sound_loop.pyx":466
 * 
 *         # Adjust new player playing position to ensure it is within the sample
 *         while player.sample_pos >= player.length:             # <<<<<<<<<<<<<<
 *             player.sample_pos -= player.length
 * 
 */
  while (1) {
    __pyx_t_7 = ((__pyx_v_player->sample_pos >= __pyx_v_player->length) != 0);
    if (!__pyx_t_7) break;

    /* "mpfmc/core/audio/track_sound_loop.pyx":467
 *         # Adjust new player playing position to ensure it is within the sample
 *         while player.sample_pos >= player.length:
 *             player.sample_pos -= player.length             # <<<<<<<<<<<<<<
 * 
 *         # Save current sound loop set so it can be referred to again while it is active (event notifications)
 */
    __pyx_v_player->sample_pos = (__pyx_v_player->sample_pos - __pyx_v_player->length);
  }

  /* "mpfmc/core/audio/track_sound_loop.pyx":470
 * 
 *         # Save current sound loop set so it can be referred to again while it is active (event notifications)
 *         self._active_sound_loop_sets[self._sound_loop_set_counter] = player_settings             # <<<<<<<<<<<<<<
 * 
 *         # Add new player to the player list
 */
  if (unlikely(__pyx_v_self->_active_sound_loop_sets == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 470, __pyx_L1_error)
  }
  __pyx_t_8 = __Pyx_PyInt_From_long(__pyx_v_self->_sound_loop_set_counter); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 470, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (unlikely(PyDict_SetItem(__pyx_v_self->_active_sound_loop_sets, __pyx_t_8, __pyx_v_player_settings) < 0)) __PYX_ERR(0, 470, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "mpfmc/core/audio/track_sound_loop.pyx":473
 * 
 *         # Add new player to the player list
 *         self.type_state.players = g_slist_prepend(self.type_state.players, player)             # <<<<<<<<<<<<<<
 * 
 *         # Send sound_loop_set started notification (if not pending/queued)
 */
  __pyx_v_self->type_state->players = g_slist_prepend(__pyx_v_self->type_state->players, __pyx_v_player);

  /* "mpfmc/core/audio/track_sound_loop.pyx":476
 * 
 *         # Send sound_loop_set started notification (if not pending/queued)
 *         if player.status not in (player_idle, player_delayed):             # <<<<<<<<<<<<<<
 *             self.type_state.current = player
 *             send_sound_loop_set_started_notification(player.master_sound_layer.sound_loop_set_id,
 */
  switch (__pyx_v_player->status) {
    case __pyx_e_5mpfmc_4core_5audio_16track_sound_loop_player_idle:
    case __pyx_e_5mpfmc_4core_5audio_16track_sound_loop_player_delayed:
    __pyx_t_7 = 0;
    break;
    default:
    __pyx_t_7 = 1;
    break;
  }
  __pyx_t_6 = (__pyx_t_7 != 0);
  if (__pyx_t_6) {

    /* "mpfmc/core/audio/track_sound_loop.pyx":477
 *         # Send sound_loop_set started notification (if not pending/queued)
 *         if player.status not in (player_idle, player_delayed):
 *             self.type_state.current = player             # <<<<<<<<<<<<<<
 *             send_sound_loop_set_started_notification(player.master_sound_layer.sound_loop_set_id,
 *                                                      player.master_sound_layer.sound_id,
 */
    __pyx_v_self->type_state->current = __pyx_v_player;

    /* "mpfmc/core/audio/track_sound_loop.pyx":478
 *         if player.status not in (player_idle, player_delayed):
 *             self.type_state.current = player
 *             send_sound_loop_set_started_notification(player.master_sound_layer.sound_loop_set_id,             # <<<<<<<<<<<<<<
 *                                                      player.master_sound_layer.sound_id,
 *                                                      player,
 */
    __pyx_f_5mpfmc_4core_5audio_20notification_message_send_sound_loop_set_started_notification(__pyx_v_player->master_sound_layer.sound_loop_set_id, __pyx_v_player->master_sound_layer.sound_id, __pyx_v_player, __pyx_v_self->__pyx_base.state);

    /* "mpfmc/core/audio/track_sound_loop.pyx":476
 * 
 *         # Send sound_loop_set started notification (if not pending/queued)
 *         if player.status not in (player_idle, player_delayed):             # <<<<<<<<<<<<<<
 *             self.type_state.current = player
 *             send_sound_loop_set_started_notification(player.master_sound_layer.sound_loop_set_id,
 */
  }

  /* "mpfmc/core/audio/track_sound_loop.pyx":485
 *         # print("play_sound_loop_set - status: ", self.get_status())
 * 
 *         SDL_UnlockAudio()             # <<<<<<<<<<<<<<
 * 
 *     cdef _apply_layer_settings(self, SoundLoopLayerSettings *layer, dict layer_settings):
 */
  SDL_UnlockAudio();

  /* "mpfmc/core/audio/track_sound_loop.pyx":283
 *         SDL_UnlockAudio()
 * 
 *     def play_sound_loop_set(self, dict sound_loop_set not None, str context=None, dict player_settings=None):             # <<<<<<<<<<<<<<
 *         """
 *         Immediately play a sound loop set.
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("mpfmc.core.audio.track_sound_loop.TrackSoundLoop.play_sound_loop_set", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_master_layer_settings);
  __Pyx_XDECREF(__pyx_v_layer_settings);
  __Pyx_XDECREF(__pyx_v_player_settings);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mpfmc/core/audio/track_sound_loop.pyx":487
 *         SDL_UnlockAudio()
 * 
 *     cdef _apply_layer_settings(self, SoundLoopLayerSettings *layer, dict layer_settings):             # <<<<<<<<<<<<<<
 *         cdef SoundFile sound_container
 * 
 */

static PyObject *__pyx_f_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop__apply_layer_settings(struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *__pyx_v_self, __pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopLayerSettings *__pyx_v_layer, PyObject *__pyx_v_layer_settings) {
  struct __pyx_obj_5mpfmc_4core_5audio_10sound_file_SoundFile *__pyx_v_sound_container = 0;
  PyObject *__pyx_v_sound = NULL;
  PyObject *__pyx_v_index = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  long __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  Uint64 __pyx_t_8;
  Uint8 __pyx_t_9;
  guint __pyx_t_10;
  Py_ssize_t __pyx_t_11;
  PyObject *(*__pyx_t_12)(PyObject *);
  PyObject *__pyx_t_13 = NULL;
  guint __pyx_t_14;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_apply_layer_settings", 0);

  /* "mpfmc/core/audio/track_sound_loop.pyx":490
 *         cdef SoundFile sound_container
 * 
 *         if 'initial_state' not in layer_settings or layer_settings['initial_state'] == 'play':             # <<<<<<<<<<<<<<
 *             layer.status = layer_playing
 *         else:
 */
  if (unlikely(__pyx_v_layer_settings == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    __PYX_ERR(0, 490, __pyx_L1_error)
  }
  __pyx_t_2 = (__Pyx_PyDict_ContainsTF(__pyx_n_u_initial_state, __pyx_v_layer_settings, Py_NE)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 490, __pyx_L1_error)
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (!__pyx_t_3) {
  } else {
    __pyx_t_1 = __pyx_t_3;
    goto __pyx_L4_bool_binop_done;
  }
  if (unlikely(__pyx_v_layer_settings == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 490, __pyx_L1_error)
  }
  __pyx_t_4 = __Pyx_PyDict_GetItem(__pyx_v_layer_settings, __pyx_n_u_initial_state); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 490, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = (__Pyx_PyUnicode_Equals(__pyx_t_4, __pyx_n_u_play, Py_EQ)); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 490, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_1 = __pyx_t_3;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_1) {

    /* "mpfmc/core/audio/track_sound_loop.pyx":491
 * 
 *         if 'initial_state' not in layer_settings or layer_settings['initial_state'] == 'play':
 *             layer.status = layer_playing             # <<<<<<<<<<<<<<
 *         else:
 *             layer.status = layer_stopped
 */
    __pyx_v_layer->status = __pyx_e_5mpfmc_4core_5audio_16track_sound_loop_layer_playing;

    /* "mpfmc/core/audio/track_sound_loop.pyx":490
 *         cdef SoundFile sound_container
 * 
 *         if 'initial_state' not in layer_settings or layer_settings['initial_state'] == 'play':             # <<<<<<<<<<<<<<
 *             layer.status = layer_playing
 *         else:
 */
    goto __pyx_L3;
  }

  /* "mpfmc/core/audio/track_sound_loop.pyx":493
 *             layer.status = layer_playing
 *         else:
 *             layer.status = layer_stopped             # <<<<<<<<<<<<<<
 * 
 *         if 'sound_loop_set_id' in layer_settings:
 */
  /*else*/ {
    __pyx_v_layer->status = __pyx_e_5mpfmc_4core_5audio_16track_sound_loop_layer_stopped;
  }
  __pyx_L3:;

  /* "mpfmc/core/audio/track_sound_loop.pyx":495
 *             layer.status = layer_stopped
 * 
 *         if 'sound_loop_set_id' in layer_settings:             # <<<<<<<<<<<<<<
 *             layer.sound_loop_set_id = layer_settings['sound_loop_set_id']
 *         else:
 */
  if (unlikely(__pyx_v_layer_settings == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    __PYX_ERR(0, 495, __pyx_L1_error)
  }
  __pyx_t_1 = (__Pyx_PyDict_ContainsTF(__pyx_n_u_sound_loop_set_id, __pyx_v_layer_settings, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 495, __pyx_L1_error)
  __pyx_t_3 = (__pyx_t_1 != 0);
  if (__pyx_t_3) {

    /* "mpfmc/core/audio/track_sound_loop.pyx":496
 * 
 *         if 'sound_loop_set_id' in layer_settings:
 *             layer.sound_loop_set_id = layer_settings['sound_loop_set_id']             # <<<<<<<<<<<<<<
 *         else:
 *             layer.sound_loop_set_id = 0
 */
    if (unlikely(__pyx_v_layer_settings == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(0, 496, __pyx_L1_error)
    }
    __pyx_t_4 = __Pyx_PyDict_GetItem(__pyx_v_layer_settings, __pyx_n_u_sound_loop_set_id); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 496, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __Pyx_PyInt_As_long(__pyx_t_4); if (unlikely((__pyx_t_5 == (long)-1) && PyErr_Occurred())) __PYX_ERR(0, 496, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_v_layer->sound_loop_set_id = __pyx_t_5;

    /* "mpfmc/core/audio/track_sound_loop.pyx":495
 *             layer.status = layer_stopped
 * 
 *         if 'sound_loop_set_id' in layer_settings:             # <<<<<<<<<<<<<<
 *             layer.sound_loop_set_id = layer_settings['sound_loop_set_id']
 *         else:
 */
    goto __pyx_L6;
  }

  /* "mpfmc/core/audio/track_sound_loop.pyx":498
 *             layer.sound_loop_set_id = layer_settings['sound_loop_set_id']
 *         else:
 *             layer.sound_loop_set_id = 0             # <<<<<<<<<<<<<<
 * 
 *         # Set layer sound
 */
  /*else*/ {
    __pyx_v_layer->sound_loop_set_id = 0;
  }
  __pyx_L6:;

  /* "mpfmc/core/audio/track_sound_loop.pyx":501
 * 
 *         # Set layer sound
 *         sound = self.mc.sounds[layer_settings['sound']]             # <<<<<<<<<<<<<<
 * 
 *         # TODO: What to do when sound is not loaded?
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->__pyx_base.mc, __pyx_n_s_sounds); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 501, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (unlikely(__pyx_v_layer_settings == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 501, __pyx_L1_error)
  }
  __pyx_t_6 = __Pyx_PyDict_GetItem(__pyx_v_layer_settings, __pyx_n_u_sound); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 501, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = __Pyx_PyObject_GetItem(__pyx_t_4, __pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 501, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_v_sound = __pyx_t_7;
  __pyx_t_7 = 0;

  /* "mpfmc/core/audio/track_sound_loop.pyx":506
 *         # TODO: Perhaps load sounds and delay play until loaded?
 * 
 *         sound_container = sound.container             # <<<<<<<<<<<<<<
 *         layer.sound = cython.address(sound_container.sample)
 *         layer.sound_id = sound.id
 */
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_sound, __pyx_n_s_container); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 506, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (!(likely(((__pyx_t_7) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_7, __pyx_ptype_5mpfmc_4core_5audio_10sound_file_SoundFile))))) __PYX_ERR(0, 506, __pyx_L1_error)
  __pyx_v_sound_container = ((struct __pyx_obj_5mpfmc_4core_5audio_10sound_file_SoundFile *)__pyx_t_7);
  __pyx_t_7 = 0;

  /* "mpfmc/core/audio/track_sound_loop.pyx":507
 * 
 *         sound_container = sound.container
 *         layer.sound = cython.address(sound_container.sample)             # <<<<<<<<<<<<<<
 *         layer.sound_id = sound.id
 * 
 */
  __pyx_v_layer->sound = (&__pyx_v_sound_container->sample);

  /* "mpfmc/core/audio/track_sound_loop.pyx":508
 *         sound_container = sound.container
 *         layer.sound = cython.address(sound_container.sample)
 *         layer.sound_id = sound.id             # <<<<<<<<<<<<<<
 * 
 *         # By default, all layers will continue to loop when played
 */
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_sound, __pyx_n_s_id); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 508, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_8 = __Pyx_PyInt_As_Uint64(__pyx_t_7); if (unlikely((__pyx_t_8 == ((Uint64)-1)) && PyErr_Occurred())) __PYX_ERR(0, 508, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_v_layer->sound_id = __pyx_t_8;

  /* "mpfmc/core/audio/track_sound_loop.pyx":511
 * 
 *         # By default, all layers will continue to loop when played
 *         layer.looping = True             # <<<<<<<<<<<<<<
 * 
 *         # Layer volume (use layer settings or sound setting if None)
 */
  __pyx_v_layer->looping = 1;

  /* "mpfmc/core/audio/track_sound_loop.pyx":514
 * 
 *         # Layer volume (use layer settings or sound setting if None)
 *         if layer_settings['volume']:             # <<<<<<<<<<<<<<
 *             layer.volume = <Uint8>(layer_settings['volume'] * SDL_MIX_MAXVOLUME)
 *         else:
 */
  if (unlikely(__pyx_v_layer_settings == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 514, __pyx_L1_error)
  }
  __pyx_t_7 = __Pyx_PyDict_GetItem(__pyx_v_layer_settings, __pyx_n_u_volume); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 514, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 514, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (__pyx_t_3) {

    /* "mpfmc/core/audio/track_sound_loop.pyx":515
 *         # Layer volume (use layer settings or sound setting if None)
 *         if layer_settings['volume']:
 *             layer.volume = <Uint8>(layer_settings['volume'] * SDL_MIX_MAXVOLUME)             # <<<<<<<<<<<<<<
 *         else:
 *             layer.volume = <Uint8>(sound.volume * SDL_MIX_MAXVOLUME)
 */
    if (unlikely(__pyx_v_layer_settings == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(0, 515, __pyx_L1_error)
    }
    __pyx_t_7 = __Pyx_PyDict_GetItem(__pyx_v_layer_settings, __pyx_n_u_volume); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 515, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_6 = __Pyx_PyInt_From_int(SDL_MIX_MAXVOLUME); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 515, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_4 = PyNumber_Multiply(__pyx_t_7, __pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 515, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_9 = __Pyx_PyInt_As_Uint8(__pyx_t_4); if (unlikely((__pyx_t_9 == ((Uint8)-1)) && PyErr_Occurred())) __PYX_ERR(0, 515, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_v_layer->volume = ((Uint8)__pyx_t_9);

    /* "mpfmc/core/audio/track_sound_loop.pyx":514
 * 
 *         # Layer volume (use layer settings or sound setting if None)
 *         if layer_settings['volume']:             # <<<<<<<<<<<<<<
 *             layer.volume = <Uint8>(layer_settings['volume'] * SDL_MIX_MAXVOLUME)
 *         else:
 */
    goto __pyx_L7;
  }

  /* "mpfmc/core/audio/track_sound_loop.pyx":517
 *             layer.volume = <Uint8>(layer_settings['volume'] * SDL_MIX_MAXVOLUME)
 *         else:
 *             layer.volume = <Uint8>(sound.volume * SDL_MIX_MAXVOLUME)             # <<<<<<<<<<<<<<
 * 
 *         # Markers (copy from source sound)
 */
  /*else*/ {
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_sound, __pyx_n_s_volume); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 517, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_6 = __Pyx_PyInt_From_int(SDL_MIX_MAXVOLUME); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 517, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = PyNumber_Multiply(__pyx_t_4, __pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 517, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_9 = __Pyx_PyInt_As_Uint8(__pyx_t_7); if (unlikely((__pyx_t_9 == ((Uint8)-1)) && PyErr_Occurred())) __PYX_ERR(0, 517, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_v_layer->volume = ((Uint8)__pyx_t_9);
  }
  __pyx_L7:;

  /* "mpfmc/core/audio/track_sound_loop.pyx":520
 * 
 *         # Markers (copy from source sound)
 *         layer.marker_count = sound.marker_count             # <<<<<<<<<<<<<<
 * 
 *         if layer.marker_count > 0:
 */
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_sound, __pyx_n_s_marker_count); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 520, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_9 = __Pyx_PyInt_As_Uint8(__pyx_t_7); if (unlikely((__pyx_t_9 == ((Uint8)-1)) && PyErr_Occurred())) __PYX_ERR(0, 520, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_v_layer->marker_count = __pyx_t_9;

  /* "mpfmc/core/audio/track_sound_loop.pyx":522
 *         layer.marker_count = sound.marker_count
 * 
 *         if layer.marker_count > 0:             # <<<<<<<<<<<<<<
 *             layer.markers = g_array_new(False, False, sizeof(guint))
 *             g_array_set_size(layer.markers, sound.marker_count)
 */
  __pyx_t_3 = ((__pyx_v_layer->marker_count > 0) != 0);
  if (__pyx_t_3) {

    /* "mpfmc/core/audio/track_sound_loop.pyx":523
 * 
 *         if layer.marker_count > 0:
 *             layer.markers = g_array_new(False, False, sizeof(guint))             # <<<<<<<<<<<<<<
 *             g_array_set_size(layer.markers, sound.marker_count)
 *             for index in range(sound.marker_count):
 */
    __pyx_v_layer->markers = g_array_new(0, 0, (sizeof(guint)));

    /* "mpfmc/core/audio/track_sound_loop.pyx":524
 *         if layer.marker_count > 0:
 *             layer.markers = g_array_new(False, False, sizeof(guint))
 *             g_array_set_size(layer.markers, sound.marker_count)             # <<<<<<<<<<<<<<
 *             for index in range(sound.marker_count):
 *                 g_array_insert_val_uint(layer.markers,
 */
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_sound, __pyx_n_s_marker_count); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 524, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_10 = __Pyx_PyInt_As_guint(__pyx_t_7); if (unlikely((__pyx_t_10 == ((guint)-1)) && PyErr_Occurred())) __PYX_ERR(0, 524, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    (void)(g_array_set_size(__pyx_v_layer->markers, __pyx_t_10));

    /* "mpfmc/core/audio/track_sound_loop.pyx":525
 *             layer.markers = g_array_new(False, False, sizeof(guint))
 *             g_array_set_size(layer.markers, sound.marker_count)
 *             for index in range(sound.marker_count):             # <<<<<<<<<<<<<<
 *                 g_array_insert_val_uint(layer.markers,
 *                                         index,
 */
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_sound, __pyx_n_s_marker_count); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 525, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_builtin_range, __pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 525, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (likely(PyList_CheckExact(__pyx_t_6)) || PyTuple_CheckExact(__pyx_t_6)) {
      __pyx_t_7 = __pyx_t_6; __Pyx_INCREF(__pyx_t_7); __pyx_t_11 = 0;
      __pyx_t_12 = NULL;
    } else {
      __pyx_t_11 = -1; __pyx_t_7 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 525, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_12 = Py_TYPE(__pyx_t_7)->tp_iternext; if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 525, __pyx_L1_error)
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    for (;;) {
      if (likely(!__pyx_t_12)) {
        if (likely(PyList_CheckExact(__pyx_t_7))) {
          if (__pyx_t_11 >= PyList_GET_SIZE(__pyx_t_7)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_6 = PyList_GET_ITEM(__pyx_t_7, __pyx_t_11); __Pyx_INCREF(__pyx_t_6); __pyx_t_11++; if (unlikely(0 < 0)) __PYX_ERR(0, 525, __pyx_L1_error)
          #else
          __pyx_t_6 = PySequence_ITEM(__pyx_t_7, __pyx_t_11); __pyx_t_11++; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 525, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          #endif
        } else {
          if (__pyx_t_11 >= PyTuple_GET_SIZE(__pyx_t_7)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_7, __pyx_t_11); __Pyx_INCREF(__pyx_t_6); __pyx_t_11++; if (unlikely(0 < 0)) __PYX_ERR(0, 525, __pyx_L1_error)
          #else
          __pyx_t_6 = PySequence_ITEM(__pyx_t_7, __pyx_t_11); __pyx_t_11++; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 525, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          #endif
        }
      } else {
        __pyx_t_6 = __pyx_t_12(__pyx_t_7);
        if (unlikely(!__pyx_t_6)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 525, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_6);
      }
      __Pyx_XDECREF_SET(__pyx_v_index, __pyx_t_6);
      __pyx_t_6 = 0;

      /* "mpfmc/core/audio/track_sound_loop.pyx":527
 *             for index in range(sound.marker_count):
 *                 g_array_insert_val_uint(layer.markers,
 *                                         index,             # <<<<<<<<<<<<<<
 *                                         <guint>(sound.markers[index]['time'] * self.state.callback_data.seconds_to_bytes_factor))
 * 
 */
      __pyx_t_10 = __Pyx_PyInt_As_guint(__pyx_v_index); if (unlikely((__pyx_t_10 == ((guint)-1)) && PyErr_Occurred())) __PYX_ERR(0, 527, __pyx_L1_error)

      /* "mpfmc/core/audio/track_sound_loop.pyx":528
 *                 g_array_insert_val_uint(layer.markers,
 *                                         index,
 *                                         <guint>(sound.markers[index]['time'] * self.state.callback_data.seconds_to_bytes_factor))             # <<<<<<<<<<<<<<
 * 
 *     def stop_current_sound_loop_set(self, fade_out=None):
 */
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_sound, __pyx_n_s_markers); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 528, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_4 = __Pyx_PyObject_GetItem(__pyx_t_6, __pyx_v_index); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 528, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_6 = __Pyx_PyObject_Dict_GetItem(__pyx_t_4, __pyx_n_u_time); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 528, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = PyFloat_FromDouble(__pyx_v_self->__pyx_base.state->callback_data->seconds_to_bytes_factor); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 528, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_13 = PyNumber_Multiply(__pyx_t_6, __pyx_t_4); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 528, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_14 = __Pyx_PyInt_As_guint(__pyx_t_13); if (unlikely((__pyx_t_14 == ((guint)-1)) && PyErr_Occurred())) __PYX_ERR(0, 528, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

      /* "mpfmc/core/audio/track_sound_loop.pyx":526
 *             g_array_set_size(layer.markers, sound.marker_count)
 *             for index in range(sound.marker_count):
 *                 g_array_insert_val_uint(layer.markers,             # <<<<<<<<<<<<<<
 *                                         index,
 *                                         <guint>(sound.markers[index]['time'] * self.state.callback_data.seconds_to_bytes_factor))
 */
      g_array_insert_val_uint(__pyx_v_layer->markers, __pyx_t_10, ((guint)__pyx_t_14));

      /* "mpfmc/core/audio/track_sound_loop.pyx":525
 *             layer.markers = g_array_new(False, False, sizeof(guint))
 *             g_array_set_size(layer.markers, sound.marker_count)
 *             for index in range(sound.marker_count):             # <<<<<<<<<<<<<<
 *                 g_array_insert_val_uint(layer.markers,
 *                                         index,
 */
    }
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "mpfmc/core/audio/track_sound_loop.pyx":522
 *         layer.marker_count = sound.marker_count
 * 
 *         if layer.marker_count > 0:             # <<<<<<<<<<<<<<
 *             layer.markers = g_array_new(False, False, sizeof(guint))
 *             g_array_set_size(layer.markers, sound.marker_count)
 */
  }

  /* "mpfmc/core/audio/track_sound_loop.pyx":487
 *         SDL_UnlockAudio()
 * 
 *     cdef _apply_layer_settings(self, SoundLoopLayerSettings *layer, dict layer_settings):             # <<<<<<<<<<<<<<
 *         cdef SoundFile sound_container
 * 
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_AddTraceback("mpfmc.core.audio.track_sound_loop.TrackSoundLoop._apply_layer_settings", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_sound_container);
  __Pyx_XDECREF(__pyx_v_sound);
  __Pyx_XDECREF(__pyx_v_index);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mpfmc/core/audio/track_sound_loop.pyx":530
 *                                         <guint>(sound.markers[index]['time'] * self.state.callback_data.seconds_to_bytes_factor))
 * 
 *     def stop_current_sound_loop_set(self, fade_out=None):             # <<<<<<<<<<<<<<
 *         """
 *         Stops the currently playing sound loop set.
 */

/* Python wrapper */
static PyObject *__pyx_pw_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_21stop_current_sound_loop_set(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_20stop_current_sound_loop_set[] = "TrackSoundLoop.stop_current_sound_loop_set(self, fade_out=None)\n\n        Stops the currently playing sound loop set.\n        Args:\n            fade_out: The number of seconds over which to fade out the currently playing\n                      sound loop set before stopping.\n        ";
static PyObject *__pyx_pw_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_21stop_current_sound_loop_set(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_fade_out = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("stop_current_sound_loop_set (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_fade_out,0};
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_fade_out);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "stop_current_sound_loop_set") < 0)) __PYX_ERR(0, 530, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_fade_out = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("stop_current_sound_loop_set", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 530, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mpfmc.core.audio.track_sound_loop.TrackSoundLoop.stop_current_sound_loop_set", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_20stop_current_sound_loop_set(((struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *)__pyx_v_self), __pyx_v_fade_out);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_20stop_current_sound_loop_set(struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *__pyx_v_self, PyObject *__pyx_v_fade_out) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  Uint32 __pyx_t_7;
  Uint8 __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("stop_current_sound_loop_set", 0);

  /* "mpfmc/core/audio/track_sound_loop.pyx":537
 *                       sound loop set before stopping.
 *         """
 *         SDL_LockAudio()             # <<<<<<<<<<<<<<
 * 
 *         self.log.debug("Stopping current sound loop set")
 */
  SDL_LockAudio();

  /* "mpfmc/core/audio/track_sound_loop.pyx":539
 *         SDL_LockAudio()
 * 
 *         self.log.debug("Stopping current sound loop set")             # <<<<<<<<<<<<<<
 * 
 *         if self.type_state.current == NULL or self.type_state.current.status not in (player_playing, player_fading_in, player_fading_out):
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->__pyx_base.log, __pyx_n_s_debug); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 539, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_kp_u_Stopping_current_sound_loop_set) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_kp_u_Stopping_current_sound_loop_set);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 539, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "mpfmc/core/audio/track_sound_loop.pyx":541
 *         self.log.debug("Stopping current sound loop set")
 * 
 *         if self.type_state.current == NULL or self.type_state.current.status not in (player_playing, player_fading_in, player_fading_out):             # <<<<<<<<<<<<<<
 *             self.log.info("Unable to stop sound loop set - no sound loop set is currently playing.")
 *             SDL_UnlockAudio()
 */
  __pyx_t_5 = ((__pyx_v_self->type_state->current == NULL) != 0);
  if (!__pyx_t_5) {
  } else {
    __pyx_t_4 = __pyx_t_5;
    goto __pyx_L4_bool_binop_done;
  }
  switch (__pyx_v_self->type_state->current->status) {
    case __pyx_e_5mpfmc_4core_5audio_16track_sound_loop_player_playing:
    case __pyx_e_5mpfmc_4core_5audio_16track_sound_loop_player_fading_in:
    case __pyx_e_5mpfmc_4core_5audio_16track_sound_loop_player_fading_out:
    __pyx_t_5 = 0;
    break;
    default:
    __pyx_t_5 = 1;
    break;
  }
  __pyx_t_6 = (__pyx_t_5 != 0);
  __pyx_t_4 = __pyx_t_6;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_4) {

    /* "mpfmc/core/audio/track_sound_loop.pyx":542
 * 
 *         if self.type_state.current == NULL or self.type_state.current.status not in (player_playing, player_fading_in, player_fading_out):
 *             self.log.info("Unable to stop sound loop set - no sound loop set is currently playing.")             # <<<<<<<<<<<<<<
 *             SDL_UnlockAudio()
 *             return
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->__pyx_base.log, __pyx_n_s_info); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 542, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_kp_u_Unable_to_stop_sound_loop_set_no) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_kp_u_Unable_to_stop_sound_loop_set_no);
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 542, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "mpfmc/core/audio/track_sound_loop.pyx":543
 *         if self.type_state.current == NULL or self.type_state.current.status not in (player_playing, player_fading_in, player_fading_out):
 *             self.log.info("Unable to stop sound loop set - no sound loop set is currently playing.")
 *             SDL_UnlockAudio()             # <<<<<<<<<<<<<<
 *             return
 * 
 */
    SDL_UnlockAudio();

    /* "mpfmc/core/audio/track_sound_loop.pyx":544
 *             self.log.info("Unable to stop sound loop set - no sound loop set is currently playing.")
 *             SDL_UnlockAudio()
 *             return             # <<<<<<<<<<<<<<
 * 
 *         # Calculate new fade out if specified (overriding current setting)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "mpfmc/core/audio/track_sound_loop.pyx":541
 *         self.log.debug("Stopping current sound loop set")
 * 
 *         if self.type_state.current == NULL or self.type_state.current.status not in (player_playing, player_fading_in, player_fading_out):             # <<<<<<<<<<<<<<
 *             self.log.info("Unable to stop sound loop set - no sound loop set is currently playing.")
 *             SDL_UnlockAudio()
 */
  }

  /* "mpfmc/core/audio/track_sound_loop.pyx":547
 * 
 *         # Calculate new fade out if specified (overriding current setting)
 *         if fade_out:             # <<<<<<<<<<<<<<
 *             self.type_state.current.master_sound_layer.fade_out_steps = fade_out * self.state.callback_data.seconds_to_bytes_factor // self.state.callback_data.bytes_per_control_point
 * 
 */
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_fade_out); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 547, __pyx_L1_error)
  if (__pyx_t_4) {

    /* "mpfmc/core/audio/track_sound_loop.pyx":548
 *         # Calculate new fade out if specified (overriding current setting)
 *         if fade_out:
 *             self.type_state.current.master_sound_layer.fade_out_steps = fade_out * self.state.callback_data.seconds_to_bytes_factor // self.state.callback_data.bytes_per_control_point             # <<<<<<<<<<<<<<
 * 
 *         # If no fade out is specified, perform quick fade out
 */
    __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->__pyx_base.state->callback_data->seconds_to_bytes_factor); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 548, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyNumber_Multiply(__pyx_v_fade_out, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 548, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyInt_From_Uint16(__pyx_v_self->__pyx_base.state->callback_data->bytes_per_control_point); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 548, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyNumber_FloorDivide(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 548, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_7 = __Pyx_PyInt_As_Uint32(__pyx_t_3); if (unlikely((__pyx_t_7 == ((Uint32)-1)) && PyErr_Occurred())) __PYX_ERR(0, 548, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_self->type_state->current->master_sound_layer.fade_out_steps = __pyx_t_7;

    /* "mpfmc/core/audio/track_sound_loop.pyx":547
 * 
 *         # Calculate new fade out if specified (overriding current setting)
 *         if fade_out:             # <<<<<<<<<<<<<<
 *             self.type_state.current.master_sound_layer.fade_out_steps = fade_out * self.state.callback_data.seconds_to_bytes_factor // self.state.callback_data.bytes_per_control_point
 * 
 */
  }

  /* "mpfmc/core/audio/track_sound_loop.pyx":551
 * 
 *         # If no fade out is specified, perform quick fade out
 *         if self.type_state.current.master_sound_layer.fade_out_steps == 0:             # <<<<<<<<<<<<<<
 *             self.type_state.current.master_sound_layer.fade_out_steps = self.state.callback_data.quick_fade_steps
 * 
 */
  __pyx_t_4 = ((__pyx_v_self->type_state->current->master_sound_layer.fade_out_steps == 0) != 0);
  if (__pyx_t_4) {

    /* "mpfmc/core/audio/track_sound_loop.pyx":552
 *         # If no fade out is specified, perform quick fade out
 *         if self.type_state.current.master_sound_layer.fade_out_steps == 0:
 *             self.type_state.current.master_sound_layer.fade_out_steps = self.state.callback_data.quick_fade_steps             # <<<<<<<<<<<<<<
 * 
 *         self.type_state.current.master_sound_layer.fade_steps_remaining = self.type_state.current.master_sound_layer.fade_out_steps
 */
    __pyx_t_8 = __pyx_v_self->__pyx_base.state->callback_data->quick_fade_steps;
    __pyx_v_self->type_state->current->master_sound_layer.fade_out_steps = __pyx_t_8;

    /* "mpfmc/core/audio/track_sound_loop.pyx":551
 * 
 *         # If no fade out is specified, perform quick fade out
 *         if self.type_state.current.master_sound_layer.fade_out_steps == 0:             # <<<<<<<<<<<<<<
 *             self.type_state.current.master_sound_layer.fade_out_steps = self.state.callback_data.quick_fade_steps
 * 
 */
  }

  /* "mpfmc/core/audio/track_sound_loop.pyx":554
 *             self.type_state.current.master_sound_layer.fade_out_steps = self.state.callback_data.quick_fade_steps
 * 
 *         self.type_state.current.master_sound_layer.fade_steps_remaining = self.type_state.current.master_sound_layer.fade_out_steps             # <<<<<<<<<<<<<<
 *         self.type_state.current.status = player_fading_out
 * 
 */
  __pyx_t_7 = __pyx_v_self->type_state->current->master_sound_layer.fade_out_steps;
  __pyx_v_self->type_state->current->master_sound_layer.fade_steps_remaining = __pyx_t_7;

  /* "mpfmc/core/audio/track_sound_loop.pyx":555
 * 
 *         self.type_state.current.master_sound_layer.fade_steps_remaining = self.type_state.current.master_sound_layer.fade_out_steps
 *         self.type_state.current.status = player_fading_out             # <<<<<<<<<<<<<<
 * 
 *         # Need to check if the next sound player has a loop set queued for playback and if so, cancel it
 */
  __pyx_v_self->type_state->current->status = __pyx_e_5mpfmc_4core_5audio_16track_sound_loop_player_fading_out;

  /* "mpfmc/core/audio/track_sound_loop.pyx":558
 * 
 *         # Need to check if the next sound player has a loop set queued for playback and if so, cancel it
 *         self._cancel_all_delayed_players()             # <<<<<<<<<<<<<<
 * 
 *         # Do we need to shorted the current fade-out?
 */
  __pyx_t_3 = ((struct __pyx_vtabstruct_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *)__pyx_v_self->__pyx_base.__pyx_vtab)->_cancel_all_delayed_players(__pyx_v_self); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 558, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "mpfmc/core/audio/track_sound_loop.pyx":561
 * 
 *         # Do we need to shorted the current fade-out?
 *         self._fade_out_all_players(self.type_state.current.master_sound_layer.fade_steps_remaining)             # <<<<<<<<<<<<<<
 * 
 *         SDL_UnlockAudio()
 */
  __pyx_t_3 = ((struct __pyx_vtabstruct_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *)__pyx_v_self->__pyx_base.__pyx_vtab)->_fade_out_all_players(__pyx_v_self, __pyx_v_self->type_state->current->master_sound_layer.fade_steps_remaining); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 561, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "mpfmc/core/audio/track_sound_loop.pyx":563
 *         self._fade_out_all_players(self.type_state.current.master_sound_layer.fade_steps_remaining)
 * 
 *         SDL_UnlockAudio()             # <<<<<<<<<<<<<<
 * 
 *     def jump_to_time_current_sound_loop_set(self, time=0.0):
 */
  SDL_UnlockAudio();

  /* "mpfmc/core/audio/track_sound_loop.pyx":530
 *                                         <guint>(sound.markers[index]['time'] * self.state.callback_data.seconds_to_bytes_factor))
 * 
 *     def stop_current_sound_loop_set(self, fade_out=None):             # <<<<<<<<<<<<<<
 *         """
 *         Stops the currently playing sound loop set.
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("mpfmc.core.audio.track_sound_loop.TrackSoundLoop.stop_current_sound_loop_set", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mpfmc/core/audio/track_sound_loop.pyx":565
 *         SDL_UnlockAudio()
 * 
 *     def jump_to_time_current_sound_loop_set(self, time=0.0):             # <<<<<<<<<<<<<<
 *         """Immediately jumps the loop playback position to the specified time."""
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_23jump_to_time_current_sound_loop_set(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_22jump_to_time_current_sound_loop_set[] = "TrackSoundLoop.jump_to_time_current_sound_loop_set(self, time=0.0)\nImmediately jumps the loop playback position to the specified time.";
static PyObject *__pyx_pw_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_23jump_to_time_current_sound_loop_set(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_time = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("jump_to_time_current_sound_loop_set (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_time,0};
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)__pyx_float_0_0);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_time);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "jump_to_time_current_sound_loop_set") < 0)) __PYX_ERR(0, 565, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_time = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("jump_to_time_current_sound_loop_set", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 565, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mpfmc.core.audio.track_sound_loop.TrackSoundLoop.jump_to_time_current_sound_loop_set", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_22jump_to_time_current_sound_loop_set(((struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *)__pyx_v_self), __pyx_v_time);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_22jump_to_time_current_sound_loop_set(struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *__pyx_v_self, PyObject *__pyx_v_time) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  Uint32 __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("jump_to_time_current_sound_loop_set", 0);

  /* "mpfmc/core/audio/track_sound_loop.pyx":568
 *         """Immediately jumps the loop playback position to the specified time."""
 * 
 *         SDL_LockAudio()             # <<<<<<<<<<<<<<
 * 
 *         self.log.debug("Jumping to %f seconds playback position in current sound loop set", time)
 */
  SDL_LockAudio();

  /* "mpfmc/core/audio/track_sound_loop.pyx":570
 *         SDL_LockAudio()
 * 
 *         self.log.debug("Jumping to %f seconds playback position in current sound loop set", time)             # <<<<<<<<<<<<<<
 * 
 *         if self.type_state.current == NULL or self.type_state.current.status not in (player_playing, player_fading_in, player_fading_out):
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->__pyx_base.log, __pyx_n_s_debug); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 570, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  __pyx_t_4 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
      __pyx_t_4 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_kp_u_Jumping_to_f_seconds_playback_po, __pyx_v_time};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 570, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_kp_u_Jumping_to_f_seconds_playback_po, __pyx_v_time};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 570, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  {
    __pyx_t_5 = PyTuple_New(2+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 570, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    if (__pyx_t_3) {
      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
    }
    __Pyx_INCREF(__pyx_kp_u_Jumping_to_f_seconds_playback_po);
    __Pyx_GIVEREF(__pyx_kp_u_Jumping_to_f_seconds_playback_po);
    PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, __pyx_kp_u_Jumping_to_f_seconds_playback_po);
    __Pyx_INCREF(__pyx_v_time);
    __Pyx_GIVEREF(__pyx_v_time);
    PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_v_time);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 570, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "mpfmc/core/audio/track_sound_loop.pyx":572
 *         self.log.debug("Jumping to %f seconds playback position in current sound loop set", time)
 * 
 *         if self.type_state.current == NULL or self.type_state.current.status not in (player_playing, player_fading_in, player_fading_out):             # <<<<<<<<<<<<<<
 *             self.log.info("Unable to jump to specified playback position - "
 *                           "no sound loop set is currently playing.")
 */
  __pyx_t_7 = ((__pyx_v_self->type_state->current == NULL) != 0);
  if (!__pyx_t_7) {
  } else {
    __pyx_t_6 = __pyx_t_7;
    goto __pyx_L4_bool_binop_done;
  }
  switch (__pyx_v_self->type_state->current->status) {
    case __pyx_e_5mpfmc_4core_5audio_16track_sound_loop_player_playing:
    case __pyx_e_5mpfmc_4core_5audio_16track_sound_loop_player_fading_in:
    case __pyx_e_5mpfmc_4core_5audio_16track_sound_loop_player_fading_out:
    __pyx_t_7 = 0;
    break;
    default:
    __pyx_t_7 = 1;
    break;
  }
  __pyx_t_8 = (__pyx_t_7 != 0);
  __pyx_t_6 = __pyx_t_8;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_6) {

    /* "mpfmc/core/audio/track_sound_loop.pyx":573
 * 
 *         if self.type_state.current == NULL or self.type_state.current.status not in (player_playing, player_fading_in, player_fading_out):
 *             self.log.info("Unable to jump to specified playback position - "             # <<<<<<<<<<<<<<
 *                           "no sound loop set is currently playing.")
 *             SDL_UnlockAudio()
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->__pyx_base.log, __pyx_n_s_info); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 573, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    __pyx_t_1 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_5, __pyx_kp_u_Unable_to_jump_to_specified_play) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_kp_u_Unable_to_jump_to_specified_play);
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 573, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "mpfmc/core/audio/track_sound_loop.pyx":575
 *             self.log.info("Unable to jump to specified playback position - "
 *                           "no sound loop set is currently playing.")
 *             SDL_UnlockAudio()             # <<<<<<<<<<<<<<
 *             return
 * 
 */
    SDL_UnlockAudio();

    /* "mpfmc/core/audio/track_sound_loop.pyx":576
 *                           "no sound loop set is currently playing.")
 *             SDL_UnlockAudio()
 *             return             # <<<<<<<<<<<<<<
 * 
 *         # Set new playback position (make sure it is within the current sample length)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "mpfmc/core/audio/track_sound_loop.pyx":572
 *         self.log.debug("Jumping to %f seconds playback position in current sound loop set", time)
 * 
 *         if self.type_state.current == NULL or self.type_state.current.status not in (player_playing, player_fading_in, player_fading_out):             # <<<<<<<<<<<<<<
 *             self.log.info("Unable to jump to specified playback position - "
 *                           "no sound loop set is currently playing.")
 */
  }

  /* "mpfmc/core/audio/track_sound_loop.pyx":579
 * 
 *         # Set new playback position (make sure it is within the current sample length)
 *         self.type_state.current.sample_pos = time * self.state.callback_data.seconds_to_bytes_factor             # <<<<<<<<<<<<<<
 *         while self.type_state.current.sample_pos >= self.type_state.current.length:
 *             self.type_state.current.sample_pos -= self.type_state.current.length
 */
  __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->__pyx_base.state->callback_data->seconds_to_bytes_factor); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 579, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyNumber_Multiply(__pyx_v_time, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 579, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_9 = __Pyx_PyInt_As_Uint32(__pyx_t_2); if (unlikely((__pyx_t_9 == ((Uint32)-1)) && PyErr_Occurred())) __PYX_ERR(0, 579, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_self->type_state->current->sample_pos = __pyx_t_9;

  /* "mpfmc/core/audio/track_sound_loop.pyx":580
 *         # Set new playback position (make sure it is within the current sample length)
 *         self.type_state.current.sample_pos = time * self.state.callback_data.seconds_to_bytes_factor
 *         while self.type_state.current.sample_pos >= self.type_state.current.length:             # <<<<<<<<<<<<<<
 *             self.type_state.current.sample_pos -= self.type_state.current.length
 * 
 */
  while (1) {
    __pyx_t_6 = ((__pyx_v_self->type_state->current->sample_pos >= __pyx_v_self->type_state->current->length) != 0);
    if (!__pyx_t_6) break;

    /* "mpfmc/core/audio/track_sound_loop.pyx":581
 *         self.type_state.current.sample_pos = time * self.state.callback_data.seconds_to_bytes_factor
 *         while self.type_state.current.sample_pos >= self.type_state.current.length:
 *             self.type_state.current.sample_pos -= self.type_state.current.length             # <<<<<<<<<<<<<<
 * 
 *         SDL_UnlockAudio()
 */
    __pyx_v_self->type_state->current->sample_pos = (__pyx_v_self->type_state->current->sample_pos - __pyx_v_self->type_state->current->length);
  }

  /* "mpfmc/core/audio/track_sound_loop.pyx":583
 *             self.type_state.current.sample_pos -= self.type_state.current.length
 * 
 *         SDL_UnlockAudio()             # <<<<<<<<<<<<<<
 * 
 *     def stop_looping_current_sound_loop_set(self):
 */
  SDL_UnlockAudio();

  /* "mpfmc/core/audio/track_sound_loop.pyx":565
 *         SDL_UnlockAudio()
 * 
 *     def jump_to_time_current_sound_loop_set(self, time=0.0):             # <<<<<<<<<<<<<<
 *         """Immediately jumps the loop playback position to the specified time."""
 * 
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("mpfmc.core.audio.track_sound_loop.TrackSoundLoop.jump_to_time_current_sound_loop_set", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mpfmc/core/audio/track_sound_loop.pyx":585
 *         SDL_UnlockAudio()
 * 
 *     def stop_looping_current_sound_loop_set(self):             # <<<<<<<<<<<<<<
 *         """
 *         Stops the currently playing sound loop set from continuing to loop (it will stop
 */

/* Python wrapper */
static PyObject *__pyx_pw_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_25stop_looping_current_sound_loop_set(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_24stop_looping_current_sound_loop_set[] = "TrackSoundLoop.stop_looping_current_sound_loop_set(self)\n\n        Stops the currently playing sound loop set from continuing to loop (it will stop\n        after the current loop iteration).\n        ";
static PyObject *__pyx_pw_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_25stop_looping_current_sound_loop_set(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("stop_looping_current_sound_loop_set (wrapper)", 0);
  __pyx_r = __pyx_pf_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_24stop_looping_current_sound_loop_set(((struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_24stop_looping_current_sound_loop_set(struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("stop_looping_current_sound_loop_set", 0);

  /* "mpfmc/core/audio/track_sound_loop.pyx":590
 *         after the current loop iteration).
 *         """
 *         SDL_LockAudio()             # <<<<<<<<<<<<<<
 * 
 *         self.log.debug("Stopping looping current sound loop set")
 */
  SDL_LockAudio();

  /* "mpfmc/core/audio/track_sound_loop.pyx":592
 *         SDL_LockAudio()
 * 
 *         self.log.debug("Stopping looping current sound loop set")             # <<<<<<<<<<<<<<
 * 
 *         if self.type_state.current == NULL or self.type_state.current.status not in (player_playing, player_fading_in, player_fading_out):
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->__pyx_base.log, __pyx_n_s_debug); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 592, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_kp_u_Stopping_looping_current_sound_l) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_kp_u_Stopping_looping_current_sound_l);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 592, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "mpfmc/core/audio/track_sound_loop.pyx":594
 *         self.log.debug("Stopping looping current sound loop set")
 * 
 *         if self.type_state.current == NULL or self.type_state.current.status not in (player_playing, player_fading_in, player_fading_out):             # <<<<<<<<<<<<<<
 *             self.log.info("Unable to stop looping sound loop set - no sound loop set is currently playing.")
 *             SDL_UnlockAudio()
 */
  __pyx_t_5 = ((__pyx_v_self->type_state->current == NULL) != 0);
  if (!__pyx_t_5) {
  } else {
    __pyx_t_4 = __pyx_t_5;
    goto __pyx_L4_bool_binop_done;
  }
  switch (__pyx_v_self->type_state->current->status) {
    case __pyx_e_5mpfmc_4core_5audio_16track_sound_loop_player_playing:
    case __pyx_e_5mpfmc_4core_5audio_16track_sound_loop_player_fading_in:
    case __pyx_e_5mpfmc_4core_5audio_16track_sound_loop_player_fading_out:
    __pyx_t_5 = 0;
    break;
    default:
    __pyx_t_5 = 1;
    break;
  }
  __pyx_t_6 = (__pyx_t_5 != 0);
  __pyx_t_4 = __pyx_t_6;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_4) {

    /* "mpfmc/core/audio/track_sound_loop.pyx":595
 * 
 *         if self.type_state.current == NULL or self.type_state.current.status not in (player_playing, player_fading_in, player_fading_out):
 *             self.log.info("Unable to stop looping sound loop set - no sound loop set is currently playing.")             # <<<<<<<<<<<<<<
 *             SDL_UnlockAudio()
 *             return
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->__pyx_base.log, __pyx_n_s_info); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 595, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_kp_u_Unable_to_stop_looping_sound_loo) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_kp_u_Unable_to_stop_looping_sound_loo);
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 595, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "mpfmc/core/audio/track_sound_loop.pyx":596
 *         if self.type_state.current == NULL or self.type_state.current.status not in (player_playing, player_fading_in, player_fading_out):
 *             self.log.info("Unable to stop looping sound loop set - no sound loop set is currently playing.")
 *             SDL_UnlockAudio()             # <<<<<<<<<<<<<<
 *             return
 * 
 */
    SDL_UnlockAudio();

    /* "mpfmc/core/audio/track_sound_loop.pyx":597
 *             self.log.info("Unable to stop looping sound loop set - no sound loop set is currently playing.")
 *             SDL_UnlockAudio()
 *             return             # <<<<<<<<<<<<<<
 * 
 *         self.type_state.current.stop_loop_samples_remaining = self.type_state.current.length - self.type_state.current.sample_pos
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "mpfmc/core/audio/track_sound_loop.pyx":594
 *         self.log.debug("Stopping looping current sound loop set")
 * 
 *         if self.type_state.current == NULL or self.type_state.current.status not in (player_playing, player_fading_in, player_fading_out):             # <<<<<<<<<<<<<<
 *             self.log.info("Unable to stop looping sound loop set - no sound loop set is currently playing.")
 *             SDL_UnlockAudio()
 */
  }

  /* "mpfmc/core/audio/track_sound_loop.pyx":599
 *             return
 * 
 *         self.type_state.current.stop_loop_samples_remaining = self.type_state.current.length - self.type_state.current.sample_pos             # <<<<<<<<<<<<<<
 * 
 *         SDL_UnlockAudio()
 */
  __pyx_v_self->type_state->current->stop_loop_samples_remaining = (__pyx_v_self->type_state->current->length - __pyx_v_self->type_state->current->sample_pos);

  /* "mpfmc/core/audio/track_sound_loop.pyx":601
 *         self.type_state.current.stop_loop_samples_remaining = self.type_state.current.length - self.type_state.current.sample_pos
 * 
 *         SDL_UnlockAudio()             # <<<<<<<<<<<<<<
 * 
 *     def play_layer(self, int layer, float fade_in=0.0, str timing="loop_end", volume=None):
 */
  SDL_UnlockAudio();

  /* "mpfmc/core/audio/track_sound_loop.pyx":585
 *         SDL_UnlockAudio()
 * 
 *     def stop_looping_current_sound_loop_set(self):             # <<<<<<<<<<<<<<
 *         """
 *         Stops the currently playing sound loop set from continuing to loop (it will stop
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("mpfmc.core.audio.track_sound_loop.TrackSoundLoop.stop_looping_current_sound_loop_set", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mpfmc/core/audio/track_sound_loop.pyx":603
 *         SDL_UnlockAudio()
 * 
 *     def play_layer(self, int layer, float fade_in=0.0, str timing="loop_end", volume=None):             # <<<<<<<<<<<<<<
 *         """
 *         Plays the specified layer number in the currently playing sound loop set.
 */

/* Python wrapper */
static PyObject *__pyx_pw_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_27play_layer(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_26play_layer[] = "TrackSoundLoop.play_layer(self, int layer, float fade_in=0.0, unicode timing=u'loop_end', volume=None)\n\n        Plays the specified layer number in the currently playing sound loop set.\n\n        Args:\n            layer: The layer number to play (1-based array position).\n            fade_in: The number of seconds over which to fade in the layer.\n            timing: Flag indicating whether the layer should be played immediately ('now')\n                    or queued until the next loop of the master layer loop ('loop_end').\n            volume: The layer volume (overrides sound loop set setting if not None)\n        ";
static PyObject *__pyx_pw_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_27play_layer(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_layer;
  float __pyx_v_fade_in;
  PyObject *__pyx_v_timing = 0;
  PyObject *__pyx_v_volume = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("play_layer (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_layer,&__pyx_n_s_fade_in,&__pyx_n_s_timing,&__pyx_n_s_volume,0};
    PyObject* values[4] = {0,0,0,0};
    values[2] = ((PyObject*)__pyx_n_u_loop_end);
    values[3] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_layer)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_fade_in);
          if (value) { values[1] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_timing);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_volume);
          if (value) { values[3] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "play_layer") < 0)) __PYX_ERR(0, 603, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_layer = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_layer == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 603, __pyx_L3_error)
    if (values[1]) {
      __pyx_v_fade_in = __pyx_PyFloat_AsFloat(values[1]); if (unlikely((__pyx_v_fade_in == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 603, __pyx_L3_error)
    } else {
      __pyx_v_fade_in = ((float)0.0);
    }
    __pyx_v_timing = ((PyObject*)values[2]);
    __pyx_v_volume = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("play_layer", 0, 1, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 603, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mpfmc.core.audio.track_sound_loop.TrackSoundLoop.play_layer", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_timing), (&PyUnicode_Type), 1, "timing", 1))) __PYX_ERR(0, 603, __pyx_L1_error)
  __pyx_r = __pyx_pf_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_26play_layer(((struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *)__pyx_v_self), __pyx_v_layer, __pyx_v_fade_in, __pyx_v_timing, __pyx_v_volume);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_26play_layer(struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *__pyx_v_self, int __pyx_v_layer, float __pyx_v_fade_in, PyObject *__pyx_v_timing, PyObject *__pyx_v_volume) {
  __pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopLayerSettings *__pyx_v_layer_settings;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  int __pyx_t_10;
  Uint8 __pyx_t_11;
  Uint32 __pyx_t_12;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("play_layer", 0);

  /* "mpfmc/core/audio/track_sound_loop.pyx":616
 *         cdef SoundLoopLayerSettings *layer_settings
 * 
 *         if layer < 1:             # <<<<<<<<<<<<<<
 *             self.log.warning("Illegal layer value in call to play_layer (must be > 0).")
 *             return
 */
  __pyx_t_1 = ((__pyx_v_layer < 1) != 0);
  if (__pyx_t_1) {

    /* "mpfmc/core/audio/track_sound_loop.pyx":617
 * 
 *         if layer < 1:
 *             self.log.warning("Illegal layer value in call to play_layer (must be > 0).")             # <<<<<<<<<<<<<<
 *             return
 * 
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->__pyx_base.log, __pyx_n_s_warning); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 617, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_kp_u_Illegal_layer_value_in_call_to_p) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_kp_u_Illegal_layer_value_in_call_to_p);
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 617, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "mpfmc/core/audio/track_sound_loop.pyx":618
 *         if layer < 1:
 *             self.log.warning("Illegal layer value in call to play_layer (must be > 0).")
 *             return             # <<<<<<<<<<<<<<
 * 
 *         SDL_LockAudio()
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "mpfmc/core/audio/track_sound_loop.pyx":616
 *         cdef SoundLoopLayerSettings *layer_settings
 * 
 *         if layer < 1:             # <<<<<<<<<<<<<<
 *             self.log.warning("Illegal layer value in call to play_layer (must be > 0).")
 *             return
 */
  }

  /* "mpfmc/core/audio/track_sound_loop.pyx":620
 *             return
 * 
 *         SDL_LockAudio()             # <<<<<<<<<<<<<<
 * 
 *         self.log.debug("play_layer - Play layer %d of the currently playing sound_loop_set (fade-in = %f sec).",
 */
  SDL_LockAudio();

  /* "mpfmc/core/audio/track_sound_loop.pyx":622
 *         SDL_LockAudio()
 * 
 *         self.log.debug("play_layer - Play layer %d of the currently playing sound_loop_set (fade-in = %f sec).",             # <<<<<<<<<<<<<<
 *                        layer, fade_in)
 * 
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->__pyx_base.log, __pyx_n_s_debug); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 622, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);

  /* "mpfmc/core/audio/track_sound_loop.pyx":623
 * 
 *         self.log.debug("play_layer - Play layer %d of the currently playing sound_loop_set (fade-in = %f sec).",
 *                        layer, fade_in)             # <<<<<<<<<<<<<<
 * 
 *         if self.type_state.current == NULL or self.type_state.current.status not in (player_playing, player_fading_in, player_fading_out):
 */
  __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_layer); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 623, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = PyFloat_FromDouble(__pyx_v_fade_in); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 623, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = NULL;
  __pyx_t_7 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_7 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[4] = {__pyx_t_6, __pyx_kp_u_play_layer_Play_layer_d_of_the_c, __pyx_t_4, __pyx_t_5};
    __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 622, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[4] = {__pyx_t_6, __pyx_kp_u_play_layer_Play_layer_d_of_the_c, __pyx_t_4, __pyx_t_5};
    __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 622, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else
  #endif
  {
    __pyx_t_8 = PyTuple_New(3+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 622, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    if (__pyx_t_6) {
      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __pyx_t_6 = NULL;
    }
    __Pyx_INCREF(__pyx_kp_u_play_layer_Play_layer_d_of_the_c);
    __Pyx_GIVEREF(__pyx_kp_u_play_layer_Play_layer_d_of_the_c);
    PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_kp_u_play_layer_Play_layer_d_of_the_c);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_8, 2+__pyx_t_7, __pyx_t_5);
    __pyx_t_4 = 0;
    __pyx_t_5 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 622, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "mpfmc/core/audio/track_sound_loop.pyx":625
 *                        layer, fade_in)
 * 
 *         if self.type_state.current == NULL or self.type_state.current.status not in (player_playing, player_fading_in, player_fading_out):             # <<<<<<<<<<<<<<
 *             self.log.info("Unable to play layer - no sound loop set is currently playing.")
 *             SDL_UnlockAudio()
 */
  __pyx_t_9 = ((__pyx_v_self->type_state->current == NULL) != 0);
  if (!__pyx_t_9) {
  } else {
    __pyx_t_1 = __pyx_t_9;
    goto __pyx_L5_bool_binop_done;
  }
  switch (__pyx_v_self->type_state->current->status) {
    case __pyx_e_5mpfmc_4core_5audio_16track_sound_loop_player_playing:
    case __pyx_e_5mpfmc_4core_5audio_16track_sound_loop_player_fading_in:
    case __pyx_e_5mpfmc_4core_5audio_16track_sound_loop_player_fading_out:
    __pyx_t_9 = 0;
    break;
    default:
    __pyx_t_9 = 1;
    break;
  }
  __pyx_t_10 = (__pyx_t_9 != 0);
  __pyx_t_1 = __pyx_t_10;
  __pyx_L5_bool_binop_done:;
  if (__pyx_t_1) {

    /* "mpfmc/core/audio/track_sound_loop.pyx":626
 * 
 *         if self.type_state.current == NULL or self.type_state.current.status not in (player_playing, player_fading_in, player_fading_out):
 *             self.log.info("Unable to play layer - no sound loop set is currently playing.")             # <<<<<<<<<<<<<<
 *             SDL_UnlockAudio()
 *             return
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->__pyx_base.log, __pyx_n_s_info); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 626, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_8 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    __pyx_t_2 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_8, __pyx_kp_u_Unable_to_play_layer_no_sound_lo) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_kp_u_Unable_to_play_layer_no_sound_lo);
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 626, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "mpfmc/core/audio/track_sound_loop.pyx":627
 *         if self.type_state.current == NULL or self.type_state.current.status not in (player_playing, player_fading_in, player_fading_out):
 *             self.log.info("Unable to play layer - no sound loop set is currently playing.")
 *             SDL_UnlockAudio()             # <<<<<<<<<<<<<<
 *             return
 * 
 */
    SDL_UnlockAudio();

    /* "mpfmc/core/audio/track_sound_loop.pyx":628
 *             self.log.info("Unable to play layer - no sound loop set is currently playing.")
 *             SDL_UnlockAudio()
 *             return             # <<<<<<<<<<<<<<
 * 
 *         # Retrieve the layer
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "mpfmc/core/audio/track_sound_loop.pyx":625
 *                        layer, fade_in)
 * 
 *         if self.type_state.current == NULL or self.type_state.current.status not in (player_playing, player_fading_in, player_fading_out):             # <<<<<<<<<<<<<<
 *             self.log.info("Unable to play layer - no sound loop set is currently playing.")
 *             SDL_UnlockAudio()
 */
  }

  /* "mpfmc/core/audio/track_sound_loop.pyx":631
 * 
 *         # Retrieve the layer
 *         if self.type_state.current.layers == NULL:             # <<<<<<<<<<<<<<
 *             self.log.info("There are no layers defined in the current sound loop set: play_layers has no effect")
 *             SDL_UnlockAudio()
 */
  __pyx_t_1 = ((__pyx_v_self->type_state->current->layers == NULL) != 0);
  if (__pyx_t_1) {

    /* "mpfmc/core/audio/track_sound_loop.pyx":632
 *         # Retrieve the layer
 *         if self.type_state.current.layers == NULL:
 *             self.log.info("There are no layers defined in the current sound loop set: play_layers has no effect")             # <<<<<<<<<<<<<<
 *             SDL_UnlockAudio()
 *             return
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->__pyx_base.log, __pyx_n_s_info); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 632, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_8 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    __pyx_t_2 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_8, __pyx_kp_u_There_are_no_layers_defined_in_t) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_kp_u_There_are_no_layers_defined_in_t);
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 632, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "mpfmc/core/audio/track_sound_loop.pyx":633
 *         if self.type_state.current.layers == NULL:
 *             self.log.info("There are no layers defined in the current sound loop set: play_layers has no effect")
 *             SDL_UnlockAudio()             # <<<<<<<<<<<<<<
 *             return
 * 
 */
    SDL_UnlockAudio();

    /* "mpfmc/core/audio/track_sound_loop.pyx":634
 *             self.log.info("There are no layers defined in the current sound loop set: play_layers has no effect")
 *             SDL_UnlockAudio()
 *             return             # <<<<<<<<<<<<<<
 * 
 *         layer_settings = <SoundLoopLayerSettings*>g_slist_nth_data(self.type_state.current.layers, layer - 1)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "mpfmc/core/audio/track_sound_loop.pyx":631
 * 
 *         # Retrieve the layer
 *         if self.type_state.current.layers == NULL:             # <<<<<<<<<<<<<<
 *             self.log.info("There are no layers defined in the current sound loop set: play_layers has no effect")
 *             SDL_UnlockAudio()
 */
  }

  /* "mpfmc/core/audio/track_sound_loop.pyx":636
 *             return
 * 
 *         layer_settings = <SoundLoopLayerSettings*>g_slist_nth_data(self.type_state.current.layers, layer - 1)             # <<<<<<<<<<<<<<
 *         if layer_settings == NULL:
 *             self.log.info("The specified layer could not be found in the current sound loop set: play_layers has no effect")
 */
  __pyx_v_layer_settings = ((__pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopLayerSettings *)g_slist_nth_data(__pyx_v_self->type_state->current->layers, (__pyx_v_layer - 1)));

  /* "mpfmc/core/audio/track_sound_loop.pyx":637
 * 
 *         layer_settings = <SoundLoopLayerSettings*>g_slist_nth_data(self.type_state.current.layers, layer - 1)
 *         if layer_settings == NULL:             # <<<<<<<<<<<<<<
 *             self.log.info("The specified layer could not be found in the current sound loop set: play_layers has no effect")
 *             SDL_UnlockAudio()
 */
  __pyx_t_1 = ((__pyx_v_layer_settings == NULL) != 0);
  if (__pyx_t_1) {

    /* "mpfmc/core/audio/track_sound_loop.pyx":638
 *         layer_settings = <SoundLoopLayerSettings*>g_slist_nth_data(self.type_state.current.layers, layer - 1)
 *         if layer_settings == NULL:
 *             self.log.info("The specified layer could not be found in the current sound loop set: play_layers has no effect")             # <<<<<<<<<<<<<<
 *             SDL_UnlockAudio()
 *             return
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->__pyx_base.log, __pyx_n_s_info); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 638, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_8 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    __pyx_t_2 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_8, __pyx_kp_u_The_specified_layer_could_not_be) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_kp_u_The_specified_layer_could_not_be);
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 638, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "mpfmc/core/audio/track_sound_loop.pyx":639
 *         if layer_settings == NULL:
 *             self.log.info("The specified layer could not be found in the current sound loop set: play_layers has no effect")
 *             SDL_UnlockAudio()             # <<<<<<<<<<<<<<
 *             return
 * 
 */
    SDL_UnlockAudio();

    /* "mpfmc/core/audio/track_sound_loop.pyx":640
 *             self.log.info("The specified layer could not be found in the current sound loop set: play_layers has no effect")
 *             SDL_UnlockAudio()
 *             return             # <<<<<<<<<<<<<<
 * 
 *         if layer_settings.status != layer_stopped:
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "mpfmc/core/audio/track_sound_loop.pyx":637
 * 
 *         layer_settings = <SoundLoopLayerSettings*>g_slist_nth_data(self.type_state.current.layers, layer - 1)
 *         if layer_settings == NULL:             # <<<<<<<<<<<<<<
 *             self.log.info("The specified layer could not be found in the current sound loop set: play_layers has no effect")
 *             SDL_UnlockAudio()
 */
  }

  /* "mpfmc/core/audio/track_sound_loop.pyx":642
 *             return
 * 
 *         if layer_settings.status != layer_stopped:             # <<<<<<<<<<<<<<
 *             self.log.info("The current sound loop set layer is already playing: play_layers has no effect")
 *             SDL_UnlockAudio()
 */
  __pyx_t_1 = ((__pyx_v_layer_settings->status != __pyx_e_5mpfmc_4core_5audio_16track_sound_loop_layer_stopped) != 0);
  if (__pyx_t_1) {

    /* "mpfmc/core/audio/track_sound_loop.pyx":643
 * 
 *         if layer_settings.status != layer_stopped:
 *             self.log.info("The current sound loop set layer is already playing: play_layers has no effect")             # <<<<<<<<<<<<<<
 *             SDL_UnlockAudio()
 *             return
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->__pyx_base.log, __pyx_n_s_info); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 643, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_8 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    __pyx_t_2 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_8, __pyx_kp_u_The_current_sound_loop_set_layer) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_kp_u_The_current_sound_loop_set_layer);
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 643, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "mpfmc/core/audio/track_sound_loop.pyx":644
 *         if layer_settings.status != layer_stopped:
 *             self.log.info("The current sound loop set layer is already playing: play_layers has no effect")
 *             SDL_UnlockAudio()             # <<<<<<<<<<<<<<
 *             return
 * 
 */
    SDL_UnlockAudio();

    /* "mpfmc/core/audio/track_sound_loop.pyx":645
 *             self.log.info("The current sound loop set layer is already playing: play_layers has no effect")
 *             SDL_UnlockAudio()
 *             return             # <<<<<<<<<<<<<<
 * 
 *         # Layer volume (use layer settings or sound setting if None)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "mpfmc/core/audio/track_sound_loop.pyx":642
 *             return
 * 
 *         if layer_settings.status != layer_stopped:             # <<<<<<<<<<<<<<
 *             self.log.info("The current sound loop set layer is already playing: play_layers has no effect")
 *             SDL_UnlockAudio()
 */
  }

  /* "mpfmc/core/audio/track_sound_loop.pyx":648
 * 
 *         # Layer volume (use layer settings or sound setting if None)
 *         if volume:             # <<<<<<<<<<<<<<
 *             layer_settings.volume = <Uint8>(volume * SDL_MIX_MAXVOLUME)
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_volume); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 648, __pyx_L1_error)
  if (__pyx_t_1) {

    /* "mpfmc/core/audio/track_sound_loop.pyx":649
 *         # Layer volume (use layer settings or sound setting if None)
 *         if volume:
 *             layer_settings.volume = <Uint8>(volume * SDL_MIX_MAXVOLUME)             # <<<<<<<<<<<<<<
 * 
 *         # Calculate fading (done at control rate; need to calculate the number of steps over which to fade in/out)
 */
    __pyx_t_2 = __Pyx_PyInt_From_int(SDL_MIX_MAXVOLUME); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 649, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyNumber_Multiply(__pyx_v_volume, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 649, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_11 = __Pyx_PyInt_As_Uint8(__pyx_t_3); if (unlikely((__pyx_t_11 == ((Uint8)-1)) && PyErr_Occurred())) __PYX_ERR(0, 649, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_layer_settings->volume = ((Uint8)__pyx_t_11);

    /* "mpfmc/core/audio/track_sound_loop.pyx":648
 * 
 *         # Layer volume (use layer settings or sound setting if None)
 *         if volume:             # <<<<<<<<<<<<<<
 *             layer_settings.volume = <Uint8>(volume * SDL_MIX_MAXVOLUME)
 * 
 */
  }

  /* "mpfmc/core/audio/track_sound_loop.pyx":652
 * 
 *         # Calculate fading (done at control rate; need to calculate the number of steps over which to fade in/out)
 *         if fade_in > 0.0:             # <<<<<<<<<<<<<<
 *             layer_settings.fade_in_steps = <Uint32>(fade_in * self.state.callback_data.seconds_to_bytes_factor) // self.state.callback_data.bytes_per_control_point
 *             layer_settings.fade_steps_remaining = layer_settings.fade_in_steps
 */
  __pyx_t_1 = ((__pyx_v_fade_in > 0.0) != 0);
  if (__pyx_t_1) {

    /* "mpfmc/core/audio/track_sound_loop.pyx":653
 *         # Calculate fading (done at control rate; need to calculate the number of steps over which to fade in/out)
 *         if fade_in > 0.0:
 *             layer_settings.fade_in_steps = <Uint32>(fade_in * self.state.callback_data.seconds_to_bytes_factor) // self.state.callback_data.bytes_per_control_point             # <<<<<<<<<<<<<<
 *             layer_settings.fade_steps_remaining = layer_settings.fade_in_steps
 * 
 */
    __pyx_t_12 = ((Uint32)(__pyx_v_fade_in * __pyx_v_self->__pyx_base.state->callback_data->seconds_to_bytes_factor));
    if (unlikely(__pyx_v_self->__pyx_base.state->callback_data->bytes_per_control_point == 0)) {
      PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
      __PYX_ERR(0, 653, __pyx_L1_error)
    }
    __pyx_v_layer_settings->fade_in_steps = (__pyx_t_12 / __pyx_v_self->__pyx_base.state->callback_data->bytes_per_control_point);

    /* "mpfmc/core/audio/track_sound_loop.pyx":654
 *         if fade_in > 0.0:
 *             layer_settings.fade_in_steps = <Uint32>(fade_in * self.state.callback_data.seconds_to_bytes_factor) // self.state.callback_data.bytes_per_control_point
 *             layer_settings.fade_steps_remaining = layer_settings.fade_in_steps             # <<<<<<<<<<<<<<
 * 
 *         if timing == 'loop_end':
 */
    __pyx_t_12 = __pyx_v_layer_settings->fade_in_steps;
    __pyx_v_layer_settings->fade_steps_remaining = __pyx_t_12;

    /* "mpfmc/core/audio/track_sound_loop.pyx":652
 * 
 *         # Calculate fading (done at control rate; need to calculate the number of steps over which to fade in/out)
 *         if fade_in > 0.0:             # <<<<<<<<<<<<<<
 *             layer_settings.fade_in_steps = <Uint32>(fade_in * self.state.callback_data.seconds_to_bytes_factor) // self.state.callback_data.bytes_per_control_point
 *             layer_settings.fade_steps_remaining = layer_settings.fade_in_steps
 */
  }

  /* "mpfmc/core/audio/track_sound_loop.pyx":656
 *             layer_settings.fade_steps_remaining = layer_settings.fade_in_steps
 * 
 *         if timing == 'loop_end':             # <<<<<<<<<<<<<<
 *             layer_settings.status = layer_queued
 * 
 */
  __pyx_t_1 = (__Pyx_PyUnicode_Equals(__pyx_v_timing, __pyx_n_u_loop_end, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 656, __pyx_L1_error)
  __pyx_t_10 = (__pyx_t_1 != 0);
  if (__pyx_t_10) {

    /* "mpfmc/core/audio/track_sound_loop.pyx":657
 * 
 *         if timing == 'loop_end':
 *             layer_settings.status = layer_queued             # <<<<<<<<<<<<<<
 * 
 *         elif timing == 'now':
 */
    __pyx_v_layer_settings->status = __pyx_e_5mpfmc_4core_5audio_16track_sound_loop_layer_queued;

    /* "mpfmc/core/audio/track_sound_loop.pyx":656
 *             layer_settings.fade_steps_remaining = layer_settings.fade_in_steps
 * 
 *         if timing == 'loop_end':             # <<<<<<<<<<<<<<
 *             layer_settings.status = layer_queued
 * 
 */
    goto __pyx_L12;
  }

  /* "mpfmc/core/audio/track_sound_loop.pyx":659
 *             layer_settings.status = layer_queued
 * 
 *         elif timing == 'now':             # <<<<<<<<<<<<<<
 *             if layer_settings.fade_in_steps > 0:
 *                 layer_settings.status = layer_fading_in
 */
  __pyx_t_10 = (__Pyx_PyUnicode_Equals(__pyx_v_timing, __pyx_n_u_now, Py_EQ)); if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(0, 659, __pyx_L1_error)
  __pyx_t_1 = (__pyx_t_10 != 0);
  if (__pyx_t_1) {

    /* "mpfmc/core/audio/track_sound_loop.pyx":660
 * 
 *         elif timing == 'now':
 *             if layer_settings.fade_in_steps > 0:             # <<<<<<<<<<<<<<
 *                 layer_settings.status = layer_fading_in
 *             else:
 */
    __pyx_t_1 = ((__pyx_v_layer_settings->fade_in_steps > 0) != 0);
    if (__pyx_t_1) {

      /* "mpfmc/core/audio/track_sound_loop.pyx":661
 *         elif timing == 'now':
 *             if layer_settings.fade_in_steps > 0:
 *                 layer_settings.status = layer_fading_in             # <<<<<<<<<<<<<<
 *             else:
 *                 layer_settings.status = layer_playing
 */
      __pyx_v_layer_settings->status = __pyx_e_5mpfmc_4core_5audio_16track_sound_loop_layer_fading_in;

      /* "mpfmc/core/audio/track_sound_loop.pyx":660
 * 
 *         elif timing == 'now':
 *             if layer_settings.fade_in_steps > 0:             # <<<<<<<<<<<<<<
 *                 layer_settings.status = layer_fading_in
 *             else:
 */
      goto __pyx_L13;
    }

    /* "mpfmc/core/audio/track_sound_loop.pyx":663
 *                 layer_settings.status = layer_fading_in
 *             else:
 *                 layer_settings.status = layer_playing             # <<<<<<<<<<<<<<
 *         else:
 *             self.log.error("Unknown timing value specified: %s", timing)
 */
    /*else*/ {
      __pyx_v_layer_settings->status = __pyx_e_5mpfmc_4core_5audio_16track_sound_loop_layer_playing;
    }
    __pyx_L13:;

    /* "mpfmc/core/audio/track_sound_loop.pyx":659
 *             layer_settings.status = layer_queued
 * 
 *         elif timing == 'now':             # <<<<<<<<<<<<<<
 *             if layer_settings.fade_in_steps > 0:
 *                 layer_settings.status = layer_fading_in
 */
    goto __pyx_L12;
  }

  /* "mpfmc/core/audio/track_sound_loop.pyx":665
 *                 layer_settings.status = layer_playing
 *         else:
 *             self.log.error("Unknown timing value specified: %s", timing)             # <<<<<<<<<<<<<<
 *             SDL_UnlockAudio()
 *             return
 */
  /*else*/ {
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->__pyx_base.log, __pyx_n_s_error); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 665, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_8 = NULL;
    __pyx_t_7 = 0;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
        __pyx_t_7 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_kp_u_Unknown_timing_value_specified_s, __pyx_v_timing};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 665, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_kp_u_Unknown_timing_value_specified_s, __pyx_v_timing};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 665, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    {
      __pyx_t_5 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 665, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      if (__pyx_t_8) {
        __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_8); __pyx_t_8 = NULL;
      }
      __Pyx_INCREF(__pyx_kp_u_Unknown_timing_value_specified_s);
      __Pyx_GIVEREF(__pyx_kp_u_Unknown_timing_value_specified_s);
      PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_7, __pyx_kp_u_Unknown_timing_value_specified_s);
      __Pyx_INCREF(__pyx_v_timing);
      __Pyx_GIVEREF(__pyx_v_timing);
      PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_7, __pyx_v_timing);
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 665, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "mpfmc/core/audio/track_sound_loop.pyx":666
 *         else:
 *             self.log.error("Unknown timing value specified: %s", timing)
 *             SDL_UnlockAudio()             # <<<<<<<<<<<<<<
 *             return
 * 
 */
    SDL_UnlockAudio();

    /* "mpfmc/core/audio/track_sound_loop.pyx":667
 *             self.log.error("Unknown timing value specified: %s", timing)
 *             SDL_UnlockAudio()
 *             return             # <<<<<<<<<<<<<<
 * 
 *         layer_settings.looping = True
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;
  }
  __pyx_L12:;

  /* "mpfmc/core/audio/track_sound_loop.pyx":669
 *             return
 * 
 *         layer_settings.looping = True             # <<<<<<<<<<<<<<
 * 
 *         SDL_UnlockAudio()
 */
  __pyx_v_layer_settings->looping = 1;

  /* "mpfmc/core/audio/track_sound_loop.pyx":671
 *         layer_settings.looping = True
 * 
 *         SDL_UnlockAudio()             # <<<<<<<<<<<<<<
 * 
 *     def stop_layer(self, int layer, float fade_out=0.0):
 */
  SDL_UnlockAudio();

  /* "mpfmc/core/audio/track_sound_loop.pyx":603
 *         SDL_UnlockAudio()
 * 
 *     def play_layer(self, int layer, float fade_in=0.0, str timing="loop_end", volume=None):             # <<<<<<<<<<<<<<
 *         """
 *         Plays the specified layer number in the currently playing sound loop set.
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("mpfmc.core.audio.track_sound_loop.TrackSoundLoop.play_layer", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mpfmc/core/audio/track_sound_loop.pyx":673
 *         SDL_UnlockAudio()
 * 
 *     def stop_layer(self, int layer, float fade_out=0.0):             # <<<<<<<<<<<<<<
 *         """
 *         Stops the specified layer number in the currently playing sound loop set.
 */

/* Python wrapper */
static PyObject *__pyx_pw_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_29stop_layer(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_28stop_layer[] = "TrackSoundLoop.stop_layer(self, int layer, float fade_out=0.0)\n\n        Stops the specified layer number in the currently playing sound loop set.\n\n        Args:\n            layer: The layer number to stop (1-based array position).\n            fade_out: The number of seconds over which to fade out the layer before stopping.\n        ";
static PyObject *__pyx_pw_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_29stop_layer(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_layer;
  float __pyx_v_fade_out;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("stop_layer (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_layer,&__pyx_n_s_fade_out,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_layer)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_fade_out);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "stop_layer") < 0)) __PYX_ERR(0, 673, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_layer = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_layer == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 673, __pyx_L3_error)
    if (values[1]) {
      __pyx_v_fade_out = __pyx_PyFloat_AsFloat(values[1]); if (unlikely((__pyx_v_fade_out == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 673, __pyx_L3_error)
    } else {
      __pyx_v_fade_out = ((float)0.0);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("stop_layer", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 673, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mpfmc.core.audio.track_sound_loop.TrackSoundLoop.stop_layer", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_28stop_layer(((struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *)__pyx_v_self), __pyx_v_layer, __pyx_v_fade_out);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_28stop_layer(struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *__pyx_v_self, int __pyx_v_layer, float __pyx_v_fade_out) {
  __pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopLayerSettings *__pyx_v_layer_settings;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  int __pyx_t_10;
  Uint32 __pyx_t_11;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("stop_layer", 0);

  /* "mpfmc/core/audio/track_sound_loop.pyx":683
 *         cdef SoundLoopLayerSettings *layer_settings
 * 
 *         if layer < 1:             # <<<<<<<<<<<<<<
 *             self.log.warning("Illegal layer value in call to stop_layer (must be > 0).")
 *             return
 */
  __pyx_t_1 = ((__pyx_v_layer < 1) != 0);
  if (__pyx_t_1) {

    /* "mpfmc/core/audio/track_sound_loop.pyx":684
 * 
 *         if layer < 1:
 *             self.log.warning("Illegal layer value in call to stop_layer (must be > 0).")             # <<<<<<<<<<<<<<
 *             return
 * 
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->__pyx_base.log, __pyx_n_s_warning); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 684, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_kp_u_Illegal_layer_value_in_call_to_s) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_kp_u_Illegal_layer_value_in_call_to_s);
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 684, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "mpfmc/core/audio/track_sound_loop.pyx":685
 *         if layer < 1:
 *             self.log.warning("Illegal layer value in call to stop_layer (must be > 0).")
 *             return             # <<<<<<<<<<<<<<
 * 
 *         SDL_LockAudio()
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "mpfmc/core/audio/track_sound_loop.pyx":683
 *         cdef SoundLoopLayerSettings *layer_settings
 * 
 *         if layer < 1:             # <<<<<<<<<<<<<<
 *             self.log.warning("Illegal layer value in call to stop_layer (must be > 0).")
 *             return
 */
  }

  /* "mpfmc/core/audio/track_sound_loop.pyx":687
 *             return
 * 
 *         SDL_LockAudio()             # <<<<<<<<<<<<<<
 * 
 *         self.log.debug("stop_layer - Stop layer %d of the currently playing sound_loop_set (fade-out = %f sec).",
 */
  SDL_LockAudio();

  /* "mpfmc/core/audio/track_sound_loop.pyx":689
 *         SDL_LockAudio()
 * 
 *         self.log.debug("stop_layer - Stop layer %d of the currently playing sound_loop_set (fade-out = %f sec).",             # <<<<<<<<<<<<<<
 *                        layer, fade_out)
 * 
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->__pyx_base.log, __pyx_n_s_debug); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 689, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);

  /* "mpfmc/core/audio/track_sound_loop.pyx":690
 * 
 *         self.log.debug("stop_layer - Stop layer %d of the currently playing sound_loop_set (fade-out = %f sec).",
 *                        layer, fade_out)             # <<<<<<<<<<<<<<
 * 
 *         if self.type_state.current == NULL or self.type_state.current.status not in (player_playing, player_fading_in, player_fading_out):
 */
  __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_layer); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 690, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = PyFloat_FromDouble(__pyx_v_fade_out); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 690, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = NULL;
  __pyx_t_7 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_7 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[4] = {__pyx_t_6, __pyx_kp_u_stop_layer_Stop_layer_d_of_the_c, __pyx_t_4, __pyx_t_5};
    __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 689, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[4] = {__pyx_t_6, __pyx_kp_u_stop_layer_Stop_layer_d_of_the_c, __pyx_t_4, __pyx_t_5};
    __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 689, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else
  #endif
  {
    __pyx_t_8 = PyTuple_New(3+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 689, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    if (__pyx_t_6) {
      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __pyx_t_6 = NULL;
    }
    __Pyx_INCREF(__pyx_kp_u_stop_layer_Stop_layer_d_of_the_c);
    __Pyx_GIVEREF(__pyx_kp_u_stop_layer_Stop_layer_d_of_the_c);
    PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_kp_u_stop_layer_Stop_layer_d_of_the_c);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_8, 2+__pyx_t_7, __pyx_t_5);
    __pyx_t_4 = 0;
    __pyx_t_5 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 689, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "mpfmc/core/audio/track_sound_loop.pyx":692
 *                        layer, fade_out)
 * 
 *         if self.type_state.current == NULL or self.type_state.current.status not in (player_playing, player_fading_in, player_fading_out):             # <<<<<<<<<<<<<<
 *             self.log.info("Unable to stop layer - no sound loop set is currently playing.")
 *             SDL_UnlockAudio()
 */
  __pyx_t_9 = ((__pyx_v_self->type_state->current == NULL) != 0);
  if (!__pyx_t_9) {
  } else {
    __pyx_t_1 = __pyx_t_9;
    goto __pyx_L5_bool_binop_done;
  }
  switch (__pyx_v_self->type_state->current->status) {
    case __pyx_e_5mpfmc_4core_5audio_16track_sound_loop_player_playing:
    case __pyx_e_5mpfmc_4core_5audio_16track_sound_loop_player_fading_in:
    case __pyx_e_5mpfmc_4core_5audio_16track_sound_loop_player_fading_out:
    __pyx_t_9 = 0;
    break;
    default:
    __pyx_t_9 = 1;
    break;
  }
  __pyx_t_10 = (__pyx_t_9 != 0);
  __pyx_t_1 = __pyx_t_10;
  __pyx_L5_bool_binop_done:;
  if (__pyx_t_1) {

    /* "mpfmc/core/audio/track_sound_loop.pyx":693
 * 
 *         if self.type_state.current == NULL or self.type_state.current.status not in (player_playing, player_fading_in, player_fading_out):
 *             self.log.info("Unable to stop layer - no sound loop set is currently playing.")             # <<<<<<<<<<<<<<
 *             SDL_UnlockAudio()
 *             return
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->__pyx_base.log, __pyx_n_s_info); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 693, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_8 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    __pyx_t_2 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_8, __pyx_kp_u_Unable_to_stop_layer_no_sound_lo) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_kp_u_Unable_to_stop_layer_no_sound_lo);
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 693, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "mpfmc/core/audio/track_sound_loop.pyx":694
 *         if self.type_state.current == NULL or self.type_state.current.status not in (player_playing, player_fading_in, player_fading_out):
 *             self.log.info("Unable to stop layer - no sound loop set is currently playing.")
 *             SDL_UnlockAudio()             # <<<<<<<<<<<<<<
 *             return
 * 
 */
    SDL_UnlockAudio();

    /* "mpfmc/core/audio/track_sound_loop.pyx":695
 *             self.log.info("Unable to stop layer - no sound loop set is currently playing.")
 *             SDL_UnlockAudio()
 *             return             # <<<<<<<<<<<<<<
 * 
 *         # Retrieve the layer
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "mpfmc/core/audio/track_sound_loop.pyx":692
 *                        layer, fade_out)
 * 
 *         if self.type_state.current == NULL or self.type_state.current.status not in (player_playing, player_fading_in, player_fading_out):             # <<<<<<<<<<<<<<
 *             self.log.info("Unable to stop layer - no sound loop set is currently playing.")
 *             SDL_UnlockAudio()
 */
  }

  /* "mpfmc/core/audio/track_sound_loop.pyx":698
 * 
 *         # Retrieve the layer
 *         if self.type_state.current.layers == NULL:             # <<<<<<<<<<<<<<
 *             self.log.info("There are no layers defined in the current sound loop set: stop_layers has no effect")
 *             SDL_UnlockAudio()
 */
  __pyx_t_1 = ((__pyx_v_self->type_state->current->layers == NULL) != 0);
  if (__pyx_t_1) {

    /* "mpfmc/core/audio/track_sound_loop.pyx":699
 *         # Retrieve the layer
 *         if self.type_state.current.layers == NULL:
 *             self.log.info("There are no layers defined in the current sound loop set: stop_layers has no effect")             # <<<<<<<<<<<<<<
 *             SDL_UnlockAudio()
 *             return
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->__pyx_base.log, __pyx_n_s_info); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 699, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_8 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    __pyx_t_2 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_8, __pyx_kp_u_There_are_no_layers_defined_in_t_2) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_kp_u_There_are_no_layers_defined_in_t_2);
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 699, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "mpfmc/core/audio/track_sound_loop.pyx":700
 *         if self.type_state.current.layers == NULL:
 *             self.log.info("There are no layers defined in the current sound loop set: stop_layers has no effect")
 *             SDL_UnlockAudio()             # <<<<<<<<<<<<<<
 *             return
 * 
 */
    SDL_UnlockAudio();

    /* "mpfmc/core/audio/track_sound_loop.pyx":701
 *             self.log.info("There are no layers defined in the current sound loop set: stop_layers has no effect")
 *             SDL_UnlockAudio()
 *             return             # <<<<<<<<<<<<<<
 * 
 *         layer_settings = <SoundLoopLayerSettings*>g_slist_nth_data(self.type_state.current.layers, layer - 1)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "mpfmc/core/audio/track_sound_loop.pyx":698
 * 
 *         # Retrieve the layer
 *         if self.type_state.current.layers == NULL:             # <<<<<<<<<<<<<<
 *             self.log.info("There are no layers defined in the current sound loop set: stop_layers has no effect")
 *             SDL_UnlockAudio()
 */
  }

  /* "mpfmc/core/audio/track_sound_loop.pyx":703
 *             return
 * 
 *         layer_settings = <SoundLoopLayerSettings*>g_slist_nth_data(self.type_state.current.layers, layer - 1)             # <<<<<<<<<<<<<<
 *         if layer_settings == NULL:
 *             self.log.info("The specified layer could not be found in the current sound loop set: stop_layers has no effect")
 */
  __pyx_v_layer_settings = ((__pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopLayerSettings *)g_slist_nth_data(__pyx_v_self->type_state->current->layers, (__pyx_v_layer - 1)));

  /* "mpfmc/core/audio/track_sound_loop.pyx":704
 * 
 *         layer_settings = <SoundLoopLayerSettings*>g_slist_nth_data(self.type_state.current.layers, layer - 1)
 *         if layer_settings == NULL:             # <<<<<<<<<<<<<<
 *             self.log.info("The specified layer could not be found in the current sound loop set: stop_layers has no effect")
 *             SDL_UnlockAudio()
 */
  __pyx_t_1 = ((__pyx_v_layer_settings == NULL) != 0);
  if (__pyx_t_1) {

    /* "mpfmc/core/audio/track_sound_loop.pyx":705
 *         layer_settings = <SoundLoopLayerSettings*>g_slist_nth_data(self.type_state.current.layers, layer - 1)
 *         if layer_settings == NULL:
 *             self.log.info("The specified layer could not be found in the current sound loop set: stop_layers has no effect")             # <<<<<<<<<<<<<<
 *             SDL_UnlockAudio()
 *             return
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->__pyx_base.log, __pyx_n_s_info); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 705, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_8 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    __pyx_t_2 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_8, __pyx_kp_u_The_specified_layer_could_not_be_2) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_kp_u_The_specified_layer_could_not_be_2);
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 705, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "mpfmc/core/audio/track_sound_loop.pyx":706
 *         if layer_settings == NULL:
 *             self.log.info("The specified layer could not be found in the current sound loop set: stop_layers has no effect")
 *             SDL_UnlockAudio()             # <<<<<<<<<<<<<<
 *             return
 * 
 */
    SDL_UnlockAudio();

    /* "mpfmc/core/audio/track_sound_loop.pyx":707
 *             self.log.info("The specified layer could not be found in the current sound loop set: stop_layers has no effect")
 *             SDL_UnlockAudio()
 *             return             # <<<<<<<<<<<<<<
 * 
 *         if layer_settings.status == layer_stopped:
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "mpfmc/core/audio/track_sound_loop.pyx":704
 * 
 *         layer_settings = <SoundLoopLayerSettings*>g_slist_nth_data(self.type_state.current.layers, layer - 1)
 *         if layer_settings == NULL:             # <<<<<<<<<<<<<<
 *             self.log.info("The specified layer could not be found in the current sound loop set: stop_layers has no effect")
 *             SDL_UnlockAudio()
 */
  }

  /* "mpfmc/core/audio/track_sound_loop.pyx":709
 *             return
 * 
 *         if layer_settings.status == layer_stopped:             # <<<<<<<<<<<<<<
 *             self.log.info("The current sound loop set layer is already stopped: stop_layers has no effect")
 *             SDL_UnlockAudio()
 */
  __pyx_t_1 = ((__pyx_v_layer_settings->status == __pyx_e_5mpfmc_4core_5audio_16track_sound_loop_layer_stopped) != 0);
  if (__pyx_t_1) {

    /* "mpfmc/core/audio/track_sound_loop.pyx":710
 * 
 *         if layer_settings.status == layer_stopped:
 *             self.log.info("The current sound loop set layer is already stopped: stop_layers has no effect")             # <<<<<<<<<<<<<<
 *             SDL_UnlockAudio()
 *             return
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->__pyx_base.log, __pyx_n_s_info); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 710, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_8 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    __pyx_t_2 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_8, __pyx_kp_u_The_current_sound_loop_set_layer_2) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_kp_u_The_current_sound_loop_set_layer_2);
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 710, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "mpfmc/core/audio/track_sound_loop.pyx":711
 *         if layer_settings.status == layer_stopped:
 *             self.log.info("The current sound loop set layer is already stopped: stop_layers has no effect")
 *             SDL_UnlockAudio()             # <<<<<<<<<<<<<<
 *             return
 * 
 */
    SDL_UnlockAudio();

    /* "mpfmc/core/audio/track_sound_loop.pyx":712
 *             self.log.info("The current sound loop set layer is already stopped: stop_layers has no effect")
 *             SDL_UnlockAudio()
 *             return             # <<<<<<<<<<<<<<
 * 
 *         # Calculate fading (done at control rate; need to calculate the number of steps over which to fade in/out)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "mpfmc/core/audio/track_sound_loop.pyx":709
 *             return
 * 
 *         if layer_settings.status == layer_stopped:             # <<<<<<<<<<<<<<
 *             self.log.info("The current sound loop set layer is already stopped: stop_layers has no effect")
 *             SDL_UnlockAudio()
 */
  }

  /* "mpfmc/core/audio/track_sound_loop.pyx":715
 * 
 *         # Calculate fading (done at control rate; need to calculate the number of steps over which to fade in/out)
 *         if fade_out > 0.0:             # <<<<<<<<<<<<<<
 *             layer_settings.fade_out_steps = <Uint32>(fade_out * self.state.callback_data.seconds_to_bytes_factor) // self.state.callback_data.bytes_per_control_point
 *             layer_settings.fade_steps_remaining = layer_settings.fade_out_steps
 */
  __pyx_t_1 = ((__pyx_v_fade_out > 0.0) != 0);
  if (__pyx_t_1) {

    /* "mpfmc/core/audio/track_sound_loop.pyx":716
 *         # Calculate fading (done at control rate; need to calculate the number of steps over which to fade in/out)
 *         if fade_out > 0.0:
 *             layer_settings.fade_out_steps = <Uint32>(fade_out * self.state.callback_data.seconds_to_bytes_factor) // self.state.callback_data.bytes_per_control_point             # <<<<<<<<<<<<<<
 *             layer_settings.fade_steps_remaining = layer_settings.fade_out_steps
 *             layer_settings.status = layer_fading_out
 */
    __pyx_t_11 = ((Uint32)(__pyx_v_fade_out * __pyx_v_self->__pyx_base.state->callback_data->seconds_to_bytes_factor));
    if (unlikely(__pyx_v_self->__pyx_base.state->callback_data->bytes_per_control_point == 0)) {
      PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
      __PYX_ERR(0, 716, __pyx_L1_error)
    }
    __pyx_v_layer_settings->fade_out_steps = (__pyx_t_11 / __pyx_v_self->__pyx_base.state->callback_data->bytes_per_control_point);

    /* "mpfmc/core/audio/track_sound_loop.pyx":717
 *         if fade_out > 0.0:
 *             layer_settings.fade_out_steps = <Uint32>(fade_out * self.state.callback_data.seconds_to_bytes_factor) // self.state.callback_data.bytes_per_control_point
 *             layer_settings.fade_steps_remaining = layer_settings.fade_out_steps             # <<<<<<<<<<<<<<
 *             layer_settings.status = layer_fading_out
 *         else:
 */
    __pyx_t_11 = __pyx_v_layer_settings->fade_out_steps;
    __pyx_v_layer_settings->fade_steps_remaining = __pyx_t_11;

    /* "mpfmc/core/audio/track_sound_loop.pyx":718
 *             layer_settings.fade_out_steps = <Uint32>(fade_out * self.state.callback_data.seconds_to_bytes_factor) // self.state.callback_data.bytes_per_control_point
 *             layer_settings.fade_steps_remaining = layer_settings.fade_out_steps
 *             layer_settings.status = layer_fading_out             # <<<<<<<<<<<<<<
 *         else:
 *             # TODO: Could perform a quick fade out rather than an abrupt stop
 */
    __pyx_v_layer_settings->status = __pyx_e_5mpfmc_4core_5audio_16track_sound_loop_layer_fading_out;

    /* "mpfmc/core/audio/track_sound_loop.pyx":715
 * 
 *         # Calculate fading (done at control rate; need to calculate the number of steps over which to fade in/out)
 *         if fade_out > 0.0:             # <<<<<<<<<<<<<<
 *             layer_settings.fade_out_steps = <Uint32>(fade_out * self.state.callback_data.seconds_to_bytes_factor) // self.state.callback_data.bytes_per_control_point
 *             layer_settings.fade_steps_remaining = layer_settings.fade_out_steps
 */
    goto __pyx_L10;
  }

  /* "mpfmc/core/audio/track_sound_loop.pyx":721
 *         else:
 *             # TODO: Could perform a quick fade out rather than an abrupt stop
 *             layer_settings.status = layer_stopped             # <<<<<<<<<<<<<<
 * 
 *         SDL_UnlockAudio()
 */
  /*else*/ {
    __pyx_v_layer_settings->status = __pyx_e_5mpfmc_4core_5audio_16track_sound_loop_layer_stopped;
  }
  __pyx_L10:;

  /* "mpfmc/core/audio/track_sound_loop.pyx":723
 *             layer_settings.status = layer_stopped
 * 
 *         SDL_UnlockAudio()             # <<<<<<<<<<<<<<
 * 
 *     def stop_looping_layer(self, int layer):
 */
  SDL_UnlockAudio();

  /* "mpfmc/core/audio/track_sound_loop.pyx":673
 *         SDL_UnlockAudio()
 * 
 *     def stop_layer(self, int layer, float fade_out=0.0):             # <<<<<<<<<<<<<<
 *         """
 *         Stops the specified layer number in the currently playing sound loop set.
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("mpfmc.core.audio.track_sound_loop.TrackSoundLoop.stop_layer", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mpfmc/core/audio/track_sound_loop.pyx":725
 *         SDL_UnlockAudio()
 * 
 *     def stop_looping_layer(self, int layer):             # <<<<<<<<<<<<<<
 *         """
 *         Stops the specified layer number in the currently playing sound loop set after
 */

/* Python wrapper */
static PyObject *__pyx_pw_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_31stop_looping_layer(PyObject *__pyx_v_self, PyObject *__pyx_arg_layer); /*proto*/
static char __pyx_doc_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_30stop_looping_layer[] = "TrackSoundLoop.stop_looping_layer(self, int layer)\n\n        Stops the specified layer number in the currently playing sound loop set after\n        the currently playing loop finishes.\n\n        Args:\n            layer: The layer number to stop looping (1-based array position).\n        ";
static PyObject *__pyx_pw_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_31stop_looping_layer(PyObject *__pyx_v_self, PyObject *__pyx_arg_layer) {
  int __pyx_v_layer;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("stop_looping_layer (wrapper)", 0);
  assert(__pyx_arg_layer); {
    __pyx_v_layer = __Pyx_PyInt_As_int(__pyx_arg_layer); if (unlikely((__pyx_v_layer == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 725, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("mpfmc.core.audio.track_sound_loop.TrackSoundLoop.stop_looping_layer", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_30stop_looping_layer(((struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *)__pyx_v_self), ((int)__pyx_v_layer));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_30stop_looping_layer(struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *__pyx_v_self, int __pyx_v_layer) {
  __pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopLayerSettings *__pyx_v_layer_settings;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("stop_looping_layer", 0);

  /* "mpfmc/core/audio/track_sound_loop.pyx":735
 *         cdef SoundLoopLayerSettings *layer_settings
 * 
 *         if layer < 1:             # <<<<<<<<<<<<<<
 *             self.log.warning("Illegal layer value in call to stop_looping_layer (must be > 0).")
 *             return
 */
  __pyx_t_1 = ((__pyx_v_layer < 1) != 0);
  if (__pyx_t_1) {

    /* "mpfmc/core/audio/track_sound_loop.pyx":736
 * 
 *         if layer < 1:
 *             self.log.warning("Illegal layer value in call to stop_looping_layer (must be > 0).")             # <<<<<<<<<<<<<<
 *             return
 * 
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->__pyx_base.log, __pyx_n_s_warning); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 736, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_kp_u_Illegal_layer_value_in_call_to_s_2) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_kp_u_Illegal_layer_value_in_call_to_s_2);
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 736, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "mpfmc/core/audio/track_sound_loop.pyx":737
 *         if layer < 1:
 *             self.log.warning("Illegal layer value in call to stop_looping_layer (must be > 0).")
 *             return             # <<<<<<<<<<<<<<
 * 
 *         SDL_LockAudio()
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "mpfmc/core/audio/track_sound_loop.pyx":735
 *         cdef SoundLoopLayerSettings *layer_settings
 * 
 *         if layer < 1:             # <<<<<<<<<<<<<<
 *             self.log.warning("Illegal layer value in call to stop_looping_layer (must be > 0).")
 *             return
 */
  }

  /* "mpfmc/core/audio/track_sound_loop.pyx":739
 *             return
 * 
 *         SDL_LockAudio()             # <<<<<<<<<<<<<<
 * 
 *         self.log.debug("stop_looping_layer - Stop looping layer %d of the currently playing sound_loop_set.", layer)
 */
  SDL_LockAudio();

  /* "mpfmc/core/audio/track_sound_loop.pyx":741
 *         SDL_LockAudio()
 * 
 *         self.log.debug("stop_looping_layer - Stop looping layer %d of the currently playing sound_loop_set.", layer)             # <<<<<<<<<<<<<<
 * 
 *         # Retrieve the layer
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->__pyx_base.log, __pyx_n_s_debug); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 741, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_layer); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 741, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = NULL;
  __pyx_t_6 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_6 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_kp_u_stop_looping_layer_Stop_looping, __pyx_t_4};
    __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 741, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_kp_u_stop_looping_layer_Stop_looping, __pyx_t_4};
    __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 741, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else
  #endif
  {
    __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 741, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    if (__pyx_t_5) {
      __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
    }
    __Pyx_INCREF(__pyx_kp_u_stop_looping_layer_Stop_looping);
    __Pyx_GIVEREF(__pyx_kp_u_stop_looping_layer_Stop_looping);
    PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_kp_u_stop_looping_layer_Stop_looping);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 741, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "mpfmc/core/audio/track_sound_loop.pyx":744
 * 
 *         # Retrieve the layer
 *         if self.type_state.current.layers == NULL:             # <<<<<<<<<<<<<<
 *             self.log.info("There are no layers defined in the current sound loop set: "
 *                           "stop_looping_layers has no effect")
 */
  __pyx_t_1 = ((__pyx_v_self->type_state->current->layers == NULL) != 0);
  if (__pyx_t_1) {

    /* "mpfmc/core/audio/track_sound_loop.pyx":745
 *         # Retrieve the layer
 *         if self.type_state.current.layers == NULL:
 *             self.log.info("There are no layers defined in the current sound loop set: "             # <<<<<<<<<<<<<<
 *                           "stop_looping_layers has no effect")
 *             SDL_UnlockAudio()
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->__pyx_base.log, __pyx_n_s_info); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 745, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_7 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    __pyx_t_2 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_7, __pyx_kp_u_There_are_no_layers_defined_in_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_kp_u_There_are_no_layers_defined_in_t_3);
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 745, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "mpfmc/core/audio/track_sound_loop.pyx":747
 *             self.log.info("There are no layers defined in the current sound loop set: "
 *                           "stop_looping_layers has no effect")
 *             SDL_UnlockAudio()             # <<<<<<<<<<<<<<
 *             return
 * 
 */
    SDL_UnlockAudio();

    /* "mpfmc/core/audio/track_sound_loop.pyx":748
 *                           "stop_looping_layers has no effect")
 *             SDL_UnlockAudio()
 *             return             # <<<<<<<<<<<<<<
 * 
 *         layer_settings = <SoundLoopLayerSettings*>g_slist_nth_data(self.type_state.current.layers, layer - 1)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "mpfmc/core/audio/track_sound_loop.pyx":744
 * 
 *         # Retrieve the layer
 *         if self.type_state.current.layers == NULL:             # <<<<<<<<<<<<<<
 *             self.log.info("There are no layers defined in the current sound loop set: "
 *                           "stop_looping_layers has no effect")
 */
  }

  /* "mpfmc/core/audio/track_sound_loop.pyx":750
 *             return
 * 
 *         layer_settings = <SoundLoopLayerSettings*>g_slist_nth_data(self.type_state.current.layers, layer - 1)             # <<<<<<<<<<<<<<
 *         if layer_settings == NULL:
 *             self.log.info("The specified layer could not be found in the current sound loop set: "
 */
  __pyx_v_layer_settings = ((__pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopLayerSettings *)g_slist_nth_data(__pyx_v_self->type_state->current->layers, (__pyx_v_layer - 1)));

  /* "mpfmc/core/audio/track_sound_loop.pyx":751
 * 
 *         layer_settings = <SoundLoopLayerSettings*>g_slist_nth_data(self.type_state.current.layers, layer - 1)
 *         if layer_settings == NULL:             # <<<<<<<<<<<<<<
 *             self.log.info("The specified layer could not be found in the current sound loop set: "
 *                           "stop_looping_layers has no effect")
 */
  __pyx_t_1 = ((__pyx_v_layer_settings == NULL) != 0);
  if (__pyx_t_1) {

    /* "mpfmc/core/audio/track_sound_loop.pyx":752
 *         layer_settings = <SoundLoopLayerSettings*>g_slist_nth_data(self.type_state.current.layers, layer - 1)
 *         if layer_settings == NULL:
 *             self.log.info("The specified layer could not be found in the current sound loop set: "             # <<<<<<<<<<<<<<
 *                           "stop_looping_layers has no effect")
 *             SDL_UnlockAudio()
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->__pyx_base.log, __pyx_n_s_info); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 752, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_7 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    __pyx_t_2 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_7, __pyx_kp_u_The_specified_layer_could_not_be_3) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_kp_u_The_specified_layer_could_not_be_3);
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 752, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "mpfmc/core/audio/track_sound_loop.pyx":754
 *             self.log.info("The specified layer could not be found in the current sound loop set: "
 *                           "stop_looping_layers has no effect")
 *             SDL_UnlockAudio()             # <<<<<<<<<<<<<<
 *             return
 * 
 */
    SDL_UnlockAudio();

    /* "mpfmc/core/audio/track_sound_loop.pyx":755
 *                           "stop_looping_layers has no effect")
 *             SDL_UnlockAudio()
 *             return             # <<<<<<<<<<<<<<
 * 
 *         if layer_settings.status == layer_stopped:
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "mpfmc/core/audio/track_sound_loop.pyx":751
 * 
 *         layer_settings = <SoundLoopLayerSettings*>g_slist_nth_data(self.type_state.current.layers, layer - 1)
 *         if layer_settings == NULL:             # <<<<<<<<<<<<<<
 *             self.log.info("The specified layer could not be found in the current sound loop set: "
 *                           "stop_looping_layers has no effect")
 */
  }

  /* "mpfmc/core/audio/track_sound_loop.pyx":757
 *             return
 * 
 *         if layer_settings.status == layer_stopped:             # <<<<<<<<<<<<<<
 *             self.log.info("The current sound loop set layer is already stopped: "
 *                           "stop_looping_layers has no effect")
 */
  __pyx_t_1 = ((__pyx_v_layer_settings->status == __pyx_e_5mpfmc_4core_5audio_16track_sound_loop_layer_stopped) != 0);
  if (__pyx_t_1) {

    /* "mpfmc/core/audio/track_sound_loop.pyx":758
 * 
 *         if layer_settings.status == layer_stopped:
 *             self.log.info("The current sound loop set layer is already stopped: "             # <<<<<<<<<<<<<<
 *                           "stop_looping_layers has no effect")
 *             SDL_UnlockAudio()
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->__pyx_base.log, __pyx_n_s_info); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 758, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_7 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    __pyx_t_2 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_7, __pyx_kp_u_The_current_sound_loop_set_layer_3) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_kp_u_The_current_sound_loop_set_layer_3);
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 758, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "mpfmc/core/audio/track_sound_loop.pyx":760
 *             self.log.info("The current sound loop set layer is already stopped: "
 *                           "stop_looping_layers has no effect")
 *             SDL_UnlockAudio()             # <<<<<<<<<<<<<<
 *             return
 * 
 */
    SDL_UnlockAudio();

    /* "mpfmc/core/audio/track_sound_loop.pyx":761
 *                           "stop_looping_layers has no effect")
 *             SDL_UnlockAudio()
 *             return             # <<<<<<<<<<<<<<
 * 
 *         layer_settings.looping = False
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "mpfmc/core/audio/track_sound_loop.pyx":757
 *             return
 * 
 *         if layer_settings.status == layer_stopped:             # <<<<<<<<<<<<<<
 *             self.log.info("The current sound loop set layer is already stopped: "
 *                           "stop_looping_layers has no effect")
 */
  }

  /* "mpfmc/core/audio/track_sound_loop.pyx":763
 *             return
 * 
 *         layer_settings.looping = False             # <<<<<<<<<<<<<<
 * 
 *         SDL_UnlockAudio()
 */
  __pyx_v_layer_settings->looping = 0;

  /* "mpfmc/core/audio/track_sound_loop.pyx":765
 *         layer_settings.looping = False
 * 
 *         SDL_UnlockAudio()             # <<<<<<<<<<<<<<
 * 
 *     cdef _initialize_player(self, SoundLoopSetPlayer *player):
 */
  SDL_UnlockAudio();

  /* "mpfmc/core/audio/track_sound_loop.pyx":725
 *         SDL_UnlockAudio()
 * 
 *     def stop_looping_layer(self, int layer):             # <<<<<<<<<<<<<<
 *         """
 *         Stops the specified layer number in the currently playing sound loop set after
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("mpfmc.core.audio.track_sound_loop.TrackSoundLoop.stop_looping_layer", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mpfmc/core/audio/track_sound_loop.pyx":767
 *         SDL_UnlockAudio()
 * 
 *     cdef _initialize_player(self, SoundLoopSetPlayer *player):             # <<<<<<<<<<<<<<
 *         """Initializes a SoundLoopSetPlayer struct."""
 *         if player != NULL:
 */

static PyObject *__pyx_f_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop__initialize_player(CYTHON_UNUSED struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *__pyx_v_self, __pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopSetPlayer *__pyx_v_player) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("_initialize_player", 0);

  /* "mpfmc/core/audio/track_sound_loop.pyx":769
 *     cdef _initialize_player(self, SoundLoopSetPlayer *player):
 *         """Initializes a SoundLoopSetPlayer struct."""
 *         if player != NULL:             # <<<<<<<<<<<<<<
 *             player.layers = NULL
 *             player.master_sound_layer.markers = NULL
 */
  __pyx_t_1 = ((__pyx_v_player != NULL) != 0);
  if (__pyx_t_1) {

    /* "mpfmc/core/audio/track_sound_loop.pyx":770
 *         """Initializes a SoundLoopSetPlayer struct."""
 *         if player != NULL:
 *             player.layers = NULL             # <<<<<<<<<<<<<<
 *             player.master_sound_layer.markers = NULL
 *             player.status = player_idle
 */
    __pyx_v_player->layers = NULL;

    /* "mpfmc/core/audio/track_sound_loop.pyx":771
 *         if player != NULL:
 *             player.layers = NULL
 *             player.master_sound_layer.markers = NULL             # <<<<<<<<<<<<<<
 *             player.status = player_idle
 *             player.length = 0
 */
    __pyx_v_player->master_sound_layer.markers = NULL;

    /* "mpfmc/core/audio/track_sound_loop.pyx":772
 *             player.layers = NULL
 *             player.master_sound_layer.markers = NULL
 *             player.status = player_idle             # <<<<<<<<<<<<<<
 *             player.length = 0
 *             player.master_sound_layer.status = layer_playing
 */
    __pyx_v_player->status = __pyx_e_5mpfmc_4core_5audio_16track_sound_loop_player_idle;

    /* "mpfmc/core/audio/track_sound_loop.pyx":773
 *             player.master_sound_layer.markers = NULL
 *             player.status = player_idle
 *             player.length = 0             # <<<<<<<<<<<<<<
 *             player.master_sound_layer.status = layer_playing
 *             player.master_sound_layer.sound = NULL
 */
    __pyx_v_player->length = 0;

    /* "mpfmc/core/audio/track_sound_loop.pyx":774
 *             player.status = player_idle
 *             player.length = 0
 *             player.master_sound_layer.status = layer_playing             # <<<<<<<<<<<<<<
 *             player.master_sound_layer.sound = NULL
 *             player.master_sound_layer.volume = 0
 */
    __pyx_v_player->master_sound_layer.status = __pyx_e_5mpfmc_4core_5audio_16track_sound_loop_layer_playing;

    /* "mpfmc/core/audio/track_sound_loop.pyx":775
 *             player.length = 0
 *             player.master_sound_layer.status = layer_playing
 *             player.master_sound_layer.sound = NULL             # <<<<<<<<<<<<<<
 *             player.master_sound_layer.volume = 0
 *             player.master_sound_layer.sound_loop_set_id = 0
 */
    __pyx_v_player->master_sound_layer.sound = NULL;

    /* "mpfmc/core/audio/track_sound_loop.pyx":776
 *             player.master_sound_layer.status = layer_playing
 *             player.master_sound_layer.sound = NULL
 *             player.master_sound_layer.volume = 0             # <<<<<<<<<<<<<<
 *             player.master_sound_layer.sound_loop_set_id = 0
 *             player.master_sound_layer.sound_id = 0
 */
    __pyx_v_player->master_sound_layer.volume = 0;

    /* "mpfmc/core/audio/track_sound_loop.pyx":777
 *             player.master_sound_layer.sound = NULL
 *             player.master_sound_layer.volume = 0
 *             player.master_sound_layer.sound_loop_set_id = 0             # <<<<<<<<<<<<<<
 *             player.master_sound_layer.sound_id = 0
 *             player.master_sound_layer.fade_in_steps = 0
 */
    __pyx_v_player->master_sound_layer.sound_loop_set_id = 0;

    /* "mpfmc/core/audio/track_sound_loop.pyx":778
 *             player.master_sound_layer.volume = 0
 *             player.master_sound_layer.sound_loop_set_id = 0
 *             player.master_sound_layer.sound_id = 0             # <<<<<<<<<<<<<<
 *             player.master_sound_layer.fade_in_steps = 0
 *             player.master_sound_layer.fade_out_steps = 0
 */
    __pyx_v_player->master_sound_layer.sound_id = 0;

    /* "mpfmc/core/audio/track_sound_loop.pyx":779
 *             player.master_sound_layer.sound_loop_set_id = 0
 *             player.master_sound_layer.sound_id = 0
 *             player.master_sound_layer.fade_in_steps = 0             # <<<<<<<<<<<<<<
 *             player.master_sound_layer.fade_out_steps = 0
 *             player.master_sound_layer.fade_steps_remaining = 0
 */
    __pyx_v_player->master_sound_layer.fade_in_steps = 0;

    /* "mpfmc/core/audio/track_sound_loop.pyx":780
 *             player.master_sound_layer.sound_id = 0
 *             player.master_sound_layer.fade_in_steps = 0
 *             player.master_sound_layer.fade_out_steps = 0             # <<<<<<<<<<<<<<
 *             player.master_sound_layer.fade_steps_remaining = 0
 *             player.master_sound_layer.looping = True
 */
    __pyx_v_player->master_sound_layer.fade_out_steps = 0;

    /* "mpfmc/core/audio/track_sound_loop.pyx":781
 *             player.master_sound_layer.fade_in_steps = 0
 *             player.master_sound_layer.fade_out_steps = 0
 *             player.master_sound_layer.fade_steps_remaining = 0             # <<<<<<<<<<<<<<
 *             player.master_sound_layer.looping = True
 *             player.master_sound_layer.marker_count = 0
 */
    __pyx_v_player->master_sound_layer.fade_steps_remaining = 0;

    /* "mpfmc/core/audio/track_sound_loop.pyx":782
 *             player.master_sound_layer.fade_out_steps = 0
 *             player.master_sound_layer.fade_steps_remaining = 0
 *             player.master_sound_layer.looping = True             # <<<<<<<<<<<<<<
 *             player.master_sound_layer.marker_count = 0
 *             player.sample_pos = 0
 */
    __pyx_v_player->master_sound_layer.looping = 1;

    /* "mpfmc/core/audio/track_sound_loop.pyx":783
 *             player.master_sound_layer.fade_steps_remaining = 0
 *             player.master_sound_layer.looping = True
 *             player.master_sound_layer.marker_count = 0             # <<<<<<<<<<<<<<
 *             player.sample_pos = 0
 *             player.start_delay_samples_remaining = 0
 */
    __pyx_v_player->master_sound_layer.marker_count = 0;

    /* "mpfmc/core/audio/track_sound_loop.pyx":784
 *             player.master_sound_layer.looping = True
 *             player.master_sound_layer.marker_count = 0
 *             player.sample_pos = 0             # <<<<<<<<<<<<<<
 *             player.start_delay_samples_remaining = 0
 *             player.stop_loop_samples_remaining = do_not_stop_loop
 */
    __pyx_v_player->sample_pos = 0;

    /* "mpfmc/core/audio/track_sound_loop.pyx":785
 *             player.master_sound_layer.marker_count = 0
 *             player.sample_pos = 0
 *             player.start_delay_samples_remaining = 0             # <<<<<<<<<<<<<<
 *             player.stop_loop_samples_remaining = do_not_stop_loop
 * 
 */
    __pyx_v_player->start_delay_samples_remaining = 0;

    /* "mpfmc/core/audio/track_sound_loop.pyx":786
 *             player.sample_pos = 0
 *             player.start_delay_samples_remaining = 0
 *             player.stop_loop_samples_remaining = do_not_stop_loop             # <<<<<<<<<<<<<<
 * 
 *     cdef _delete_player(self, SoundLoopSetPlayer *player):
 */
    __pyx_v_player->stop_loop_samples_remaining = __pyx_e_5mpfmc_4core_5audio_16track_sound_loop_do_not_stop_loop;

    /* "mpfmc/core/audio/track_sound_loop.pyx":769
 *     cdef _initialize_player(self, SoundLoopSetPlayer *player):
 *         """Initializes a SoundLoopSetPlayer struct."""
 *         if player != NULL:             # <<<<<<<<<<<<<<
 *             player.layers = NULL
 *             player.master_sound_layer.markers = NULL
 */
  }

  /* "mpfmc/core/audio/track_sound_loop.pyx":767
 *         SDL_UnlockAudio()
 * 
 *     cdef _initialize_player(self, SoundLoopSetPlayer *player):             # <<<<<<<<<<<<<<
 *         """Initializes a SoundLoopSetPlayer struct."""
 *         if player != NULL:
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mpfmc/core/audio/track_sound_loop.pyx":788
 *             player.stop_loop_samples_remaining = do_not_stop_loop
 * 
 *     cdef _delete_player(self, SoundLoopSetPlayer *player):             # <<<<<<<<<<<<<<
 *         """Delete player (frees any allocated memory, including in layers)"""
 *         if player != NULL:
 */

static PyObject *__pyx_f_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop__delete_player(struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *__pyx_v_self, __pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopSetPlayer *__pyx_v_player) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_delete_player", 0);

  /* "mpfmc/core/audio/track_sound_loop.pyx":790
 *     cdef _delete_player(self, SoundLoopSetPlayer *player):
 *         """Delete player (frees any allocated memory, including in layers)"""
 *         if player != NULL:             # <<<<<<<<<<<<<<
 *             self._delete_player_layers(player)
 *             g_slice_free1(sizeof(SoundLoopSetPlayer), player)
 */
  __pyx_t_1 = ((__pyx_v_player != NULL) != 0);
  if (__pyx_t_1) {

    /* "mpfmc/core/audio/track_sound_loop.pyx":791
 *         """Delete player (frees any allocated memory, including in layers)"""
 *         if player != NULL:
 *             self._delete_player_layers(player)             # <<<<<<<<<<<<<<
 *             g_slice_free1(sizeof(SoundLoopSetPlayer), player)
 * 
 */
    __pyx_t_2 = ((struct __pyx_vtabstruct_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *)__pyx_v_self->__pyx_base.__pyx_vtab)->_delete_player_layers(__pyx_v_self, __pyx_v_player); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 791, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "mpfmc/core/audio/track_sound_loop.pyx":792
 *         if player != NULL:
 *             self._delete_player_layers(player)
 *             g_slice_free1(sizeof(SoundLoopSetPlayer), player)             # <<<<<<<<<<<<<<
 * 
 *     cdef _delete_player_layers(self, SoundLoopSetPlayer *player):
 */
    g_slice_free1((sizeof(__pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopSetPlayer)), __pyx_v_player);

    /* "mpfmc/core/audio/track_sound_loop.pyx":790
 *     cdef _delete_player(self, SoundLoopSetPlayer *player):
 *         """Delete player (frees any allocated memory, including in layers)"""
 *         if player != NULL:             # <<<<<<<<<<<<<<
 *             self._delete_player_layers(player)
 *             g_slice_free1(sizeof(SoundLoopSetPlayer), player)
 */
  }

  /* "mpfmc/core/audio/track_sound_loop.pyx":788
 *             player.stop_loop_samples_remaining = do_not_stop_loop
 * 
 *     cdef _delete_player(self, SoundLoopSetPlayer *player):             # <<<<<<<<<<<<<<
 *         """Delete player (frees any allocated memory, including in layers)"""
 *         if player != NULL:
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("mpfmc.core.audio.track_sound_loop.TrackSoundLoop._delete_player", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mpfmc/core/audio/track_sound_loop.pyx":794
 *             g_slice_free1(sizeof(SoundLoopSetPlayer), player)
 * 
 *     cdef _delete_player_layers(self, SoundLoopSetPlayer *player):             # <<<<<<<<<<<<<<
 *         """Delete (free memory) for sound loop set player layers."""
 *         if player != NULL:
 */

static PyObject *__pyx_f_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop__delete_player_layers(CYTHON_UNUSED struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *__pyx_v_self, __pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopSetPlayer *__pyx_v_player) {
  GSList *__pyx_v_iterator;
  __pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopLayerSettings *__pyx_v_layer;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  GSList *__pyx_t_2;
  __Pyx_RefNannySetupContext("_delete_player_layers", 0);

  /* "mpfmc/core/audio/track_sound_loop.pyx":796
 *     cdef _delete_player_layers(self, SoundLoopSetPlayer *player):
 *         """Delete (free memory) for sound loop set player layers."""
 *         if player != NULL:             # <<<<<<<<<<<<<<
 *             if player.master_sound_layer.markers != NULL:
 *                 g_array_free(player.master_sound_layer.markers, True)
 */
  __pyx_t_1 = ((__pyx_v_player != NULL) != 0);
  if (__pyx_t_1) {

    /* "mpfmc/core/audio/track_sound_loop.pyx":797
 *         """Delete (free memory) for sound loop set player layers."""
 *         if player != NULL:
 *             if player.master_sound_layer.markers != NULL:             # <<<<<<<<<<<<<<
 *                 g_array_free(player.master_sound_layer.markers, True)
 * 
 */
    __pyx_t_1 = ((__pyx_v_player->master_sound_layer.markers != NULL) != 0);
    if (__pyx_t_1) {

      /* "mpfmc/core/audio/track_sound_loop.pyx":798
 *         if player != NULL:
 *             if player.master_sound_layer.markers != NULL:
 *                 g_array_free(player.master_sound_layer.markers, True)             # <<<<<<<<<<<<<<
 * 
 *             if player.layers != NULL:
 */
      (void)(g_array_free(__pyx_v_player->master_sound_layer.markers, 1));

      /* "mpfmc/core/audio/track_sound_loop.pyx":797
 *         """Delete (free memory) for sound loop set player layers."""
 *         if player != NULL:
 *             if player.master_sound_layer.markers != NULL:             # <<<<<<<<<<<<<<
 *                 g_array_free(player.master_sound_layer.markers, True)
 * 
 */
    }

    /* "mpfmc/core/audio/track_sound_loop.pyx":800
 *                 g_array_free(player.master_sound_layer.markers, True)
 * 
 *             if player.layers != NULL:             # <<<<<<<<<<<<<<
 *                 iterator = player.layers
 *                 while iterator != NULL:
 */
    __pyx_t_1 = ((__pyx_v_player->layers != NULL) != 0);
    if (__pyx_t_1) {

      /* "mpfmc/core/audio/track_sound_loop.pyx":801
 * 
 *             if player.layers != NULL:
 *                 iterator = player.layers             # <<<<<<<<<<<<<<
 *                 while iterator != NULL:
 *                     layer = <SoundLoopLayerSettings*>iterator.data
 */
      __pyx_t_2 = __pyx_v_player->layers;
      __pyx_v_iterator = __pyx_t_2;

      /* "mpfmc/core/audio/track_sound_loop.pyx":802
 *             if player.layers != NULL:
 *                 iterator = player.layers
 *                 while iterator != NULL:             # <<<<<<<<<<<<<<
 *                     layer = <SoundLoopLayerSettings*>iterator.data
 *                     if layer.markers != NULL:
 */
      while (1) {
        __pyx_t_1 = ((__pyx_v_iterator != NULL) != 0);
        if (!__pyx_t_1) break;

        /* "mpfmc/core/audio/track_sound_loop.pyx":803
 *                 iterator = player.layers
 *                 while iterator != NULL:
 *                     layer = <SoundLoopLayerSettings*>iterator.data             # <<<<<<<<<<<<<<
 *                     if layer.markers != NULL:
 *                         g_array_free(layer.markers, True)
 */
        __pyx_v_layer = ((__pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopLayerSettings *)__pyx_v_iterator->data);

        /* "mpfmc/core/audio/track_sound_loop.pyx":804
 *                 while iterator != NULL:
 *                     layer = <SoundLoopLayerSettings*>iterator.data
 *                     if layer.markers != NULL:             # <<<<<<<<<<<<<<
 *                         g_array_free(layer.markers, True)
 *                     g_slice_free1(sizeof(SoundLoopLayerSettings), layer)
 */
        __pyx_t_1 = ((__pyx_v_layer->markers != NULL) != 0);
        if (__pyx_t_1) {

          /* "mpfmc/core/audio/track_sound_loop.pyx":805
 *                     layer = <SoundLoopLayerSettings*>iterator.data
 *                     if layer.markers != NULL:
 *                         g_array_free(layer.markers, True)             # <<<<<<<<<<<<<<
 *                     g_slice_free1(sizeof(SoundLoopLayerSettings), layer)
 *                     iterator = iterator.next
 */
          (void)(g_array_free(__pyx_v_layer->markers, 1));

          /* "mpfmc/core/audio/track_sound_loop.pyx":804
 *                 while iterator != NULL:
 *                     layer = <SoundLoopLayerSettings*>iterator.data
 *                     if layer.markers != NULL:             # <<<<<<<<<<<<<<
 *                         g_array_free(layer.markers, True)
 *                     g_slice_free1(sizeof(SoundLoopLayerSettings), layer)
 */
        }

        /* "mpfmc/core/audio/track_sound_loop.pyx":806
 *                     if layer.markers != NULL:
 *                         g_array_free(layer.markers, True)
 *                     g_slice_free1(sizeof(SoundLoopLayerSettings), layer)             # <<<<<<<<<<<<<<
 *                     iterator = iterator.next
 * 
 */
        g_slice_free1((sizeof(__pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopLayerSettings)), __pyx_v_layer);

        /* "mpfmc/core/audio/track_sound_loop.pyx":807
 *                         g_array_free(layer.markers, True)
 *                     g_slice_free1(sizeof(SoundLoopLayerSettings), layer)
 *                     iterator = iterator.next             # <<<<<<<<<<<<<<
 * 
 *                 g_slist_free(player.layers)
 */
        __pyx_t_2 = __pyx_v_iterator->next;
        __pyx_v_iterator = __pyx_t_2;
      }

      /* "mpfmc/core/audio/track_sound_loop.pyx":809
 *                     iterator = iterator.next
 * 
 *                 g_slist_free(player.layers)             # <<<<<<<<<<<<<<
 * 
 *     cdef _cancel_all_delayed_players(self):
 */
      g_slist_free(__pyx_v_player->layers);

      /* "mpfmc/core/audio/track_sound_loop.pyx":800
 *                 g_array_free(player.master_sound_layer.markers, True)
 * 
 *             if player.layers != NULL:             # <<<<<<<<<<<<<<
 *                 iterator = player.layers
 *                 while iterator != NULL:
 */
    }

    /* "mpfmc/core/audio/track_sound_loop.pyx":796
 *     cdef _delete_player_layers(self, SoundLoopSetPlayer *player):
 *         """Delete (free memory) for sound loop set player layers."""
 *         if player != NULL:             # <<<<<<<<<<<<<<
 *             if player.master_sound_layer.markers != NULL:
 *                 g_array_free(player.master_sound_layer.markers, True)
 */
  }

  /* "mpfmc/core/audio/track_sound_loop.pyx":794
 *             g_slice_free1(sizeof(SoundLoopSetPlayer), player)
 * 
 *     cdef _delete_player_layers(self, SoundLoopSetPlayer *player):             # <<<<<<<<<<<<<<
 *         """Delete (free memory) for sound loop set player layers."""
 *         if player != NULL:
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mpfmc/core/audio/track_sound_loop.pyx":811
 *                 g_slist_free(player.layers)
 * 
 *     cdef _cancel_all_delayed_players(self):             # <<<<<<<<<<<<<<
 *         """Cancels and removes all delayed (pending) players."""
 *         cdef SoundLoopSetPlayer *player
 */

static PyObject *__pyx_f_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop__cancel_all_delayed_players(struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *__pyx_v_self) {
  __pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopSetPlayer *__pyx_v_player;
  GSList *__pyx_v_iterator;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  GSList *__pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_cancel_all_delayed_players", 0);

  /* "mpfmc/core/audio/track_sound_loop.pyx":814
 *         """Cancels and removes all delayed (pending) players."""
 *         cdef SoundLoopSetPlayer *player
 *         cdef GSList *iterator = self.type_state.players             # <<<<<<<<<<<<<<
 * 
 *         # Loop over players
 */
  __pyx_t_1 = __pyx_v_self->type_state->players;
  __pyx_v_iterator = __pyx_t_1;

  /* "mpfmc/core/audio/track_sound_loop.pyx":817
 * 
 *         # Loop over players
 *         while iterator != NULL:             # <<<<<<<<<<<<<<
 *             player = <SoundLoopSetPlayer*>iterator.data
 *             iterator = iterator.next
 */
  while (1) {
    __pyx_t_2 = ((__pyx_v_iterator != NULL) != 0);
    if (!__pyx_t_2) break;

    /* "mpfmc/core/audio/track_sound_loop.pyx":818
 *         # Loop over players
 *         while iterator != NULL:
 *             player = <SoundLoopSetPlayer*>iterator.data             # <<<<<<<<<<<<<<
 *             iterator = iterator.next
 * 
 */
    __pyx_v_player = ((__pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopSetPlayer *)__pyx_v_iterator->data);

    /* "mpfmc/core/audio/track_sound_loop.pyx":819
 *         while iterator != NULL:
 *             player = <SoundLoopSetPlayer*>iterator.data
 *             iterator = iterator.next             # <<<<<<<<<<<<<<
 * 
 *             # Remove player if it currently has a delayed status
 */
    __pyx_t_1 = __pyx_v_iterator->next;
    __pyx_v_iterator = __pyx_t_1;

    /* "mpfmc/core/audio/track_sound_loop.pyx":822
 * 
 *             # Remove player if it currently has a delayed status
 *             if player != NULL and player.status == player_delayed:             # <<<<<<<<<<<<<<
 *                 self.type_state.players = g_slist_remove(self.type_state.players, player)
 * 
 */
    __pyx_t_3 = ((__pyx_v_player != NULL) != 0);
    if (__pyx_t_3) {
    } else {
      __pyx_t_2 = __pyx_t_3;
      goto __pyx_L6_bool_binop_done;
    }
    __pyx_t_3 = ((__pyx_v_player->status == __pyx_e_5mpfmc_4core_5audio_16track_sound_loop_player_delayed) != 0);
    __pyx_t_2 = __pyx_t_3;
    __pyx_L6_bool_binop_done:;
    if (__pyx_t_2) {

      /* "mpfmc/core/audio/track_sound_loop.pyx":823
 *             # Remove player if it currently has a delayed status
 *             if player != NULL and player.status == player_delayed:
 *                 self.type_state.players = g_slist_remove(self.type_state.players, player)             # <<<<<<<<<<<<<<
 * 
 *                 # Remove sound loop set from list of active sound loop sets
 */
      __pyx_v_self->type_state->players = g_slist_remove(__pyx_v_self->type_state->players, __pyx_v_player);

      /* "mpfmc/core/audio/track_sound_loop.pyx":826
 * 
 *                 # Remove sound loop set from list of active sound loop sets
 *                 if player.master_sound_layer.sound_id in self._active_sound_loop_sets.keys():             # <<<<<<<<<<<<<<
 *                     del self._active_sound_loop_sets[player.master_sound_layer.sound_id]
 * 
 */
      __pyx_t_4 = __Pyx_PyInt_From_Uint64(__pyx_v_player->master_sound_layer.sound_id); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 826, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (unlikely(__pyx_v_self->_active_sound_loop_sets == Py_None)) {
        PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "keys");
        __PYX_ERR(0, 826, __pyx_L1_error)
      }
      __pyx_t_5 = __Pyx_PyDict_Keys(__pyx_v_self->_active_sound_loop_sets); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 826, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_2 = (__Pyx_PySequence_ContainsTF(__pyx_t_4, __pyx_t_5, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 826, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_3 = (__pyx_t_2 != 0);
      if (__pyx_t_3) {

        /* "mpfmc/core/audio/track_sound_loop.pyx":827
 *                 # Remove sound loop set from list of active sound loop sets
 *                 if player.master_sound_layer.sound_id in self._active_sound_loop_sets.keys():
 *                     del self._active_sound_loop_sets[player.master_sound_layer.sound_id]             # <<<<<<<<<<<<<<
 * 
 *                 # Clean up allocated player memory
 */
        if (unlikely(__pyx_v_self->_active_sound_loop_sets == Py_None)) {
          PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
          __PYX_ERR(0, 827, __pyx_L1_error)
        }
        __pyx_t_5 = __Pyx_PyInt_From_Uint64(__pyx_v_player->master_sound_layer.sound_id); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 827, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        if (unlikely(PyDict_DelItem(__pyx_v_self->_active_sound_loop_sets, __pyx_t_5) < 0)) __PYX_ERR(0, 827, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

        /* "mpfmc/core/audio/track_sound_loop.pyx":826
 * 
 *                 # Remove sound loop set from list of active sound loop sets
 *                 if player.master_sound_layer.sound_id in self._active_sound_loop_sets.keys():             # <<<<<<<<<<<<<<
 *                     del self._active_sound_loop_sets[player.master_sound_layer.sound_id]
 * 
 */
      }

      /* "mpfmc/core/audio/track_sound_loop.pyx":830
 * 
 *                 # Clean up allocated player memory
 *                 self._delete_player_layers(player)             # <<<<<<<<<<<<<<
 *                 g_slice_free1(sizeof(SoundLoopSetPlayer), player)
 * 
 */
      __pyx_t_5 = ((struct __pyx_vtabstruct_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *)__pyx_v_self->__pyx_base.__pyx_vtab)->_delete_player_layers(__pyx_v_self, __pyx_v_player); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 830, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

      /* "mpfmc/core/audio/track_sound_loop.pyx":831
 *                 # Clean up allocated player memory
 *                 self._delete_player_layers(player)
 *                 g_slice_free1(sizeof(SoundLoopSetPlayer), player)             # <<<<<<<<<<<<<<
 * 
 *     cdef _fade_out_all_players(self, Uint32 fade_steps):
 */
      g_slice_free1((sizeof(__pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopSetPlayer)), __pyx_v_player);

      /* "mpfmc/core/audio/track_sound_loop.pyx":822
 * 
 *             # Remove player if it currently has a delayed status
 *             if player != NULL and player.status == player_delayed:             # <<<<<<<<<<<<<<
 *                 self.type_state.players = g_slist_remove(self.type_state.players, player)
 * 
 */
    }
  }

  /* "mpfmc/core/audio/track_sound_loop.pyx":811
 *                 g_slist_free(player.layers)
 * 
 *     cdef _cancel_all_delayed_players(self):             # <<<<<<<<<<<<<<
 *         """Cancels and removes all delayed (pending) players."""
 *         cdef SoundLoopSetPlayer *player
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("mpfmc.core.audio.track_sound_loop.TrackSoundLoop._cancel_all_delayed_players", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mpfmc/core/audio/track_sound_loop.pyx":833
 *                 g_slice_free1(sizeof(SoundLoopSetPlayer), player)
 * 
 *     cdef _fade_out_all_players(self, Uint32 fade_steps):             # <<<<<<<<<<<<<<
 *         """Fades out all currently playing players."""
 *         cdef SoundLoopSetPlayer *player
 */

static PyObject *__pyx_f_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop__fade_out_all_players(struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *__pyx_v_self, Uint32 __pyx_v_fade_steps) {
  __pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopSetPlayer *__pyx_v_player;
  GSList *__pyx_v_iterator;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  GSList *__pyx_t_1;
  int __pyx_t_2;
  Uint32 __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  double __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_fade_out_all_players", 0);

  /* "mpfmc/core/audio/track_sound_loop.pyx":836
 *         """Fades out all currently playing players."""
 *         cdef SoundLoopSetPlayer *player
 *         cdef GSList *iterator = self.type_state.players             # <<<<<<<<<<<<<<
 * 
 *         # Loop over players
 */
  __pyx_t_1 = __pyx_v_self->type_state->players;
  __pyx_v_iterator = __pyx_t_1;

  /* "mpfmc/core/audio/track_sound_loop.pyx":839
 * 
 *         # Loop over players
 *         while iterator != NULL:             # <<<<<<<<<<<<<<
 *             player = <SoundLoopSetPlayer*>iterator.data
 *             iterator = iterator.next
 */
  while (1) {
    __pyx_t_2 = ((__pyx_v_iterator != NULL) != 0);
    if (!__pyx_t_2) break;

    /* "mpfmc/core/audio/track_sound_loop.pyx":840
 *         # Loop over players
 *         while iterator != NULL:
 *             player = <SoundLoopSetPlayer*>iterator.data             # <<<<<<<<<<<<<<
 *             iterator = iterator.next
 * 
 */
    __pyx_v_player = ((__pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopSetPlayer *)__pyx_v_iterator->data);

    /* "mpfmc/core/audio/track_sound_loop.pyx":841
 *         while iterator != NULL:
 *             player = <SoundLoopSetPlayer*>iterator.data
 *             iterator = iterator.next             # <<<<<<<<<<<<<<
 * 
 *             if player == NULL:
 */
    __pyx_t_1 = __pyx_v_iterator->next;
    __pyx_v_iterator = __pyx_t_1;

    /* "mpfmc/core/audio/track_sound_loop.pyx":843
 *             iterator = iterator.next
 * 
 *             if player == NULL:             # <<<<<<<<<<<<<<
 *                 continue
 * 
 */
    __pyx_t_2 = ((__pyx_v_player == NULL) != 0);
    if (__pyx_t_2) {

      /* "mpfmc/core/audio/track_sound_loop.pyx":844
 * 
 *             if player == NULL:
 *                 continue             # <<<<<<<<<<<<<<
 * 
 *             elif player.status == player_playing:
 */
      goto __pyx_L3_continue;

      /* "mpfmc/core/audio/track_sound_loop.pyx":843
 *             iterator = iterator.next
 * 
 *             if player == NULL:             # <<<<<<<<<<<<<<
 *                 continue
 * 
 */
    }

    /* "mpfmc/core/audio/track_sound_loop.pyx":846
 *                 continue
 * 
 *             elif player.status == player_playing:             # <<<<<<<<<<<<<<
 *                 player.status = player_fading_out
 *                 player.master_sound_layer.fade_out_steps = fade_steps
 */
    __pyx_t_2 = ((__pyx_v_player->status == __pyx_e_5mpfmc_4core_5audio_16track_sound_loop_player_playing) != 0);
    if (__pyx_t_2) {

      /* "mpfmc/core/audio/track_sound_loop.pyx":847
 * 
 *             elif player.status == player_playing:
 *                 player.status = player_fading_out             # <<<<<<<<<<<<<<
 *                 player.master_sound_layer.fade_out_steps = fade_steps
 *                 player.master_sound_layer.fade_steps_remaining = fade_steps
 */
      __pyx_v_player->status = __pyx_e_5mpfmc_4core_5audio_16track_sound_loop_player_fading_out;

      /* "mpfmc/core/audio/track_sound_loop.pyx":848
 *             elif player.status == player_playing:
 *                 player.status = player_fading_out
 *                 player.master_sound_layer.fade_out_steps = fade_steps             # <<<<<<<<<<<<<<
 *                 player.master_sound_layer.fade_steps_remaining = fade_steps
 * 
 */
      __pyx_v_player->master_sound_layer.fade_out_steps = __pyx_v_fade_steps;

      /* "mpfmc/core/audio/track_sound_loop.pyx":849
 *                 player.status = player_fading_out
 *                 player.master_sound_layer.fade_out_steps = fade_steps
 *                 player.master_sound_layer.fade_steps_remaining = fade_steps             # <<<<<<<<<<<<<<
 * 
 *             elif player.status == player_fading_out:
 */
      __pyx_v_player->master_sound_layer.fade_steps_remaining = __pyx_v_fade_steps;

      /* "mpfmc/core/audio/track_sound_loop.pyx":846
 *                 continue
 * 
 *             elif player.status == player_playing:             # <<<<<<<<<<<<<<
 *                 player.status = player_fading_out
 *                 player.master_sound_layer.fade_out_steps = fade_steps
 */
      goto __pyx_L5;
    }

    /* "mpfmc/core/audio/track_sound_loop.pyx":851
 *                 player.master_sound_layer.fade_steps_remaining = fade_steps
 * 
 *             elif player.status == player_fading_out:             # <<<<<<<<<<<<<<
 *                 # The existing fade will only be adjusted if it has more steps remaining than specified here
 *                 if player.master_sound_layer.fade_steps_remaining > fade_steps:
 */
    __pyx_t_2 = ((__pyx_v_player->status == __pyx_e_5mpfmc_4core_5audio_16track_sound_loop_player_fading_out) != 0);
    if (__pyx_t_2) {

      /* "mpfmc/core/audio/track_sound_loop.pyx":853
 *             elif player.status == player_fading_out:
 *                 # The existing fade will only be adjusted if it has more steps remaining than specified here
 *                 if player.master_sound_layer.fade_steps_remaining > fade_steps:             # <<<<<<<<<<<<<<
 *                     player.master_sound_layer.fade_out_steps = <Uint32>round(fade_steps * player.master_sound_layer.fade_out_steps / player.master_sound_layer.fade_steps_remaining)
 *                     player.master_sound_layer.fade_steps_remaining = fade_steps
 */
      __pyx_t_2 = ((__pyx_v_player->master_sound_layer.fade_steps_remaining > __pyx_v_fade_steps) != 0);
      if (__pyx_t_2) {

        /* "mpfmc/core/audio/track_sound_loop.pyx":854
 *                 # The existing fade will only be adjusted if it has more steps remaining than specified here
 *                 if player.master_sound_layer.fade_steps_remaining > fade_steps:
 *                     player.master_sound_layer.fade_out_steps = <Uint32>round(fade_steps * player.master_sound_layer.fade_out_steps / player.master_sound_layer.fade_steps_remaining)             # <<<<<<<<<<<<<<
 *                     player.master_sound_layer.fade_steps_remaining = fade_steps
 * 
 */
        __pyx_t_3 = (__pyx_v_fade_steps * __pyx_v_player->master_sound_layer.fade_out_steps);
        if (unlikely(__pyx_v_player->master_sound_layer.fade_steps_remaining == 0)) {
          PyErr_SetString(PyExc_ZeroDivisionError, "float division");
          __PYX_ERR(0, 854, __pyx_L1_error)
        }
        __pyx_t_4 = PyFloat_FromDouble((((double)__pyx_t_3) / ((double)__pyx_v_player->master_sound_layer.fade_steps_remaining))); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 854, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_builtin_round, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 854, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_3 = __Pyx_PyInt_As_Uint32(__pyx_t_5); if (unlikely((__pyx_t_3 == ((Uint32)-1)) && PyErr_Occurred())) __PYX_ERR(0, 854, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_v_player->master_sound_layer.fade_out_steps = ((Uint32)__pyx_t_3);

        /* "mpfmc/core/audio/track_sound_loop.pyx":855
 *                 if player.master_sound_layer.fade_steps_remaining > fade_steps:
 *                     player.master_sound_layer.fade_out_steps = <Uint32>round(fade_steps * player.master_sound_layer.fade_out_steps / player.master_sound_layer.fade_steps_remaining)
 *                     player.master_sound_layer.fade_steps_remaining = fade_steps             # <<<<<<<<<<<<<<
 * 
 *             elif player.status == player_fading_in:
 */
        __pyx_v_player->master_sound_layer.fade_steps_remaining = __pyx_v_fade_steps;

        /* "mpfmc/core/audio/track_sound_loop.pyx":853
 *             elif player.status == player_fading_out:
 *                 # The existing fade will only be adjusted if it has more steps remaining than specified here
 *                 if player.master_sound_layer.fade_steps_remaining > fade_steps:             # <<<<<<<<<<<<<<
 *                     player.master_sound_layer.fade_out_steps = <Uint32>round(fade_steps * player.master_sound_layer.fade_out_steps / player.master_sound_layer.fade_steps_remaining)
 *                     player.master_sound_layer.fade_steps_remaining = fade_steps
 */
      }

      /* "mpfmc/core/audio/track_sound_loop.pyx":851
 *                 player.master_sound_layer.fade_steps_remaining = fade_steps
 * 
 *             elif player.status == player_fading_out:             # <<<<<<<<<<<<<<
 *                 # The existing fade will only be adjusted if it has more steps remaining than specified here
 *                 if player.master_sound_layer.fade_steps_remaining > fade_steps:
 */
      goto __pyx_L5;
    }

    /* "mpfmc/core/audio/track_sound_loop.pyx":857
 *                     player.master_sound_layer.fade_steps_remaining = fade_steps
 * 
 *             elif player.status == player_fading_in:             # <<<<<<<<<<<<<<
 *                 # Keep the same volume level to start as the current fade in
 *                 player.master_sound_layer.fade_out_steps = <Uint32>round(fade_steps / (1.0 - (player.master_sound_layer.fade_steps_remaining / player.master_sound_layer.fade_in_steps)))
 */
    __pyx_t_2 = ((__pyx_v_player->status == __pyx_e_5mpfmc_4core_5audio_16track_sound_loop_player_fading_in) != 0);
    if (__pyx_t_2) {

      /* "mpfmc/core/audio/track_sound_loop.pyx":859
 *             elif player.status == player_fading_in:
 *                 # Keep the same volume level to start as the current fade in
 *                 player.master_sound_layer.fade_out_steps = <Uint32>round(fade_steps / (1.0 - (player.master_sound_layer.fade_steps_remaining / player.master_sound_layer.fade_in_steps)))             # <<<<<<<<<<<<<<
 *                 player.master_sound_layer.fade_steps_remaining = fade_steps
 *                 player.status = player_fading_out
 */
      if (unlikely(__pyx_v_player->master_sound_layer.fade_in_steps == 0)) {
        PyErr_SetString(PyExc_ZeroDivisionError, "float division");
        __PYX_ERR(0, 859, __pyx_L1_error)
      }
      __pyx_t_6 = (1.0 - (((double)__pyx_v_player->master_sound_layer.fade_steps_remaining) / ((double)__pyx_v_player->master_sound_layer.fade_in_steps)));
      if (unlikely(__pyx_t_6 == 0)) {
        PyErr_SetString(PyExc_ZeroDivisionError, "float division");
        __PYX_ERR(0, 859, __pyx_L1_error)
      }
      __pyx_t_5 = PyFloat_FromDouble((((double)__pyx_v_fade_steps) / __pyx_t_6)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 859, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_round, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 859, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_3 = __Pyx_PyInt_As_Uint32(__pyx_t_4); if (unlikely((__pyx_t_3 == ((Uint32)-1)) && PyErr_Occurred())) __PYX_ERR(0, 859, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_v_player->master_sound_layer.fade_out_steps = ((Uint32)__pyx_t_3);

      /* "mpfmc/core/audio/track_sound_loop.pyx":860
 *                 # Keep the same volume level to start as the current fade in
 *                 player.master_sound_layer.fade_out_steps = <Uint32>round(fade_steps / (1.0 - (player.master_sound_layer.fade_steps_remaining / player.master_sound_layer.fade_in_steps)))
 *                 player.master_sound_layer.fade_steps_remaining = fade_steps             # <<<<<<<<<<<<<<
 *                 player.status = player_fading_out
 * 
 */
      __pyx_v_player->master_sound_layer.fade_steps_remaining = __pyx_v_fade_steps;

      /* "mpfmc/core/audio/track_sound_loop.pyx":861
 *                 player.master_sound_layer.fade_out_steps = <Uint32>round(fade_steps / (1.0 - (player.master_sound_layer.fade_steps_remaining / player.master_sound_layer.fade_in_steps)))
 *                 player.master_sound_layer.fade_steps_remaining = fade_steps
 *                 player.status = player_fading_out             # <<<<<<<<<<<<<<
 * 
 *     def get_status(self):
 */
      __pyx_v_player->status = __pyx_e_5mpfmc_4core_5audio_16track_sound_loop_player_fading_out;

      /* "mpfmc/core/audio/track_sound_loop.pyx":857
 *                     player.master_sound_layer.fade_steps_remaining = fade_steps
 * 
 *             elif player.status == player_fading_in:             # <<<<<<<<<<<<<<
 *                 # Keep the same volume level to start as the current fade in
 *                 player.master_sound_layer.fade_out_steps = <Uint32>round(fade_steps / (1.0 - (player.master_sound_layer.fade_steps_remaining / player.master_sound_layer.fade_in_steps)))
 */
    }
    __pyx_L5:;
    __pyx_L3_continue:;
  }

  /* "mpfmc/core/audio/track_sound_loop.pyx":833
 *                 g_slice_free1(sizeof(SoundLoopSetPlayer), player)
 * 
 *     cdef _fade_out_all_players(self, Uint32 fade_steps):             # <<<<<<<<<<<<<<
 *         """Fades out all currently playing players."""
 *         cdef SoundLoopSetPlayer *player
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("mpfmc.core.audio.track_sound_loop.TrackSoundLoop._fade_out_all_players", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mpfmc/core/audio/track_sound_loop.pyx":863
 *                 player.status = player_fading_out
 * 
 *     def get_status(self):             # <<<<<<<<<<<<<<
 *         """
 *         Get the current track status (status of all sound loop players on the track).
 */

/* Python wrapper */
static PyObject *__pyx_pw_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_33get_status(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_32get_status[] = "TrackSoundLoop.get_status(self)\n\n        Get the current track status (status of all sound loop players on the track).\n        Used for debugging and testing.\n        Returns:\n            A list of status dictionaries containing the current settings for each\n            sound loop player.\n        ";
static PyObject *__pyx_pw_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_33get_status(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_status (wrapper)", 0);
  __pyx_r = __pyx_pf_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_32get_status(((struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_32get_status(struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *__pyx_v_self) {
  __pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopSetPlayer *__pyx_v_player;
  __pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopLayerSettings *__pyx_v_layer;
  int __pyx_v_index;
  GSList *__pyx_v_iterator;
  PyObject *__pyx_v_status = NULL;
  PyObject *__pyx_v_layers = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  GSList *__pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_status", 0);

  /* "mpfmc/core/audio/track_sound_loop.pyx":873
 *         cdef SoundLoopSetPlayer *player
 *         cdef SoundLoopLayerSettings *layer
 *         cdef int index = 0             # <<<<<<<<<<<<<<
 *         cdef GSList *iterator
 * 
 */
  __pyx_v_index = 0;

  /* "mpfmc/core/audio/track_sound_loop.pyx":876
 *         cdef GSList *iterator
 * 
 *         SDL_LockAudio()             # <<<<<<<<<<<<<<
 *         status = []
 * 
 */
  SDL_LockAudio();

  /* "mpfmc/core/audio/track_sound_loop.pyx":877
 * 
 *         SDL_LockAudio()
 *         status = []             # <<<<<<<<<<<<<<
 * 
 *         iterator = self.type_state.players
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 877, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_status = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "mpfmc/core/audio/track_sound_loop.pyx":879
 *         status = []
 * 
 *         iterator = self.type_state.players             # <<<<<<<<<<<<<<
 *         while iterator != NULL:
 *             player = <SoundLoopSetPlayer*>iterator.data
 */
  __pyx_t_2 = __pyx_v_self->type_state->players;
  __pyx_v_iterator = __pyx_t_2;

  /* "mpfmc/core/audio/track_sound_loop.pyx":880
 * 
 *         iterator = self.type_state.players
 *         while iterator != NULL:             # <<<<<<<<<<<<<<
 *             player = <SoundLoopSetPlayer*>iterator.data
 *             if player == NULL:
 */
  while (1) {
    __pyx_t_3 = ((__pyx_v_iterator != NULL) != 0);
    if (!__pyx_t_3) break;

    /* "mpfmc/core/audio/track_sound_loop.pyx":881
 *         iterator = self.type_state.players
 *         while iterator != NULL:
 *             player = <SoundLoopSetPlayer*>iterator.data             # <<<<<<<<<<<<<<
 *             if player == NULL:
 *                 status.append({
 */
    __pyx_v_player = ((__pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopSetPlayer *)__pyx_v_iterator->data);

    /* "mpfmc/core/audio/track_sound_loop.pyx":882
 *         while iterator != NULL:
 *             player = <SoundLoopSetPlayer*>iterator.data
 *             if player == NULL:             # <<<<<<<<<<<<<<
 *                 status.append({
 *                     "status": TrackSoundLoop.player_status_to_text(player_idle),
 */
    __pyx_t_3 = ((__pyx_v_player == NULL) != 0);
    if (__pyx_t_3) {

      /* "mpfmc/core/audio/track_sound_loop.pyx":884
 *             if player == NULL:
 *                 status.append({
 *                     "status": TrackSoundLoop.player_status_to_text(player_idle),             # <<<<<<<<<<<<<<
 *                     "length": 0
 *                 })
 */
      __pyx_t_1 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 884, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop), __pyx_n_s_player_status_to_text); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 884, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = __Pyx_PyInt_From_enum____pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopSetPlayerStatus(__pyx_e_5mpfmc_4core_5audio_16track_sound_loop_player_idle); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 884, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_7 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
        __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
        if (likely(__pyx_t_7)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
          __Pyx_INCREF(__pyx_t_7);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_5, function);
        }
      }
      __pyx_t_4 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_7, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6);
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 884, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_status, __pyx_t_4) < 0) __PYX_ERR(0, 884, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_length, __pyx_int_0) < 0) __PYX_ERR(0, 884, __pyx_L1_error)

      /* "mpfmc/core/audio/track_sound_loop.pyx":883
 *             player = <SoundLoopSetPlayer*>iterator.data
 *             if player == NULL:
 *                 status.append({             # <<<<<<<<<<<<<<
 *                     "status": TrackSoundLoop.player_status_to_text(player_idle),
 *                     "length": 0
 */
      __pyx_t_8 = __Pyx_PyList_Append(__pyx_v_status, __pyx_t_1); if (unlikely(__pyx_t_8 == ((int)-1))) __PYX_ERR(0, 883, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "mpfmc/core/audio/track_sound_loop.pyx":882
 *         while iterator != NULL:
 *             player = <SoundLoopSetPlayer*>iterator.data
 *             if player == NULL:             # <<<<<<<<<<<<<<
 *                 status.append({
 *                     "status": TrackSoundLoop.player_status_to_text(player_idle),
 */
      goto __pyx_L5;
    }

    /* "mpfmc/core/audio/track_sound_loop.pyx":888
 *                 })
 *             else:
 *                 layers = []             # <<<<<<<<<<<<<<
 *                 layer = <SoundLoopLayerSettings*>g_slist_nth_data(player.layers, index)
 *                 while layer != NULL:
 */
    /*else*/ {
      __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 888, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_XDECREF_SET(__pyx_v_layers, ((PyObject*)__pyx_t_1));
      __pyx_t_1 = 0;

      /* "mpfmc/core/audio/track_sound_loop.pyx":889
 *             else:
 *                 layers = []
 *                 layer = <SoundLoopLayerSettings*>g_slist_nth_data(player.layers, index)             # <<<<<<<<<<<<<<
 *                 while layer != NULL:
 *                     layers.append({
 */
      __pyx_v_layer = ((__pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopLayerSettings *)g_slist_nth_data(__pyx_v_player->layers, __pyx_v_index));

      /* "mpfmc/core/audio/track_sound_loop.pyx":890
 *                 layers = []
 *                 layer = <SoundLoopLayerSettings*>g_slist_nth_data(player.layers, index)
 *                 while layer != NULL:             # <<<<<<<<<<<<<<
 *                     layers.append({
 *                         "status": TrackSoundLoop.layer_status_to_text(layer.status),
 */
      while (1) {
        __pyx_t_3 = ((__pyx_v_layer != NULL) != 0);
        if (!__pyx_t_3) break;

        /* "mpfmc/core/audio/track_sound_loop.pyx":892
 *                 while layer != NULL:
 *                     layers.append({
 *                         "status": TrackSoundLoop.layer_status_to_text(layer.status),             # <<<<<<<<<<<<<<
 *                         "sound_id": layer.sound_id,
 *                         "sound_length": layer.sound.data.memory.size,
 */
        __pyx_t_1 = __Pyx_PyDict_NewPresized(9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 892, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop), __pyx_n_s_layer_status_to_text); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 892, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_6 = __Pyx_PyInt_From_enum____pyx_t_5mpfmc_4core_5audio_16track_sound_loop_LayerStatus(__pyx_v_layer->status); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 892, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_7 = NULL;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
          __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
          if (likely(__pyx_t_7)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
            __Pyx_INCREF(__pyx_t_7);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_5, function);
          }
        }
        __pyx_t_4 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_7, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6);
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 892, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_status, __pyx_t_4) < 0) __PYX_ERR(0, 892, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

        /* "mpfmc/core/audio/track_sound_loop.pyx":893
 *                     layers.append({
 *                         "status": TrackSoundLoop.layer_status_to_text(layer.status),
 *                         "sound_id": layer.sound_id,             # <<<<<<<<<<<<<<
 *                         "sound_length": layer.sound.data.memory.size,
 *                         "volume": layer.volume,
 */
        __pyx_t_4 = __Pyx_PyInt_From_Uint64(__pyx_v_layer->sound_id); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 893, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_sound_id, __pyx_t_4) < 0) __PYX_ERR(0, 892, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

        /* "mpfmc/core/audio/track_sound_loop.pyx":894
 *                         "status": TrackSoundLoop.layer_status_to_text(layer.status),
 *                         "sound_id": layer.sound_id,
 *                         "sound_length": layer.sound.data.memory.size,             # <<<<<<<<<<<<<<
 *                         "volume": layer.volume,
 *                         "fade_in_steps": layer.fade_in_steps,
 */
        __pyx_t_4 = __Pyx_PyInt_From_gsize(__pyx_v_layer->sound->data.memory->size); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 894, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_sound_length, __pyx_t_4) < 0) __PYX_ERR(0, 892, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

        /* "mpfmc/core/audio/track_sound_loop.pyx":895
 *                         "sound_id": layer.sound_id,
 *                         "sound_length": layer.sound.data.memory.size,
 *                         "volume": layer.volume,             # <<<<<<<<<<<<<<
 *                         "fade_in_steps": layer.fade_in_steps,
 *                         "fade_out_steps": layer.fade_out_steps,
 */
        __pyx_t_4 = __Pyx_PyInt_From_Uint8(__pyx_v_layer->volume); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 895, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_volume, __pyx_t_4) < 0) __PYX_ERR(0, 892, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

        /* "mpfmc/core/audio/track_sound_loop.pyx":896
 *                         "sound_length": layer.sound.data.memory.size,
 *                         "volume": layer.volume,
 *                         "fade_in_steps": layer.fade_in_steps,             # <<<<<<<<<<<<<<
 *                         "fade_out_steps": layer.fade_out_steps,
 *                         "fade_steps_remaining": layer.fade_steps_remaining,
 */
        __pyx_t_4 = __Pyx_PyInt_From_Uint32(__pyx_v_layer->fade_in_steps); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 896, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_fade_in_steps, __pyx_t_4) < 0) __PYX_ERR(0, 892, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

        /* "mpfmc/core/audio/track_sound_loop.pyx":897
 *                         "volume": layer.volume,
 *                         "fade_in_steps": layer.fade_in_steps,
 *                         "fade_out_steps": layer.fade_out_steps,             # <<<<<<<<<<<<<<
 *                         "fade_steps_remaining": layer.fade_steps_remaining,
 *                         "looping": layer.looping,
 */
        __pyx_t_4 = __Pyx_PyInt_From_Uint32(__pyx_v_layer->fade_out_steps); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 897, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_fade_out_steps, __pyx_t_4) < 0) __PYX_ERR(0, 892, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

        /* "mpfmc/core/audio/track_sound_loop.pyx":898
 *                         "fade_in_steps": layer.fade_in_steps,
 *                         "fade_out_steps": layer.fade_out_steps,
 *                         "fade_steps_remaining": layer.fade_steps_remaining,             # <<<<<<<<<<<<<<
 *                         "looping": layer.looping,
 *                         "marker_count": layer.marker_count,
 */
        __pyx_t_4 = __Pyx_PyInt_From_Uint32(__pyx_v_layer->fade_steps_remaining); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 898, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_fade_steps_remaining, __pyx_t_4) < 0) __PYX_ERR(0, 892, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

        /* "mpfmc/core/audio/track_sound_loop.pyx":899
 *                         "fade_out_steps": layer.fade_out_steps,
 *                         "fade_steps_remaining": layer.fade_steps_remaining,
 *                         "looping": layer.looping,             # <<<<<<<<<<<<<<
 *                         "marker_count": layer.marker_count,
 *                     })
 */
        __pyx_t_4 = __Pyx_PyBool_FromLong(__pyx_v_layer->looping); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 899, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_looping, __pyx_t_4) < 0) __PYX_ERR(0, 892, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

        /* "mpfmc/core/audio/track_sound_loop.pyx":900
 *                         "fade_steps_remaining": layer.fade_steps_remaining,
 *                         "looping": layer.looping,
 *                         "marker_count": layer.marker_count,             # <<<<<<<<<<<<<<
 *                     })
 *                     index += 1
 */
        __pyx_t_4 = __Pyx_PyInt_From_Uint8(__pyx_v_layer->marker_count); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 900, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_marker_count, __pyx_t_4) < 0) __PYX_ERR(0, 892, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

        /* "mpfmc/core/audio/track_sound_loop.pyx":891
 *                 layer = <SoundLoopLayerSettings*>g_slist_nth_data(player.layers, index)
 *                 while layer != NULL:
 *                     layers.append({             # <<<<<<<<<<<<<<
 *                         "status": TrackSoundLoop.layer_status_to_text(layer.status),
 *                         "sound_id": layer.sound_id,
 */
        __pyx_t_8 = __Pyx_PyList_Append(__pyx_v_layers, __pyx_t_1); if (unlikely(__pyx_t_8 == ((int)-1))) __PYX_ERR(0, 891, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

        /* "mpfmc/core/audio/track_sound_loop.pyx":902
 *                         "marker_count": layer.marker_count,
 *                     })
 *                     index += 1             # <<<<<<<<<<<<<<
 *                     layer = <SoundLoopLayerSettings*>g_slist_nth_data(player.layers, index)
 * 
 */
        __pyx_v_index = (__pyx_v_index + 1);

        /* "mpfmc/core/audio/track_sound_loop.pyx":903
 *                     })
 *                     index += 1
 *                     layer = <SoundLoopLayerSettings*>g_slist_nth_data(player.layers, index)             # <<<<<<<<<<<<<<
 * 
 *                 status.append({
 */
        __pyx_v_layer = ((__pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopLayerSettings *)g_slist_nth_data(__pyx_v_player->layers, __pyx_v_index));
      }

      /* "mpfmc/core/audio/track_sound_loop.pyx":906
 * 
 *                 status.append({
 *                     "status": TrackSoundLoop.player_status_to_text(<int>player.status),             # <<<<<<<<<<<<<<
 *                     "length": player.length,
 *                     "sound_id": player.master_sound_layer.sound_id,
 */
      __pyx_t_1 = __Pyx_PyDict_NewPresized(12); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 906, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop), __pyx_n_s_player_status_to_text); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 906, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = __Pyx_PyInt_From_int(((int)__pyx_v_player->status)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 906, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_7 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
        __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
        if (likely(__pyx_t_7)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
          __Pyx_INCREF(__pyx_t_7);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_5, function);
        }
      }
      __pyx_t_4 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_7, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6);
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 906, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_status, __pyx_t_4) < 0) __PYX_ERR(0, 906, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "mpfmc/core/audio/track_sound_loop.pyx":907
 *                 status.append({
 *                     "status": TrackSoundLoop.player_status_to_text(<int>player.status),
 *                     "length": player.length,             # <<<<<<<<<<<<<<
 *                     "sound_id": player.master_sound_layer.sound_id,
 *                     "volume": player.master_sound_layer.volume,
 */
      __pyx_t_4 = __Pyx_PyInt_From_Uint32(__pyx_v_player->length); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 907, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_length, __pyx_t_4) < 0) __PYX_ERR(0, 906, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "mpfmc/core/audio/track_sound_loop.pyx":908
 *                     "status": TrackSoundLoop.player_status_to_text(<int>player.status),
 *                     "length": player.length,
 *                     "sound_id": player.master_sound_layer.sound_id,             # <<<<<<<<<<<<<<
 *                     "volume": player.master_sound_layer.volume,
 *                     "tempo": player.tempo,
 */
      __pyx_t_4 = __Pyx_PyInt_From_Uint64(__pyx_v_player->master_sound_layer.sound_id); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 908, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_sound_id, __pyx_t_4) < 0) __PYX_ERR(0, 906, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "mpfmc/core/audio/track_sound_loop.pyx":909
 *                     "length": player.length,
 *                     "sound_id": player.master_sound_layer.sound_id,
 *                     "volume": player.master_sound_layer.volume,             # <<<<<<<<<<<<<<
 *                     "tempo": player.tempo,
 *                     "layers": layers,
 */
      __pyx_t_4 = __Pyx_PyInt_From_Uint8(__pyx_v_player->master_sound_layer.volume); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 909, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_volume, __pyx_t_4) < 0) __PYX_ERR(0, 906, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "mpfmc/core/audio/track_sound_loop.pyx":910
 *                     "sound_id": player.master_sound_layer.sound_id,
 *                     "volume": player.master_sound_layer.volume,
 *                     "tempo": player.tempo,             # <<<<<<<<<<<<<<
 *                     "layers": layers,
 *                     "sample_pos": player.sample_pos,
 */
      __pyx_t_4 = PyFloat_FromDouble(__pyx_v_player->tempo); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 910, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_tempo, __pyx_t_4) < 0) __PYX_ERR(0, 906, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "mpfmc/core/audio/track_sound_loop.pyx":911
 *                     "volume": player.master_sound_layer.volume,
 *                     "tempo": player.tempo,
 *                     "layers": layers,             # <<<<<<<<<<<<<<
 *                     "sample_pos": player.sample_pos,
 *                     "stop_loop_samples_remaining": "DO NOT STOP LOOP" if player.stop_loop_samples_remaining == do_not_stop_loop else player.stop_loop_samples_remaining,
 */
      if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_layers, __pyx_v_layers) < 0) __PYX_ERR(0, 906, __pyx_L1_error)

      /* "mpfmc/core/audio/track_sound_loop.pyx":912
 *                     "tempo": player.tempo,
 *                     "layers": layers,
 *                     "sample_pos": player.sample_pos,             # <<<<<<<<<<<<<<
 *                     "stop_loop_samples_remaining": "DO NOT STOP LOOP" if player.stop_loop_samples_remaining == do_not_stop_loop else player.stop_loop_samples_remaining,
 *                     "start_delay_samples_remaining": player.start_delay_samples_remaining,
 */
      __pyx_t_4 = __Pyx_PyInt_From_Uint32(__pyx_v_player->sample_pos); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 912, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_sample_pos, __pyx_t_4) < 0) __PYX_ERR(0, 906, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "mpfmc/core/audio/track_sound_loop.pyx":913
 *                     "layers": layers,
 *                     "sample_pos": player.sample_pos,
 *                     "stop_loop_samples_remaining": "DO NOT STOP LOOP" if player.stop_loop_samples_remaining == do_not_stop_loop else player.stop_loop_samples_remaining,             # <<<<<<<<<<<<<<
 *                     "start_delay_samples_remaining": player.start_delay_samples_remaining,
 *                     "fade_in_steps": player.master_sound_layer.fade_in_steps,
 */
      if (((__pyx_v_player->stop_loop_samples_remaining == __pyx_e_5mpfmc_4core_5audio_16track_sound_loop_do_not_stop_loop) != 0)) {
        __Pyx_INCREF(__pyx_kp_u_DO_NOT_STOP_LOOP);
        __pyx_t_4 = __pyx_kp_u_DO_NOT_STOP_LOOP;
      } else {
        __pyx_t_5 = __Pyx_PyInt_From_Uint32(__pyx_v_player->stop_loop_samples_remaining); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 913, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_4 = __pyx_t_5;
        __pyx_t_5 = 0;
      }
      if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_stop_loop_samples_remaining, __pyx_t_4) < 0) __PYX_ERR(0, 906, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "mpfmc/core/audio/track_sound_loop.pyx":914
 *                     "sample_pos": player.sample_pos,
 *                     "stop_loop_samples_remaining": "DO NOT STOP LOOP" if player.stop_loop_samples_remaining == do_not_stop_loop else player.stop_loop_samples_remaining,
 *                     "start_delay_samples_remaining": player.start_delay_samples_remaining,             # <<<<<<<<<<<<<<
 *                     "fade_in_steps": player.master_sound_layer.fade_in_steps,
 *                     "fade_out_steps": player.master_sound_layer.fade_out_steps,
 */
      __pyx_t_4 = __Pyx_PyInt_From_Uint32(__pyx_v_player->start_delay_samples_remaining); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 914, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_start_delay_samples_remaining, __pyx_t_4) < 0) __PYX_ERR(0, 906, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "mpfmc/core/audio/track_sound_loop.pyx":915
 *                     "stop_loop_samples_remaining": "DO NOT STOP LOOP" if player.stop_loop_samples_remaining == do_not_stop_loop else player.stop_loop_samples_remaining,
 *                     "start_delay_samples_remaining": player.start_delay_samples_remaining,
 *                     "fade_in_steps": player.master_sound_layer.fade_in_steps,             # <<<<<<<<<<<<<<
 *                     "fade_out_steps": player.master_sound_layer.fade_out_steps,
 *                     "fade_steps_remaining": player.master_sound_layer.fade_steps_remaining,
 */
      __pyx_t_4 = __Pyx_PyInt_From_Uint32(__pyx_v_player->master_sound_layer.fade_in_steps); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 915, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_fade_in_steps, __pyx_t_4) < 0) __PYX_ERR(0, 906, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "mpfmc/core/audio/track_sound_loop.pyx":916
 *                     "start_delay_samples_remaining": player.start_delay_samples_remaining,
 *                     "fade_in_steps": player.master_sound_layer.fade_in_steps,
 *                     "fade_out_steps": player.master_sound_layer.fade_out_steps,             # <<<<<<<<<<<<<<
 *                     "fade_steps_remaining": player.master_sound_layer.fade_steps_remaining,
 *                 })
 */
      __pyx_t_4 = __Pyx_PyInt_From_Uint32(__pyx_v_player->master_sound_layer.fade_out_steps); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 916, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_fade_out_steps, __pyx_t_4) < 0) __PYX_ERR(0, 906, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "mpfmc/core/audio/track_sound_loop.pyx":917
 *                     "fade_in_steps": player.master_sound_layer.fade_in_steps,
 *                     "fade_out_steps": player.master_sound_layer.fade_out_steps,
 *                     "fade_steps_remaining": player.master_sound_layer.fade_steps_remaining,             # <<<<<<<<<<<<<<
 *                 })
 * 
 */
      __pyx_t_4 = __Pyx_PyInt_From_Uint32(__pyx_v_player->master_sound_layer.fade_steps_remaining); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 917, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_fade_steps_remaining, __pyx_t_4) < 0) __PYX_ERR(0, 906, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "mpfmc/core/audio/track_sound_loop.pyx":905
 *                     layer = <SoundLoopLayerSettings*>g_slist_nth_data(player.layers, index)
 * 
 *                 status.append({             # <<<<<<<<<<<<<<
 *                     "status": TrackSoundLoop.player_status_to_text(<int>player.status),
 *                     "length": player.length,
 */
      __pyx_t_8 = __Pyx_PyList_Append(__pyx_v_status, __pyx_t_1); if (unlikely(__pyx_t_8 == ((int)-1))) __PYX_ERR(0, 905, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    }
    __pyx_L5:;

    /* "mpfmc/core/audio/track_sound_loop.pyx":920
 *                 })
 * 
 *             iterator = iterator.next             # <<<<<<<<<<<<<<
 * 
 *         SDL_UnlockAudio()
 */
    __pyx_t_2 = __pyx_v_iterator->next;
    __pyx_v_iterator = __pyx_t_2;
  }

  /* "mpfmc/core/audio/track_sound_loop.pyx":922
 *             iterator = iterator.next
 * 
 *         SDL_UnlockAudio()             # <<<<<<<<<<<<<<
 * 
 *         return status
 */
  SDL_UnlockAudio();

  /* "mpfmc/core/audio/track_sound_loop.pyx":924
 *         SDL_UnlockAudio()
 * 
 *         return status             # <<<<<<<<<<<<<<
 * 
 *     @staticmethod
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_status);
  __pyx_r = __pyx_v_status;
  goto __pyx_L0;

  /* "mpfmc/core/audio/track_sound_loop.pyx":863
 *                 player.status = player_fading_out
 * 
 *     def get_status(self):             # <<<<<<<<<<<<<<
 *         """
 *         Get the current track status (status of all sound loop players on the track).
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("mpfmc.core.audio.track_sound_loop.TrackSoundLoop.get_status", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_status);
  __Pyx_XDECREF(__pyx_v_layers);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mpfmc/core/audio/track_sound_loop.pyx":927
 * 
 *     @staticmethod
 *     def player_status_to_text(int status):             # <<<<<<<<<<<<<<
 *         """
 *         Converts a sound loop player status value into an equivalent text string.  Used for testing
 */

/* Python wrapper */
static PyObject *__pyx_pw_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_35player_status_to_text(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_34player_status_to_text[] = "TrackSoundLoop.player_status_to_text(int status)\n\n        Converts a sound loop player status value into an equivalent text string.  Used for testing\n        purposes only.\n        Args:\n            status: Integer sound loop player status value\n\n        Returns:\n            string containing the equivalent status text\n        ";
static PyMethodDef __pyx_mdef_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_35player_status_to_text = {"player_status_to_text", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_35player_status_to_text, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_34player_status_to_text};
static PyObject *__pyx_pw_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_35player_status_to_text(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_status;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("player_status_to_text (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_status,0};
    PyObject* values[1] = {0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_status)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "player_status_to_text") < 0)) __PYX_ERR(0, 927, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
    }
    __pyx_v_status = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_status == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 927, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("player_status_to_text", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 927, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mpfmc.core.audio.track_sound_loop.TrackSoundLoop.player_status_to_text", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_34player_status_to_text(__pyx_v_status);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_34player_status_to_text(int __pyx_v_status) {
  PyObject *__pyx_v_status_values = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("player_status_to_text", 0);

  /* "mpfmc/core/audio/track_sound_loop.pyx":938
 *         """
 *         status_values = {
 *             player_idle: "idle",             # <<<<<<<<<<<<<<
 *             player_delayed: "delayed",
 *             player_playing: "playing",
 */
  __pyx_t_1 = __Pyx_PyDict_NewPresized(5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 938, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopSetPlayerStatus(__pyx_e_5mpfmc_4core_5audio_16track_sound_loop_player_idle); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 938, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_t_2, __pyx_n_u_idle) < 0) __PYX_ERR(0, 938, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "mpfmc/core/audio/track_sound_loop.pyx":939
 *         status_values = {
 *             player_idle: "idle",
 *             player_delayed: "delayed",             # <<<<<<<<<<<<<<
 *             player_playing: "playing",
 *             player_fading_in: "fading in",
 */
  __pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopSetPlayerStatus(__pyx_e_5mpfmc_4core_5audio_16track_sound_loop_player_delayed); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 939, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_t_2, __pyx_n_u_delayed) < 0) __PYX_ERR(0, 938, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "mpfmc/core/audio/track_sound_loop.pyx":940
 *             player_idle: "idle",
 *             player_delayed: "delayed",
 *             player_playing: "playing",             # <<<<<<<<<<<<<<
 *             player_fading_in: "fading in",
 *             player_fading_out: "fading out",
 */
  __pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopSetPlayerStatus(__pyx_e_5mpfmc_4core_5audio_16track_sound_loop_player_playing); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 940, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_t_2, __pyx_n_u_playing) < 0) __PYX_ERR(0, 938, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "mpfmc/core/audio/track_sound_loop.pyx":941
 *             player_delayed: "delayed",
 *             player_playing: "playing",
 *             player_fading_in: "fading in",             # <<<<<<<<<<<<<<
 *             player_fading_out: "fading out",
 *         }
 */
  __pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopSetPlayerStatus(__pyx_e_5mpfmc_4core_5audio_16track_sound_loop_player_fading_in); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 941, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_t_2, __pyx_kp_u_fading_in) < 0) __PYX_ERR(0, 938, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "mpfmc/core/audio/track_sound_loop.pyx":942
 *             player_playing: "playing",
 *             player_fading_in: "fading in",
 *             player_fading_out: "fading out",             # <<<<<<<<<<<<<<
 *         }
 * 
 */
  __pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopSetPlayerStatus(__pyx_e_5mpfmc_4core_5audio_16track_sound_loop_player_fading_out); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 942, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_t_2, __pyx_kp_u_fading_out) < 0) __PYX_ERR(0, 938, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_status_values = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "mpfmc/core/audio/track_sound_loop.pyx":945
 *         }
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             return status_values.get(status)
 *         except KeyError:
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_3, &__pyx_t_4, &__pyx_t_5);
    __Pyx_XGOTREF(__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_4);
    __Pyx_XGOTREF(__pyx_t_5);
    /*try:*/ {

      /* "mpfmc/core/audio/track_sound_loop.pyx":946
 * 
 *         try:
 *             return status_values.get(status)             # <<<<<<<<<<<<<<
 *         except KeyError:
 *             return "unknown"
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_status); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 946, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = __Pyx_PyDict_GetItemDefault(__pyx_v_status_values, __pyx_t_1, Py_None); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 946, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      goto __pyx_L7_try_return;

      /* "mpfmc/core/audio/track_sound_loop.pyx":945
 *         }
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             return status_values.get(status)
 *         except KeyError:
 */
    }
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "mpfmc/core/audio/track_sound_loop.pyx":947
 *         try:
 *             return status_values.get(status)
 *         except KeyError:             # <<<<<<<<<<<<<<
 *             return "unknown"
 * 
 */
    __pyx_t_6 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_KeyError);
    if (__pyx_t_6) {
      __Pyx_AddTraceback("mpfmc.core.audio.track_sound_loop.TrackSoundLoop.player_status_to_text", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_1, &__pyx_t_7) < 0) __PYX_ERR(0, 947, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_7);

      /* "mpfmc/core/audio/track_sound_loop.pyx":948
 *             return status_values.get(status)
 *         except KeyError:
 *             return "unknown"             # <<<<<<<<<<<<<<
 * 
 *     @staticmethod
 */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_n_u_unknown);
      __pyx_r = __pyx_n_u_unknown;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L6_except_return;
    }
    goto __pyx_L5_except_error;
    __pyx_L5_except_error:;

    /* "mpfmc/core/audio/track_sound_loop.pyx":945
 *         }
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             return status_values.get(status)
 *         except KeyError:
 */
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
    goto __pyx_L1_error;
    __pyx_L7_try_return:;
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
    goto __pyx_L0;
    __pyx_L6_except_return:;
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
    goto __pyx_L0;
  }

  /* "mpfmc/core/audio/track_sound_loop.pyx":927
 * 
 *     @staticmethod
 *     def player_status_to_text(int status):             # <<<<<<<<<<<<<<
 *         """
 *         Converts a sound loop player status value into an equivalent text string.  Used for testing
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("mpfmc.core.audio.track_sound_loop.TrackSoundLoop.player_status_to_text", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_status_values);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mpfmc/core/audio/track_sound_loop.pyx":951
 * 
 *     @staticmethod
 *     def layer_status_to_text(int status):             # <<<<<<<<<<<<<<
 *         """
 *         Converts a sound loop set layer status value into an equivalent text string.  Used for testing
 */

/* Python wrapper */
static PyObject *__pyx_pw_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_37layer_status_to_text(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_36layer_status_to_text[] = "TrackSoundLoop.layer_status_to_text(int status)\n\n        Converts a sound loop set layer status value into an equivalent text string.  Used for testing\n        purposes only.\n        Args:\n            status: Integer sound loop set layer status value\n\n        Returns:\n            string containing the equivalent status text\n        ";
static PyMethodDef __pyx_mdef_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_37layer_status_to_text = {"layer_status_to_text", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_37layer_status_to_text, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_36layer_status_to_text};
static PyObject *__pyx_pw_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_37layer_status_to_text(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_status;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("layer_status_to_text (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_status,0};
    PyObject* values[1] = {0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_status)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "layer_status_to_text") < 0)) __PYX_ERR(0, 951, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
    }
    __pyx_v_status = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_status == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 951, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("layer_status_to_text", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 951, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mpfmc.core.audio.track_sound_loop.TrackSoundLoop.layer_status_to_text", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_36layer_status_to_text(__pyx_v_status);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_36layer_status_to_text(int __pyx_v_status) {
  PyObject *__pyx_v_status_values = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("layer_status_to_text", 0);

  /* "mpfmc/core/audio/track_sound_loop.pyx":962
 *         """
 *         status_values = {
 *             layer_stopped: "stopped",             # <<<<<<<<<<<<<<
 *             layer_queued: "queued",
 *             layer_playing: "playing",
 */
  __pyx_t_1 = __Pyx_PyDict_NewPresized(5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 962, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5mpfmc_4core_5audio_16track_sound_loop_LayerStatus(__pyx_e_5mpfmc_4core_5audio_16track_sound_loop_layer_stopped); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 962, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_t_2, __pyx_n_u_stopped) < 0) __PYX_ERR(0, 962, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "mpfmc/core/audio/track_sound_loop.pyx":963
 *         status_values = {
 *             layer_stopped: "stopped",
 *             layer_queued: "queued",             # <<<<<<<<<<<<<<
 *             layer_playing: "playing",
 *             layer_fading_in: "fading in",
 */
  __pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5mpfmc_4core_5audio_16track_sound_loop_LayerStatus(__pyx_e_5mpfmc_4core_5audio_16track_sound_loop_layer_queued); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 963, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_t_2, __pyx_n_u_queued) < 0) __PYX_ERR(0, 962, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "mpfmc/core/audio/track_sound_loop.pyx":964
 *             layer_stopped: "stopped",
 *             layer_queued: "queued",
 *             layer_playing: "playing",             # <<<<<<<<<<<<<<
 *             layer_fading_in: "fading in",
 *             layer_fading_out: "fading out",
 */
  __pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5mpfmc_4core_5audio_16track_sound_loop_LayerStatus(__pyx_e_5mpfmc_4core_5audio_16track_sound_loop_layer_playing); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 964, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_t_2, __pyx_n_u_playing) < 0) __PYX_ERR(0, 962, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "mpfmc/core/audio/track_sound_loop.pyx":965
 *             layer_queued: "queued",
 *             layer_playing: "playing",
 *             layer_fading_in: "fading in",             # <<<<<<<<<<<<<<
 *             layer_fading_out: "fading out",
 *         }
 */
  __pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5mpfmc_4core_5audio_16track_sound_loop_LayerStatus(__pyx_e_5mpfmc_4core_5audio_16track_sound_loop_layer_fading_in); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 965, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_t_2, __pyx_kp_u_fading_in) < 0) __PYX_ERR(0, 962, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "mpfmc/core/audio/track_sound_loop.pyx":966
 *             layer_playing: "playing",
 *             layer_fading_in: "fading in",
 *             layer_fading_out: "fading out",             # <<<<<<<<<<<<<<
 *         }
 * 
 */
  __pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_5mpfmc_4core_5audio_16track_sound_loop_LayerStatus(__pyx_e_5mpfmc_4core_5audio_16track_sound_loop_layer_fading_out); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 966, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_t_2, __pyx_kp_u_fading_out) < 0) __PYX_ERR(0, 962, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_status_values = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "mpfmc/core/audio/track_sound_loop.pyx":969
 *         }
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             return status_values.get(status)
 *         except KeyError:
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_3, &__pyx_t_4, &__pyx_t_5);
    __Pyx_XGOTREF(__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_4);
    __Pyx_XGOTREF(__pyx_t_5);
    /*try:*/ {

      /* "mpfmc/core/audio/track_sound_loop.pyx":970
 * 
 *         try:
 *             return status_values.get(status)             # <<<<<<<<<<<<<<
 *         except KeyError:
 *             return "unknown"
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_status); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 970, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = __Pyx_PyDict_GetItemDefault(__pyx_v_status_values, __pyx_t_1, Py_None); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 970, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      goto __pyx_L7_try_return;

      /* "mpfmc/core/audio/track_sound_loop.pyx":969
 *         }
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             return status_values.get(status)
 *         except KeyError:
 */
    }
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "mpfmc/core/audio/track_sound_loop.pyx":971
 *         try:
 *             return status_values.get(status)
 *         except KeyError:             # <<<<<<<<<<<<<<
 *             return "unknown"
 * 
 */
    __pyx_t_6 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_KeyError);
    if (__pyx_t_6) {
      __Pyx_AddTraceback("mpfmc.core.audio.track_sound_loop.TrackSoundLoop.layer_status_to_text", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_1, &__pyx_t_7) < 0) __PYX_ERR(0, 971, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_7);

      /* "mpfmc/core/audio/track_sound_loop.pyx":972
 *             return status_values.get(status)
 *         except KeyError:
 *             return "unknown"             # <<<<<<<<<<<<<<
 * 
 *     cdef inline Uint32 _round_sample_pos_up_to_interval(self, Uint32 sample_pos, Uint32 interval, int bytes_per_sample_frame):
 */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_n_u_unknown);
      __pyx_r = __pyx_n_u_unknown;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L6_except_return;
    }
    goto __pyx_L5_except_error;
    __pyx_L5_except_error:;

    /* "mpfmc/core/audio/track_sound_loop.pyx":969
 *         }
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             return status_values.get(status)
 *         except KeyError:
 */
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
    goto __pyx_L1_error;
    __pyx_L7_try_return:;
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
    goto __pyx_L0;
    __pyx_L6_except_return:;
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
    goto __pyx_L0;
  }

  /* "mpfmc/core/audio/track_sound_loop.pyx":951
 * 
 *     @staticmethod
 *     def layer_status_to_text(int status):             # <<<<<<<<<<<<<<
 *         """
 *         Converts a sound loop set layer status value into an equivalent text string.  Used for testing
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("mpfmc.core.audio.track_sound_loop.TrackSoundLoop.layer_status_to_text", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_status_values);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mpfmc/core/audio/track_sound_loop.pyx":974
 *             return "unknown"
 * 
 *     cdef inline Uint32 _round_sample_pos_up_to_interval(self, Uint32 sample_pos, Uint32 interval, int bytes_per_sample_frame):             # <<<<<<<<<<<<<<
 *         """
 *         Rounds sample position up to the nearest specified interval.
 */

static CYTHON_INLINE Uint32 __pyx_f_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop__round_sample_pos_up_to_interval(CYTHON_UNUSED struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *__pyx_v_self, Uint32 __pyx_v_sample_pos, Uint32 __pyx_v_interval, int __pyx_v_bytes_per_sample_frame) {
  Uint32 __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  Uint32 __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_round_sample_pos_up_to_interval", 0);

  /* "mpfmc/core/audio/track_sound_loop.pyx":992
 *             a whole sample frame boundary.
 *         """
 *         return bytes_per_sample_frame * ceil((interval * ceil(sample_pos / interval)) / bytes_per_sample_frame)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_bytes_per_sample_frame); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 992, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_ceil); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 992, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyInt_From_Uint32(__pyx_v_interval); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 992, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_ceil); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 992, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  if (unlikely(__pyx_v_interval == 0)) {
    PyErr_SetString(PyExc_ZeroDivisionError, "float division");
    __PYX_ERR(0, 992, __pyx_L1_error)
  }
  __pyx_t_7 = PyFloat_FromDouble((((double)__pyx_v_sample_pos) / ((double)__pyx_v_interval))); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 992, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_8 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_8)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_8);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
    }
  }
  __pyx_t_5 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_8, __pyx_t_7) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 992, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyNumber_Multiply(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 992, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_bytes_per_sample_frame); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 992, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_4 = __Pyx_PyNumber_Divide(__pyx_t_6, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 992, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  __pyx_t_2 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_5, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 992, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyNumber_Multiply(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 992, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_9 = __Pyx_PyInt_As_Uint32(__pyx_t_3); if (unlikely((__pyx_t_9 == ((Uint32)-1)) && PyErr_Occurred())) __PYX_ERR(0, 992, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_9;
  goto __pyx_L0;

  /* "mpfmc/core/audio/track_sound_loop.pyx":974
 *             return "unknown"
 * 
 *     cdef inline Uint32 _round_sample_pos_up_to_interval(self, Uint32 sample_pos, Uint32 interval, int bytes_per_sample_frame):             # <<<<<<<<<<<<<<
 *         """
 *         Rounds sample position up to the nearest specified interval.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_WriteUnraisable("mpfmc.core.audio.track_sound_loop.TrackSoundLoop._round_sample_pos_up_to_interval", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mpfmc/core/audio/track_sound_loop.pyx":1006
 * 
 *     @staticmethod
 *     cdef void mix_playing_sounds(TrackState *track, Uint32 buffer_length, AudioCallbackData *callback_data) nogil:             # <<<<<<<<<<<<<<
 *         """
 *         Mixes any sounds that are playing on the specified standard track into the specified audio buffer.
 */

static void __pyx_f_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_mix_playing_sounds(__pyx_t_5mpfmc_4core_5audio_5track_TrackState *__pyx_v_track, Uint32 __pyx_v_buffer_length, __pyx_t_5mpfmc_4core_5audio_4sdl2_AudioCallbackData *__pyx_v_callback_data) {
  __pyx_t_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoopState *__pyx_v_sound_loop_track;
  CYTHON_UNUSED int __pyx_v_first_layer;
  GSList *__pyx_v_iterator;
  __pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopSetPlayer *__pyx_v_player;
  Uint32 __pyx_v_track_buffer_pos;
  int __pyx_t_1;
  int __pyx_t_2;
  GSList *__pyx_t_3;
  Uint32 __pyx_t_4;
  int __pyx_t_5;

  /* "mpfmc/core/audio/track_sound_loop.pyx":1018
 *         cdef TrackState *target_track
 *         cdef TrackSoundLoopState *sound_loop_track
 *         cdef bint first_layer = True             # <<<<<<<<<<<<<<
 *         cdef GSList *iterator
 *         cdef SoundLoopSetPlayer *player
 */
  __pyx_v_first_layer = 1;

  /* "mpfmc/core/audio/track_sound_loop.pyx":1022
 *         cdef SoundLoopSetPlayer *player
 * 
 *         if track == NULL or track.type_state == NULL:             # <<<<<<<<<<<<<<
 *             return
 * 
 */
  __pyx_t_2 = ((__pyx_v_track == NULL) != 0);
  if (!__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_2 = ((__pyx_v_track->type_state == NULL) != 0);
  __pyx_t_1 = __pyx_t_2;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_1) {

    /* "mpfmc/core/audio/track_sound_loop.pyx":1023
 * 
 *         if track == NULL or track.type_state == NULL:
 *             return             # <<<<<<<<<<<<<<
 * 
 *         sound_loop_track = <TrackSoundLoopState*>track.type_state
 */
    goto __pyx_L0;

    /* "mpfmc/core/audio/track_sound_loop.pyx":1022
 *         cdef SoundLoopSetPlayer *player
 * 
 *         if track == NULL or track.type_state == NULL:             # <<<<<<<<<<<<<<
 *             return
 * 
 */
  }

  /* "mpfmc/core/audio/track_sound_loop.pyx":1025
 *             return
 * 
 *         sound_loop_track = <TrackSoundLoopState*>track.type_state             # <<<<<<<<<<<<<<
 * 
 *         # Setup local variables
 */
  __pyx_v_sound_loop_track = ((__pyx_t_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoopState *)__pyx_v_track->type_state);

  /* "mpfmc/core/audio/track_sound_loop.pyx":1031
 * 
 *         # Loop over the current sound loop players
 *         iterator = sound_loop_track.players             # <<<<<<<<<<<<<<
 *         while iterator != NULL:
 *             player = <SoundLoopSetPlayer*>iterator.data
 */
  __pyx_t_3 = __pyx_v_sound_loop_track->players;
  __pyx_v_iterator = __pyx_t_3;

  /* "mpfmc/core/audio/track_sound_loop.pyx":1032
 *         # Loop over the current sound loop players
 *         iterator = sound_loop_track.players
 *         while iterator != NULL:             # <<<<<<<<<<<<<<
 *             player = <SoundLoopSetPlayer*>iterator.data
 *             iterator = iterator.next
 */
  while (1) {
    __pyx_t_1 = ((__pyx_v_iterator != NULL) != 0);
    if (!__pyx_t_1) break;

    /* "mpfmc/core/audio/track_sound_loop.pyx":1033
 *         iterator = sound_loop_track.players
 *         while iterator != NULL:
 *             player = <SoundLoopSetPlayer*>iterator.data             # <<<<<<<<<<<<<<
 *             iterator = iterator.next
 * 
 */
    __pyx_v_player = ((__pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopSetPlayer *)__pyx_v_iterator->data);

    /* "mpfmc/core/audio/track_sound_loop.pyx":1034
 *         while iterator != NULL:
 *             player = <SoundLoopSetPlayer*>iterator.data
 *             iterator = iterator.next             # <<<<<<<<<<<<<<
 * 
 *             # If the current player is idle, the track is not active so there is nothing to do for this player
 */
    __pyx_t_3 = __pyx_v_iterator->next;
    __pyx_v_iterator = __pyx_t_3;

    /* "mpfmc/core/audio/track_sound_loop.pyx":1037
 * 
 *             # If the current player is idle, the track is not active so there is nothing to do for this player
 *             if player == NULL or player.status == player_idle:             # <<<<<<<<<<<<<<
 *                 continue
 * 
 */
    __pyx_t_2 = ((__pyx_v_player == NULL) != 0);
    if (!__pyx_t_2) {
    } else {
      __pyx_t_1 = __pyx_t_2;
      goto __pyx_L9_bool_binop_done;
    }
    __pyx_t_2 = ((__pyx_v_player->status == __pyx_e_5mpfmc_4core_5audio_16track_sound_loop_player_idle) != 0);
    __pyx_t_1 = __pyx_t_2;
    __pyx_L9_bool_binop_done:;
    if (__pyx_t_1) {

      /* "mpfmc/core/audio/track_sound_loop.pyx":1038
 *             # If the current player is idle, the track is not active so there is nothing to do for this player
 *             if player == NULL or player.status == player_idle:
 *                 continue             # <<<<<<<<<<<<<<
 * 
 *             # Process the current loop player (fill the track buffer with samples)
 */
      goto __pyx_L6_continue;

      /* "mpfmc/core/audio/track_sound_loop.pyx":1037
 * 
 *             # If the current player is idle, the track is not active so there is nothing to do for this player
 *             if player == NULL or player.status == player_idle:             # <<<<<<<<<<<<<<
 *                 continue
 * 
 */
    }

    /* "mpfmc/core/audio/track_sound_loop.pyx":1041
 * 
 *             # Process the current loop player (fill the track buffer with samples)
 *             track_buffer_pos = 0             # <<<<<<<<<<<<<<
 * 
 *             # Handle any player delay
 */
    __pyx_v_track_buffer_pos = 0;

    /* "mpfmc/core/audio/track_sound_loop.pyx":1044
 * 
 *             # Handle any player delay
 *             if player.status == player_delayed:             # <<<<<<<<<<<<<<
 * 
 *                 # Determine if player should start (delay elapses during this buffer)
 */
    __pyx_t_1 = ((__pyx_v_player->status == __pyx_e_5mpfmc_4core_5audio_16track_sound_loop_player_delayed) != 0);
    if (__pyx_t_1) {

      /* "mpfmc/core/audio/track_sound_loop.pyx":1047
 * 
 *                 # Determine if player should start (delay elapses during this buffer)
 *                 if player.start_delay_samples_remaining < buffer_length:             # <<<<<<<<<<<<<<
 * 
 *                     # Start player playing
 */
      __pyx_t_1 = ((__pyx_v_player->start_delay_samples_remaining < __pyx_v_buffer_length) != 0);
      if (__pyx_t_1) {

        /* "mpfmc/core/audio/track_sound_loop.pyx":1050
 * 
 *                     # Start player playing
 *                     track_buffer_pos = player.start_delay_samples_remaining             # <<<<<<<<<<<<<<
 *                     player.start_delay_samples_remaining = 0
 *                     player.status = player_playing
 */
        __pyx_t_4 = __pyx_v_player->start_delay_samples_remaining;
        __pyx_v_track_buffer_pos = __pyx_t_4;

        /* "mpfmc/core/audio/track_sound_loop.pyx":1051
 *                     # Start player playing
 *                     track_buffer_pos = player.start_delay_samples_remaining
 *                     player.start_delay_samples_remaining = 0             # <<<<<<<<<<<<<<
 *                     player.status = player_playing
 * 
 */
        __pyx_v_player->start_delay_samples_remaining = 0;

        /* "mpfmc/core/audio/track_sound_loop.pyx":1052
 *                     track_buffer_pos = player.start_delay_samples_remaining
 *                     player.start_delay_samples_remaining = 0
 *                     player.status = player_playing             # <<<<<<<<<<<<<<
 * 
 *                     # This player now becomes the current player
 */
        __pyx_v_player->status = __pyx_e_5mpfmc_4core_5audio_16track_sound_loop_player_playing;

        /* "mpfmc/core/audio/track_sound_loop.pyx":1055
 * 
 *                     # This player now becomes the current player
 *                     sound_loop_track.current = player             # <<<<<<<<<<<<<<
 * 
 *                     # Send started notification
 */
        __pyx_v_sound_loop_track->current = __pyx_v_player;

        /* "mpfmc/core/audio/track_sound_loop.pyx":1058
 * 
 *                     # Send started notification
 *                     send_sound_loop_set_started_notification(player.master_sound_layer.sound_loop_set_id,             # <<<<<<<<<<<<<<
 *                                                              player.master_sound_layer.sound_id,
 *                                                              player,
 */
        __pyx_f_5mpfmc_4core_5audio_20notification_message_send_sound_loop_set_started_notification(__pyx_v_player->master_sound_layer.sound_loop_set_id, __pyx_v_player->master_sound_layer.sound_id, __pyx_v_player, __pyx_v_track);

        /* "mpfmc/core/audio/track_sound_loop.pyx":1047
 * 
 *                 # Determine if player should start (delay elapses during this buffer)
 *                 if player.start_delay_samples_remaining < buffer_length:             # <<<<<<<<<<<<<<
 * 
 *                     # Start player playing
 */
        goto __pyx_L12;
      }

      /* "mpfmc/core/audio/track_sound_loop.pyx":1065
 *                 else:
 *                     # Continue to delay until a future buffer
 *                     player.start_delay_samples_remaining -= buffer_length             # <<<<<<<<<<<<<<
 *                     track_buffer_pos = buffer_length
 * 
 */
      /*else*/ {
        __pyx_v_player->start_delay_samples_remaining = (__pyx_v_player->start_delay_samples_remaining - __pyx_v_buffer_length);

        /* "mpfmc/core/audio/track_sound_loop.pyx":1066
 *                     # Continue to delay until a future buffer
 *                     player.start_delay_samples_remaining -= buffer_length
 *                     track_buffer_pos = buffer_length             # <<<<<<<<<<<<<<
 * 
 *             # Loop over track buffer, filling samples for player (if applicable)
 */
        __pyx_v_track_buffer_pos = __pyx_v_buffer_length;
      }
      __pyx_L12:;

      /* "mpfmc/core/audio/track_sound_loop.pyx":1044
 * 
 *             # Handle any player delay
 *             if player.status == player_delayed:             # <<<<<<<<<<<<<<
 * 
 *                 # Determine if player should start (delay elapses during this buffer)
 */
    }

    /* "mpfmc/core/audio/track_sound_loop.pyx":1069
 * 
 *             # Loop over track buffer, filling samples for player (if applicable)
 *             while track_buffer_pos < buffer_length and player.status \             # <<<<<<<<<<<<<<
 *                     in (player_playing, player_fading_in, player_fading_out):
 * 
 */
    while (1) {
      __pyx_t_2 = ((__pyx_v_track_buffer_pos < __pyx_v_buffer_length) != 0);
      if (__pyx_t_2) {
      } else {
        __pyx_t_1 = __pyx_t_2;
        goto __pyx_L15_bool_binop_done;
      }

      /* "mpfmc/core/audio/track_sound_loop.pyx":1070
 *             # Loop over track buffer, filling samples for player (if applicable)
 *             while track_buffer_pos < buffer_length and player.status \
 *                     in (player_playing, player_fading_in, player_fading_out):             # <<<<<<<<<<<<<<
 * 
 *                 # Set flag indicating there is at least some activity on the track (it is active)
 */
      switch (__pyx_v_player->status) {
        case __pyx_e_5mpfmc_4core_5audio_16track_sound_loop_player_playing:
        case __pyx_e_5mpfmc_4core_5audio_16track_sound_loop_player_fading_in:
        case __pyx_e_5mpfmc_4core_5audio_16track_sound_loop_player_fading_out:
        __pyx_t_2 = 1;
        break;
        default:
        __pyx_t_2 = 0;
        break;
      }
      __pyx_t_5 = (__pyx_t_2 != 0);
      __pyx_t_1 = __pyx_t_5;
      __pyx_L15_bool_binop_done:;
      if (!__pyx_t_1) break;

      /* "mpfmc/core/audio/track_sound_loop.pyx":1073
 * 
 *                 # Set flag indicating there is at least some activity on the track (it is active)
 *                 track.active = True             # <<<<<<<<<<<<<<
 * 
 *                 track_buffer_pos = get_player_sound_samples(track, player, buffer_length,
 */
      __pyx_v_track->active = 1;

      /* "mpfmc/core/audio/track_sound_loop.pyx":1075
 *                 track.active = True
 * 
 *                 track_buffer_pos = get_player_sound_samples(track, player, buffer_length,             # <<<<<<<<<<<<<<
 *                                                             track_buffer_pos, callback_data)
 * 
 */
      __pyx_v_track_buffer_pos = __pyx_f_5mpfmc_4core_5audio_16track_sound_loop_get_player_sound_samples(__pyx_v_track, __pyx_v_player, __pyx_v_buffer_length, __pyx_v_track_buffer_pos, __pyx_v_callback_data);

      /* "mpfmc/core/audio/track_sound_loop.pyx":1079
 * 
 *                 # Determine if the player has finished
 *                 if player.status == player_idle:             # <<<<<<<<<<<<<<
 * 
 *                     # Player has stopped and is now idle, if it is set as the current one, set current to NULL
 */
      __pyx_t_1 = ((__pyx_v_player->status == __pyx_e_5mpfmc_4core_5audio_16track_sound_loop_player_idle) != 0);
      if (__pyx_t_1) {

        /* "mpfmc/core/audio/track_sound_loop.pyx":1082
 * 
 *                     # Player has stopped and is now idle, if it is set as the current one, set current to NULL
 *                     if sound_loop_track.current == player:             # <<<<<<<<<<<<<<
 *                         sound_loop_track.current = NULL
 * 
 */
        __pyx_t_1 = ((__pyx_v_sound_loop_track->current == __pyx_v_player) != 0);
        if (__pyx_t_1) {

          /* "mpfmc/core/audio/track_sound_loop.pyx":1083
 *                     # Player has stopped and is now idle, if it is set as the current one, set current to NULL
 *                     if sound_loop_track.current == player:
 *                         sound_loop_track.current = NULL             # <<<<<<<<<<<<<<
 * 
 *                     # Send stopped notification
 */
          __pyx_v_sound_loop_track->current = NULL;

          /* "mpfmc/core/audio/track_sound_loop.pyx":1082
 * 
 *                     # Player has stopped and is now idle, if it is set as the current one, set current to NULL
 *                     if sound_loop_track.current == player:             # <<<<<<<<<<<<<<
 *                         sound_loop_track.current = NULL
 * 
 */
        }

        /* "mpfmc/core/audio/track_sound_loop.pyx":1086
 * 
 *                     # Send stopped notification
 *                     send_sound_loop_set_stopped_notification(player.master_sound_layer.sound_loop_set_id,             # <<<<<<<<<<<<<<
 *                                                              player.master_sound_layer.sound_id,
 *                                                              player,
 */
        __pyx_f_5mpfmc_4core_5audio_20notification_message_send_sound_loop_set_stopped_notification(__pyx_v_player->master_sound_layer.sound_loop_set_id, __pyx_v_player->master_sound_layer.sound_id, __pyx_v_player, __pyx_v_track);

        /* "mpfmc/core/audio/track_sound_loop.pyx":1079
 * 
 *                 # Determine if the player has finished
 *                 if player.status == player_idle:             # <<<<<<<<<<<<<<
 * 
 *                     # Player has stopped and is now idle, if it is set as the current one, set current to NULL
 */
        goto __pyx_L17;
      }

      /* "mpfmc/core/audio/track_sound_loop.pyx":1092
 * 
 *                 # Determine if sound is looping
 *                 elif player.sample_pos >= player.length:             # <<<<<<<<<<<<<<
 * 
 *                     # Send looping notification
 */
      __pyx_t_1 = ((__pyx_v_player->sample_pos >= __pyx_v_player->length) != 0);
      if (__pyx_t_1) {

        /* "mpfmc/core/audio/track_sound_loop.pyx":1095
 * 
 *                     # Send looping notification
 *                     send_sound_loop_set_looping_notification(player.master_sound_layer.sound_loop_set_id,             # <<<<<<<<<<<<<<
 *                                                              player.master_sound_layer.sound_id,
 *                                                              player,
 */
        __pyx_f_5mpfmc_4core_5audio_20notification_message_send_sound_loop_set_looping_notification(__pyx_v_player->master_sound_layer.sound_loop_set_id, __pyx_v_player->master_sound_layer.sound_id, __pyx_v_player, __pyx_v_track);

        /* "mpfmc/core/audio/track_sound_loop.pyx":1099
 *                                                              player,
 *                                                              track)
 *                     player.sample_pos = 0             # <<<<<<<<<<<<<<
 * 
 * cdef Uint32 get_player_sound_samples(TrackState *track, SoundLoopSetPlayer *player,
 */
        __pyx_v_player->sample_pos = 0;

        /* "mpfmc/core/audio/track_sound_loop.pyx":1092
 * 
 *                 # Determine if sound is looping
 *                 elif player.sample_pos >= player.length:             # <<<<<<<<<<<<<<
 * 
 *                     # Send looping notification
 */
      }
      __pyx_L17:;
    }
    __pyx_L6_continue:;
  }

  /* "mpfmc/core/audio/track_sound_loop.pyx":1006
 * 
 *     @staticmethod
 *     cdef void mix_playing_sounds(TrackState *track, Uint32 buffer_length, AudioCallbackData *callback_data) nogil:             # <<<<<<<<<<<<<<
 *         """
 *         Mixes any sounds that are playing on the specified standard track into the specified audio buffer.
 */

  /* function exit code */
  __pyx_L0:;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("self.state,self.type_state cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):
 */

/* Python wrapper */
static PyObject *__pyx_pw_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_39__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_38__reduce_cython__[] = "TrackSoundLoop.__reduce_cython__(self)";
static PyObject *__pyx_pw_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_39__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_38__reduce_cython__(((struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_38__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":2
 * def __reduce_cython__(self):
 *     raise TypeError("self.state,self.type_state cannot be converted to a Python object for pickling")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("self.state,self.type_state cannot be converted to a Python object for pickling")
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(1, 2, __pyx_L1_error)

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("self.state,self.type_state cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("mpfmc.core.audio.track_sound_loop.TrackSoundLoop.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("self.state,self.type_state cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("self.state,self.type_state cannot be converted to a Python object for pickling")
 */

/* Python wrapper */
static PyObject *__pyx_pw_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_41__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static char __pyx_doc_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_40__setstate_cython__[] = "TrackSoundLoop.__setstate_cython__(self, __pyx_state)";
static PyObject *__pyx_pw_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_41__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_40__setstate_cython__(((struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_40__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);

  /* "(tree fragment)":4
 *     raise TypeError("self.state,self.type_state cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("self.state,self.type_state cannot be converted to a Python object for pickling")             # <<<<<<<<<<<<<<
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(1, 4, __pyx_L1_error)

  /* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("self.state,self.type_state cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("self.state,self.type_state cannot be converted to a Python object for pickling")
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("mpfmc.core.audio.track_sound_loop.TrackSoundLoop.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mpfmc/core/audio/track_sound_loop.pyx":1101
 *                     player.sample_pos = 0
 * 
 * cdef Uint32 get_player_sound_samples(TrackState *track, SoundLoopSetPlayer *player,             # <<<<<<<<<<<<<<
 *                                      Uint32 buffer_length, Uint32 track_buffer_pos,
 *                                      AudioCallbackData *callback_data) nogil:
 */

static Uint32 __pyx_f_5mpfmc_4core_5audio_16track_sound_loop_get_player_sound_samples(__pyx_t_5mpfmc_4core_5audio_5track_TrackState *__pyx_v_track, __pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopSetPlayer *__pyx_v_player, Uint32 __pyx_v_buffer_length, Uint32 __pyx_v_track_buffer_pos, __pyx_t_5mpfmc_4core_5audio_4sdl2_AudioCallbackData *__pyx_v_callback_data) {
  __pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopLayerSettings *__pyx_v_layer;
  GSList *__pyx_v_layer_iterator;
  Uint8 __pyx_v_player_volume;
  Uint8 __pyx_v_layer_volume;
  Uint32 __pyx_v_layer_sample_pos;
  Uint32 __pyx_v_layer_bytes_remaining;
  Uint32 __pyx_v_layer_chunk_bytes;
  Uint32 __pyx_v_current_chunk_bytes;
  Uint32 __pyx_v_layer_track_buffer_pos_offset;
  Uint32 __pyx_v_buffer_bytes_remaining;
  Uint8 __pyx_v_marker_id;
  Uint32 __pyx_r;
  int __pyx_t_1;
  Uint32 __pyx_t_2;
  Uint16 __pyx_t_3;
  Uint32 __pyx_t_4;
  Uint32 __pyx_t_5;
  int __pyx_t_6;
  int __pyx_t_7;
  Uint8 __pyx_t_8;
  Uint8 __pyx_t_9;
  Uint8 __pyx_t_10;
  guint __pyx_t_11;
  GSList *__pyx_t_12;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;

  /* "mpfmc/core/audio/track_sound_loop.pyx":1130
 *     cdef Uint32 layer_sample_pos, layer_bytes_remaining, layer_chunk_bytes, current_chunk_bytes, temp_chunk_bytes
 *     cdef Uint32 layer_track_buffer_pos_offset
 *     cdef Uint32 buffer_bytes_remaining = buffer_length - track_buffer_pos             # <<<<<<<<<<<<<<
 * 
 *     # Loop over the output buffer
 */
  __pyx_v_buffer_bytes_remaining = (__pyx_v_buffer_length - __pyx_v_track_buffer_pos);

  /* "mpfmc/core/audio/track_sound_loop.pyx":1133
 * 
 *     # Loop over the output buffer
 *     while buffer_bytes_remaining > 0:             # <<<<<<<<<<<<<<
 * 
 *         # Mix current player into track buffer.  Processing is done at control rate during player
 */
  while (1) {
    __pyx_t_1 = ((__pyx_v_buffer_bytes_remaining > 0) != 0);
    if (!__pyx_t_1) break;

    /* "mpfmc/core/audio/track_sound_loop.pyx":1139
 * 
 *         # Calculate the size and volume of chunk (handle fading)
 *         if player.status == player_fading_in:             # <<<<<<<<<<<<<<
 *             current_chunk_bytes = min(buffer_bytes_remaining,
 *                                       player.length - player.sample_pos,
 */
    switch (__pyx_v_player->status) {
      case __pyx_e_5mpfmc_4core_5audio_16track_sound_loop_player_fading_in:

      /* "mpfmc/core/audio/track_sound_loop.pyx":1141
 *         if player.status == player_fading_in:
 *             current_chunk_bytes = min(buffer_bytes_remaining,
 *                                       player.length - player.sample_pos,             # <<<<<<<<<<<<<<
 *                                       callback_data.bytes_per_control_point)
 *             player_volume = <Uint8> (in_out_quad((player.master_sound_layer.fade_in_steps - player.master_sound_layer.fade_steps_remaining) / player.master_sound_layer.fade_in_steps) * SDL_MIX_MAXVOLUME)
 */
      __pyx_t_2 = (__pyx_v_player->length - __pyx_v_player->sample_pos);

      /* "mpfmc/core/audio/track_sound_loop.pyx":1142
 *             current_chunk_bytes = min(buffer_bytes_remaining,
 *                                       player.length - player.sample_pos,
 *                                       callback_data.bytes_per_control_point)             # <<<<<<<<<<<<<<
 *             player_volume = <Uint8> (in_out_quad((player.master_sound_layer.fade_in_steps - player.master_sound_layer.fade_steps_remaining) / player.master_sound_layer.fade_in_steps) * SDL_MIX_MAXVOLUME)
 *             player.master_sound_layer.fade_steps_remaining -= 1
 */
      __pyx_t_3 = __pyx_v_callback_data->bytes_per_control_point;

      /* "mpfmc/core/audio/track_sound_loop.pyx":1140
 *         # Calculate the size and volume of chunk (handle fading)
 *         if player.status == player_fading_in:
 *             current_chunk_bytes = min(buffer_bytes_remaining,             # <<<<<<<<<<<<<<
 *                                       player.length - player.sample_pos,
 *                                       callback_data.bytes_per_control_point)
 */
      __pyx_t_4 = __pyx_v_buffer_bytes_remaining;

      /* "mpfmc/core/audio/track_sound_loop.pyx":1141
 *         if player.status == player_fading_in:
 *             current_chunk_bytes = min(buffer_bytes_remaining,
 *                                       player.length - player.sample_pos,             # <<<<<<<<<<<<<<
 *                                       callback_data.bytes_per_control_point)
 *             player_volume = <Uint8> (in_out_quad((player.master_sound_layer.fade_in_steps - player.master_sound_layer.fade_steps_remaining) / player.master_sound_layer.fade_in_steps) * SDL_MIX_MAXVOLUME)
 */
      if (((__pyx_t_2 < __pyx_t_4) != 0)) {
        __pyx_t_5 = __pyx_t_2;
      } else {
        __pyx_t_5 = __pyx_t_4;
      }
      __pyx_t_4 = __pyx_t_5;

      /* "mpfmc/core/audio/track_sound_loop.pyx":1142
 *             current_chunk_bytes = min(buffer_bytes_remaining,
 *                                       player.length - player.sample_pos,
 *                                       callback_data.bytes_per_control_point)             # <<<<<<<<<<<<<<
 *             player_volume = <Uint8> (in_out_quad((player.master_sound_layer.fade_in_steps - player.master_sound_layer.fade_steps_remaining) / player.master_sound_layer.fade_in_steps) * SDL_MIX_MAXVOLUME)
 *             player.master_sound_layer.fade_steps_remaining -= 1
 */
      if (((__pyx_t_3 < __pyx_t_4) != 0)) {
        __pyx_t_5 = __pyx_t_3;
      } else {
        __pyx_t_5 = __pyx_t_4;
      }
      __pyx_v_current_chunk_bytes = __pyx_t_5;

      /* "mpfmc/core/audio/track_sound_loop.pyx":1143
 *                                       player.length - player.sample_pos,
 *                                       callback_data.bytes_per_control_point)
 *             player_volume = <Uint8> (in_out_quad((player.master_sound_layer.fade_in_steps - player.master_sound_layer.fade_steps_remaining) / player.master_sound_layer.fade_in_steps) * SDL_MIX_MAXVOLUME)             # <<<<<<<<<<<<<<
 *             player.master_sound_layer.fade_steps_remaining -= 1
 *             if player.master_sound_layer.fade_steps_remaining == 0:
 */
      __pyx_t_5 = (__pyx_v_player->master_sound_layer.fade_in_steps - __pyx_v_player->master_sound_layer.fade_steps_remaining);
      if (unlikely(__pyx_v_player->master_sound_layer.fade_in_steps == 0)) {
        #ifdef WITH_THREAD
        PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
        #endif
        PyErr_SetString(PyExc_ZeroDivisionError, "float division");
        #ifdef WITH_THREAD
        __Pyx_PyGILState_Release(__pyx_gilstate_save);
        #endif
        __PYX_ERR(0, 1143, __pyx_L1_error)
      }
      __pyx_v_player_volume = ((Uint8)(__pyx_f_5mpfmc_4core_5audio_6inline_in_out_quad((((double)__pyx_t_5) / ((double)__pyx_v_player->master_sound_layer.fade_in_steps))) * SDL_MIX_MAXVOLUME));

      /* "mpfmc/core/audio/track_sound_loop.pyx":1144
 *                                       callback_data.bytes_per_control_point)
 *             player_volume = <Uint8> (in_out_quad((player.master_sound_layer.fade_in_steps - player.master_sound_layer.fade_steps_remaining) / player.master_sound_layer.fade_in_steps) * SDL_MIX_MAXVOLUME)
 *             player.master_sound_layer.fade_steps_remaining -= 1             # <<<<<<<<<<<<<<
 *             if player.master_sound_layer.fade_steps_remaining == 0:
 *                 player.status = player_playing
 */
      __pyx_v_player->master_sound_layer.fade_steps_remaining = (__pyx_v_player->master_sound_layer.fade_steps_remaining - 1);

      /* "mpfmc/core/audio/track_sound_loop.pyx":1145
 *             player_volume = <Uint8> (in_out_quad((player.master_sound_layer.fade_in_steps - player.master_sound_layer.fade_steps_remaining) / player.master_sound_layer.fade_in_steps) * SDL_MIX_MAXVOLUME)
 *             player.master_sound_layer.fade_steps_remaining -= 1
 *             if player.master_sound_layer.fade_steps_remaining == 0:             # <<<<<<<<<<<<<<
 *                 player.status = player_playing
 * 
 */
      __pyx_t_1 = ((__pyx_v_player->master_sound_layer.fade_steps_remaining == 0) != 0);
      if (__pyx_t_1) {

        /* "mpfmc/core/audio/track_sound_loop.pyx":1146
 *             player.master_sound_layer.fade_steps_remaining -= 1
 *             if player.master_sound_layer.fade_steps_remaining == 0:
 *                 player.status = player_playing             # <<<<<<<<<<<<<<
 * 
 *         elif player.status == player_fading_out:
 */
        __pyx_v_player->status = __pyx_e_5mpfmc_4core_5audio_16track_sound_loop_player_playing;

        /* "mpfmc/core/audio/track_sound_loop.pyx":1145
 *             player_volume = <Uint8> (in_out_quad((player.master_sound_layer.fade_in_steps - player.master_sound_layer.fade_steps_remaining) / player.master_sound_layer.fade_in_steps) * SDL_MIX_MAXVOLUME)
 *             player.master_sound_layer.fade_steps_remaining -= 1
 *             if player.master_sound_layer.fade_steps_remaining == 0:             # <<<<<<<<<<<<<<
 *                 player.status = player_playing
 * 
 */
      }

      /* "mpfmc/core/audio/track_sound_loop.pyx":1139
 * 
 *         # Calculate the size and volume of chunk (handle fading)
 *         if player.status == player_fading_in:             # <<<<<<<<<<<<<<
 *             current_chunk_bytes = min(buffer_bytes_remaining,
 *                                       player.length - player.sample_pos,
 */
      break;
      case __pyx_e_5mpfmc_4core_5audio_16track_sound_loop_player_fading_out:

      /* "mpfmc/core/audio/track_sound_loop.pyx":1150
 *         elif player.status == player_fading_out:
 *             current_chunk_bytes = min(buffer_bytes_remaining,
 *                                       player.length - player.sample_pos,             # <<<<<<<<<<<<<<
 *                                       callback_data.bytes_per_control_point)
 *             player_volume = <Uint8> (in_out_quad(player.master_sound_layer.fade_steps_remaining / player.master_sound_layer.fade_out_steps) * SDL_MIX_MAXVOLUME)
 */
      __pyx_t_5 = (__pyx_v_player->length - __pyx_v_player->sample_pos);

      /* "mpfmc/core/audio/track_sound_loop.pyx":1151
 *             current_chunk_bytes = min(buffer_bytes_remaining,
 *                                       player.length - player.sample_pos,
 *                                       callback_data.bytes_per_control_point)             # <<<<<<<<<<<<<<
 *             player_volume = <Uint8> (in_out_quad(player.master_sound_layer.fade_steps_remaining / player.master_sound_layer.fade_out_steps) * SDL_MIX_MAXVOLUME)
 *             player.master_sound_layer.fade_steps_remaining -= 1
 */
      __pyx_t_3 = __pyx_v_callback_data->bytes_per_control_point;

      /* "mpfmc/core/audio/track_sound_loop.pyx":1149
 * 
 *         elif player.status == player_fading_out:
 *             current_chunk_bytes = min(buffer_bytes_remaining,             # <<<<<<<<<<<<<<
 *                                       player.length - player.sample_pos,
 *                                       callback_data.bytes_per_control_point)
 */
      __pyx_t_2 = __pyx_v_buffer_bytes_remaining;

      /* "mpfmc/core/audio/track_sound_loop.pyx":1150
 *         elif player.status == player_fading_out:
 *             current_chunk_bytes = min(buffer_bytes_remaining,
 *                                       player.length - player.sample_pos,             # <<<<<<<<<<<<<<
 *                                       callback_data.bytes_per_control_point)
 *             player_volume = <Uint8> (in_out_quad(player.master_sound_layer.fade_steps_remaining / player.master_sound_layer.fade_out_steps) * SDL_MIX_MAXVOLUME)
 */
      if (((__pyx_t_5 < __pyx_t_2) != 0)) {
        __pyx_t_4 = __pyx_t_5;
      } else {
        __pyx_t_4 = __pyx_t_2;
      }
      __pyx_t_2 = __pyx_t_4;

      /* "mpfmc/core/audio/track_sound_loop.pyx":1151
 *             current_chunk_bytes = min(buffer_bytes_remaining,
 *                                       player.length - player.sample_pos,
 *                                       callback_data.bytes_per_control_point)             # <<<<<<<<<<<<<<
 *             player_volume = <Uint8> (in_out_quad(player.master_sound_layer.fade_steps_remaining / player.master_sound_layer.fade_out_steps) * SDL_MIX_MAXVOLUME)
 *             player.master_sound_layer.fade_steps_remaining -= 1
 */
      if (((__pyx_t_3 < __pyx_t_2) != 0)) {
        __pyx_t_4 = __pyx_t_3;
      } else {
        __pyx_t_4 = __pyx_t_2;
      }
      __pyx_v_current_chunk_bytes = __pyx_t_4;

      /* "mpfmc/core/audio/track_sound_loop.pyx":1152
 *                                       player.length - player.sample_pos,
 *                                       callback_data.bytes_per_control_point)
 *             player_volume = <Uint8> (in_out_quad(player.master_sound_layer.fade_steps_remaining / player.master_sound_layer.fade_out_steps) * SDL_MIX_MAXVOLUME)             # <<<<<<<<<<<<<<
 *             player.master_sound_layer.fade_steps_remaining -= 1
 *             if player.master_sound_layer.fade_steps_remaining == 0:
 */
      if (unlikely(__pyx_v_player->master_sound_layer.fade_out_steps == 0)) {
        #ifdef WITH_THREAD
        PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
        #endif
        PyErr_SetString(PyExc_ZeroDivisionError, "float division");
        #ifdef WITH_THREAD
        __Pyx_PyGILState_Release(__pyx_gilstate_save);
        #endif
        __PYX_ERR(0, 1152, __pyx_L1_error)
      }
      __pyx_v_player_volume = ((Uint8)(__pyx_f_5mpfmc_4core_5audio_6inline_in_out_quad((((double)__pyx_v_player->master_sound_layer.fade_steps_remaining) / ((double)__pyx_v_player->master_sound_layer.fade_out_steps))) * SDL_MIX_MAXVOLUME));

      /* "mpfmc/core/audio/track_sound_loop.pyx":1153
 *                                       callback_data.bytes_per_control_point)
 *             player_volume = <Uint8> (in_out_quad(player.master_sound_layer.fade_steps_remaining / player.master_sound_layer.fade_out_steps) * SDL_MIX_MAXVOLUME)
 *             player.master_sound_layer.fade_steps_remaining -= 1             # <<<<<<<<<<<<<<
 *             if player.master_sound_layer.fade_steps_remaining == 0:
 *                 player.status = player_idle
 */
      __pyx_v_player->master_sound_layer.fade_steps_remaining = (__pyx_v_player->master_sound_layer.fade_steps_remaining - 1);

      /* "mpfmc/core/audio/track_sound_loop.pyx":1154
 *             player_volume = <Uint8> (in_out_quad(player.master_sound_layer.fade_steps_remaining / player.master_sound_layer.fade_out_steps) * SDL_MIX_MAXVOLUME)
 *             player.master_sound_layer.fade_steps_remaining -= 1
 *             if player.master_sound_layer.fade_steps_remaining == 0:             # <<<<<<<<<<<<<<
 *                 player.status = player_idle
 *         else:
 */
      __pyx_t_1 = ((__pyx_v_player->master_sound_layer.fade_steps_remaining == 0) != 0);
      if (__pyx_t_1) {

        /* "mpfmc/core/audio/track_sound_loop.pyx":1155
 *             player.master_sound_layer.fade_steps_remaining -= 1
 *             if player.master_sound_layer.fade_steps_remaining == 0:
 *                 player.status = player_idle             # <<<<<<<<<<<<<<
 *         else:
 *             current_chunk_bytes = min(buffer_bytes_remaining, player.length - player.sample_pos)
 */
        __pyx_v_player->status = __pyx_e_5mpfmc_4core_5audio_16track_sound_loop_player_idle;

        /* "mpfmc/core/audio/track_sound_loop.pyx":1154
 *             player_volume = <Uint8> (in_out_quad(player.master_sound_layer.fade_steps_remaining / player.master_sound_layer.fade_out_steps) * SDL_MIX_MAXVOLUME)
 *             player.master_sound_layer.fade_steps_remaining -= 1
 *             if player.master_sound_layer.fade_steps_remaining == 0:             # <<<<<<<<<<<<<<
 *                 player.status = player_idle
 *         else:
 */
      }

      /* "mpfmc/core/audio/track_sound_loop.pyx":1148
 *                 player.status = player_playing
 * 
 *         elif player.status == player_fading_out:             # <<<<<<<<<<<<<<
 *             current_chunk_bytes = min(buffer_bytes_remaining,
 *                                       player.length - player.sample_pos,
 */
      break;
      default:

      /* "mpfmc/core/audio/track_sound_loop.pyx":1157
 *                 player.status = player_idle
 *         else:
 *             current_chunk_bytes = min(buffer_bytes_remaining, player.length - player.sample_pos)             # <<<<<<<<<<<<<<
 *             player_volume = SDL_MIX_MAXVOLUME
 * 
 */
      __pyx_t_4 = (__pyx_v_player->length - __pyx_v_player->sample_pos);
      __pyx_t_5 = __pyx_v_buffer_bytes_remaining;
      if (((__pyx_t_4 < __pyx_t_5) != 0)) {
        __pyx_t_2 = __pyx_t_4;
      } else {
        __pyx_t_2 = __pyx_t_5;
      }
      __pyx_v_current_chunk_bytes = __pyx_t_2;

      /* "mpfmc/core/audio/track_sound_loop.pyx":1158
 *         else:
 *             current_chunk_bytes = min(buffer_bytes_remaining, player.length - player.sample_pos)
 *             player_volume = SDL_MIX_MAXVOLUME             # <<<<<<<<<<<<<<
 * 
 *         # Adjust chunk size if the loop is set to stop early (if not the chunk size will remain unchanged)
 */
      __pyx_v_player_volume = SDL_MIX_MAXVOLUME;
      break;
    }

    /* "mpfmc/core/audio/track_sound_loop.pyx":1161
 * 
 *         # Adjust chunk size if the loop is set to stop early (if not the chunk size will remain unchanged)
 *         current_chunk_bytes = min(current_chunk_bytes, player.stop_loop_samples_remaining)             # <<<<<<<<<<<<<<
 * 
 *         if player.status == player_idle or current_chunk_bytes == 0:
 */
    __pyx_t_2 = __pyx_v_player->stop_loop_samples_remaining;
    __pyx_t_4 = __pyx_v_current_chunk_bytes;
    if (((__pyx_t_2 < __pyx_t_4) != 0)) {
      __pyx_t_5 = __pyx_t_2;
    } else {
      __pyx_t_5 = __pyx_t_4;
    }
    __pyx_v_current_chunk_bytes = __pyx_t_5;

    /* "mpfmc/core/audio/track_sound_loop.pyx":1163
 *         current_chunk_bytes = min(current_chunk_bytes, player.stop_loop_samples_remaining)
 * 
 *         if player.status == player_idle or current_chunk_bytes == 0:             # <<<<<<<<<<<<<<
 *             return buffer_length
 * 
 */
    __pyx_t_6 = ((__pyx_v_player->status == __pyx_e_5mpfmc_4core_5audio_16track_sound_loop_player_idle) != 0);
    if (!__pyx_t_6) {
    } else {
      __pyx_t_1 = __pyx_t_6;
      goto __pyx_L8_bool_binop_done;
    }
    __pyx_t_6 = ((__pyx_v_current_chunk_bytes == 0) != 0);
    __pyx_t_1 = __pyx_t_6;
    __pyx_L8_bool_binop_done:;
    if (__pyx_t_1) {

      /* "mpfmc/core/audio/track_sound_loop.pyx":1164
 * 
 *         if player.status == player_idle or current_chunk_bytes == 0:
 *             return buffer_length             # <<<<<<<<<<<<<<
 * 
 *         # Get master layer samples
 */
      __pyx_r = __pyx_v_buffer_length;
      goto __pyx_L0;

      /* "mpfmc/core/audio/track_sound_loop.pyx":1163
 *         current_chunk_bytes = min(current_chunk_bytes, player.stop_loop_samples_remaining)
 * 
 *         if player.status == player_idle or current_chunk_bytes == 0:             # <<<<<<<<<<<<<<
 *             return buffer_length
 * 
 */
    }

    /* "mpfmc/core/audio/track_sound_loop.pyx":1171
 *                            track.callback_data.format,
 *                            current_chunk_bytes,
 *                            player_volume * player.master_sound_layer.volume // SDL_MIX_MAXVOLUME)             # <<<<<<<<<<<<<<
 * 
 *         # Process markers (do any markers fall in the current chunk?)
 */
    __pyx_t_7 = (__pyx_v_player_volume * __pyx_v_player->master_sound_layer.volume);
    if (unlikely(SDL_MIX_MAXVOLUME == 0)) {
      #ifdef WITH_THREAD
      PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
      #endif
      PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
      #ifdef WITH_THREAD
      __Pyx_PyGILState_Release(__pyx_gilstate_save);
      #endif
      __PYX_ERR(0, 1171, __pyx_L1_error)
    }
    else if (sizeof(int) == sizeof(long) && (!(((int)-1) > 0)) && unlikely(SDL_MIX_MAXVOLUME == (int)-1)  && unlikely(UNARY_NEG_WOULD_OVERFLOW(__pyx_t_7))) {
      #ifdef WITH_THREAD
      PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
      #endif
      PyErr_SetString(PyExc_OverflowError, "value too large to perform division");
      #ifdef WITH_THREAD
      __Pyx_PyGILState_Release(__pyx_gilstate_save);
      #endif
      __PYX_ERR(0, 1171, __pyx_L1_error)
    }

    /* "mpfmc/core/audio/track_sound_loop.pyx":1167
 * 
 *         # Get master layer samples
 *         SDL_MixAudioFormat(track.buffer + track_buffer_pos,             # <<<<<<<<<<<<<<
 *                            <Uint8*>player.master_sound_layer.sound.data.memory.data + player.sample_pos,
 *                            track.callback_data.format,
 */
    SDL_MixAudioFormat((__pyx_v_track->buffer + __pyx_v_track_buffer_pos), (((Uint8 *)__pyx_v_player->master_sound_layer.sound->data.memory->data) + __pyx_v_player->sample_pos), __pyx_v_track->callback_data->format, __pyx_v_current_chunk_bytes, __Pyx_div_int(__pyx_t_7, SDL_MIX_MAXVOLUME));

    /* "mpfmc/core/audio/track_sound_loop.pyx":1176
 *         # Note: the current sample position has already been incremented when the sample data was received so
 *         # we need to look backwards from the current position to determine if marker falls in chunk window.
 *         for marker_id in range(player.master_sound_layer.marker_count):             # <<<<<<<<<<<<<<
 *             if player.sample_pos - current_chunk_bytes <= g_array_index_uint(player.master_sound_layer.markers, marker_id) < player.sample_pos:
 *                 # Marker is in window, send notification
 */
    __pyx_t_8 = __pyx_v_player->master_sound_layer.marker_count;
    __pyx_t_9 = __pyx_t_8;
    for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_9; __pyx_t_10+=1) {
      __pyx_v_marker_id = __pyx_t_10;

      /* "mpfmc/core/audio/track_sound_loop.pyx":1177
 *         # we need to look backwards from the current position to determine if marker falls in chunk window.
 *         for marker_id in range(player.master_sound_layer.marker_count):
 *             if player.sample_pos - current_chunk_bytes <= g_array_index_uint(player.master_sound_layer.markers, marker_id) < player.sample_pos:             # <<<<<<<<<<<<<<
 *                 # Marker is in window, send notification
 *                 send_sound_marker_notification(0,
 */
      __pyx_t_11 = g_array_index_uint(__pyx_v_player->master_sound_layer.markers, __pyx_v_marker_id);
      __pyx_t_1 = ((__pyx_v_player->sample_pos - __pyx_v_current_chunk_bytes) <= __pyx_t_11);
      if (__pyx_t_1) {
        __pyx_t_1 = (__pyx_t_11 < __pyx_v_player->sample_pos);
      }
      __pyx_t_6 = (__pyx_t_1 != 0);
      if (__pyx_t_6) {

        /* "mpfmc/core/audio/track_sound_loop.pyx":1179
 *             if player.sample_pos - current_chunk_bytes <= g_array_index_uint(player.master_sound_layer.markers, marker_id) < player.sample_pos:
 *                 # Marker is in window, send notification
 *                 send_sound_marker_notification(0,             # <<<<<<<<<<<<<<
 *                                                player.master_sound_layer.sound_id,
 *                                                player.master_sound_layer.sound_loop_set_id,
 */
        __pyx_f_5mpfmc_4core_5audio_20notification_message_send_sound_marker_notification(0, __pyx_v_player->master_sound_layer.sound_id, __pyx_v_player->master_sound_layer.sound_loop_set_id, __pyx_v_track, __pyx_v_marker_id);

        /* "mpfmc/core/audio/track_sound_loop.pyx":1177
 *         # we need to look backwards from the current position to determine if marker falls in chunk window.
 *         for marker_id in range(player.master_sound_layer.marker_count):
 *             if player.sample_pos - current_chunk_bytes <= g_array_index_uint(player.master_sound_layer.markers, marker_id) < player.sample_pos:             # <<<<<<<<<<<<<<
 *                 # Marker is in window, send notification
 *                 send_sound_marker_notification(0,
 */
      }
    }

    /* "mpfmc/core/audio/track_sound_loop.pyx":1186
 * 
 *         # Now mix any additional loop layers
 *         layer_iterator = player.layers             # <<<<<<<<<<<<<<
 *         while layer_iterator != NULL:
 *             layer = <SoundLoopLayerSettings*>layer_iterator.data
 */
    __pyx_t_12 = __pyx_v_player->layers;
    __pyx_v_layer_iterator = __pyx_t_12;

    /* "mpfmc/core/audio/track_sound_loop.pyx":1187
 *         # Now mix any additional loop layers
 *         layer_iterator = player.layers
 *         while layer_iterator != NULL:             # <<<<<<<<<<<<<<
 *             layer = <SoundLoopLayerSettings*>layer_iterator.data
 * 
 */
    while (1) {
      __pyx_t_6 = ((__pyx_v_layer_iterator != NULL) != 0);
      if (!__pyx_t_6) break;

      /* "mpfmc/core/audio/track_sound_loop.pyx":1188
 *         layer_iterator = player.layers
 *         while layer_iterator != NULL:
 *             layer = <SoundLoopLayerSettings*>layer_iterator.data             # <<<<<<<<<<<<<<
 * 
 *             if player.sample_pos == 0:
 */
      __pyx_v_layer = ((__pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopLayerSettings *)__pyx_v_layer_iterator->data);

      /* "mpfmc/core/audio/track_sound_loop.pyx":1190
 *             layer = <SoundLoopLayerSettings*>layer_iterator.data
 * 
 *             if player.sample_pos == 0:             # <<<<<<<<<<<<<<
 * 
 *                 if layer.status == layer_queued:
 */
      __pyx_t_6 = ((__pyx_v_player->sample_pos == 0) != 0);
      if (__pyx_t_6) {

        /* "mpfmc/core/audio/track_sound_loop.pyx":1192
 *             if player.sample_pos == 0:
 * 
 *                 if layer.status == layer_queued:             # <<<<<<<<<<<<<<
 *                     layer.status = layer_playing
 * 
 */
        __pyx_t_6 = ((__pyx_v_layer->status == __pyx_e_5mpfmc_4core_5audio_16track_sound_loop_layer_queued) != 0);
        if (__pyx_t_6) {

          /* "mpfmc/core/audio/track_sound_loop.pyx":1193
 * 
 *                 if layer.status == layer_queued:
 *                     layer.status = layer_playing             # <<<<<<<<<<<<<<
 * 
 *                 if not layer.looping:
 */
          __pyx_v_layer->status = __pyx_e_5mpfmc_4core_5audio_16track_sound_loop_layer_playing;

          /* "mpfmc/core/audio/track_sound_loop.pyx":1192
 *             if player.sample_pos == 0:
 * 
 *                 if layer.status == layer_queued:             # <<<<<<<<<<<<<<
 *                     layer.status = layer_playing
 * 
 */
        }

        /* "mpfmc/core/audio/track_sound_loop.pyx":1195
 *                     layer.status = layer_playing
 * 
 *                 if not layer.looping:             # <<<<<<<<<<<<<<
 *                     layer.status = layer_stopped
 * 
 */
        __pyx_t_6 = ((!(__pyx_v_layer->looping != 0)) != 0);
        if (__pyx_t_6) {

          /* "mpfmc/core/audio/track_sound_loop.pyx":1196
 * 
 *                 if not layer.looping:
 *                     layer.status = layer_stopped             # <<<<<<<<<<<<<<
 * 
 *             if layer.status in (layer_playing, layer_fading_in, layer_fading_out):
 */
          __pyx_v_layer->status = __pyx_e_5mpfmc_4core_5audio_16track_sound_loop_layer_stopped;

          /* "mpfmc/core/audio/track_sound_loop.pyx":1195
 *                     layer.status = layer_playing
 * 
 *                 if not layer.looping:             # <<<<<<<<<<<<<<
 *                     layer.status = layer_stopped
 * 
 */
        }

        /* "mpfmc/core/audio/track_sound_loop.pyx":1190
 *             layer = <SoundLoopLayerSettings*>layer_iterator.data
 * 
 *             if player.sample_pos == 0:             # <<<<<<<<<<<<<<
 * 
 *                 if layer.status == layer_queued:
 */
      }

      /* "mpfmc/core/audio/track_sound_loop.pyx":1198
 *                     layer.status = layer_stopped
 * 
 *             if layer.status in (layer_playing, layer_fading_in, layer_fading_out):             # <<<<<<<<<<<<<<
 *                 layer_track_buffer_pos_offset = 0
 *                 layer_sample_pos = player.sample_pos
 */
      switch (__pyx_v_layer->status) {
        case __pyx_e_5mpfmc_4core_5audio_16track_sound_loop_layer_playing:
        case __pyx_e_5mpfmc_4core_5audio_16track_sound_loop_layer_fading_in:
        case __pyx_e_5mpfmc_4core_5audio_16track_sound_loop_layer_fading_out:

        /* "mpfmc/core/audio/track_sound_loop.pyx":1199
 * 
 *             if layer.status in (layer_playing, layer_fading_in, layer_fading_out):
 *                 layer_track_buffer_pos_offset = 0             # <<<<<<<<<<<<<<
 *                 layer_sample_pos = player.sample_pos
 *                 layer_bytes_remaining = current_chunk_bytes
 */
        __pyx_v_layer_track_buffer_pos_offset = 0;

        /* "mpfmc/core/audio/track_sound_loop.pyx":1200
 *             if layer.status in (layer_playing, layer_fading_in, layer_fading_out):
 *                 layer_track_buffer_pos_offset = 0
 *                 layer_sample_pos = player.sample_pos             # <<<<<<<<<<<<<<
 *                 layer_bytes_remaining = current_chunk_bytes
 * 
 */
        __pyx_t_5 = __pyx_v_player->sample_pos;
        __pyx_v_layer_sample_pos = __pyx_t_5;

        /* "mpfmc/core/audio/track_sound_loop.pyx":1201
 *                 layer_track_buffer_pos_offset = 0
 *                 layer_sample_pos = player.sample_pos
 *                 layer_bytes_remaining = current_chunk_bytes             # <<<<<<<<<<<<<<
 * 
 *                 while layer_bytes_remaining > 0:
 */
        __pyx_v_layer_bytes_remaining = __pyx_v_current_chunk_bytes;

        /* "mpfmc/core/audio/track_sound_loop.pyx":1203
 *                 layer_bytes_remaining = current_chunk_bytes
 * 
 *                 while layer_bytes_remaining > 0:             # <<<<<<<<<<<<<<
 *                     if layer.status == layer_playing:
 *                         layer_chunk_bytes = layer_bytes_remaining
 */
        while (1) {
          __pyx_t_6 = ((__pyx_v_layer_bytes_remaining > 0) != 0);
          if (!__pyx_t_6) break;

          /* "mpfmc/core/audio/track_sound_loop.pyx":1204
 * 
 *                 while layer_bytes_remaining > 0:
 *                     if layer.status == layer_playing:             # <<<<<<<<<<<<<<
 *                         layer_chunk_bytes = layer_bytes_remaining
 *                         layer_volume = layer.volume
 */
          __pyx_t_6 = ((__pyx_v_layer->status == __pyx_e_5mpfmc_4core_5audio_16track_sound_loop_layer_playing) != 0);
          if (__pyx_t_6) {

            /* "mpfmc/core/audio/track_sound_loop.pyx":1205
 *                 while layer_bytes_remaining > 0:
 *                     if layer.status == layer_playing:
 *                         layer_chunk_bytes = layer_bytes_remaining             # <<<<<<<<<<<<<<
 *                         layer_volume = layer.volume
 *                     else:
 */
            __pyx_v_layer_chunk_bytes = __pyx_v_layer_bytes_remaining;

            /* "mpfmc/core/audio/track_sound_loop.pyx":1206
 *                     if layer.status == layer_playing:
 *                         layer_chunk_bytes = layer_bytes_remaining
 *                         layer_volume = layer.volume             # <<<<<<<<<<<<<<
 *                     else:
 *                         # Calculate layer volume (handle fading)
 */
            __pyx_t_8 = __pyx_v_layer->volume;
            __pyx_v_layer_volume = __pyx_t_8;

            /* "mpfmc/core/audio/track_sound_loop.pyx":1204
 * 
 *                 while layer_bytes_remaining > 0:
 *                     if layer.status == layer_playing:             # <<<<<<<<<<<<<<
 *                         layer_chunk_bytes = layer_bytes_remaining
 *                         layer_volume = layer.volume
 */
            goto __pyx_L20;
          }

          /* "mpfmc/core/audio/track_sound_loop.pyx":1209
 *                     else:
 *                         # Calculate layer volume (handle fading)
 *                         layer_chunk_bytes = min(callback_data.bytes_per_control_point, layer_bytes_remaining)             # <<<<<<<<<<<<<<
 *                         if layer.status == layer_fading_in:
 *                             layer_volume = <Uint8> (in_out_quad((layer.fade_in_steps - layer.fade_steps_remaining) / layer.fade_in_steps) * layer.volume)
 */
          /*else*/ {
            __pyx_t_5 = __pyx_v_layer_bytes_remaining;
            __pyx_t_3 = __pyx_v_callback_data->bytes_per_control_point;
            if (((__pyx_t_5 < __pyx_t_3) != 0)) {
              __pyx_t_2 = __pyx_t_5;
            } else {
              __pyx_t_2 = __pyx_t_3;
            }
            __pyx_v_layer_chunk_bytes = __pyx_t_2;

            /* "mpfmc/core/audio/track_sound_loop.pyx":1210
 *                         # Calculate layer volume (handle fading)
 *                         layer_chunk_bytes = min(callback_data.bytes_per_control_point, layer_bytes_remaining)
 *                         if layer.status == layer_fading_in:             # <<<<<<<<<<<<<<
 *                             layer_volume = <Uint8> (in_out_quad((layer.fade_in_steps - layer.fade_steps_remaining) / layer.fade_in_steps) * layer.volume)
 *                             layer.fade_steps_remaining -= 1
 */
            switch (__pyx_v_layer->status) {
              case __pyx_e_5mpfmc_4core_5audio_16track_sound_loop_layer_fading_in:

              /* "mpfmc/core/audio/track_sound_loop.pyx":1211
 *                         layer_chunk_bytes = min(callback_data.bytes_per_control_point, layer_bytes_remaining)
 *                         if layer.status == layer_fading_in:
 *                             layer_volume = <Uint8> (in_out_quad((layer.fade_in_steps - layer.fade_steps_remaining) / layer.fade_in_steps) * layer.volume)             # <<<<<<<<<<<<<<
 *                             layer.fade_steps_remaining -= 1
 *                             if layer.fade_steps_remaining == 0:
 */
              __pyx_t_2 = (__pyx_v_layer->fade_in_steps - __pyx_v_layer->fade_steps_remaining);
              if (unlikely(__pyx_v_layer->fade_in_steps == 0)) {
                #ifdef WITH_THREAD
                PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
                #endif
                PyErr_SetString(PyExc_ZeroDivisionError, "float division");
                #ifdef WITH_THREAD
                __Pyx_PyGILState_Release(__pyx_gilstate_save);
                #endif
                __PYX_ERR(0, 1211, __pyx_L1_error)
              }
              __pyx_v_layer_volume = ((Uint8)(__pyx_f_5mpfmc_4core_5audio_6inline_in_out_quad((((double)__pyx_t_2) / ((double)__pyx_v_layer->fade_in_steps))) * __pyx_v_layer->volume));

              /* "mpfmc/core/audio/track_sound_loop.pyx":1212
 *                         if layer.status == layer_fading_in:
 *                             layer_volume = <Uint8> (in_out_quad((layer.fade_in_steps - layer.fade_steps_remaining) / layer.fade_in_steps) * layer.volume)
 *                             layer.fade_steps_remaining -= 1             # <<<<<<<<<<<<<<
 *                             if layer.fade_steps_remaining == 0:
 *                                 layer.status = layer_playing
 */
              __pyx_v_layer->fade_steps_remaining = (__pyx_v_layer->fade_steps_remaining - 1);

              /* "mpfmc/core/audio/track_sound_loop.pyx":1213
 *                             layer_volume = <Uint8> (in_out_quad((layer.fade_in_steps - layer.fade_steps_remaining) / layer.fade_in_steps) * layer.volume)
 *                             layer.fade_steps_remaining -= 1
 *                             if layer.fade_steps_remaining == 0:             # <<<<<<<<<<<<<<
 *                                 layer.status = layer_playing
 *                         elif layer.status == layer_fading_out:
 */
              __pyx_t_6 = ((__pyx_v_layer->fade_steps_remaining == 0) != 0);
              if (__pyx_t_6) {

                /* "mpfmc/core/audio/track_sound_loop.pyx":1214
 *                             layer.fade_steps_remaining -= 1
 *                             if layer.fade_steps_remaining == 0:
 *                                 layer.status = layer_playing             # <<<<<<<<<<<<<<
 *                         elif layer.status == layer_fading_out:
 *                             layer_volume = <Uint8> (in_out_quad(layer.fade_steps_remaining / layer.fade_out_steps) * layer.volume)
 */
                __pyx_v_layer->status = __pyx_e_5mpfmc_4core_5audio_16track_sound_loop_layer_playing;

                /* "mpfmc/core/audio/track_sound_loop.pyx":1213
 *                             layer_volume = <Uint8> (in_out_quad((layer.fade_in_steps - layer.fade_steps_remaining) / layer.fade_in_steps) * layer.volume)
 *                             layer.fade_steps_remaining -= 1
 *                             if layer.fade_steps_remaining == 0:             # <<<<<<<<<<<<<<
 *                                 layer.status = layer_playing
 *                         elif layer.status == layer_fading_out:
 */
              }

              /* "mpfmc/core/audio/track_sound_loop.pyx":1210
 *                         # Calculate layer volume (handle fading)
 *                         layer_chunk_bytes = min(callback_data.bytes_per_control_point, layer_bytes_remaining)
 *                         if layer.status == layer_fading_in:             # <<<<<<<<<<<<<<
 *                             layer_volume = <Uint8> (in_out_quad((layer.fade_in_steps - layer.fade_steps_remaining) / layer.fade_in_steps) * layer.volume)
 *                             layer.fade_steps_remaining -= 1
 */
              break;
              case __pyx_e_5mpfmc_4core_5audio_16track_sound_loop_layer_fading_out:

              /* "mpfmc/core/audio/track_sound_loop.pyx":1216
 *                                 layer.status = layer_playing
 *                         elif layer.status == layer_fading_out:
 *                             layer_volume = <Uint8> (in_out_quad(layer.fade_steps_remaining / layer.fade_out_steps) * layer.volume)             # <<<<<<<<<<<<<<
 *                             layer.fade_steps_remaining -= 1
 *                             if layer.fade_steps_remaining == 0:
 */
              if (unlikely(__pyx_v_layer->fade_out_steps == 0)) {
                #ifdef WITH_THREAD
                PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
                #endif
                PyErr_SetString(PyExc_ZeroDivisionError, "float division");
                #ifdef WITH_THREAD
                __Pyx_PyGILState_Release(__pyx_gilstate_save);
                #endif
                __PYX_ERR(0, 1216, __pyx_L1_error)
              }
              __pyx_v_layer_volume = ((Uint8)(__pyx_f_5mpfmc_4core_5audio_6inline_in_out_quad((((double)__pyx_v_layer->fade_steps_remaining) / ((double)__pyx_v_layer->fade_out_steps))) * __pyx_v_layer->volume));

              /* "mpfmc/core/audio/track_sound_loop.pyx":1217
 *                         elif layer.status == layer_fading_out:
 *                             layer_volume = <Uint8> (in_out_quad(layer.fade_steps_remaining / layer.fade_out_steps) * layer.volume)
 *                             layer.fade_steps_remaining -= 1             # <<<<<<<<<<<<<<
 *                             if layer.fade_steps_remaining == 0:
 *                                 layer.status = layer_stopped
 */
              __pyx_v_layer->fade_steps_remaining = (__pyx_v_layer->fade_steps_remaining - 1);

              /* "mpfmc/core/audio/track_sound_loop.pyx":1218
 *                             layer_volume = <Uint8> (in_out_quad(layer.fade_steps_remaining / layer.fade_out_steps) * layer.volume)
 *                             layer.fade_steps_remaining -= 1
 *                             if layer.fade_steps_remaining == 0:             # <<<<<<<<<<<<<<
 *                                 layer.status = layer_stopped
 *                                 layer_bytes_remaining = 0
 */
              __pyx_t_6 = ((__pyx_v_layer->fade_steps_remaining == 0) != 0);
              if (__pyx_t_6) {

                /* "mpfmc/core/audio/track_sound_loop.pyx":1219
 *                             layer.fade_steps_remaining -= 1
 *                             if layer.fade_steps_remaining == 0:
 *                                 layer.status = layer_stopped             # <<<<<<<<<<<<<<
 *                                 layer_bytes_remaining = 0
 * 
 */
                __pyx_v_layer->status = __pyx_e_5mpfmc_4core_5audio_16track_sound_loop_layer_stopped;

                /* "mpfmc/core/audio/track_sound_loop.pyx":1220
 *                             if layer.fade_steps_remaining == 0:
 *                                 layer.status = layer_stopped
 *                                 layer_bytes_remaining = 0             # <<<<<<<<<<<<<<
 * 
 *                     if layer_sample_pos < layer.sound.data.memory.size:
 */
                __pyx_v_layer_bytes_remaining = 0;

                /* "mpfmc/core/audio/track_sound_loop.pyx":1218
 *                             layer_volume = <Uint8> (in_out_quad(layer.fade_steps_remaining / layer.fade_out_steps) * layer.volume)
 *                             layer.fade_steps_remaining -= 1
 *                             if layer.fade_steps_remaining == 0:             # <<<<<<<<<<<<<<
 *                                 layer.status = layer_stopped
 *                                 layer_bytes_remaining = 0
 */
              }

              /* "mpfmc/core/audio/track_sound_loop.pyx":1215
 *                             if layer.fade_steps_remaining == 0:
 *                                 layer.status = layer_playing
 *                         elif layer.status == layer_fading_out:             # <<<<<<<<<<<<<<
 *                             layer_volume = <Uint8> (in_out_quad(layer.fade_steps_remaining / layer.fade_out_steps) * layer.volume)
 *                             layer.fade_steps_remaining -= 1
 */
              break;
              default: break;
            }
          }
          __pyx_L20:;

          /* "mpfmc/core/audio/track_sound_loop.pyx":1222
 *                                 layer_bytes_remaining = 0
 * 
 *                     if layer_sample_pos < layer.sound.data.memory.size:             # <<<<<<<<<<<<<<
 *                         SDL_MixAudioFormat(track.buffer + track_buffer_pos + layer_track_buffer_pos_offset,
 *                                            <Uint8*>layer.sound.data.memory.data + layer_sample_pos,
 */
          __pyx_t_6 = ((__pyx_v_layer_sample_pos < __pyx_v_layer->sound->data.memory->size) != 0);
          if (__pyx_t_6) {

            /* "mpfmc/core/audio/track_sound_loop.pyx":1226
 *                                            <Uint8*>layer.sound.data.memory.data + layer_sample_pos,
 *                                            callback_data.format,
 *                                            min(layer_chunk_bytes, layer.sound.data.memory.size - layer_sample_pos),             # <<<<<<<<<<<<<<
 *                                            player_volume * layer_volume // SDL_MIX_MAXVOLUME)
 * 
 */
            __pyx_t_2 = (__pyx_v_layer->sound->data.memory->size - __pyx_v_layer_sample_pos);
            __pyx_t_5 = __pyx_v_layer_chunk_bytes;
            if (((__pyx_t_2 < __pyx_t_5) != 0)) {
              __pyx_t_4 = __pyx_t_2;
            } else {
              __pyx_t_4 = __pyx_t_5;
            }

            /* "mpfmc/core/audio/track_sound_loop.pyx":1227
 *                                            callback_data.format,
 *                                            min(layer_chunk_bytes, layer.sound.data.memory.size - layer_sample_pos),
 *                                            player_volume * layer_volume // SDL_MIX_MAXVOLUME)             # <<<<<<<<<<<<<<
 * 
 *                         # Process markers (do any markers fall in the current chunk?)
 */
            __pyx_t_7 = (__pyx_v_player_volume * __pyx_v_layer_volume);
            if (unlikely(SDL_MIX_MAXVOLUME == 0)) {
              #ifdef WITH_THREAD
              PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
              #endif
              PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
              #ifdef WITH_THREAD
              __Pyx_PyGILState_Release(__pyx_gilstate_save);
              #endif
              __PYX_ERR(0, 1227, __pyx_L1_error)
            }
            else if (sizeof(int) == sizeof(long) && (!(((int)-1) > 0)) && unlikely(SDL_MIX_MAXVOLUME == (int)-1)  && unlikely(UNARY_NEG_WOULD_OVERFLOW(__pyx_t_7))) {
              #ifdef WITH_THREAD
              PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
              #endif
              PyErr_SetString(PyExc_OverflowError, "value too large to perform division");
              #ifdef WITH_THREAD
              __Pyx_PyGILState_Release(__pyx_gilstate_save);
              #endif
              __PYX_ERR(0, 1227, __pyx_L1_error)
            }

            /* "mpfmc/core/audio/track_sound_loop.pyx":1223
 * 
 *                     if layer_sample_pos < layer.sound.data.memory.size:
 *                         SDL_MixAudioFormat(track.buffer + track_buffer_pos + layer_track_buffer_pos_offset,             # <<<<<<<<<<<<<<
 *                                            <Uint8*>layer.sound.data.memory.data + layer_sample_pos,
 *                                            callback_data.format,
 */
            SDL_MixAudioFormat(((__pyx_v_track->buffer + __pyx_v_track_buffer_pos) + __pyx_v_layer_track_buffer_pos_offset), (((Uint8 *)__pyx_v_layer->sound->data.memory->data) + __pyx_v_layer_sample_pos), __pyx_v_callback_data->format, __pyx_t_4, __Pyx_div_int(__pyx_t_7, SDL_MIX_MAXVOLUME));

            /* "mpfmc/core/audio/track_sound_loop.pyx":1232
 *                         # Note: the current sample position has already been incremented when the sample data was received so
 *                         # we need to look backwards from the current position to determine if marker falls in chunk window.
 *                         for marker_id in range(layer.marker_count):             # <<<<<<<<<<<<<<
 *                             if layer_sample_pos - layer_chunk_bytes <= g_array_index_uint(layer.markers, marker_id) < layer_sample_pos:
 *                                 # Marker is in window, send notification
 */
            __pyx_t_8 = __pyx_v_layer->marker_count;
            __pyx_t_9 = __pyx_t_8;
            for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_9; __pyx_t_10+=1) {
              __pyx_v_marker_id = __pyx_t_10;

              /* "mpfmc/core/audio/track_sound_loop.pyx":1233
 *                         # we need to look backwards from the current position to determine if marker falls in chunk window.
 *                         for marker_id in range(layer.marker_count):
 *                             if layer_sample_pos - layer_chunk_bytes <= g_array_index_uint(layer.markers, marker_id) < layer_sample_pos:             # <<<<<<<<<<<<<<
 *                                 # Marker is in window, send notification
 *                                 send_sound_marker_notification(0,
 */
              __pyx_t_11 = g_array_index_uint(__pyx_v_layer->markers, __pyx_v_marker_id);
              __pyx_t_6 = ((__pyx_v_layer_sample_pos - __pyx_v_layer_chunk_bytes) <= __pyx_t_11);
              if (__pyx_t_6) {
                __pyx_t_6 = (__pyx_t_11 < __pyx_v_layer_sample_pos);
              }
              __pyx_t_1 = (__pyx_t_6 != 0);
              if (__pyx_t_1) {

                /* "mpfmc/core/audio/track_sound_loop.pyx":1235
 *                             if layer_sample_pos - layer_chunk_bytes <= g_array_index_uint(layer.markers, marker_id) < layer_sample_pos:
 *                                 # Marker is in window, send notification
 *                                 send_sound_marker_notification(0,             # <<<<<<<<<<<<<<
 *                                                                layer.sound_id,
 *                                                                layer.sound_loop_set_id,
 */
                __pyx_f_5mpfmc_4core_5audio_20notification_message_send_sound_marker_notification(0, __pyx_v_layer->sound_id, __pyx_v_layer->sound_loop_set_id, __pyx_v_track, __pyx_v_marker_id);

                /* "mpfmc/core/audio/track_sound_loop.pyx":1233
 *                         # we need to look backwards from the current position to determine if marker falls in chunk window.
 *                         for marker_id in range(layer.marker_count):
 *                             if layer_sample_pos - layer_chunk_bytes <= g_array_index_uint(layer.markers, marker_id) < layer_sample_pos:             # <<<<<<<<<<<<<<
 *                                 # Marker is in window, send notification
 *                                 send_sound_marker_notification(0,
 */
              }
            }

            /* "mpfmc/core/audio/track_sound_loop.pyx":1222
 *                                 layer_bytes_remaining = 0
 * 
 *                     if layer_sample_pos < layer.sound.data.memory.size:             # <<<<<<<<<<<<<<
 *                         SDL_MixAudioFormat(track.buffer + track_buffer_pos + layer_track_buffer_pos_offset,
 *                                            <Uint8*>layer.sound.data.memory.data + layer_sample_pos,
 */
          }

          /* "mpfmc/core/audio/track_sound_loop.pyx":1241
 *                                                                marker_id)
 * 
 *                     layer_track_buffer_pos_offset += layer_chunk_bytes             # <<<<<<<<<<<<<<
 *                     layer_sample_pos += layer_chunk_bytes
 *                     layer_bytes_remaining -= layer_chunk_bytes
 */
          __pyx_v_layer_track_buffer_pos_offset = (__pyx_v_layer_track_buffer_pos_offset + __pyx_v_layer_chunk_bytes);

          /* "mpfmc/core/audio/track_sound_loop.pyx":1242
 * 
 *                     layer_track_buffer_pos_offset += layer_chunk_bytes
 *                     layer_sample_pos += layer_chunk_bytes             # <<<<<<<<<<<<<<
 *                     layer_bytes_remaining -= layer_chunk_bytes
 * 
 */
          __pyx_v_layer_sample_pos = (__pyx_v_layer_sample_pos + __pyx_v_layer_chunk_bytes);

          /* "mpfmc/core/audio/track_sound_loop.pyx":1243
 *                     layer_track_buffer_pos_offset += layer_chunk_bytes
 *                     layer_sample_pos += layer_chunk_bytes
 *                     layer_bytes_remaining -= layer_chunk_bytes             # <<<<<<<<<<<<<<
 * 
 *             # Move to next layer
 */
          __pyx_v_layer_bytes_remaining = (__pyx_v_layer_bytes_remaining - __pyx_v_layer_chunk_bytes);
        }

        /* "mpfmc/core/audio/track_sound_loop.pyx":1198
 *                     layer.status = layer_stopped
 * 
 *             if layer.status in (layer_playing, layer_fading_in, layer_fading_out):             # <<<<<<<<<<<<<<
 *                 layer_track_buffer_pos_offset = 0
 *                 layer_sample_pos = player.sample_pos
 */
        break;
        default: break;
      }

      /* "mpfmc/core/audio/track_sound_loop.pyx":1246
 * 
 *             # Move to next layer
 *             layer_iterator = layer_iterator.next             # <<<<<<<<<<<<<<
 * 
 *         # Advance buffer pointers
 */
      __pyx_t_12 = __pyx_v_layer_iterator->next;
      __pyx_v_layer_iterator = __pyx_t_12;
    }

    /* "mpfmc/core/audio/track_sound_loop.pyx":1249
 * 
 *         # Advance buffer pointers
 *         player.sample_pos += current_chunk_bytes             # <<<<<<<<<<<<<<
 *         track_buffer_pos += current_chunk_bytes
 *         buffer_bytes_remaining -= current_chunk_bytes
 */
    __pyx_v_player->sample_pos = (__pyx_v_player->sample_pos + __pyx_v_current_chunk_bytes);

    /* "mpfmc/core/audio/track_sound_loop.pyx":1250
 *         # Advance buffer pointers
 *         player.sample_pos += current_chunk_bytes
 *         track_buffer_pos += current_chunk_bytes             # <<<<<<<<<<<<<<
 *         buffer_bytes_remaining -= current_chunk_bytes
 * 
 */
    __pyx_v_track_buffer_pos = (__pyx_v_track_buffer_pos + __pyx_v_current_chunk_bytes);

    /* "mpfmc/core/audio/track_sound_loop.pyx":1251
 *         player.sample_pos += current_chunk_bytes
 *         track_buffer_pos += current_chunk_bytes
 *         buffer_bytes_remaining -= current_chunk_bytes             # <<<<<<<<<<<<<<
 * 
 *         # If player is counting down to stop, decrement remaining samples and see if player is done
 */
    __pyx_v_buffer_bytes_remaining = (__pyx_v_buffer_bytes_remaining - __pyx_v_current_chunk_bytes);

    /* "mpfmc/core/audio/track_sound_loop.pyx":1254
 * 
 *         # If player is counting down to stop, decrement remaining samples and see if player is done
 *         if player.stop_loop_samples_remaining != do_not_stop_loop:             # <<<<<<<<<<<<<<
 *             player.stop_loop_samples_remaining -= current_chunk_bytes
 * 
 */
    __pyx_t_1 = ((__pyx_v_player->stop_loop_samples_remaining != __pyx_e_5mpfmc_4core_5audio_16track_sound_loop_do_not_stop_loop) != 0);
    if (__pyx_t_1) {

      /* "mpfmc/core/audio/track_sound_loop.pyx":1255
 *         # If player is counting down to stop, decrement remaining samples and see if player is done
 *         if player.stop_loop_samples_remaining != do_not_stop_loop:
 *             player.stop_loop_samples_remaining -= current_chunk_bytes             # <<<<<<<<<<<<<<
 * 
 *             if player.stop_loop_samples_remaining == 0:
 */
      __pyx_v_player->stop_loop_samples_remaining = (__pyx_v_player->stop_loop_samples_remaining - __pyx_v_current_chunk_bytes);

      /* "mpfmc/core/audio/track_sound_loop.pyx":1257
 *             player.stop_loop_samples_remaining -= current_chunk_bytes
 * 
 *             if player.stop_loop_samples_remaining == 0:             # <<<<<<<<<<<<<<
 *                 player.status = player_idle
 * 
 */
      __pyx_t_1 = ((__pyx_v_player->stop_loop_samples_remaining == 0) != 0);
      if (__pyx_t_1) {

        /* "mpfmc/core/audio/track_sound_loop.pyx":1258
 * 
 *             if player.stop_loop_samples_remaining == 0:
 *                 player.status = player_idle             # <<<<<<<<<<<<<<
 * 
 *         # Stop looping and generating samples if we have reached the end of the sound or
 */
        __pyx_v_player->status = __pyx_e_5mpfmc_4core_5audio_16track_sound_loop_player_idle;

        /* "mpfmc/core/audio/track_sound_loop.pyx":1257
 *             player.stop_loop_samples_remaining -= current_chunk_bytes
 * 
 *             if player.stop_loop_samples_remaining == 0:             # <<<<<<<<<<<<<<
 *                 player.status = player_idle
 * 
 */
      }

      /* "mpfmc/core/audio/track_sound_loop.pyx":1254
 * 
 *         # If player is counting down to stop, decrement remaining samples and see if player is done
 *         if player.stop_loop_samples_remaining != do_not_stop_loop:             # <<<<<<<<<<<<<<
 *             player.stop_loop_samples_remaining -= current_chunk_bytes
 * 
 */
    }

    /* "mpfmc/core/audio/track_sound_loop.pyx":1262
 *         # Stop looping and generating samples if we have reached the end of the sound or
 *         # the player is now idle (due to reaching end of a fade out)
 *         if player.status == player_idle or player.sample_pos >= player.length:             # <<<<<<<<<<<<<<
 *             break
 * 
 */
    __pyx_t_6 = ((__pyx_v_player->status == __pyx_e_5mpfmc_4core_5audio_16track_sound_loop_player_idle) != 0);
    if (!__pyx_t_6) {
    } else {
      __pyx_t_1 = __pyx_t_6;
      goto __pyx_L30_bool_binop_done;
    }
    __pyx_t_6 = ((__pyx_v_player->sample_pos >= __pyx_v_player->length) != 0);
    __pyx_t_1 = __pyx_t_6;
    __pyx_L30_bool_binop_done:;
    if (__pyx_t_1) {

      /* "mpfmc/core/audio/track_sound_loop.pyx":1263
 *         # the player is now idle (due to reaching end of a fade out)
 *         if player.status == player_idle or player.sample_pos >= player.length:
 *             break             # <<<<<<<<<<<<<<
 * 
 *     return track_buffer_pos
 */
      goto __pyx_L4_break;

      /* "mpfmc/core/audio/track_sound_loop.pyx":1262
 *         # Stop looping and generating samples if we have reached the end of the sound or
 *         # the player is now idle (due to reaching end of a fade out)
 *         if player.status == player_idle or player.sample_pos >= player.length:             # <<<<<<<<<<<<<<
 *             break
 * 
 */
    }
  }
  __pyx_L4_break:;

  /* "mpfmc/core/audio/track_sound_loop.pyx":1265
 *             break
 * 
 *     return track_buffer_pos             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = __pyx_v_track_buffer_pos;
  goto __pyx_L0;

  /* "mpfmc/core/audio/track_sound_loop.pyx":1101
 *                     player.sample_pos = 0
 * 
 * cdef Uint32 get_player_sound_samples(TrackState *track, SoundLoopSetPlayer *player,             # <<<<<<<<<<<<<<
 *                                      Uint32 buffer_length, Uint32 track_buffer_pos,
 *                                      AudioCallbackData *callback_data) nogil:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_WriteUnraisable("mpfmc.core.audio.track_sound_loop.get_player_sound_samples", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 1);
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "mpfmc/core/audio/track_sound_loop.pyx":1268
 * 
 * 
 * cdef inline SoundLoopLayerSettings *_create_sound_loop_layer_settings() nogil:             # <<<<<<<<<<<<<<
 *     """
 *     Creates a new sound loop layer settings struct.
 */

static CYTHON_INLINE __pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopLayerSettings *__pyx_f_5mpfmc_4core_5audio_16track_sound_loop__create_sound_loop_layer_settings(void) {
  __pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopLayerSettings *__pyx_r;

  /* "mpfmc/core/audio/track_sound_loop.pyx":1273
 *     :return: A pointer to the new settings struct.
 *     """
 *     return <SoundLoopLayerSettings*>g_slice_alloc0(sizeof(SoundLoopLayerSettings))             # <<<<<<<<<<<<<<
 */
  __pyx_r = ((__pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopLayerSettings *)g_slice_alloc0((sizeof(__pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopLayerSettings))));
  goto __pyx_L0;

  /* "mpfmc/core/audio/track_sound_loop.pyx":1268
 * 
 * 
 * cdef inline SoundLoopLayerSettings *_create_sound_loop_layer_settings() nogil:             # <<<<<<<<<<<<<<
 *     """
 *     Creates a new sound loop layer settings struct.
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "mpfmc/core/audio/inline.pxd":7
 * # ---------------------------------------------------------------------------
 * 
 * cdef inline Uint8 lerpU8(float progress, Uint8 a, Uint8 b) nogil:             # <<<<<<<<<<<<<<
 *     """
 *     Linearly interpolate between 2 8-bit values.
 */

static CYTHON_INLINE Uint8 __pyx_f_5mpfmc_4core_5audio_6inline_lerpU8(float __pyx_v_progress, Uint8 __pyx_v_a, Uint8 __pyx_v_b) {
  Uint8 __pyx_r;

  /* "mpfmc/core/audio/inline.pxd":18
 *         New 8-bit value between the supplied values
 *     """
 *     return <Uint8> ((1.0 - progress) * a + progress * b)             # <<<<<<<<<<<<<<
 * 
 * cdef inline float in_out_quad(float progress) nogil:
 */
  __pyx_r = ((Uint8)(((1.0 - __pyx_v_progress) * __pyx_v_a) + (__pyx_v_progress * __pyx_v_b)));
  goto __pyx_L0;

  /* "mpfmc/core/audio/inline.pxd":7
 * # ---------------------------------------------------------------------------
 * 
 * cdef inline Uint8 lerpU8(float progress, Uint8 a, Uint8 b) nogil:             # <<<<<<<<<<<<<<
 *     """
 *     Linearly interpolate between 2 8-bit values.
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "mpfmc/core/audio/inline.pxd":20
 *     return <Uint8> ((1.0 - progress) * a + progress * b)
 * 
 * cdef inline float in_out_quad(float progress) nogil:             # <<<<<<<<<<<<<<
 *     """
 *     A quadratic easing function used for smoother audio fading
 */

static CYTHON_INLINE float __pyx_f_5mpfmc_4core_5audio_6inline_in_out_quad(float __pyx_v_progress) {
  float __pyx_v_p;
  float __pyx_r;
  int __pyx_t_1;

  /* "mpfmc/core/audio/inline.pxd":30
 *     """
 *     cdef float p
 *     p = progress * 2             # <<<<<<<<<<<<<<
 *     if p < 1:
 *         return 0.5 * p * p
 */
  __pyx_v_p = (__pyx_v_progress * 2.0);

  /* "mpfmc/core/audio/inline.pxd":31
 *     cdef float p
 *     p = progress * 2
 *     if p < 1:             # <<<<<<<<<<<<<<
 *         return 0.5 * p * p
 *     p -= 1.0
 */
  __pyx_t_1 = ((__pyx_v_p < 1.0) != 0);
  if (__pyx_t_1) {

    /* "mpfmc/core/audio/inline.pxd":32
 *     p = progress * 2
 *     if p < 1:
 *         return 0.5 * p * p             # <<<<<<<<<<<<<<
 *     p -= 1.0
 *     return -0.5 * (p * (p - 2.0) - 1.0)
 */
    __pyx_r = ((0.5 * __pyx_v_p) * __pyx_v_p);
    goto __pyx_L0;

    /* "mpfmc/core/audio/inline.pxd":31
 *     cdef float p
 *     p = progress * 2
 *     if p < 1:             # <<<<<<<<<<<<<<
 *         return 0.5 * p * p
 *     p -= 1.0
 */
  }

  /* "mpfmc/core/audio/inline.pxd":33
 *     if p < 1:
 *         return 0.5 * p * p
 *     p -= 1.0             # <<<<<<<<<<<<<<
 *     return -0.5 * (p * (p - 2.0) - 1.0)
 * 
 */
  __pyx_v_p = (__pyx_v_p - 1.0);

  /* "mpfmc/core/audio/inline.pxd":34
 *         return 0.5 * p * p
 *     p -= 1.0
 *     return -0.5 * (p * (p - 2.0) - 1.0)             # <<<<<<<<<<<<<<
 * 
 */
  __pyx_r = (-0.5 * ((__pyx_v_p * (__pyx_v_p - 2.0)) - 1.0));
  goto __pyx_L0;

  /* "mpfmc/core/audio/inline.pxd":20
 *     return <Uint8> ((1.0 - progress) * a + progress * b)
 * 
 * cdef inline float in_out_quad(float progress) nogil:             # <<<<<<<<<<<<<<
 *     """
 *     A quadratic easing function used for smoother audio fading
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "mpfmc/core/audio/notification_message.pxd":52
 * # ---------------------------------------------------------------------------
 * 
 * cdef inline NotificationMessageContainer *_create_notification_message() nogil:             # <<<<<<<<<<<<<<
 *     """
 *     Creates a new notification message.
 */

static CYTHON_INLINE __pyx_t_5mpfmc_4core_5audio_20notification_message_NotificationMessageContainer *__pyx_f_5mpfmc_4core_5audio_20notification_message__create_notification_message(void) {
  __pyx_t_5mpfmc_4core_5audio_20notification_message_NotificationMessageContainer *__pyx_r;

  /* "mpfmc/core/audio/notification_message.pxd":57
 *     :return: A pointer to the new notification message.
 *     """
 *     return <NotificationMessageContainer*>g_slice_alloc0(sizeof(NotificationMessageContainer))             # <<<<<<<<<<<<<<
 * 
 * cdef inline void send_sound_started_notification(int player, Uint64 sound_id, Uint64 sound_instance_id,
 */
  __pyx_r = ((__pyx_t_5mpfmc_4core_5audio_20notification_message_NotificationMessageContainer *)g_slice_alloc0((sizeof(__pyx_t_5mpfmc_4core_5audio_20notification_message_NotificationMessageContainer))));
  goto __pyx_L0;

  /* "mpfmc/core/audio/notification_message.pxd":52
 * # ---------------------------------------------------------------------------
 * 
 * cdef inline NotificationMessageContainer *_create_notification_message() nogil:             # <<<<<<<<<<<<<<
 *     """
 *     Creates a new notification message.
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "mpfmc/core/audio/notification_message.pxd":59
 *     return <NotificationMessageContainer*>g_slice_alloc0(sizeof(NotificationMessageContainer))
 * 
 * cdef inline void send_sound_started_notification(int player, Uint64 sound_id, Uint64 sound_instance_id,             # <<<<<<<<<<<<<<
 *                                                  TrackState *track) nogil:
 *     """
 */

static CYTHON_INLINE void __pyx_f_5mpfmc_4core_5audio_20notification_message_send_sound_started_notification(int __pyx_v_player, Uint64 __pyx_v_sound_id, Uint64 __pyx_v_sound_instance_id, __pyx_t_5mpfmc_4core_5audio_5track_TrackState *__pyx_v_track) {
  __pyx_t_5mpfmc_4core_5audio_20notification_message_NotificationMessageContainer *__pyx_v_notification_message;
  int __pyx_t_1;

  /* "mpfmc/core/audio/notification_message.pxd":69
 *         track: The TrackState pointer
 *     """
 *     cdef NotificationMessageContainer *notification_message = _create_notification_message()             # <<<<<<<<<<<<<<
 *     if notification_message != NULL:
 *         notification_message.message = notification_sound_started
 */
  __pyx_v_notification_message = __pyx_f_5mpfmc_4core_5audio_20notification_message__create_notification_message();

  /* "mpfmc/core/audio/notification_message.pxd":70
 *     """
 *     cdef NotificationMessageContainer *notification_message = _create_notification_message()
 *     if notification_message != NULL:             # <<<<<<<<<<<<<<
 *         notification_message.message = notification_sound_started
 *         notification_message.player = player
 */
  __pyx_t_1 = ((__pyx_v_notification_message != NULL) != 0);
  if (__pyx_t_1) {

    /* "mpfmc/core/audio/notification_message.pxd":71
 *     cdef NotificationMessageContainer *notification_message = _create_notification_message()
 *     if notification_message != NULL:
 *         notification_message.message = notification_sound_started             # <<<<<<<<<<<<<<
 *         notification_message.player = player
 *         notification_message.sound_id = sound_id
 */
    __pyx_v_notification_message->message = __pyx_e_5mpfmc_4core_5audio_20notification_message_notification_sound_started;

    /* "mpfmc/core/audio/notification_message.pxd":72
 *     if notification_message != NULL:
 *         notification_message.message = notification_sound_started
 *         notification_message.player = player             # <<<<<<<<<<<<<<
 *         notification_message.sound_id = sound_id
 *         notification_message.sound_instance_id = sound_instance_id
 */
    __pyx_v_notification_message->player = __pyx_v_player;

    /* "mpfmc/core/audio/notification_message.pxd":73
 *         notification_message.message = notification_sound_started
 *         notification_message.player = player
 *         notification_message.sound_id = sound_id             # <<<<<<<<<<<<<<
 *         notification_message.sound_instance_id = sound_instance_id
 * 
 */
    __pyx_v_notification_message->sound_id = __pyx_v_sound_id;

    /* "mpfmc/core/audio/notification_message.pxd":74
 *         notification_message.player = player
 *         notification_message.sound_id = sound_id
 *         notification_message.sound_instance_id = sound_instance_id             # <<<<<<<<<<<<<<
 * 
 *         track.notification_messages = g_slist_prepend(track.notification_messages, notification_message)
 */
    __pyx_v_notification_message->sound_instance_id = __pyx_v_sound_instance_id;

    /* "mpfmc/core/audio/notification_message.pxd":76
 *         notification_message.sound_instance_id = sound_instance_id
 * 
 *         track.notification_messages = g_slist_prepend(track.notification_messages, notification_message)             # <<<<<<<<<<<<<<
 * 
 * cdef inline void send_sound_stopped_notification(int player, Uint64 sound_id, Uint64 sound_instance_id,
 */
    __pyx_v_track->notification_messages = g_slist_prepend(__pyx_v_track->notification_messages, __pyx_v_notification_message);

    /* "mpfmc/core/audio/notification_message.pxd":70
 *     """
 *     cdef NotificationMessageContainer *notification_message = _create_notification_message()
 *     if notification_message != NULL:             # <<<<<<<<<<<<<<
 *         notification_message.message = notification_sound_started
 *         notification_message.player = player
 */
  }

  /* "mpfmc/core/audio/notification_message.pxd":59
 *     return <NotificationMessageContainer*>g_slice_alloc0(sizeof(NotificationMessageContainer))
 * 
 * cdef inline void send_sound_started_notification(int player, Uint64 sound_id, Uint64 sound_instance_id,             # <<<<<<<<<<<<<<
 *                                                  TrackState *track) nogil:
 *     """
 */

  /* function exit code */
}

/* "mpfmc/core/audio/notification_message.pxd":78
 *         track.notification_messages = g_slist_prepend(track.notification_messages, notification_message)
 * 
 * cdef inline void send_sound_stopped_notification(int player, Uint64 sound_id, Uint64 sound_instance_id,             # <<<<<<<<<<<<<<
 *                                                  TrackState *track) nogil:
 *     """
 */

static CYTHON_INLINE void __pyx_f_5mpfmc_4core_5audio_20notification_message_send_sound_stopped_notification(int __pyx_v_player, Uint64 __pyx_v_sound_id, Uint64 __pyx_v_sound_instance_id, __pyx_t_5mpfmc_4core_5audio_5track_TrackState *__pyx_v_track) {
  __pyx_t_5mpfmc_4core_5audio_20notification_message_NotificationMessageContainer *__pyx_v_notification_message;
  int __pyx_t_1;

  /* "mpfmc/core/audio/notification_message.pxd":88
 *         track: The TrackState pointer
 *     """
 *     cdef NotificationMessageContainer *notification_message = _create_notification_message()             # <<<<<<<<<<<<<<
 *     if notification_message != NULL:
 *         notification_message.message = notification_sound_stopped
 */
  __pyx_v_notification_message = __pyx_f_5mpfmc_4core_5audio_20notification_message__create_notification_message();

  /* "mpfmc/core/audio/notification_message.pxd":89
 *     """
 *     cdef NotificationMessageContainer *notification_message = _create_notification_message()
 *     if notification_message != NULL:             # <<<<<<<<<<<<<<
 *         notification_message.message = notification_sound_stopped
 *         notification_message.player = player
 */
  __pyx_t_1 = ((__pyx_v_notification_message != NULL) != 0);
  if (__pyx_t_1) {

    /* "mpfmc/core/audio/notification_message.pxd":90
 *     cdef NotificationMessageContainer *notification_message = _create_notification_message()
 *     if notification_message != NULL:
 *         notification_message.message = notification_sound_stopped             # <<<<<<<<<<<<<<
 *         notification_message.player = player
 *         notification_message.sound_id = sound_id
 */
    __pyx_v_notification_message->message = __pyx_e_5mpfmc_4core_5audio_20notification_message_notification_sound_stopped;

    /* "mpfmc/core/audio/notification_message.pxd":91
 *     if notification_message != NULL:
 *         notification_message.message = notification_sound_stopped
 *         notification_message.player = player             # <<<<<<<<<<<<<<
 *         notification_message.sound_id = sound_id
 *         notification_message.sound_instance_id = sound_instance_id
 */
    __pyx_v_notification_message->player = __pyx_v_player;

    /* "mpfmc/core/audio/notification_message.pxd":92
 *         notification_message.message = notification_sound_stopped
 *         notification_message.player = player
 *         notification_message.sound_id = sound_id             # <<<<<<<<<<<<<<
 *         notification_message.sound_instance_id = sound_instance_id
 * 
 */
    __pyx_v_notification_message->sound_id = __pyx_v_sound_id;

    /* "mpfmc/core/audio/notification_message.pxd":93
 *         notification_message.player = player
 *         notification_message.sound_id = sound_id
 *         notification_message.sound_instance_id = sound_instance_id             # <<<<<<<<<<<<<<
 * 
 *         track.notification_messages = g_slist_prepend(track.notification_messages, notification_message)
 */
    __pyx_v_notification_message->sound_instance_id = __pyx_v_sound_instance_id;

    /* "mpfmc/core/audio/notification_message.pxd":95
 *         notification_message.sound_instance_id = sound_instance_id
 * 
 *         track.notification_messages = g_slist_prepend(track.notification_messages, notification_message)             # <<<<<<<<<<<<<<
 * 
 * cdef inline void send_sound_looping_notification(int player, Uint64 sound_id, Uint64 sound_instance_id,
 */
    __pyx_v_track->notification_messages = g_slist_prepend(__pyx_v_track->notification_messages, __pyx_v_notification_message);

    /* "mpfmc/core/audio/notification_message.pxd":89
 *     """
 *     cdef NotificationMessageContainer *notification_message = _create_notification_message()
 *     if notification_message != NULL:             # <<<<<<<<<<<<<<
 *         notification_message.message = notification_sound_stopped
 *         notification_message.player = player
 */
  }

  /* "mpfmc/core/audio/notification_message.pxd":78
 *         track.notification_messages = g_slist_prepend(track.notification_messages, notification_message)
 * 
 * cdef inline void send_sound_stopped_notification(int player, Uint64 sound_id, Uint64 sound_instance_id,             # <<<<<<<<<<<<<<
 *                                                  TrackState *track) nogil:
 *     """
 */

  /* function exit code */
}

/* "mpfmc/core/audio/notification_message.pxd":97
 *         track.notification_messages = g_slist_prepend(track.notification_messages, notification_message)
 * 
 * cdef inline void send_sound_looping_notification(int player, Uint64 sound_id, Uint64 sound_instance_id,             # <<<<<<<<<<<<<<
 *                                                  TrackState *track) nogil:
 *     """
 */

static CYTHON_INLINE void __pyx_f_5mpfmc_4core_5audio_20notification_message_send_sound_looping_notification(int __pyx_v_player, Uint64 __pyx_v_sound_id, Uint64 __pyx_v_sound_instance_id, __pyx_t_5mpfmc_4core_5audio_5track_TrackState *__pyx_v_track) {
  __pyx_t_5mpfmc_4core_5audio_20notification_message_NotificationMessageContainer *__pyx_v_notification_message;
  int __pyx_t_1;

  /* "mpfmc/core/audio/notification_message.pxd":107
 *         track: The TrackState pointer
 *     """
 *     cdef NotificationMessageContainer *notification_message = _create_notification_message()             # <<<<<<<<<<<<<<
 *     if notification_message != NULL:
 *         notification_message.message = notification_sound_looping
 */
  __pyx_v_notification_message = __pyx_f_5mpfmc_4core_5audio_20notification_message__create_notification_message();

  /* "mpfmc/core/audio/notification_message.pxd":108
 *     """
 *     cdef NotificationMessageContainer *notification_message = _create_notification_message()
 *     if notification_message != NULL:             # <<<<<<<<<<<<<<
 *         notification_message.message = notification_sound_looping
 *         notification_message.player = player
 */
  __pyx_t_1 = ((__pyx_v_notification_message != NULL) != 0);
  if (__pyx_t_1) {

    /* "mpfmc/core/audio/notification_message.pxd":109
 *     cdef NotificationMessageContainer *notification_message = _create_notification_message()
 *     if notification_message != NULL:
 *         notification_message.message = notification_sound_looping             # <<<<<<<<<<<<<<
 *         notification_message.player = player
 *         notification_message.sound_id = sound_id
 */
    __pyx_v_notification_message->message = __pyx_e_5mpfmc_4core_5audio_20notification_message_notification_sound_looping;

    /* "mpfmc/core/audio/notification_message.pxd":110
 *     if notification_message != NULL:
 *         notification_message.message = notification_sound_looping
 *         notification_message.player = player             # <<<<<<<<<<<<<<
 *         notification_message.sound_id = sound_id
 *         notification_message.sound_instance_id = sound_instance_id
 */
    __pyx_v_notification_message->player = __pyx_v_player;

    /* "mpfmc/core/audio/notification_message.pxd":111
 *         notification_message.message = notification_sound_looping
 *         notification_message.player = player
 *         notification_message.sound_id = sound_id             # <<<<<<<<<<<<<<
 *         notification_message.sound_instance_id = sound_instance_id
 * 
 */
    __pyx_v_notification_message->sound_id = __pyx_v_sound_id;

    /* "mpfmc/core/audio/notification_message.pxd":112
 *         notification_message.player = player
 *         notification_message.sound_id = sound_id
 *         notification_message.sound_instance_id = sound_instance_id             # <<<<<<<<<<<<<<
 * 
 *         track.notification_messages = g_slist_prepend(track.notification_messages, notification_message)
 */
    __pyx_v_notification_message->sound_instance_id = __pyx_v_sound_instance_id;

    /* "mpfmc/core/audio/notification_message.pxd":114
 *         notification_message.sound_instance_id = sound_instance_id
 * 
 *         track.notification_messages = g_slist_prepend(track.notification_messages, notification_message)             # <<<<<<<<<<<<<<
 * 
 * cdef inline void send_sound_about_to_finish_notification(int player, Uint64 sound_id, Uint64 sound_instance_id,
 */
    __pyx_v_track->notification_messages = g_slist_prepend(__pyx_v_track->notification_messages, __pyx_v_notification_message);

    /* "mpfmc/core/audio/notification_message.pxd":108
 *     """
 *     cdef NotificationMessageContainer *notification_message = _create_notification_message()
 *     if notification_message != NULL:             # <<<<<<<<<<<<<<
 *         notification_message.message = notification_sound_looping
 *         notification_message.player = player
 */
  }

  /* "mpfmc/core/audio/notification_message.pxd":97
 *         track.notification_messages = g_slist_prepend(track.notification_messages, notification_message)
 * 
 * cdef inline void send_sound_looping_notification(int player, Uint64 sound_id, Uint64 sound_instance_id,             # <<<<<<<<<<<<<<
 *                                                  TrackState *track) nogil:
 *     """
 */

  /* function exit code */
}

/* "mpfmc/core/audio/notification_message.pxd":116
 *         track.notification_messages = g_slist_prepend(track.notification_messages, notification_message)
 * 
 * cdef inline void send_sound_about_to_finish_notification(int player, Uint64 sound_id, Uint64 sound_instance_id,             # <<<<<<<<<<<<<<
 *                                                          TrackState *track) nogil:
 *     """
 */

static CYTHON_INLINE void __pyx_f_5mpfmc_4core_5audio_20notification_message_send_sound_about_to_finish_notification(int __pyx_v_player, Uint64 __pyx_v_sound_id, Uint64 __pyx_v_sound_instance_id, __pyx_t_5mpfmc_4core_5audio_5track_TrackState *__pyx_v_track) {
  __pyx_t_5mpfmc_4core_5audio_20notification_message_NotificationMessageContainer *__pyx_v_notification_message;
  int __pyx_t_1;

  /* "mpfmc/core/audio/notification_message.pxd":126
 *         track: The TrackState pointer
 *     """
 *     cdef NotificationMessageContainer *notification_message = _create_notification_message()             # <<<<<<<<<<<<<<
 *     if notification_message != NULL:
 *         notification_message.message = notification_sound_about_to_finish
 */
  __pyx_v_notification_message = __pyx_f_5mpfmc_4core_5audio_20notification_message__create_notification_message();

  /* "mpfmc/core/audio/notification_message.pxd":127
 *     """
 *     cdef NotificationMessageContainer *notification_message = _create_notification_message()
 *     if notification_message != NULL:             # <<<<<<<<<<<<<<
 *         notification_message.message = notification_sound_about_to_finish
 *         notification_message.player = player
 */
  __pyx_t_1 = ((__pyx_v_notification_message != NULL) != 0);
  if (__pyx_t_1) {

    /* "mpfmc/core/audio/notification_message.pxd":128
 *     cdef NotificationMessageContainer *notification_message = _create_notification_message()
 *     if notification_message != NULL:
 *         notification_message.message = notification_sound_about_to_finish             # <<<<<<<<<<<<<<
 *         notification_message.player = player
 *         notification_message.sound_id = sound_id
 */
    __pyx_v_notification_message->message = __pyx_e_5mpfmc_4core_5audio_20notification_message_notification_sound_about_to_finish;

    /* "mpfmc/core/audio/notification_message.pxd":129
 *     if notification_message != NULL:
 *         notification_message.message = notification_sound_about_to_finish
 *         notification_message.player = player             # <<<<<<<<<<<<<<
 *         notification_message.sound_id = sound_id
 *         notification_message.sound_instance_id = sound_instance_id
 */
    __pyx_v_notification_message->player = __pyx_v_player;

    /* "mpfmc/core/audio/notification_message.pxd":130
 *         notification_message.message = notification_sound_about_to_finish
 *         notification_message.player = player
 *         notification_message.sound_id = sound_id             # <<<<<<<<<<<<<<
 *         notification_message.sound_instance_id = sound_instance_id
 * 
 */
    __pyx_v_notification_message->sound_id = __pyx_v_sound_id;

    /* "mpfmc/core/audio/notification_message.pxd":131
 *         notification_message.player = player
 *         notification_message.sound_id = sound_id
 *         notification_message.sound_instance_id = sound_instance_id             # <<<<<<<<<<<<<<
 * 
 *         track.notification_messages = g_slist_prepend(track.notification_messages, notification_message)
 */
    __pyx_v_notification_message->sound_instance_id = __pyx_v_sound_instance_id;

    /* "mpfmc/core/audio/notification_message.pxd":133
 *         notification_message.sound_instance_id = sound_instance_id
 * 
 *         track.notification_messages = g_slist_prepend(track.notification_messages, notification_message)             # <<<<<<<<<<<<<<
 * 
 * cdef inline void send_sound_marker_notification(int player, Uint64 sound_id, Uint64 sound_instance_id,
 */
    __pyx_v_track->notification_messages = g_slist_prepend(__pyx_v_track->notification_messages, __pyx_v_notification_message);

    /* "mpfmc/core/audio/notification_message.pxd":127
 *     """
 *     cdef NotificationMessageContainer *notification_message = _create_notification_message()
 *     if notification_message != NULL:             # <<<<<<<<<<<<<<
 *         notification_message.message = notification_sound_about_to_finish
 *         notification_message.player = player
 */
  }

  /* "mpfmc/core/audio/notification_message.pxd":116
 *         track.notification_messages = g_slist_prepend(track.notification_messages, notification_message)
 * 
 * cdef inline void send_sound_about_to_finish_notification(int player, Uint64 sound_id, Uint64 sound_instance_id,             # <<<<<<<<<<<<<<
 *                                                          TrackState *track) nogil:
 *     """
 */

  /* function exit code */
}

/* "mpfmc/core/audio/notification_message.pxd":135
 *         track.notification_messages = g_slist_prepend(track.notification_messages, notification_message)
 * 
 * cdef inline void send_sound_marker_notification(int player, Uint64 sound_id, Uint64 sound_instance_id,             # <<<<<<<<<<<<<<
 *                                                 TrackState *track,
 *                                                 int marker_id) nogil:
 */

static CYTHON_INLINE void __pyx_f_5mpfmc_4core_5audio_20notification_message_send_sound_marker_notification(int __pyx_v_player, Uint64 __pyx_v_sound_id, Uint64 __pyx_v_sound_instance_id, __pyx_t_5mpfmc_4core_5audio_5track_TrackState *__pyx_v_track, int __pyx_v_marker_id) {
  __pyx_t_5mpfmc_4core_5audio_20notification_message_NotificationMessageContainer *__pyx_v_notification_message;
  int __pyx_t_1;

  /* "mpfmc/core/audio/notification_message.pxd":147
 *         marker_id: The id of the marker being sent for the specified sound
 *     """
 *     cdef NotificationMessageContainer *notification_message = _create_notification_message()             # <<<<<<<<<<<<<<
 *     if notification_message != NULL:
 *         notification_message.message = notification_sound_marker
 */
  __pyx_v_notification_message = __pyx_f_5mpfmc_4core_5audio_20notification_message__create_notification_message();

  /* "mpfmc/core/audio/notification_message.pxd":148
 *     """
 *     cdef NotificationMessageContainer *notification_message = _create_notification_message()
 *     if notification_message != NULL:             # <<<<<<<<<<<<<<
 *         notification_message.message = notification_sound_marker
 *         notification_message.player = player
 */
  __pyx_t_1 = ((__pyx_v_notification_message != NULL) != 0);
  if (__pyx_t_1) {

    /* "mpfmc/core/audio/notification_message.pxd":149
 *     cdef NotificationMessageContainer *notification_message = _create_notification_message()
 *     if notification_message != NULL:
 *         notification_message.message = notification_sound_marker             # <<<<<<<<<<<<<<
 *         notification_message.player = player
 *         notification_message.sound_id = sound_id
 */
    __pyx_v_notification_message->message = __pyx_e_5mpfmc_4core_5audio_20notification_message_notification_sound_marker;

    /* "mpfmc/core/audio/notification_message.pxd":150
 *     if notification_message != NULL:
 *         notification_message.message = notification_sound_marker
 *         notification_message.player = player             # <<<<<<<<<<<<<<
 *         notification_message.sound_id = sound_id
 *         notification_message.sound_instance_id = sound_instance_id
 */
    __pyx_v_notification_message->player = __pyx_v_player;

    /* "mpfmc/core/audio/notification_message.pxd":151
 *         notification_message.message = notification_sound_marker
 *         notification_message.player = player
 *         notification_message.sound_id = sound_id             # <<<<<<<<<<<<<<
 *         notification_message.sound_instance_id = sound_instance_id
 *         notification_message.data.marker.id = marker_id
 */
    __pyx_v_notification_message->sound_id = __pyx_v_sound_id;

    /* "mpfmc/core/audio/notification_message.pxd":152
 *         notification_message.player = player
 *         notification_message.sound_id = sound_id
 *         notification_message.sound_instance_id = sound_instance_id             # <<<<<<<<<<<<<<
 *         notification_message.data.marker.id = marker_id
 * 
 */
    __pyx_v_notification_message->sound_instance_id = __pyx_v_sound_instance_id;

    /* "mpfmc/core/audio/notification_message.pxd":153
 *         notification_message.sound_id = sound_id
 *         notification_message.sound_instance_id = sound_instance_id
 *         notification_message.data.marker.id = marker_id             # <<<<<<<<<<<<<<
 * 
 *         track.notification_messages = g_slist_prepend(track.notification_messages, notification_message)
 */
    __pyx_v_notification_message->data.marker.id = __pyx_v_marker_id;

    /* "mpfmc/core/audio/notification_message.pxd":155
 *         notification_message.data.marker.id = marker_id
 * 
 *         track.notification_messages = g_slist_prepend(track.notification_messages, notification_message)             # <<<<<<<<<<<<<<
 * 
 * cdef inline void send_track_stopped_notification(TrackState *track) nogil:
 */
    __pyx_v_track->notification_messages = g_slist_prepend(__pyx_v_track->notification_messages, __pyx_v_notification_message);

    /* "mpfmc/core/audio/notification_message.pxd":148
 *     """
 *     cdef NotificationMessageContainer *notification_message = _create_notification_message()
 *     if notification_message != NULL:             # <<<<<<<<<<<<<<
 *         notification_message.message = notification_sound_marker
 *         notification_message.player = player
 */
  }

  /* "mpfmc/core/audio/notification_message.pxd":135
 *         track.notification_messages = g_slist_prepend(track.notification_messages, notification_message)
 * 
 * cdef inline void send_sound_marker_notification(int player, Uint64 sound_id, Uint64 sound_instance_id,             # <<<<<<<<<<<<<<
 *                                                 TrackState *track,
 *                                                 int marker_id) nogil:
 */

  /* function exit code */
}

/* "mpfmc/core/audio/notification_message.pxd":157
 *         track.notification_messages = g_slist_prepend(track.notification_messages, notification_message)
 * 
 * cdef inline void send_track_stopped_notification(TrackState *track) nogil:             # <<<<<<<<<<<<<<
 *     """
 *     Sends a track stopped notification
 */

static CYTHON_INLINE void __pyx_f_5mpfmc_4core_5audio_20notification_message_send_track_stopped_notification(__pyx_t_5mpfmc_4core_5audio_5track_TrackState *__pyx_v_track) {
  __pyx_t_5mpfmc_4core_5audio_20notification_message_NotificationMessageContainer *__pyx_v_notification_message;
  int __pyx_t_1;

  /* "mpfmc/core/audio/notification_message.pxd":163
 *         track: The TrackState pointer
 *     """
 *     cdef NotificationMessageContainer *notification_message = _create_notification_message()             # <<<<<<<<<<<<<<
 *     if notification_message != NULL:
 *         notification_message.message = notification_track_stopped
 */
  __pyx_v_notification_message = __pyx_f_5mpfmc_4core_5audio_20notification_message__create_notification_message();

  /* "mpfmc/core/audio/notification_message.pxd":164
 *     """
 *     cdef NotificationMessageContainer *notification_message = _create_notification_message()
 *     if notification_message != NULL:             # <<<<<<<<<<<<<<
 *         notification_message.message = notification_track_stopped
 *         track.notification_messages = g_slist_prepend(track.notification_messages, notification_message)
 */
  __pyx_t_1 = ((__pyx_v_notification_message != NULL) != 0);
  if (__pyx_t_1) {

    /* "mpfmc/core/audio/notification_message.pxd":165
 *     cdef NotificationMessageContainer *notification_message = _create_notification_message()
 *     if notification_message != NULL:
 *         notification_message.message = notification_track_stopped             # <<<<<<<<<<<<<<
 *         track.notification_messages = g_slist_prepend(track.notification_messages, notification_message)
 * 
 */
    __pyx_v_notification_message->message = __pyx_e_5mpfmc_4core_5audio_20notification_message_notification_track_stopped;

    /* "mpfmc/core/audio/notification_message.pxd":166
 *     if notification_message != NULL:
 *         notification_message.message = notification_track_stopped
 *         track.notification_messages = g_slist_prepend(track.notification_messages, notification_message)             # <<<<<<<<<<<<<<
 * 
 * cdef inline void send_track_paused_notification(TrackState *track) nogil:
 */
    __pyx_v_track->notification_messages = g_slist_prepend(__pyx_v_track->notification_messages, __pyx_v_notification_message);

    /* "mpfmc/core/audio/notification_message.pxd":164
 *     """
 *     cdef NotificationMessageContainer *notification_message = _create_notification_message()
 *     if notification_message != NULL:             # <<<<<<<<<<<<<<
 *         notification_message.message = notification_track_stopped
 *         track.notification_messages = g_slist_prepend(track.notification_messages, notification_message)
 */
  }

  /* "mpfmc/core/audio/notification_message.pxd":157
 *         track.notification_messages = g_slist_prepend(track.notification_messages, notification_message)
 * 
 * cdef inline void send_track_stopped_notification(TrackState *track) nogil:             # <<<<<<<<<<<<<<
 *     """
 *     Sends a track stopped notification
 */

  /* function exit code */
}

/* "mpfmc/core/audio/notification_message.pxd":168
 *         track.notification_messages = g_slist_prepend(track.notification_messages, notification_message)
 * 
 * cdef inline void send_track_paused_notification(TrackState *track) nogil:             # <<<<<<<<<<<<<<
 *     """
 *     Sends a track paused notification
 */

static CYTHON_INLINE void __pyx_f_5mpfmc_4core_5audio_20notification_message_send_track_paused_notification(__pyx_t_5mpfmc_4core_5audio_5track_TrackState *__pyx_v_track) {
  __pyx_t_5mpfmc_4core_5audio_20notification_message_NotificationMessageContainer *__pyx_v_notification_message;
  int __pyx_t_1;

  /* "mpfmc/core/audio/notification_message.pxd":174
 *         track: The TrackState pointer
 *     """
 *     cdef NotificationMessageContainer *notification_message = _create_notification_message()             # <<<<<<<<<<<<<<
 *     if notification_message != NULL:
 *         notification_message.message = notification_track_paused
 */
  __pyx_v_notification_message = __pyx_f_5mpfmc_4core_5audio_20notification_message__create_notification_message();

  /* "mpfmc/core/audio/notification_message.pxd":175
 *     """
 *     cdef NotificationMessageContainer *notification_message = _create_notification_message()
 *     if notification_message != NULL:             # <<<<<<<<<<<<<<
 *         notification_message.message = notification_track_paused
 *         track.notification_messages = g_slist_prepend(track.notification_messages, notification_message)
 */
  __pyx_t_1 = ((__pyx_v_notification_message != NULL) != 0);
  if (__pyx_t_1) {

    /* "mpfmc/core/audio/notification_message.pxd":176
 *     cdef NotificationMessageContainer *notification_message = _create_notification_message()
 *     if notification_message != NULL:
 *         notification_message.message = notification_track_paused             # <<<<<<<<<<<<<<
 *         track.notification_messages = g_slist_prepend(track.notification_messages, notification_message)
 * 
 */
    __pyx_v_notification_message->message = __pyx_e_5mpfmc_4core_5audio_20notification_message_notification_track_paused;

    /* "mpfmc/core/audio/notification_message.pxd":177
 *     if notification_message != NULL:
 *         notification_message.message = notification_track_paused
 *         track.notification_messages = g_slist_prepend(track.notification_messages, notification_message)             # <<<<<<<<<<<<<<
 * 
 * cdef inline void send_sound_loop_set_started_notification(int sound_loop_set_id, Uint64 sound_id, gpointer player, TrackState *track) nogil:
 */
    __pyx_v_track->notification_messages = g_slist_prepend(__pyx_v_track->notification_messages, __pyx_v_notification_message);

    /* "mpfmc/core/audio/notification_message.pxd":175
 *     """
 *     cdef NotificationMessageContainer *notification_message = _create_notification_message()
 *     if notification_message != NULL:             # <<<<<<<<<<<<<<
 *         notification_message.message = notification_track_paused
 *         track.notification_messages = g_slist_prepend(track.notification_messages, notification_message)
 */
  }

  /* "mpfmc/core/audio/notification_message.pxd":168
 *         track.notification_messages = g_slist_prepend(track.notification_messages, notification_message)
 * 
 * cdef inline void send_track_paused_notification(TrackState *track) nogil:             # <<<<<<<<<<<<<<
 *     """
 *     Sends a track paused notification
 */

  /* function exit code */
}

/* "mpfmc/core/audio/notification_message.pxd":179
 *         track.notification_messages = g_slist_prepend(track.notification_messages, notification_message)
 * 
 * cdef inline void send_sound_loop_set_started_notification(int sound_loop_set_id, Uint64 sound_id, gpointer player, TrackState *track) nogil:             # <<<<<<<<<<<<<<
 *     """
 *     Sends a sound_loop_set started notification
 */

static CYTHON_INLINE void __pyx_f_5mpfmc_4core_5audio_20notification_message_send_sound_loop_set_started_notification(int __pyx_v_sound_loop_set_id, Uint64 __pyx_v_sound_id, gpointer __pyx_v_player, __pyx_t_5mpfmc_4core_5audio_5track_TrackState *__pyx_v_track) {
  __pyx_t_5mpfmc_4core_5audio_20notification_message_NotificationMessageContainer *__pyx_v_notification_message;
  int __pyx_t_1;

  /* "mpfmc/core/audio/notification_message.pxd":188
 *         track: The TrackState pointer
 *     """
 *     cdef NotificationMessageContainer *notification_message = _create_notification_message()             # <<<<<<<<<<<<<<
 *     if notification_message != NULL:
 *         notification_message.message = notification_sound_loop_set_started
 */
  __pyx_v_notification_message = __pyx_f_5mpfmc_4core_5audio_20notification_message__create_notification_message();

  /* "mpfmc/core/audio/notification_message.pxd":189
 *     """
 *     cdef NotificationMessageContainer *notification_message = _create_notification_message()
 *     if notification_message != NULL:             # <<<<<<<<<<<<<<
 *         notification_message.message = notification_sound_loop_set_started
 *         notification_message.player = 0
 */
  __pyx_t_1 = ((__pyx_v_notification_message != NULL) != 0);
  if (__pyx_t_1) {

    /* "mpfmc/core/audio/notification_message.pxd":190
 *     cdef NotificationMessageContainer *notification_message = _create_notification_message()
 *     if notification_message != NULL:
 *         notification_message.message = notification_sound_loop_set_started             # <<<<<<<<<<<<<<
 *         notification_message.player = 0
 *         notification_message.sound_id = sound_id
 */
    __pyx_v_notification_message->message = __pyx_e_5mpfmc_4core_5audio_20notification_message_notification_sound_loop_set_started;

    /* "mpfmc/core/audio/notification_message.pxd":191
 *     if notification_message != NULL:
 *         notification_message.message = notification_sound_loop_set_started
 *         notification_message.player = 0             # <<<<<<<<<<<<<<
 *         notification_message.sound_id = sound_id
 *         notification_message.sound_instance_id = 0
 */
    __pyx_v_notification_message->player = 0;

    /* "mpfmc/core/audio/notification_message.pxd":192
 *         notification_message.message = notification_sound_loop_set_started
 *         notification_message.player = 0
 *         notification_message.sound_id = sound_id             # <<<<<<<<<<<<<<
 *         notification_message.sound_instance_id = 0
 *         notification_message.data.sound_loop_set.id = sound_loop_set_id
 */
    __pyx_v_notification_message->sound_id = __pyx_v_sound_id;

    /* "mpfmc/core/audio/notification_message.pxd":193
 *         notification_message.player = 0
 *         notification_message.sound_id = sound_id
 *         notification_message.sound_instance_id = 0             # <<<<<<<<<<<<<<
 *         notification_message.data.sound_loop_set.id = sound_loop_set_id
 *         notification_message.data.sound_loop_set.player = player
 */
    __pyx_v_notification_message->sound_instance_id = 0;

    /* "mpfmc/core/audio/notification_message.pxd":194
 *         notification_message.sound_id = sound_id
 *         notification_message.sound_instance_id = 0
 *         notification_message.data.sound_loop_set.id = sound_loop_set_id             # <<<<<<<<<<<<<<
 *         notification_message.data.sound_loop_set.player = player
 * 
 */
    __pyx_v_notification_message->data.sound_loop_set.id = __pyx_v_sound_loop_set_id;

    /* "mpfmc/core/audio/notification_message.pxd":195
 *         notification_message.sound_instance_id = 0
 *         notification_message.data.sound_loop_set.id = sound_loop_set_id
 *         notification_message.data.sound_loop_set.player = player             # <<<<<<<<<<<<<<
 * 
 *         track.notification_messages = g_slist_prepend(track.notification_messages, notification_message)
 */
    __pyx_v_notification_message->data.sound_loop_set.player = __pyx_v_player;

    /* "mpfmc/core/audio/notification_message.pxd":197
 *         notification_message.data.sound_loop_set.player = player
 * 
 *         track.notification_messages = g_slist_prepend(track.notification_messages, notification_message)             # <<<<<<<<<<<<<<
 * 
 * cdef inline void send_sound_loop_set_stopped_notification(int sound_loop_set_id, Uint64 sound_id, gpointer player, TrackState *track) nogil:
 */
    __pyx_v_track->notification_messages = g_slist_prepend(__pyx_v_track->notification_messages, __pyx_v_notification_message);

    /* "mpfmc/core/audio/notification_message.pxd":189
 *     """
 *     cdef NotificationMessageContainer *notification_message = _create_notification_message()
 *     if notification_message != NULL:             # <<<<<<<<<<<<<<
 *         notification_message.message = notification_sound_loop_set_started
 *         notification_message.player = 0
 */
  }

  /* "mpfmc/core/audio/notification_message.pxd":179
 *         track.notification_messages = g_slist_prepend(track.notification_messages, notification_message)
 * 
 * cdef inline void send_sound_loop_set_started_notification(int sound_loop_set_id, Uint64 sound_id, gpointer player, TrackState *track) nogil:             # <<<<<<<<<<<<<<
 *     """
 *     Sends a sound_loop_set started notification
 */

  /* function exit code */
}

/* "mpfmc/core/audio/notification_message.pxd":199
 *         track.notification_messages = g_slist_prepend(track.notification_messages, notification_message)
 * 
 * cdef inline void send_sound_loop_set_stopped_notification(int sound_loop_set_id, Uint64 sound_id, gpointer player, TrackState *track) nogil:             # <<<<<<<<<<<<<<
 *     """
 *     Sends a sound_loop_set stopped notification
 */

static CYTHON_INLINE void __pyx_f_5mpfmc_4core_5audio_20notification_message_send_sound_loop_set_stopped_notification(int __pyx_v_sound_loop_set_id, Uint64 __pyx_v_sound_id, gpointer __pyx_v_player, __pyx_t_5mpfmc_4core_5audio_5track_TrackState *__pyx_v_track) {
  __pyx_t_5mpfmc_4core_5audio_20notification_message_NotificationMessageContainer *__pyx_v_notification_message;
  int __pyx_t_1;

  /* "mpfmc/core/audio/notification_message.pxd":208
 *         track: The TrackState pointer
 *     """
 *     cdef NotificationMessageContainer *notification_message = _create_notification_message()             # <<<<<<<<<<<<<<
 *     if notification_message != NULL:
 *         notification_message.message = notification_sound_loop_set_stopped
 */
  __pyx_v_notification_message = __pyx_f_5mpfmc_4core_5audio_20notification_message__create_notification_message();

  /* "mpfmc/core/audio/notification_message.pxd":209
 *     """
 *     cdef NotificationMessageContainer *notification_message = _create_notification_message()
 *     if notification_message != NULL:             # <<<<<<<<<<<<<<
 *         notification_message.message = notification_sound_loop_set_stopped
 *         notification_message.player = 0
 */
  __pyx_t_1 = ((__pyx_v_notification_message != NULL) != 0);
  if (__pyx_t_1) {

    /* "mpfmc/core/audio/notification_message.pxd":210
 *     cdef NotificationMessageContainer *notification_message = _create_notification_message()
 *     if notification_message != NULL:
 *         notification_message.message = notification_sound_loop_set_stopped             # <<<<<<<<<<<<<<
 *         notification_message.player = 0
 *         notification_message.sound_id = sound_id
 */
    __pyx_v_notification_message->message = __pyx_e_5mpfmc_4core_5audio_20notification_message_notification_sound_loop_set_stopped;

    /* "mpfmc/core/audio/notification_message.pxd":211
 *     if notification_message != NULL:
 *         notification_message.message = notification_sound_loop_set_stopped
 *         notification_message.player = 0             # <<<<<<<<<<<<<<
 *         notification_message.sound_id = sound_id
 *         notification_message.sound_instance_id = 0
 */
    __pyx_v_notification_message->player = 0;

    /* "mpfmc/core/audio/notification_message.pxd":212
 *         notification_message.message = notification_sound_loop_set_stopped
 *         notification_message.player = 0
 *         notification_message.sound_id = sound_id             # <<<<<<<<<<<<<<
 *         notification_message.sound_instance_id = 0
 *         notification_message.data.sound_loop_set.id = sound_loop_set_id
 */
    __pyx_v_notification_message->sound_id = __pyx_v_sound_id;

    /* "mpfmc/core/audio/notification_message.pxd":213
 *         notification_message.player = 0
 *         notification_message.sound_id = sound_id
 *         notification_message.sound_instance_id = 0             # <<<<<<<<<<<<<<
 *         notification_message.data.sound_loop_set.id = sound_loop_set_id
 *         notification_message.data.sound_loop_set.player = player
 */
    __pyx_v_notification_message->sound_instance_id = 0;

    /* "mpfmc/core/audio/notification_message.pxd":214
 *         notification_message.sound_id = sound_id
 *         notification_message.sound_instance_id = 0
 *         notification_message.data.sound_loop_set.id = sound_loop_set_id             # <<<<<<<<<<<<<<
 *         notification_message.data.sound_loop_set.player = player
 * 
 */
    __pyx_v_notification_message->data.sound_loop_set.id = __pyx_v_sound_loop_set_id;

    /* "mpfmc/core/audio/notification_message.pxd":215
 *         notification_message.sound_instance_id = 0
 *         notification_message.data.sound_loop_set.id = sound_loop_set_id
 *         notification_message.data.sound_loop_set.player = player             # <<<<<<<<<<<<<<
 * 
 *         track.notification_messages = g_slist_prepend(track.notification_messages, notification_message)
 */
    __pyx_v_notification_message->data.sound_loop_set.player = __pyx_v_player;

    /* "mpfmc/core/audio/notification_message.pxd":217
 *         notification_message.data.sound_loop_set.player = player
 * 
 *         track.notification_messages = g_slist_prepend(track.notification_messages, notification_message)             # <<<<<<<<<<<<<<
 * 
 * cdef inline void send_sound_loop_set_looping_notification(int sound_loop_set_id, Uint64 sound_id, gpointer player, TrackState *track) nogil:
 */
    __pyx_v_track->notification_messages = g_slist_prepend(__pyx_v_track->notification_messages, __pyx_v_notification_message);

    /* "mpfmc/core/audio/notification_message.pxd":209
 *     """
 *     cdef NotificationMessageContainer *notification_message = _create_notification_message()
 *     if notification_message != NULL:             # <<<<<<<<<<<<<<
 *         notification_message.message = notification_sound_loop_set_stopped
 *         notification_message.player = 0
 */
  }

  /* "mpfmc/core/audio/notification_message.pxd":199
 *         track.notification_messages = g_slist_prepend(track.notification_messages, notification_message)
 * 
 * cdef inline void send_sound_loop_set_stopped_notification(int sound_loop_set_id, Uint64 sound_id, gpointer player, TrackState *track) nogil:             # <<<<<<<<<<<<<<
 *     """
 *     Sends a sound_loop_set stopped notification
 */

  /* function exit code */
}

/* "mpfmc/core/audio/notification_message.pxd":219
 *         track.notification_messages = g_slist_prepend(track.notification_messages, notification_message)
 * 
 * cdef inline void send_sound_loop_set_looping_notification(int sound_loop_set_id, Uint64 sound_id, gpointer player, TrackState *track) nogil:             # <<<<<<<<<<<<<<
 *     """
 *     Sends a sound_loop_set looping notification
 */

static CYTHON_INLINE void __pyx_f_5mpfmc_4core_5audio_20notification_message_send_sound_loop_set_looping_notification(int __pyx_v_sound_loop_set_id, Uint64 __pyx_v_sound_id, gpointer __pyx_v_player, __pyx_t_5mpfmc_4core_5audio_5track_TrackState *__pyx_v_track) {
  __pyx_t_5mpfmc_4core_5audio_20notification_message_NotificationMessageContainer *__pyx_v_notification_message;
  int __pyx_t_1;

  /* "mpfmc/core/audio/notification_message.pxd":228
 *         track: The TrackState pointer
 *     """
 *     cdef NotificationMessageContainer *notification_message = _create_notification_message()             # <<<<<<<<<<<<<<
 *     if notification_message != NULL:
 *         notification_message.message = notification_sound_loop_set_looping
 */
  __pyx_v_notification_message = __pyx_f_5mpfmc_4core_5audio_20notification_message__create_notification_message();

  /* "mpfmc/core/audio/notification_message.pxd":229
 *     """
 *     cdef NotificationMessageContainer *notification_message = _create_notification_message()
 *     if notification_message != NULL:             # <<<<<<<<<<<<<<
 *         notification_message.message = notification_sound_loop_set_looping
 *         notification_message.player = 0
 */
  __pyx_t_1 = ((__pyx_v_notification_message != NULL) != 0);
  if (__pyx_t_1) {

    /* "mpfmc/core/audio/notification_message.pxd":230
 *     cdef NotificationMessageContainer *notification_message = _create_notification_message()
 *     if notification_message != NULL:
 *         notification_message.message = notification_sound_loop_set_looping             # <<<<<<<<<<<<<<
 *         notification_message.player = 0
 *         notification_message.sound_id = sound_id
 */
    __pyx_v_notification_message->message = __pyx_e_5mpfmc_4core_5audio_20notification_message_notification_sound_loop_set_looping;

    /* "mpfmc/core/audio/notification_message.pxd":231
 *     if notification_message != NULL:
 *         notification_message.message = notification_sound_loop_set_looping
 *         notification_message.player = 0             # <<<<<<<<<<<<<<
 *         notification_message.sound_id = sound_id
 *         notification_message.sound_instance_id = 0
 */
    __pyx_v_notification_message->player = 0;

    /* "mpfmc/core/audio/notification_message.pxd":232
 *         notification_message.message = notification_sound_loop_set_looping
 *         notification_message.player = 0
 *         notification_message.sound_id = sound_id             # <<<<<<<<<<<<<<
 *         notification_message.sound_instance_id = 0
 *         notification_message.data.sound_loop_set.id = sound_loop_set_id
 */
    __pyx_v_notification_message->sound_id = __pyx_v_sound_id;

    /* "mpfmc/core/audio/notification_message.pxd":233
 *         notification_message.player = 0
 *         notification_message.sound_id = sound_id
 *         notification_message.sound_instance_id = 0             # <<<<<<<<<<<<<<
 *         notification_message.data.sound_loop_set.id = sound_loop_set_id
 *         notification_message.data.sound_loop_set.player = player
 */
    __pyx_v_notification_message->sound_instance_id = 0;

    /* "mpfmc/core/audio/notification_message.pxd":234
 *         notification_message.sound_id = sound_id
 *         notification_message.sound_instance_id = 0
 *         notification_message.data.sound_loop_set.id = sound_loop_set_id             # <<<<<<<<<<<<<<
 *         notification_message.data.sound_loop_set.player = player
 * 
 */
    __pyx_v_notification_message->data.sound_loop_set.id = __pyx_v_sound_loop_set_id;

    /* "mpfmc/core/audio/notification_message.pxd":235
 *         notification_message.sound_instance_id = 0
 *         notification_message.data.sound_loop_set.id = sound_loop_set_id
 *         notification_message.data.sound_loop_set.player = player             # <<<<<<<<<<<<<<
 * 
 *         track.notification_messages = g_slist_prepend(track.notification_messages, notification_message)
 */
    __pyx_v_notification_message->data.sound_loop_set.player = __pyx_v_player;

    /* "mpfmc/core/audio/notification_message.pxd":237
 *         notification_message.data.sound_loop_set.player = player
 * 
 *         track.notification_messages = g_slist_prepend(track.notification_messages, notification_message)             # <<<<<<<<<<<<<<
 * 
 */
    __pyx_v_track->notification_messages = g_slist_prepend(__pyx_v_track->notification_messages, __pyx_v_notification_message);

    /* "mpfmc/core/audio/notification_message.pxd":229
 *     """
 *     cdef NotificationMessageContainer *notification_message = _create_notification_message()
 *     if notification_message != NULL:             # <<<<<<<<<<<<<<
 *         notification_message.message = notification_sound_loop_set_looping
 *         notification_message.player = 0
 */
  }

  /* "mpfmc/core/audio/notification_message.pxd":219
 *         track.notification_messages = g_slist_prepend(track.notification_messages, notification_message)
 * 
 * cdef inline void send_sound_loop_set_looping_notification(int sound_loop_set_id, Uint64 sound_id, gpointer player, TrackState *track) nogil:             # <<<<<<<<<<<<<<
 *     """
 *     Sends a sound_loop_set looping notification
 */

  /* function exit code */
}
static struct __pyx_vtabstruct_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop __pyx_vtable_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop;

static PyObject *__pyx_tp_new_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *p;
  PyObject *o = __pyx_ptype_5mpfmc_4core_5audio_5track_Track->tp_new(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_5mpfmc_4core_5audio_5track_Track*)__pyx_vtabptr_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop;
  p->_active_sound_loop_sets = ((PyObject*)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop(PyObject *o) {
  struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *p = (struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    __Pyx_SET_REFCNT(o, Py_REFCNT(o) + 1);
    __pyx_pw_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_3__dealloc__(o);
    __Pyx_SET_REFCNT(o, Py_REFCNT(o) - 1);
    PyErr_Restore(etype, eval, etb);
  }
  Py_CLEAR(p->_active_sound_loop_sets);
  PyObject_GC_Track(o);
  if (likely(__pyx_ptype_5mpfmc_4core_5audio_5track_Track)) __pyx_ptype_5mpfmc_4core_5audio_5track_Track->tp_dealloc(o); else __Pyx_call_next_tp_dealloc(o, __pyx_tp_dealloc_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop);
}

static int __pyx_tp_traverse_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *p = (struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *)o;
  e = ((likely(__pyx_ptype_5mpfmc_4core_5audio_5track_Track)) ? ((__pyx_ptype_5mpfmc_4core_5audio_5track_Track->tp_traverse) ? __pyx_ptype_5mpfmc_4core_5audio_5track_Track->tp_traverse(o, v, a) : 0) : __Pyx_call_next_tp_traverse(o, v, a, __pyx_tp_traverse_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop)); if (e) return e;
  if (p->_active_sound_loop_sets) {
    e = (*v)(p->_active_sound_loop_sets, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *p = (struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *)o;
  if (likely(__pyx_ptype_5mpfmc_4core_5audio_5track_Track)) { if (__pyx_ptype_5mpfmc_4core_5audio_5track_Track->tp_clear) __pyx_ptype_5mpfmc_4core_5audio_5track_Track->tp_clear(o); } else __Pyx_call_next_tp_clear(o, __pyx_tp_clear_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop);
  tmp = ((PyObject*)p->_active_sound_loop_sets);
  p->_active_sound_loop_sets = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_type(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_4type_1__get__(o);
}

static PyObject *__pyx_getprop_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_supports_in_memory_sounds(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_25supports_in_memory_sounds_1__get__(o);
}

static PyObject *__pyx_getprop_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_supports_streaming_sounds(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_25supports_streaming_sounds_1__get__(o);
}

static PyMethodDef __pyx_methods_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop[] = {
  {"stop_all_sounds", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_7stop_all_sounds, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_6stop_all_sounds},
  {"stop_sound", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_9stop_sound, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_8stop_sound},
  {"stop_sound_instance", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_11stop_sound_instance, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_10stop_sound_instance},
  {"stop_sound_looping", (PyCFunction)__pyx_pw_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_13stop_sound_looping, METH_O, __pyx_doc_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_12stop_sound_looping},
  {"stop_sound_instance_looping", (PyCFunction)__pyx_pw_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_15stop_sound_instance_looping, METH_O, __pyx_doc_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_14stop_sound_instance_looping},
  {"process", (PyCFunction)__pyx_pw_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_17process, METH_NOARGS, __pyx_doc_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_16process},
  {"play_sound_loop_set", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_19play_sound_loop_set, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_18play_sound_loop_set},
  {"stop_current_sound_loop_set", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_21stop_current_sound_loop_set, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_20stop_current_sound_loop_set},
  {"jump_to_time_current_sound_loop_set", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_23jump_to_time_current_sound_loop_set, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_22jump_to_time_current_sound_loop_set},
  {"stop_looping_current_sound_loop_set", (PyCFunction)__pyx_pw_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_25stop_looping_current_sound_loop_set, METH_NOARGS, __pyx_doc_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_24stop_looping_current_sound_loop_set},
  {"play_layer", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_27play_layer, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_26play_layer},
  {"stop_layer", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_29stop_layer, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_28stop_layer},
  {"stop_looping_layer", (PyCFunction)__pyx_pw_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_31stop_looping_layer, METH_O, __pyx_doc_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_30stop_looping_layer},
  {"get_status", (PyCFunction)__pyx_pw_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_33get_status, METH_NOARGS, __pyx_doc_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_32get_status},
  {"player_status_to_text", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_35player_status_to_text, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_34player_status_to_text},
  {"layer_status_to_text", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_37layer_status_to_text, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_36layer_status_to_text},
  {"__reduce_cython__", (PyCFunction)__pyx_pw_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_39__reduce_cython__, METH_NOARGS, __pyx_doc_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_38__reduce_cython__},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_41__setstate_cython__, METH_O, __pyx_doc_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_40__setstate_cython__},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop[] = {
  {(char *)"type", __pyx_getprop_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_type, 0, (char *)0, 0},
  {(char *)"supports_in_memory_sounds", __pyx_getprop_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_supports_in_memory_sounds, 0, (char *)"Return whether or not track accepts in-memory sounds", 0},
  {(char *)"supports_streaming_sounds", __pyx_getprop_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_supports_streaming_sounds, 0, (char *)"Return whether or not track accepts streaming sounds", 0},
  {0, 0, 0, 0, 0}
};

static PyTypeObject __pyx_type_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop = {
  PyVarObject_HEAD_INIT(0, 0)
  "mpfmc.core.audio.track_sound_loop.TrackSoundLoop", /*tp_name*/
  sizeof(struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  __pyx_pw_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_5__repr__, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "TrackSoundLoop(mc, audio_callback_data, unicode name, int track_num, int buffer_size, int max_layers=8, float volume=1.0)\n\n    Live Loop track class\n    ", /*tp_doc*/
  __pyx_tp_traverse_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop, /*tp_traverse*/
  __pyx_tp_clear_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
};

static PyMethodDef __pyx_methods[] = {
  {0, 0, 0, 0}
};

#if PY_MAJOR_VERSION >= 3
#if CYTHON_PEP489_MULTI_PHASE_INIT
static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/
static int __pyx_pymod_exec_track_sound_loop(PyObject* module); /*proto*/
static PyModuleDef_Slot __pyx_moduledef_slots[] = {
  {Py_mod_create, (void*)__pyx_pymod_create},
  {Py_mod_exec, (void*)__pyx_pymod_exec_track_sound_loop},
  {0, NULL}
};
#endif

static struct PyModuleDef __pyx_moduledef = {
    PyModuleDef_HEAD_INIT,
    "track_sound_loop",
    0, /* m_doc */
  #if CYTHON_PEP489_MULTI_PHASE_INIT
    0, /* m_size */
  #else
    -1, /* m_size */
  #endif
    __pyx_methods /* m_methods */,
  #if CYTHON_PEP489_MULTI_PHASE_INIT
    __pyx_moduledef_slots, /* m_slots */
  #else
    NULL, /* m_reload */
  #endif
    NULL, /* m_traverse */
    NULL, /* m_clear */
    NULL /* m_free */
};
#endif
#ifndef CYTHON_SMALL_CODE
#if defined(__clang__)
    #define CYTHON_SMALL_CODE
#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
    #define CYTHON_SMALL_CODE __attribute__((cold))
#else
    #define CYTHON_SMALL_CODE
#endif
#endif

static __Pyx_StringTabEntry __pyx_string_tab[] = {
  {&__pyx_kp_u_Could_not_retrieve_settings_for, __pyx_k_Could_not_retrieve_settings_for, sizeof(__pyx_k_Could_not_retrieve_settings_for), 0, 1, 0, 0},
  {&__pyx_kp_u_Created_Track_d_s, __pyx_k_Created_Track_d_s, sizeof(__pyx_k_Created_Track_d_s), 0, 1, 0, 0},
  {&__pyx_kp_u_DO_NOT_STOP_LOOP, __pyx_k_DO_NOT_STOP_LOOP, sizeof(__pyx_k_DO_NOT_STOP_LOOP), 0, 1, 0, 0},
  {&__pyx_kp_u_Illegal_layer_value_in_call_to_p, __pyx_k_Illegal_layer_value_in_call_to_p, sizeof(__pyx_k_Illegal_layer_value_in_call_to_p), 0, 1, 0, 0},
  {&__pyx_kp_u_Illegal_layer_value_in_call_to_s, __pyx_k_Illegal_layer_value_in_call_to_s, sizeof(__pyx_k_Illegal_layer_value_in_call_to_s), 0, 1, 0, 0},
  {&__pyx_kp_u_Illegal_layer_value_in_call_to_s_2, __pyx_k_Illegal_layer_value_in_call_to_s_2, sizeof(__pyx_k_Illegal_layer_value_in_call_to_s_2), 0, 1, 0, 0},
  {&__pyx_kp_u_Jumping_to_f_seconds_playback_po, __pyx_k_Jumping_to_f_seconds_playback_po, sizeof(__pyx_k_Jumping_to_f_seconds_playback_po), 0, 1, 0, 0},
  {&__pyx_n_s_KeyError, __pyx_k_KeyError, sizeof(__pyx_k_KeyError), 0, 0, 1, 1},
  {&__pyx_kp_u_Processing_notification_message, __pyx_k_Processing_notification_message, sizeof(__pyx_k_Processing_notification_message), 0, 1, 0, 0},
  {&__pyx_kp_u_Received_a_notification_message, __pyx_k_Received_a_notification_message, sizeof(__pyx_k_Received_a_notification_message), 0, 1, 0, 0},
  {&__pyx_kp_u_Received_a_notification_message_2, __pyx_k_Received_a_notification_message_2, sizeof(__pyx_k_Received_a_notification_message_2), 0, 1, 0, 0},
  {&__pyx_kp_u_Removing_sound_loop_set_settings, __pyx_k_Removing_sound_loop_set_settings, sizeof(__pyx_k_Removing_sound_loop_set_settings), 0, 1, 0, 0},
  {&__pyx_kp_u_Stopping_current_sound_loop_set, __pyx_k_Stopping_current_sound_loop_set, sizeof(__pyx_k_Stopping_current_sound_loop_set), 0, 1, 0, 0},
  {&__pyx_kp_u_Stopping_looping_current_sound_l, __pyx_k_Stopping_looping_current_sound_l, sizeof(__pyx_k_Stopping_looping_current_sound_l), 0, 1, 0, 0},
  {&__pyx_kp_u_The_current_sound_loop_set_layer, __pyx_k_The_current_sound_loop_set_layer, sizeof(__pyx_k_The_current_sound_loop_set_layer), 0, 1, 0, 0},
  {&__pyx_kp_u_The_current_sound_loop_set_layer_2, __pyx_k_The_current_sound_loop_set_layer_2, sizeof(__pyx_k_The_current_sound_loop_set_layer_2), 0, 1, 0, 0},
  {&__pyx_kp_u_The_current_sound_loop_set_layer_3, __pyx_k_The_current_sound_loop_set_layer_3, sizeof(__pyx_k_The_current_sound_loop_set_layer_3), 0, 1, 0, 0},
  {&__pyx_kp_u_The_specified_layer_could_not_be, __pyx_k_The_specified_layer_could_not_be, sizeof(__pyx_k_The_specified_layer_could_not_be), 0, 1, 0, 0},
  {&__pyx_kp_u_The_specified_layer_could_not_be_2, __pyx_k_The_specified_layer_could_not_be_2, sizeof(__pyx_k_The_specified_layer_could_not_be_2), 0, 1, 0, 0},
  {&__pyx_kp_u_The_specified_layer_could_not_be_3, __pyx_k_The_specified_layer_could_not_be_3, sizeof(__pyx_k_The_specified_layer_could_not_be_3), 0, 1, 0, 0},
  {&__pyx_kp_u_There_are_no_layers_defined_in_t, __pyx_k_There_are_no_layers_defined_in_t, sizeof(__pyx_k_There_are_no_layers_defined_in_t), 0, 1, 0, 0},
  {&__pyx_kp_u_There_are_no_layers_defined_in_t_2, __pyx_k_There_are_no_layers_defined_in_t_2, sizeof(__pyx_k_There_are_no_layers_defined_in_t_2), 0, 1, 0, 0},
  {&__pyx_kp_u_There_are_no_layers_defined_in_t_3, __pyx_k_There_are_no_layers_defined_in_t_3, sizeof(__pyx_k_There_are_no_layers_defined_in_t_3), 0, 1, 0, 0},
  {&__pyx_kp_u_Track, __pyx_k_Track, sizeof(__pyx_k_Track), 0, 1, 0, 0},
  {&__pyx_kp_u_TrackSoundLoop, __pyx_k_TrackSoundLoop, sizeof(__pyx_k_TrackSoundLoop), 0, 1, 0, 0},
  {&__pyx_n_s_TrackSoundLoop_2, __pyx_k_TrackSoundLoop_2, sizeof(__pyx_k_TrackSoundLoop_2), 0, 0, 1, 1},
  {&__pyx_kp_u_Track_SoundLoop, __pyx_k_Track_SoundLoop, sizeof(__pyx_k_Track_SoundLoop), 0, 1, 0, 0},
  {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1},
  {&__pyx_kp_u_Unable_to_jump_to_specified_play, __pyx_k_Unable_to_jump_to_specified_play, sizeof(__pyx_k_Unable_to_jump_to_specified_play), 0, 1, 0, 0},
  {&__pyx_kp_u_Unable_to_play_layer_no_sound_lo, __pyx_k_Unable_to_play_layer_no_sound_lo, sizeof(__pyx_k_Unable_to_play_layer_no_sound_lo), 0, 1, 0, 0},
  {&__pyx_kp_u_Unable_to_stop_layer_no_sound_lo, __pyx_k_Unable_to_stop_layer_no_sound_lo, sizeof(__pyx_k_Unable_to_stop_layer_no_sound_lo), 0, 1, 0, 0},
  {&__pyx_kp_u_Unable_to_stop_looping_sound_loo, __pyx_k_Unable_to_stop_looping_sound_loo, sizeof(__pyx_k_Unable_to_stop_looping_sound_loo), 0, 1, 0, 0},
  {&__pyx_kp_u_Unable_to_stop_sound_loop_set_no, __pyx_k_Unable_to_stop_sound_loop_set_no, sizeof(__pyx_k_Unable_to_stop_sound_loop_set_no), 0, 1, 0, 0},
  {&__pyx_kp_u_Unknown_timing_value_specified_s, __pyx_k_Unknown_timing_value_specified_s, sizeof(__pyx_k_Unknown_timing_value_specified_s), 0, 1, 0, 0},
  {&__pyx_n_s_audio_callback_data, __pyx_k_audio_callback_data, sizeof(__pyx_k_audio_callback_data), 0, 0, 1, 1},
  {&__pyx_n_s_buffer_size, __pyx_k_buffer_size, sizeof(__pyx_k_buffer_size), 0, 0, 1, 1},
  {&__pyx_n_s_ceil, __pyx_k_ceil, sizeof(__pyx_k_ceil), 0, 0, 1, 1},
  {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1},
  {&__pyx_n_s_container, __pyx_k_container, sizeof(__pyx_k_container), 0, 0, 1, 1},
  {&__pyx_n_s_context, __pyx_k_context, sizeof(__pyx_k_context), 0, 0, 1, 1},
  {&__pyx_n_u_context, __pyx_k_context, sizeof(__pyx_k_context), 0, 1, 0, 1},
  {&__pyx_n_s_debug, __pyx_k_debug, sizeof(__pyx_k_debug), 0, 0, 1, 1},
  {&__pyx_n_u_delayed, __pyx_k_delayed, sizeof(__pyx_k_delayed), 0, 1, 0, 1},
  {&__pyx_n_s_error, __pyx_k_error, sizeof(__pyx_k_error), 0, 0, 1, 1},
  {&__pyx_n_u_events, __pyx_k_events, sizeof(__pyx_k_events), 0, 1, 0, 1},
  {&__pyx_n_u_events_when_looping, __pyx_k_events_when_looping, sizeof(__pyx_k_events_when_looping), 0, 1, 0, 1},
  {&__pyx_n_u_events_when_played, __pyx_k_events_when_played, sizeof(__pyx_k_events_when_played), 0, 1, 0, 1},
  {&__pyx_n_u_events_when_stopped, __pyx_k_events_when_stopped, sizeof(__pyx_k_events_when_stopped), 0, 1, 0, 1},
  {&__pyx_n_s_fade_in, __pyx_k_fade_in, sizeof(__pyx_k_fade_in), 0, 0, 1, 1},
  {&__pyx_n_u_fade_in, __pyx_k_fade_in, sizeof(__pyx_k_fade_in), 0, 1, 0, 1},
  {&__pyx_n_u_fade_in_steps, __pyx_k_fade_in_steps, sizeof(__pyx_k_fade_in_steps), 0, 1, 0, 1},
  {&__pyx_n_s_fade_out, __pyx_k_fade_out, sizeof(__pyx_k_fade_out), 0, 0, 1, 1},
  {&__pyx_n_u_fade_out, __pyx_k_fade_out, sizeof(__pyx_k_fade_out), 0, 1, 0, 1},
  {&__pyx_n_s_fade_out_seconds, __pyx_k_fade_out_seconds, sizeof(__pyx_k_fade_out_seconds), 0, 0, 1, 1},
  {&__pyx_n_u_fade_out_steps, __pyx_k_fade_out_steps, sizeof(__pyx_k_fade_out_steps), 0, 1, 0, 1},
  {&__pyx_n_u_fade_steps_remaining, __pyx_k_fade_steps_remaining, sizeof(__pyx_k_fade_steps_remaining), 0, 1, 0, 1},
  {&__pyx_kp_u_fading_in, __pyx_k_fading_in, sizeof(__pyx_k_fading_in), 0, 1, 0, 0},
  {&__pyx_kp_u_fading_out, __pyx_k_fading_out, sizeof(__pyx_k_fading_out), 0, 1, 0, 0},
  {&__pyx_n_s_format, __pyx_k_format, sizeof(__pyx_k_format), 0, 0, 1, 1},
  {&__pyx_n_s_get, __pyx_k_get, sizeof(__pyx_k_get), 0, 0, 1, 1},
  {&__pyx_n_s_getLogger, __pyx_k_getLogger, sizeof(__pyx_k_getLogger), 0, 0, 1, 1},
  {&__pyx_n_s_getstate, __pyx_k_getstate, sizeof(__pyx_k_getstate), 0, 0, 1, 1},
  {&__pyx_n_s_id, __pyx_k_id, sizeof(__pyx_k_id), 0, 0, 1, 1},
  {&__pyx_n_u_idle, __pyx_k_idle, sizeof(__pyx_k_idle), 0, 1, 0, 1},
  {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
  {&__pyx_n_s_info, __pyx_k_info, sizeof(__pyx_k_info), 0, 0, 1, 1},
  {&__pyx_n_s_init, __pyx_k_init, sizeof(__pyx_k_init), 0, 0, 1, 1},
  {&__pyx_n_u_initial_state, __pyx_k_initial_state, sizeof(__pyx_k_initial_state), 0, 1, 0, 1},
  {&__pyx_n_u_interval, __pyx_k_interval, sizeof(__pyx_k_interval), 0, 1, 0, 1},
  {&__pyx_n_s_keys, __pyx_k_keys, sizeof(__pyx_k_keys), 0, 0, 1, 1},
  {&__pyx_n_s_layer, __pyx_k_layer, sizeof(__pyx_k_layer), 0, 0, 1, 1},
  {&__pyx_n_s_layer_status_to_text, __pyx_k_layer_status_to_text, sizeof(__pyx_k_layer_status_to_text), 0, 0, 1, 1},
  {&__pyx_n_u_layers, __pyx_k_layers, sizeof(__pyx_k_layers), 0, 1, 0, 1},
  {&__pyx_n_u_length, __pyx_k_length, sizeof(__pyx_k_length), 0, 1, 0, 1},
  {&__pyx_n_s_loaded, __pyx_k_loaded, sizeof(__pyx_k_loaded), 0, 0, 1, 1},
  {&__pyx_n_s_logging, __pyx_k_logging, sizeof(__pyx_k_logging), 0, 0, 1, 1},
  {&__pyx_n_u_loop_end, __pyx_k_loop_end, sizeof(__pyx_k_loop_end), 0, 1, 0, 1},
  {&__pyx_n_u_looping, __pyx_k_looping, sizeof(__pyx_k_looping), 0, 1, 0, 1},
  {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
  {&__pyx_n_s_marker_count, __pyx_k_marker_count, sizeof(__pyx_k_marker_count), 0, 0, 1, 1},
  {&__pyx_n_u_marker_count, __pyx_k_marker_count, sizeof(__pyx_k_marker_count), 0, 1, 0, 1},
  {&__pyx_n_s_marker_id, __pyx_k_marker_id, sizeof(__pyx_k_marker_id), 0, 0, 1, 1},
  {&__pyx_n_s_markers, __pyx_k_markers, sizeof(__pyx_k_markers), 0, 0, 1, 1},
  {&__pyx_n_s_math, __pyx_k_math, sizeof(__pyx_k_math), 0, 0, 1, 1},
  {&__pyx_n_s_max_layers, __pyx_k_max_layers, sizeof(__pyx_k_max_layers), 0, 0, 1, 1},
  {&__pyx_n_s_mc, __pyx_k_mc, sizeof(__pyx_k_mc), 0, 0, 1, 1},
  {&__pyx_n_u_mode_end_action, __pyx_k_mode_end_action, sizeof(__pyx_k_mode_end_action), 0, 1, 0, 1},
  {&__pyx_kp_s_mpfmc_core_audio_track_sound_loo, __pyx_k_mpfmc_core_audio_track_sound_loo, sizeof(__pyx_k_mpfmc_core_audio_track_sound_loo), 0, 0, 1, 0},
  {&__pyx_n_s_mpfmc_core_audio_track_sound_loo_2, __pyx_k_mpfmc_core_audio_track_sound_loo_2, sizeof(__pyx_k_mpfmc_core_audio_track_sound_loo_2), 0, 0, 1, 1},
  {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1},
  {&__pyx_n_s_name_2, __pyx_k_name_2, sizeof(__pyx_k_name_2), 0, 0, 1, 1},
  {&__pyx_n_u_next_beat_interval, __pyx_k_next_beat_interval, sizeof(__pyx_k_next_beat_interval), 0, 1, 0, 1},
  {&__pyx_n_u_next_time_interval, __pyx_k_next_time_interval, sizeof(__pyx_k_next_time_interval), 0, 1, 0, 1},
  {&__pyx_n_u_now, __pyx_k_now, sizeof(__pyx_k_now), 0, 1, 0, 1},
  {&__pyx_n_s_number, __pyx_k_number, sizeof(__pyx_k_number), 0, 0, 1, 1},
  {&__pyx_n_u_play, __pyx_k_play, sizeof(__pyx_k_play), 0, 1, 0, 1},
  {&__pyx_kp_u_play_layer_Play_layer_d_of_the_c, __pyx_k_play_layer_Play_layer_d_of_the_c, sizeof(__pyx_k_play_layer_Play_layer_d_of_the_c), 0, 1, 0, 0},
  {&__pyx_kp_u_play_sound_loop_set_Preparing_so, __pyx_k_play_sound_loop_set_Preparing_so, sizeof(__pyx_k_play_sound_loop_set_Preparing_so), 0, 1, 0, 0},
  {&__pyx_kp_u_play_sound_loop_set_sound_s_in_s, __pyx_k_play_sound_loop_set_sound_s_in_s, sizeof(__pyx_k_play_sound_loop_set_sound_s_in_s), 0, 1, 0, 0},
  {&__pyx_kp_u_play_sound_loop_set_sound_s_in_s_2, __pyx_k_play_sound_loop_set_sound_s_in_s_2, sizeof(__pyx_k_play_sound_loop_set_sound_s_in_s_2), 0, 1, 0, 0},
  {&__pyx_n_s_player_settings, __pyx_k_player_settings, sizeof(__pyx_k_player_settings), 0, 0, 1, 1},
  {&__pyx_n_s_player_status_to_text, __pyx_k_player_status_to_text, sizeof(__pyx_k_player_status_to_text), 0, 0, 1, 1},
  {&__pyx_n_u_playing, __pyx_k_playing, sizeof(__pyx_k_playing), 0, 1, 0, 1},
  {&__pyx_n_s_post_mc_native_event, __pyx_k_post_mc_native_event, sizeof(__pyx_k_post_mc_native_event), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1},
  {&__pyx_n_u_queued, __pyx_k_queued, sizeof(__pyx_k_queued), 0, 1, 0, 1},
  {&__pyx_n_s_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1},
  {&__pyx_n_s_reduce, __pyx_k_reduce, sizeof(__pyx_k_reduce), 0, 0, 1, 1},
  {&__pyx_n_s_reduce_cython, __pyx_k_reduce_cython, sizeof(__pyx_k_reduce_cython), 0, 0, 1, 1},
  {&__pyx_n_s_reduce_ex, __pyx_k_reduce_ex, sizeof(__pyx_k_reduce_ex), 0, 0, 1, 1},
  {&__pyx_n_s_round, __pyx_k_round, sizeof(__pyx_k_round), 0, 0, 1, 1},
  {&__pyx_n_u_sample_pos, __pyx_k_sample_pos, sizeof(__pyx_k_sample_pos), 0, 1, 0, 1},
  {&__pyx_kp_s_self_state_self_type_state_canno, __pyx_k_self_state_self_type_state_canno, sizeof(__pyx_k_self_state_self_type_state_canno), 0, 0, 1, 0},
  {&__pyx_n_s_setdefault, __pyx_k_setdefault, sizeof(__pyx_k_setdefault), 0, 0, 1, 1},
  {&__pyx_n_s_setstate, __pyx_k_setstate, sizeof(__pyx_k_setstate), 0, 0, 1, 1},
  {&__pyx_n_s_setstate_cython, __pyx_k_setstate_cython, sizeof(__pyx_k_setstate_cython), 0, 0, 1, 1},
  {&__pyx_n_s_sound, __pyx_k_sound, sizeof(__pyx_k_sound), 0, 0, 1, 1},
  {&__pyx_n_u_sound, __pyx_k_sound, sizeof(__pyx_k_sound), 0, 1, 0, 1},
  {&__pyx_n_u_sound_id, __pyx_k_sound_id, sizeof(__pyx_k_sound_id), 0, 1, 0, 1},
  {&__pyx_n_s_sound_instance, __pyx_k_sound_instance, sizeof(__pyx_k_sound_instance), 0, 0, 1, 1},
  {&__pyx_n_u_sound_length, __pyx_k_sound_length, sizeof(__pyx_k_sound_length), 0, 1, 0, 1},
  {&__pyx_n_u_sound_loop, __pyx_k_sound_loop, sizeof(__pyx_k_sound_loop), 0, 1, 0, 1},
  {&__pyx_n_s_sound_loop_set, __pyx_k_sound_loop_set, sizeof(__pyx_k_sound_loop_set), 0, 0, 1, 1},
  {&__pyx_n_u_sound_loop_set_id, __pyx_k_sound_loop_set_id, sizeof(__pyx_k_sound_loop_set_id), 0, 1, 0, 1},
  {&__pyx_n_s_sounds, __pyx_k_sounds, sizeof(__pyx_k_sounds), 0, 0, 1, 1},
  {&__pyx_n_s_sounds_by_id, __pyx_k_sounds_by_id, sizeof(__pyx_k_sounds_by_id), 0, 0, 1, 1},
  {&__pyx_n_u_start_at, __pyx_k_start_at, sizeof(__pyx_k_start_at), 0, 1, 0, 1},
  {&__pyx_n_u_start_delay_samples_remaining, __pyx_k_start_delay_samples_remaining, sizeof(__pyx_k_start_delay_samples_remaining), 0, 1, 0, 1},
  {&__pyx_n_s_staticmethod, __pyx_k_staticmethod, sizeof(__pyx_k_staticmethod), 0, 0, 1, 1},
  {&__pyx_n_s_status, __pyx_k_status, sizeof(__pyx_k_status), 0, 0, 1, 1},
  {&__pyx_n_u_status, __pyx_k_status, sizeof(__pyx_k_status), 0, 1, 0, 1},
  {&__pyx_n_s_status_values, __pyx_k_status_values, sizeof(__pyx_k_status_values), 0, 0, 1, 1},
  {&__pyx_kp_u_stop_layer_Stop_layer_d_of_the_c, __pyx_k_stop_layer_Stop_layer_d_of_the_c, sizeof(__pyx_k_stop_layer_Stop_layer_d_of_the_c), 0, 1, 0, 0},
  {&__pyx_n_u_stop_loop_samples_remaining, __pyx_k_stop_loop_samples_remaining, sizeof(__pyx_k_stop_loop_samples_remaining), 0, 1, 0, 1},
  {&__pyx_kp_u_stop_looping_layer_Stop_looping, __pyx_k_stop_looping_layer_Stop_looping, sizeof(__pyx_k_stop_looping_layer_Stop_looping), 0, 1, 0, 0},
  {&__pyx_n_u_stopped, __pyx_k_stopped, sizeof(__pyx_k_stopped), 0, 1, 0, 1},
  {&__pyx_n_s_super, __pyx_k_super, sizeof(__pyx_k_super), 0, 0, 1, 1},
  {&__pyx_n_u_synchronize, __pyx_k_synchronize, sizeof(__pyx_k_synchronize), 0, 1, 0, 1},
  {&__pyx_n_u_tempo, __pyx_k_tempo, sizeof(__pyx_k_tempo), 0, 1, 0, 1},
  {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
  {&__pyx_n_s_time, __pyx_k_time, sizeof(__pyx_k_time), 0, 0, 1, 1},
  {&__pyx_n_u_time, __pyx_k_time, sizeof(__pyx_k_time), 0, 1, 0, 1},
  {&__pyx_n_s_timing, __pyx_k_timing, sizeof(__pyx_k_timing), 0, 0, 1, 1},
  {&__pyx_n_u_timing, __pyx_k_timing, sizeof(__pyx_k_timing), 0, 1, 0, 1},
  {&__pyx_n_s_track, __pyx_k_track, sizeof(__pyx_k_track), 0, 0, 1, 1},
  {&__pyx_n_s_track_num, __pyx_k_track_num, sizeof(__pyx_k_track_num), 0, 0, 1, 1},
  {&__pyx_n_u_unknown, __pyx_k_unknown, sizeof(__pyx_k_unknown), 0, 1, 0, 1},
  {&__pyx_n_s_volume, __pyx_k_volume, sizeof(__pyx_k_volume), 0, 0, 1, 1},
  {&__pyx_n_u_volume, __pyx_k_volume, sizeof(__pyx_k_volume), 0, 1, 0, 1},
  {&__pyx_n_s_warning, __pyx_k_warning, sizeof(__pyx_k_warning), 0, 0, 1, 1},
  {0, 0, 0, 0, 0, 0, 0}
};
static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) {
  __pyx_builtin_staticmethod = __Pyx_GetBuiltinName(__pyx_n_s_staticmethod); if (!__pyx_builtin_staticmethod) __PYX_ERR(0, 926, __pyx_L1_error)
  __pyx_builtin_super = __Pyx_GetBuiltinName(__pyx_n_s_super); if (!__pyx_builtin_super) __PYX_ERR(0, 42, __pyx_L1_error)
  __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(0, 525, __pyx_L1_error)
  __pyx_builtin_round = __Pyx_GetBuiltinName(__pyx_n_s_round); if (!__pyx_builtin_round) __PYX_ERR(0, 854, __pyx_L1_error)
  __pyx_builtin_KeyError = __Pyx_GetBuiltinName(__pyx_n_s_KeyError); if (!__pyx_builtin_KeyError) __PYX_ERR(0, 947, __pyx_L1_error)
  __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) __PYX_ERR(1, 2, __pyx_L1_error)
  return 0;
  __pyx_L1_error:;
  return -1;
}

static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);

  /* "(tree fragment)":2
 * def __reduce_cython__(self):
 *     raise TypeError("self.state,self.type_state cannot be converted to a Python object for pickling")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("self.state,self.type_state cannot be converted to a Python object for pickling")
 */
  __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_s_self_state_self_type_state_canno); if (unlikely(!__pyx_tuple_)) __PYX_ERR(1, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple_);
  __Pyx_GIVEREF(__pyx_tuple_);

  /* "(tree fragment)":4
 *     raise TypeError("self.state,self.type_state cannot be converted to a Python object for pickling")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("self.state,self.type_state cannot be converted to a Python object for pickling")             # <<<<<<<<<<<<<<
 */
  __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_s_self_state_self_type_state_canno); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(1, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__2);
  __Pyx_GIVEREF(__pyx_tuple__2);

  /* "mpfmc/core/audio/track_sound_loop.pyx":927
 * 
 *     @staticmethod
 *     def player_status_to_text(int status):             # <<<<<<<<<<<<<<
 *         """
 *         Converts a sound loop player status value into an equivalent text string.  Used for testing
 */
  __pyx_tuple__3 = PyTuple_Pack(2, __pyx_n_s_status, __pyx_n_s_status_values); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(0, 927, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__3);
  __Pyx_GIVEREF(__pyx_tuple__3);
  __pyx_codeobj__4 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__3, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mpfmc_core_audio_track_sound_loo, __pyx_n_s_player_status_to_text, 927, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__4)) __PYX_ERR(0, 927, __pyx_L1_error)

  /* "mpfmc/core/audio/track_sound_loop.pyx":951
 * 
 *     @staticmethod
 *     def layer_status_to_text(int status):             # <<<<<<<<<<<<<<
 *         """
 *         Converts a sound loop set layer status value into an equivalent text string.  Used for testing
 */
  __pyx_tuple__5 = PyTuple_Pack(2, __pyx_n_s_status, __pyx_n_s_status_values); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(0, 951, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__5);
  __Pyx_GIVEREF(__pyx_tuple__5);
  __pyx_codeobj__6 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__5, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mpfmc_core_audio_track_sound_loo, __pyx_n_s_layer_status_to_text, 951, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__6)) __PYX_ERR(0, 951, __pyx_L1_error)
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_RefNannyFinishContext();
  return -1;
}

static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) {
  __pyx_umethod_PyDict_Type_get.type = (PyObject*)&PyDict_Type;
  __pyx_umethod_PyDict_Type_keys.type = (PyObject*)&PyDict_Type;
  __pyx_umethod_PyDict_Type_setdefault.type = (PyObject*)&PyDict_Type;
  if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
  __pyx_float_0_0 = PyFloat_FromDouble(0.0); if (unlikely(!__pyx_float_0_0)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_float_60_0 = PyFloat_FromDouble(60.0); if (unlikely(!__pyx_float_60_0)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) __PYX_ERR(0, 1, __pyx_L1_error)
  return 0;
  __pyx_L1_error:;
  return -1;
}

static CYTHON_SMALL_CODE int __Pyx_modinit_global_init_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_variable_export_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_function_export_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_type_init_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_type_import_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_variable_import_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_function_import_code(void); /*proto*/

static int __Pyx_modinit_global_init_code(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0);
  /*--- Global init code ---*/
  __Pyx_RefNannyFinishContext();
  return 0;
}

static int __Pyx_modinit_variable_export_code(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0);
  /*--- Variable export code ---*/
  __Pyx_RefNannyFinishContext();
  return 0;
}

static int __Pyx_modinit_function_export_code(void) {
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0);
  /*--- Function export code ---*/
  if (__Pyx_ExportFunction("_create_sound_loop_layer_settings", (void (*)(void))__pyx_f_5mpfmc_4core_5audio_16track_sound_loop__create_sound_loop_layer_settings, "__pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopLayerSettings *(void)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_RefNannyFinishContext();
  return -1;
}

static int __Pyx_modinit_type_init_code(void) {
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0);
  /*--- Type init code ---*/
  __pyx_t_1 = PyImport_ImportModule("mpfmc.core.audio.track"); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_ptype_5mpfmc_4core_5audio_5track_Track = __Pyx_ImportType(__pyx_t_1, "mpfmc.core.audio.track", "Track", sizeof(struct __pyx_obj_5mpfmc_4core_5audio_5track_Track), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_5mpfmc_4core_5audio_5track_Track) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_vtabptr_5mpfmc_4core_5audio_5track_Track = (struct __pyx_vtabstruct_5mpfmc_4core_5audio_5track_Track*)__Pyx_GetVtable(__pyx_ptype_5mpfmc_4core_5audio_5track_Track->tp_dict); if (unlikely(!__pyx_vtabptr_5mpfmc_4core_5audio_5track_Track)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_vtabptr_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop = &__pyx_vtable_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop;
  __pyx_vtable_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop.__pyx_base = *__pyx_vtabptr_5mpfmc_4core_5audio_5track_Track;
  __pyx_vtable_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop.process_notification_message = (PyObject *(*)(struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *, __pyx_t_5mpfmc_4core_5audio_20notification_message_NotificationMessageContainer *))__pyx_f_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_process_notification_message;
  __pyx_vtable_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop._apply_layer_settings = (PyObject *(*)(struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *, __pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopLayerSettings *, PyObject *))__pyx_f_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop__apply_layer_settings;
  __pyx_vtable_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop._initialize_player = (PyObject *(*)(struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *, __pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopSetPlayer *))__pyx_f_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop__initialize_player;
  __pyx_vtable_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop._delete_player = (PyObject *(*)(struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *, __pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopSetPlayer *))__pyx_f_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop__delete_player;
  __pyx_vtable_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop._delete_player_layers = (PyObject *(*)(struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *, __pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopSetPlayer *))__pyx_f_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop__delete_player_layers;
  __pyx_vtable_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop._cancel_all_delayed_players = (PyObject *(*)(struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *))__pyx_f_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop__cancel_all_delayed_players;
  __pyx_vtable_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop._fade_out_all_players = (PyObject *(*)(struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *, Uint32))__pyx_f_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop__fade_out_all_players;
  __pyx_vtable_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop._round_sample_pos_up_to_interval = (Uint32 (*)(struct __pyx_obj_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop *, Uint32, Uint32, int))__pyx_f_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop__round_sample_pos_up_to_interval;
  __pyx_vtable_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop.mix_playing_sounds = (void (*)(__pyx_t_5mpfmc_4core_5audio_5track_TrackState *, Uint32, __pyx_t_5mpfmc_4core_5audio_4sdl2_AudioCallbackData *))__pyx_f_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_mix_playing_sounds;
  __pyx_type_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop.tp_base = __pyx_ptype_5mpfmc_4core_5audio_5track_Track;
  if (PyType_Ready(&__pyx_type_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop) < 0) __PYX_ERR(0, 21, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop.tp_dictoffset && __pyx_type_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  #if CYTHON_COMPILING_IN_CPYTHON
  {
    PyObject *wrapper = PyObject_GetAttrString((PyObject *)&__pyx_type_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop, "__init__"); if (unlikely(!wrapper)) __PYX_ERR(0, 21, __pyx_L1_error)
    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
      __pyx_wrapperbase_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop___init__ = *((PyWrapperDescrObject *)wrapper)->d_base;
      __pyx_wrapperbase_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop___init__.doc = __pyx_doc_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop___init__;
      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop___init__;
    }
  }
  #endif
  if (__Pyx_SetVtable(__pyx_type_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop.tp_dict, __pyx_vtabptr_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop) < 0) __PYX_ERR(0, 21, __pyx_L1_error)
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_TrackSoundLoop_2, (PyObject *)&__pyx_type_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop) < 0) __PYX_ERR(0, 21, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop) < 0) __PYX_ERR(0, 21, __pyx_L1_error)
  __pyx_ptype_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop = &__pyx_type_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_RefNannyFinishContext();
  return -1;
}

static int __Pyx_modinit_type_import_code(void) {
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0);
  /*--- Type import code ---*/
  __pyx_t_1 = PyImport_ImportModule("mpfmc.core.audio.sound_file"); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 34, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_ptype_5mpfmc_4core_5audio_10sound_file_SoundFile = __Pyx_ImportType(__pyx_t_1, "mpfmc.core.audio.sound_file", "SoundFile", sizeof(struct __pyx_obj_5mpfmc_4core_5audio_10sound_file_SoundFile), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_5mpfmc_4core_5audio_10sound_file_SoundFile) __PYX_ERR(2, 34, __pyx_L1_error)
  __pyx_ptype_5mpfmc_4core_5audio_10sound_file_SoundMemoryFile = __Pyx_ImportType(__pyx_t_1, "mpfmc.core.audio.sound_file", "SoundMemoryFile", sizeof(struct __pyx_obj_5mpfmc_4core_5audio_10sound_file_SoundMemoryFile), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_5mpfmc_4core_5audio_10sound_file_SoundMemoryFile) __PYX_ERR(2, 42, __pyx_L1_error)
  __pyx_ptype_5mpfmc_4core_5audio_10sound_file_SoundStreamingFile = __Pyx_ImportType(__pyx_t_1, "mpfmc.core.audio.sound_file", "SoundStreamingFile", sizeof(struct __pyx_obj_5mpfmc_4core_5audio_10sound_file_SoundStreamingFile), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_5mpfmc_4core_5audio_10sound_file_SoundStreamingFile) __PYX_ERR(2, 48, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_RefNannyFinishContext();
  return -1;
}

static int __Pyx_modinit_variable_import_code(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0);
  /*--- Variable import code ---*/
  __Pyx_RefNannyFinishContext();
  return 0;
}

static int __Pyx_modinit_function_import_code(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0);
  /*--- Function import code ---*/
  __Pyx_RefNannyFinishContext();
  return 0;
}


#ifndef CYTHON_NO_PYINIT_EXPORT
#define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
#elif PY_MAJOR_VERSION < 3
#ifdef __cplusplus
#define __Pyx_PyMODINIT_FUNC extern "C" void
#else
#define __Pyx_PyMODINIT_FUNC void
#endif
#else
#ifdef __cplusplus
#define __Pyx_PyMODINIT_FUNC extern "C" PyObject *
#else
#define __Pyx_PyMODINIT_FUNC PyObject *
#endif
#endif


#if PY_MAJOR_VERSION < 3
__Pyx_PyMODINIT_FUNC inittrack_sound_loop(void) CYTHON_SMALL_CODE; /*proto*/
__Pyx_PyMODINIT_FUNC inittrack_sound_loop(void)
#else
__Pyx_PyMODINIT_FUNC PyInit_track_sound_loop(void) CYTHON_SMALL_CODE; /*proto*/
__Pyx_PyMODINIT_FUNC PyInit_track_sound_loop(void)
#if CYTHON_PEP489_MULTI_PHASE_INIT
{
  return PyModuleDef_Init(&__pyx_moduledef);
}
static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) {
    #if PY_VERSION_HEX >= 0x030700A1
    static PY_INT64_T main_interpreter_id = -1;
    PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp);
    if (main_interpreter_id == -1) {
        main_interpreter_id = current_id;
        return (unlikely(current_id == -1)) ? -1 : 0;
    } else if (unlikely(main_interpreter_id != current_id))
    #else
    static PyInterpreterState *main_interpreter = NULL;
    PyInterpreterState *current_interpreter = PyThreadState_Get()->interp;
    if (!main_interpreter) {
        main_interpreter = current_interpreter;
    } else if (unlikely(main_interpreter != current_interpreter))
    #endif
    {
        PyErr_SetString(
            PyExc_ImportError,
            "Interpreter change detected - this module can only be loaded into one interpreter per process.");
        return -1;
    }
    return 0;
}
static CYTHON_SMALL_CODE int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name, int allow_none) {
    PyObject *value = PyObject_GetAttrString(spec, from_name);
    int result = 0;
    if (likely(value)) {
        if (allow_none || value != Py_None) {
            result = PyDict_SetItemString(moddict, to_name, value);
        }
        Py_DECREF(value);
    } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
        PyErr_Clear();
    } else {
        result = -1;
    }
    return result;
}
static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) {
    PyObject *module = NULL, *moddict, *modname;
    if (__Pyx_check_single_interpreter())
        return NULL;
    if (__pyx_m)
        return __Pyx_NewRef(__pyx_m);
    modname = PyObject_GetAttrString(spec, "name");
    if (unlikely(!modname)) goto bad;
    module = PyModule_NewObject(modname);
    Py_DECREF(modname);
    if (unlikely(!module)) goto bad;
    moddict = PyModule_GetDict(module);
    if (unlikely(!moddict)) goto bad;
    if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__", 1) < 0)) goto bad;
    if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__", 1) < 0)) goto bad;
    if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__", 1) < 0)) goto bad;
    if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__", 0) < 0)) goto bad;
    return module;
bad:
    Py_XDECREF(module);
    return NULL;
}


static CYTHON_SMALL_CODE int __pyx_pymod_exec_track_sound_loop(PyObject *__pyx_pyinit_module)
#endif
#endif
{
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  #if CYTHON_PEP489_MULTI_PHASE_INIT
  if (__pyx_m) {
    if (__pyx_m == __pyx_pyinit_module) return 0;
    PyErr_SetString(PyExc_RuntimeError, "Module 'track_sound_loop' has already been imported. Re-initialisation is not supported.");
    return -1;
  }
  #elif PY_MAJOR_VERSION >= 3
  if (__pyx_m) return __Pyx_NewRef(__pyx_m);
  #endif
  #if CYTHON_REFNANNY
__Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
if (!__Pyx_RefNanny) {
  PyErr_Clear();
  __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
  if (!__Pyx_RefNanny)
      Py_FatalError("failed to import 'refnanny' module");
}
#endif
  __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit_track_sound_loop(void)", 0);
  if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #ifdef __Pxy_PyFrame_Initialize_Offsets
  __Pxy_PyFrame_Initialize_Offsets();
  #endif
  __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error)
  #ifdef __Pyx_CyFunction_USED
  if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_FusedFunction_USED
  if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_Coroutine_USED
  if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_Generator_USED
  if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_AsyncGen_USED
  if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_StopAsyncIteration_USED
  if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  /*--- Library function declarations ---*/
  /*--- Threads initialization code ---*/
  #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
  #ifdef WITH_THREAD /* Python build with threading support? */
  PyEval_InitThreads();
  #endif
  #endif
  /*--- Module creation code ---*/
  #if CYTHON_PEP489_MULTI_PHASE_INIT
  __pyx_m = __pyx_pyinit_module;
  Py_INCREF(__pyx_m);
  #else
  #if PY_MAJOR_VERSION < 3
  __pyx_m = Py_InitModule4("track_sound_loop", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
  #else
  __pyx_m = PyModule_Create(&__pyx_moduledef);
  #endif
  if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error)
  Py_INCREF(__pyx_d);
  __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error)
  Py_INCREF(__pyx_b);
  __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error)
  Py_INCREF(__pyx_cython_runtime);
  if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
  /*--- Initialize various global constants etc. ---*/
  if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
  if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  if (__pyx_module_is_main_mpfmc__core__audio__track_sound_loop) {
    if (PyObject_SetAttr(__pyx_m, __pyx_n_s_name_2, __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  }
  #if PY_MAJOR_VERSION >= 3
  {
    PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error)
    if (!PyDict_GetItemString(modules, "mpfmc.core.audio.track_sound_loop")) {
      if (unlikely(PyDict_SetItemString(modules, "mpfmc.core.audio.track_sound_loop", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
    }
  }
  #endif
  /*--- Builtin init code ---*/
  if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  /*--- Constants init code ---*/
  if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  /*--- Global type/function init code ---*/
  (void)__Pyx_modinit_global_init_code();
  (void)__Pyx_modinit_variable_export_code();
  if (unlikely(__Pyx_modinit_function_export_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
  if (unlikely(__Pyx_modinit_type_init_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
  if (unlikely(__Pyx_modinit_type_import_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
  (void)__Pyx_modinit_variable_import_code();
  (void)__Pyx_modinit_function_import_code();
  /*--- Execution code ---*/
  #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
  if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif

  /* "mpfmc/core/audio/track_sound_loop.pyx":7
 * from cpython.mem cimport PyMem_Malloc, PyMem_Realloc, PyMem_Free
 * import cython
 * import logging             # <<<<<<<<<<<<<<
 * from math import ceil
 * 
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_logging, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_logging, __pyx_t_1) < 0) __PYX_ERR(0, 7, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "mpfmc/core/audio/track_sound_loop.pyx":8
 * import cython
 * import logging
 * from math import ceil             # <<<<<<<<<<<<<<
 * 
 * from mpfmc.core.audio.sdl2 cimport *
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_ceil);
  __Pyx_GIVEREF(__pyx_n_s_ceil);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_ceil);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_math, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_ceil); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_ceil, __pyx_t_1) < 0) __PYX_ERR(0, 8, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "mpfmc/core/audio/track_sound_loop.pyx":927
 * 
 *     @staticmethod
 *     def player_status_to_text(int status):             # <<<<<<<<<<<<<<
 *         """
 *         Converts a sound loop player status value into an equivalent text string.  Used for testing
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_35player_status_to_text, NULL, __pyx_n_s_mpfmc_core_audio_track_sound_loo_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 927, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop->tp_dict, __pyx_n_s_player_status_to_text, __pyx_t_2) < 0) __PYX_ERR(0, 927, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  PyType_Modified(__pyx_ptype_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop);

  /* "mpfmc/core/audio/track_sound_loop.pyx":926
 *         return status
 * 
 *     @staticmethod             # <<<<<<<<<<<<<<
 *     def player_status_to_text(int status):
 *         """
 */
  __Pyx_GetNameInClass(__pyx_t_2, (PyObject *)__pyx_ptype_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop, __pyx_n_s_player_status_to_text); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 927, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_staticmethod, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 926, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (PyDict_SetItem((PyObject *)__pyx_ptype_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop->tp_dict, __pyx_n_s_player_status_to_text, __pyx_t_1) < 0) __PYX_ERR(0, 927, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_ptype_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop);

  /* "mpfmc/core/audio/track_sound_loop.pyx":951
 * 
 *     @staticmethod
 *     def layer_status_to_text(int status):             # <<<<<<<<<<<<<<
 *         """
 *         Converts a sound loop set layer status value into an equivalent text string.  Used for testing
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_5mpfmc_4core_5audio_16track_sound_loop_14TrackSoundLoop_37layer_status_to_text, NULL, __pyx_n_s_mpfmc_core_audio_track_sound_loo_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 951, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop->tp_dict, __pyx_n_s_layer_status_to_text, __pyx_t_1) < 0) __PYX_ERR(0, 951, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_ptype_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop);

  /* "mpfmc/core/audio/track_sound_loop.pyx":950
 *             return "unknown"
 * 
 *     @staticmethod             # <<<<<<<<<<<<<<
 *     def layer_status_to_text(int status):
 *         """
 */
  __Pyx_GetNameInClass(__pyx_t_1, (PyObject *)__pyx_ptype_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop, __pyx_n_s_layer_status_to_text); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 951, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_staticmethod, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 950, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (PyDict_SetItem((PyObject *)__pyx_ptype_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop->tp_dict, __pyx_n_s_layer_status_to_text, __pyx_t_2) < 0) __PYX_ERR(0, 951, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  PyType_Modified(__pyx_ptype_5mpfmc_4core_5audio_16track_sound_loop_TrackSoundLoop);

  /* "mpfmc/core/audio/track_sound_loop.pyx":1
 * #!python             # <<<<<<<<<<<<<<
 * #cython: embedsignature=True, language_level=3
 * 
 */
  __pyx_t_2 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_2) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "mpfmc/core/audio/notification_message.pxd":219
 *         track.notification_messages = g_slist_prepend(track.notification_messages, notification_message)
 * 
 * cdef inline void send_sound_loop_set_looping_notification(int sound_loop_set_id, Uint64 sound_id, gpointer player, TrackState *track) nogil:             # <<<<<<<<<<<<<<
 *     """
 *     Sends a sound_loop_set looping notification
 */

  /*--- Wrapped vars code ---*/

  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  if (__pyx_m) {
    if (__pyx_d) {
      __Pyx_AddTraceback("init mpfmc.core.audio.track_sound_loop", __pyx_clineno, __pyx_lineno, __pyx_filename);
    }
    Py_CLEAR(__pyx_m);
  } else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_ImportError, "init mpfmc.core.audio.track_sound_loop");
  }
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  #if CYTHON_PEP489_MULTI_PHASE_INIT
  return (__pyx_m != NULL) ? 0 : -1;
  #elif PY_MAJOR_VERSION >= 3
  return __pyx_m;
  #else
  return;
  #endif
}

/* --- Runtime support code --- */
/* Refnanny */
#if CYTHON_REFNANNY
static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
    PyObject *m = NULL, *p = NULL;
    void *r = NULL;
    m = PyImport_ImportModule(modname);
    if (!m) goto end;
    p = PyObject_GetAttrString(m, "RefNannyAPI");
    if (!p) goto end;
    r = PyLong_AsVoidPtr(p);
end:
    Py_XDECREF(p);
    Py_XDECREF(m);
    return (__Pyx_RefNannyAPIStruct *)r;
}
#endif

/* PyObjectGetAttrStr */
#if CYTHON_USE_TYPE_SLOTS
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
    PyTypeObject* tp = Py_TYPE(obj);
    if (likely(tp->tp_getattro))
        return tp->tp_getattro(obj, attr_name);
#if PY_MAJOR_VERSION < 3
    if (likely(tp->tp_getattr))
        return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
#endif
    return PyObject_GetAttr(obj, attr_name);
}
#endif

/* GetBuiltinName */
static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
    PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
    if (unlikely(!result)) {
        PyErr_Format(PyExc_NameError,
#if PY_MAJOR_VERSION >= 3
            "name '%U' is not defined", name);
#else
            "name '%.200s' is not defined", PyString_AS_STRING(name));
#endif
    }
    return result;
}

/* RaiseArgTupleInvalid */
static void __Pyx_RaiseArgtupleInvalid(
    const char* func_name,
    int exact,
    Py_ssize_t num_min,
    Py_ssize_t num_max,
    Py_ssize_t num_found)
{
    Py_ssize_t num_expected;
    const char *more_or_less;
    if (num_found < num_min) {
        num_expected = num_min;
        more_or_less = "at least";
    } else {
        num_expected = num_max;
        more_or_less = "at most";
    }
    if (exact) {
        more_or_less = "exactly";
    }
    PyErr_Format(PyExc_TypeError,
                 "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
                 func_name, more_or_less, num_expected,
                 (num_expected == 1) ? "" : "s", num_found);
}

/* RaiseDoubleKeywords */
static void __Pyx_RaiseDoubleKeywordsError(
    const char* func_name,
    PyObject* kw_name)
{
    PyErr_Format(PyExc_TypeError,
        #if PY_MAJOR_VERSION >= 3
        "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
        #else
        "%s() got multiple values for keyword argument '%s'", func_name,
        PyString_AsString(kw_name));
        #endif
}

/* ParseKeywords */
static int __Pyx_ParseOptionalKeywords(
    PyObject *kwds,
    PyObject **argnames[],
    PyObject *kwds2,
    PyObject *values[],
    Py_ssize_t num_pos_args,
    const char* function_name)
{
    PyObject *key = 0, *value = 0;
    Py_ssize_t pos = 0;
    PyObject*** name;
    PyObject*** first_kw_arg = argnames + num_pos_args;
    while (PyDict_Next(kwds, &pos, &key, &value)) {
        name = first_kw_arg;
        while (*name && (**name != key)) name++;
        if (*name) {
            values[name-argnames] = value;
            continue;
        }
        name = first_kw_arg;
        #if PY_MAJOR_VERSION < 3
        if (likely(PyString_Check(key))) {
            while (*name) {
                if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
                        && _PyString_Eq(**name, key)) {
                    values[name-argnames] = value;
                    break;
                }
                name++;
            }
            if (*name) continue;
            else {
                PyObject*** argname = argnames;
                while (argname != first_kw_arg) {
                    if ((**argname == key) || (
                            (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
                             && _PyString_Eq(**argname, key))) {
                        goto arg_passed_twice;
                    }
                    argname++;
                }
            }
        } else
        #endif
        if (likely(PyUnicode_Check(key))) {
            while (*name) {
                int cmp = (**name == key) ? 0 :
                #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
                    (__Pyx_PyUnicode_GET_LENGTH(**name) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
                #endif
                    PyUnicode_Compare(**name, key);
                if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
                if (cmp == 0) {
                    values[name-argnames] = value;
                    break;
                }
                name++;
            }
            if (*name) continue;
            else {
                PyObject*** argname = argnames;
                while (argname != first_kw_arg) {
                    int cmp = (**argname == key) ? 0 :
                    #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
                        (__Pyx_PyUnicode_GET_LENGTH(**argname) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
                    #endif
                        PyUnicode_Compare(**argname, key);
                    if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
                    if (cmp == 0) goto arg_passed_twice;
                    argname++;
                }
            }
        } else
            goto invalid_keyword_type;
        if (kwds2) {
            if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
        } else {
            goto invalid_keyword;
        }
    }
    return 0;
arg_passed_twice:
    __Pyx_RaiseDoubleKeywordsError(function_name, key);
    goto bad;
invalid_keyword_type:
    PyErr_Format(PyExc_TypeError,
        "%.200s() keywords must be strings", function_name);
    goto bad;
invalid_keyword:
    PyErr_Format(PyExc_TypeError,
    #if PY_MAJOR_VERSION < 3
        "%.200s() got an unexpected keyword argument '%.200s'",
        function_name, PyString_AsString(key));
    #else
        "%s() got an unexpected keyword argument '%U'",
        function_name, key);
    #endif
bad:
    return -1;
}

/* ArgTypeTest */
static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact)
{
    if (unlikely(!type)) {
        PyErr_SetString(PyExc_SystemError, "Missing type object");
        return 0;
    }
    else if (exact) {
        #if PY_MAJOR_VERSION == 2
        if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1;
        #endif
    }
    else {
        if (likely(__Pyx_TypeCheck(obj, type))) return 1;
    }
    PyErr_Format(PyExc_TypeError,
        "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)",
        name, type->tp_name, Py_TYPE(obj)->tp_name);
    return 0;
}

/* PyObjectCall */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
    PyObject *result;
    ternaryfunc call = func->ob_type->tp_call;
    if (unlikely(!call))
        return PyObject_Call(func, arg, kw);
    if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
        return NULL;
    result = (*call)(func, arg, kw);
    Py_LeaveRecursiveCall();
    if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
        PyErr_SetString(
            PyExc_SystemError,
            "NULL result without error in PyObject_Call");
    }
    return result;
}
#endif

/* PyFunctionFastCall */
#if CYTHON_FAST_PYCALL
static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na,
                                               PyObject *globals) {
    PyFrameObject *f;
    PyThreadState *tstate = __Pyx_PyThreadState_Current;
    PyObject **fastlocals;
    Py_ssize_t i;
    PyObject *result;
    assert(globals != NULL);
    /* XXX Perhaps we should create a specialized
       PyFrame_New() that doesn't take locals, but does
       take builtins without sanity checking them.
       */
    assert(tstate != NULL);
    f = PyFrame_New(tstate, co, globals, NULL);
    if (f == NULL) {
        return NULL;
    }
    fastlocals = __Pyx_PyFrame_GetLocalsplus(f);
    for (i = 0; i < na; i++) {
        Py_INCREF(*args);
        fastlocals[i] = *args++;
    }
    result = PyEval_EvalFrameEx(f,0);
    ++tstate->recursion_depth;
    Py_DECREF(f);
    --tstate->recursion_depth;
    return result;
}
#if 1 || PY_VERSION_HEX < 0x030600B1
static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs) {
    PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func);
    PyObject *globals = PyFunction_GET_GLOBALS(func);
    PyObject *argdefs = PyFunction_GET_DEFAULTS(func);
    PyObject *closure;
#if PY_MAJOR_VERSION >= 3
    PyObject *kwdefs;
#endif
    PyObject *kwtuple, **k;
    PyObject **d;
    Py_ssize_t nd;
    Py_ssize_t nk;
    PyObject *result;
    assert(kwargs == NULL || PyDict_Check(kwargs));
    nk = kwargs ? PyDict_Size(kwargs) : 0;
    if (Py_EnterRecursiveCall((char*)" while calling a Python object")) {
        return NULL;
    }
    if (
#if PY_MAJOR_VERSION >= 3
            co->co_kwonlyargcount == 0 &&
#endif
            likely(kwargs == NULL || nk == 0) &&
            co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) {
        if (argdefs == NULL && co->co_argcount == nargs) {
            result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals);
            goto done;
        }
        else if (nargs == 0 && argdefs != NULL
                 && co->co_argcount == Py_SIZE(argdefs)) {
            /* function called with no arguments, but all parameters have
               a default value: use default values as arguments .*/
            args = &PyTuple_GET_ITEM(argdefs, 0);
            result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals);
            goto done;
        }
    }
    if (kwargs != NULL) {
        Py_ssize_t pos, i;
        kwtuple = PyTuple_New(2 * nk);
        if (kwtuple == NULL) {
            result = NULL;
            goto done;
        }
        k = &PyTuple_GET_ITEM(kwtuple, 0);
        pos = i = 0;
        while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) {
            Py_INCREF(k[i]);
            Py_INCREF(k[i+1]);
            i += 2;
        }
        nk = i / 2;
    }
    else {
        kwtuple = NULL;
        k = NULL;
    }
    closure = PyFunction_GET_CLOSURE(func);
#if PY_MAJOR_VERSION >= 3
    kwdefs = PyFunction_GET_KW_DEFAULTS(func);
#endif
    if (argdefs != NULL) {
        d = &PyTuple_GET_ITEM(argdefs, 0);
        nd = Py_SIZE(argdefs);
    }
    else {
        d = NULL;
        nd = 0;
    }
#if PY_MAJOR_VERSION >= 3
    result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL,
                               args, (int)nargs,
                               k, (int)nk,
                               d, (int)nd, kwdefs, closure);
#else
    result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL,
                               args, (int)nargs,
                               k, (int)nk,
                               d, (int)nd, closure);
#endif
    Py_XDECREF(kwtuple);
done:
    Py_LeaveRecursiveCall();
    return result;
}
#endif
#endif

/* PyCFunctionFastCall */
#if CYTHON_FAST_PYCCALL
static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) {
    PyCFunctionObject *func = (PyCFunctionObject*)func_obj;
    PyCFunction meth = PyCFunction_GET_FUNCTION(func);
    PyObject *self = PyCFunction_GET_SELF(func);
    int flags = PyCFunction_GET_FLAGS(func);
    assert(PyCFunction_Check(func));
    assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)));
    assert(nargs >= 0);
    assert(nargs == 0 || args != NULL);
    /* _PyCFunction_FastCallDict() must not be called with an exception set,
       because it may clear it (directly or indirectly) and so the
       caller loses its exception */
    assert(!PyErr_Occurred());
    if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) {
        return (*((__Pyx_PyCFunctionFastWithKeywords)(void*)meth)) (self, args, nargs, NULL);
    } else {
        return (*((__Pyx_PyCFunctionFast)(void*)meth)) (self, args, nargs);
    }
}
#endif

/* PyDictVersioning */
#if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) {
    PyObject *dict = Py_TYPE(obj)->tp_dict;
    return likely(dict) ? __PYX_GET_DICT_VERSION(dict) : 0;
}
static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj) {
    PyObject **dictptr = NULL;
    Py_ssize_t offset = Py_TYPE(obj)->tp_dictoffset;
    if (offset) {
#if CYTHON_COMPILING_IN_CPYTHON
        dictptr = (likely(offset > 0)) ? (PyObject **) ((char *)obj + offset) : _PyObject_GetDictPtr(obj);
#else
        dictptr = _PyObject_GetDictPtr(obj);
#endif
    }
    return (dictptr && *dictptr) ? __PYX_GET_DICT_VERSION(*dictptr) : 0;
}
static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version) {
    PyObject *dict = Py_TYPE(obj)->tp_dict;
    if (unlikely(!dict) || unlikely(tp_dict_version != __PYX_GET_DICT_VERSION(dict)))
        return 0;
    return obj_dict_version == __Pyx_get_object_dict_version(obj);
}
#endif

/* GetModuleGlobalName */
#if CYTHON_USE_DICT_VERSIONS
static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value)
#else
static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name)
#endif
{
    PyObject *result;
#if !CYTHON_AVOID_BORROWED_REFS
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1
    result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash);
    __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
    if (likely(result)) {
        return __Pyx_NewRef(result);
    } else if (unlikely(PyErr_Occurred())) {
        return NULL;
    }
#else
    result = PyDict_GetItem(__pyx_d, name);
    __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
    if (likely(result)) {
        return __Pyx_NewRef(result);
    }
#endif
#else
    result = PyObject_GetItem(__pyx_d, name);
    __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
    if (likely(result)) {
        return __Pyx_NewRef(result);
    }
    PyErr_Clear();
#endif
    return __Pyx_GetBuiltinName(name);
}

/* PyObjectCallMethO */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
    PyObject *self, *result;
    PyCFunction cfunc;
    cfunc = PyCFunction_GET_FUNCTION(func);
    self = PyCFunction_GET_SELF(func);
    if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
        return NULL;
    result = cfunc(self, arg);
    Py_LeaveRecursiveCall();
    if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
        PyErr_SetString(
            PyExc_SystemError,
            "NULL result without error in PyObject_Call");
    }
    return result;
}
#endif

/* PyObjectCallOneArg */
#if CYTHON_COMPILING_IN_CPYTHON
static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
    PyObject *result;
    PyObject *args = PyTuple_New(1);
    if (unlikely(!args)) return NULL;
    Py_INCREF(arg);
    PyTuple_SET_ITEM(args, 0, arg);
    result = __Pyx_PyObject_Call(func, args, NULL);
    Py_DECREF(args);
    return result;
}
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
#if CYTHON_FAST_PYCALL
    if (PyFunction_Check(func)) {
        return __Pyx_PyFunction_FastCall(func, &arg, 1);
    }
#endif
    if (likely(PyCFunction_Check(func))) {
        if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
            return __Pyx_PyObject_CallMethO(func, arg);
#if CYTHON_FAST_PYCCALL
        } else if (PyCFunction_GET_FLAGS(func) & METH_FASTCALL) {
            return __Pyx_PyCFunction_FastCall(func, &arg, 1);
#endif
        }
    }
    return __Pyx__PyObject_CallOneArg(func, arg);
}
#else
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
    PyObject *result;
    PyObject *args = PyTuple_Pack(1, arg);
    if (unlikely(!args)) return NULL;
    result = __Pyx_PyObject_Call(func, args, NULL);
    Py_DECREF(args);
    return result;
}
#endif

/* PyObjectCall2Args */
static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2) {
    PyObject *args, *result = NULL;
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(function)) {
        PyObject *args[2] = {arg1, arg2};
        return __Pyx_PyFunction_FastCall(function, args, 2);
    }
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(function)) {
        PyObject *args[2] = {arg1, arg2};
        return __Pyx_PyCFunction_FastCall(function, args, 2);
    }
    #endif
    args = PyTuple_New(2);
    if (unlikely(!args)) goto done;
    Py_INCREF(arg1);
    PyTuple_SET_ITEM(args, 0, arg1);
    Py_INCREF(arg2);
    PyTuple_SET_ITEM(args, 1, arg2);
    Py_INCREF(function);
    result = __Pyx_PyObject_Call(function, args, NULL);
    Py_DECREF(args);
    Py_DECREF(function);
done:
    return result;
}

/* PyErrFetchRestore */
#if CYTHON_FAST_THREAD_STATE
static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    tmp_type = tstate->curexc_type;
    tmp_value = tstate->curexc_value;
    tmp_tb = tstate->curexc_traceback;
    tstate->curexc_type = type;
    tstate->curexc_value = value;
    tstate->curexc_traceback = tb;
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
}
static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
    *type = tstate->curexc_type;
    *value = tstate->curexc_value;
    *tb = tstate->curexc_traceback;
    tstate->curexc_type = 0;
    tstate->curexc_value = 0;
    tstate->curexc_traceback = 0;
}
#endif

/* WriteUnraisableException */
static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno,
                                  CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename,
                                  int full_traceback, CYTHON_UNUSED int nogil) {
    PyObject *old_exc, *old_val, *old_tb;
    PyObject *ctx;
    __Pyx_PyThreadState_declare
#ifdef WITH_THREAD
    PyGILState_STATE state;
    if (nogil)
        state = PyGILState_Ensure();
#ifdef _MSC_VER
    else state = (PyGILState_STATE)-1;
#endif
#endif
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&old_exc, &old_val, &old_tb);
    if (full_traceback) {
        Py_XINCREF(old_exc);
        Py_XINCREF(old_val);
        Py_XINCREF(old_tb);
        __Pyx_ErrRestore(old_exc, old_val, old_tb);
        PyErr_PrintEx(1);
    }
    #if PY_MAJOR_VERSION < 3
    ctx = PyString_FromString(name);
    #else
    ctx = PyUnicode_FromString(name);
    #endif
    __Pyx_ErrRestore(old_exc, old_val, old_tb);
    if (!ctx) {
        PyErr_WriteUnraisable(Py_None);
    } else {
        PyErr_WriteUnraisable(ctx);
        Py_DECREF(ctx);
    }
#ifdef WITH_THREAD
    if (nogil)
        PyGILState_Release(state);
#endif
}

/* UnpackUnboundCMethod */
static int __Pyx_TryUnpackUnboundCMethod(__Pyx_CachedCFunction* target) {
    PyObject *method;
    method = __Pyx_PyObject_GetAttrStr(target->type, *target->method_name);
    if (unlikely(!method))
        return -1;
    target->method = method;
#if CYTHON_COMPILING_IN_CPYTHON
    #if PY_MAJOR_VERSION >= 3
    if (likely(__Pyx_TypeCheck(method, &PyMethodDescr_Type)))
    #endif
    {
        PyMethodDescrObject *descr = (PyMethodDescrObject*) method;
        target->func = descr->d_method->ml_meth;
        target->flag = descr->d_method->ml_flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_STACKLESS);
    }
#endif
    return 0;
}

/* CallUnboundCMethod0 */
static PyObject* __Pyx__CallUnboundCMethod0(__Pyx_CachedCFunction* cfunc, PyObject* self) {
    PyObject *args, *result = NULL;
    if (unlikely(!cfunc->method) && unlikely(__Pyx_TryUnpackUnboundCMethod(cfunc) < 0)) return NULL;
#if CYTHON_ASSUME_SAFE_MACROS
    args = PyTuple_New(1);
    if (unlikely(!args)) goto bad;
    Py_INCREF(self);
    PyTuple_SET_ITEM(args, 0, self);
#else
    args = PyTuple_Pack(1, self);
    if (unlikely(!args)) goto bad;
#endif
    result = __Pyx_PyObject_Call(cfunc->method, args, NULL);
    Py_DECREF(args);
bad:
    return result;
}

/* py_dict_keys */
static CYTHON_INLINE PyObject* __Pyx_PyDict_Keys(PyObject* d) {
    if (PY_MAJOR_VERSION >= 3)
        return __Pyx_CallUnboundCMethod0(&__pyx_umethod_PyDict_Type_keys, d);
    else
        return PyDict_Keys(d);
}

/* DictGetItem */
#if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY
static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) {
    PyObject *value;
    value = PyDict_GetItemWithError(d, key);
    if (unlikely(!value)) {
        if (!PyErr_Occurred()) {
            if (unlikely(PyTuple_Check(key))) {
                PyObject* args = PyTuple_Pack(1, key);
                if (likely(args)) {
                    PyErr_SetObject(PyExc_KeyError, args);
                    Py_DECREF(args);
                }
            } else {
                PyErr_SetObject(PyExc_KeyError, key);
            }
        }
        return NULL;
    }
    Py_INCREF(value);
    return value;
}
#endif

/* PyObjectCallNoArg */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
#if CYTHON_FAST_PYCALL
    if (PyFunction_Check(func)) {
        return __Pyx_PyFunction_FastCall(func, NULL, 0);
    }
#endif
#ifdef __Pyx_CyFunction_USED
    if (likely(PyCFunction_Check(func) || __Pyx_CyFunction_Check(func)))
#else
    if (likely(PyCFunction_Check(func)))
#endif
    {
        if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) {
            return __Pyx_PyObject_CallMethO(func, NULL);
        }
    }
    return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL);
}
#endif

/* GetItemInt */
static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
    PyObject *r;
    if (!j) return NULL;
    r = PyObject_GetItem(o, j);
    Py_DECREF(j);
    return r;
}
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
                                                              CYTHON_NCP_UNUSED int wraparound,
                                                              CYTHON_NCP_UNUSED int boundscheck) {
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    Py_ssize_t wrapped_i = i;
    if (wraparound & unlikely(i < 0)) {
        wrapped_i += PyList_GET_SIZE(o);
    }
    if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyList_GET_SIZE(o)))) {
        PyObject *r = PyList_GET_ITEM(o, wrapped_i);
        Py_INCREF(r);
        return r;
    }
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
#else
    return PySequence_GetItem(o, i);
#endif
}
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
                                                              CYTHON_NCP_UNUSED int wraparound,
                                                              CYTHON_NCP_UNUSED int boundscheck) {
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    Py_ssize_t wrapped_i = i;
    if (wraparound & unlikely(i < 0)) {
        wrapped_i += PyTuple_GET_SIZE(o);
    }
    if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyTuple_GET_SIZE(o)))) {
        PyObject *r = PyTuple_GET_ITEM(o, wrapped_i);
        Py_INCREF(r);
        return r;
    }
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
#else
    return PySequence_GetItem(o, i);
#endif
}
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list,
                                                     CYTHON_NCP_UNUSED int wraparound,
                                                     CYTHON_NCP_UNUSED int boundscheck) {
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS
    if (is_list || PyList_CheckExact(o)) {
        Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
        if ((!boundscheck) || (likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o))))) {
            PyObject *r = PyList_GET_ITEM(o, n);
            Py_INCREF(r);
            return r;
        }
    }
    else if (PyTuple_CheckExact(o)) {
        Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
        if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyTuple_GET_SIZE(o)))) {
            PyObject *r = PyTuple_GET_ITEM(o, n);
            Py_INCREF(r);
            return r;
        }
    } else {
        PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
        if (likely(m && m->sq_item)) {
            if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
                Py_ssize_t l = m->sq_length(o);
                if (likely(l >= 0)) {
                    i += l;
                } else {
                    if (!PyErr_ExceptionMatches(PyExc_OverflowError))
                        return NULL;
                    PyErr_Clear();
                }
            }
            return m->sq_item(o, i);
        }
    }
#else
    if (is_list || PySequence_Check(o)) {
        return PySequence_GetItem(o, i);
    }
#endif
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
}

/* CallUnboundCMethod2 */
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030600B1
static CYTHON_INLINE PyObject *__Pyx_CallUnboundCMethod2(__Pyx_CachedCFunction *cfunc, PyObject *self, PyObject *arg1, PyObject *arg2) {
    if (likely(cfunc->func)) {
        PyObject *args[2] = {arg1, arg2};
        if (cfunc->flag == METH_FASTCALL) {
            #if PY_VERSION_HEX >= 0x030700A0
            return (*(__Pyx_PyCFunctionFast)(void*)(PyCFunction)cfunc->func)(self, args, 2);
            #else
            return (*(__Pyx_PyCFunctionFastWithKeywords)(void*)(PyCFunction)cfunc->func)(self, args, 2, NULL);
            #endif
        }
        #if PY_VERSION_HEX >= 0x030700A0
        if (cfunc->flag == (METH_FASTCALL | METH_KEYWORDS))
            return (*(__Pyx_PyCFunctionFastWithKeywords)(void*)(PyCFunction)cfunc->func)(self, args, 2, NULL);
        #endif
    }
    return __Pyx__CallUnboundCMethod2(cfunc, self, arg1, arg2);
}
#endif
static PyObject* __Pyx__CallUnboundCMethod2(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg1, PyObject* arg2){
    PyObject *args, *result = NULL;
    if (unlikely(!cfunc->func && !cfunc->method) && unlikely(__Pyx_TryUnpackUnboundCMethod(cfunc) < 0)) return NULL;
#if CYTHON_COMPILING_IN_CPYTHON
    if (cfunc->func && (cfunc->flag & METH_VARARGS)) {
        args = PyTuple_New(2);
        if (unlikely(!args)) goto bad;
        Py_INCREF(arg1);
        PyTuple_SET_ITEM(args, 0, arg1);
        Py_INCREF(arg2);
        PyTuple_SET_ITEM(args, 1, arg2);
        if (cfunc->flag & METH_KEYWORDS)
            result = (*(PyCFunctionWithKeywords)(void*)(PyCFunction)cfunc->func)(self, args, NULL);
        else
            result = (*cfunc->func)(self, args);
    } else {
        args = PyTuple_New(3);
        if (unlikely(!args)) goto bad;
        Py_INCREF(self);
        PyTuple_SET_ITEM(args, 0, self);
        Py_INCREF(arg1);
        PyTuple_SET_ITEM(args, 1, arg1);
        Py_INCREF(arg2);
        PyTuple_SET_ITEM(args, 2, arg2);
        result = __Pyx_PyObject_Call(cfunc->method, args, NULL);
    }
#else
    args = PyTuple_Pack(3, self, arg1, arg2);
    if (unlikely(!args)) goto bad;
    result = __Pyx_PyObject_Call(cfunc->method, args, NULL);
#endif
bad:
    Py_XDECREF(args);
    return result;
}

/* dict_setdefault */
static CYTHON_INLINE PyObject *__Pyx_PyDict_SetDefault(PyObject *d, PyObject *key, PyObject *default_value,
                                                       CYTHON_UNUSED int is_safe_type) {
    PyObject* value;
#if PY_VERSION_HEX >= 0x030400A0
    if ((1)) {
        value = PyDict_SetDefault(d, key, default_value);
        if (unlikely(!value)) return NULL;
        Py_INCREF(value);
#else
    if (is_safe_type == 1 || (is_safe_type == -1 &&
#if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY
            (PyUnicode_CheckExact(key) || PyString_CheckExact(key) || PyLong_CheckExact(key)))) {
        value = PyDict_GetItemWithError(d, key);
        if (unlikely(!value)) {
            if (unlikely(PyErr_Occurred()))
                return NULL;
            if (unlikely(PyDict_SetItem(d, key, default_value) == -1))
                return NULL;
            value = default_value;
        }
        Py_INCREF(value);
#else
            (PyString_CheckExact(key) || PyUnicode_CheckExact(key) || PyInt_CheckExact(key) || PyLong_CheckExact(key)))) {
        value = PyDict_GetItem(d, key);
        if (unlikely(!value)) {
            if (unlikely(PyDict_SetItem(d, key, default_value) == -1))
                return NULL;
            value = default_value;
        }
        Py_INCREF(value);
#endif
#endif
    } else {
        value = __Pyx_CallUnboundCMethod2(&__pyx_umethod_PyDict_Type_setdefault, d, key, default_value);
    }
    return value;
}

/* ObjectGetItem */
    #if CYTHON_USE_TYPE_SLOTS
static PyObject *__Pyx_PyObject_GetIndex(PyObject *obj, PyObject* index) {
    PyObject *runerr;
    Py_ssize_t key_value;
    PySequenceMethods *m = Py_TYPE(obj)->tp_as_sequence;
    if (unlikely(!(m && m->sq_item))) {
        PyErr_Format(PyExc_TypeError, "'%.200s' object is not subscriptable", Py_TYPE(obj)->tp_name);
        return NULL;
    }
    key_value = __Pyx_PyIndex_AsSsize_t(index);
    if (likely(key_value != -1 || !(runerr = PyErr_Occurred()))) {
        return __Pyx_GetItemInt_Fast(obj, key_value, 0, 1, 1);
    }
    if (PyErr_GivenExceptionMatches(runerr, PyExc_OverflowError)) {
        PyErr_Clear();
        PyErr_Format(PyExc_IndexError, "cannot fit '%.200s' into an index-sized integer", Py_TYPE(index)->tp_name);
    }
    return NULL;
}
static PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key) {
    PyMappingMethods *m = Py_TYPE(obj)->tp_as_mapping;
    if (likely(m && m->mp_subscript)) {
        return m->mp_subscript(obj, key);
    }
    return __Pyx_PyObject_GetIndex(obj, key);
}
#endif

/* BytesEquals */
    static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) {
#if CYTHON_COMPILING_IN_PYPY
    return PyObject_RichCompareBool(s1, s2, equals);
#else
    if (s1 == s2) {
        return (equals == Py_EQ);
    } else if (PyBytes_CheckExact(s1) & PyBytes_CheckExact(s2)) {
        const char *ps1, *ps2;
        Py_ssize_t length = PyBytes_GET_SIZE(s1);
        if (length != PyBytes_GET_SIZE(s2))
            return (equals == Py_NE);
        ps1 = PyBytes_AS_STRING(s1);
        ps2 = PyBytes_AS_STRING(s2);
        if (ps1[0] != ps2[0]) {
            return (equals == Py_NE);
        } else if (length == 1) {
            return (equals == Py_EQ);
        } else {
            int result;
#if CYTHON_USE_UNICODE_INTERNALS
            Py_hash_t hash1, hash2;
            hash1 = ((PyBytesObject*)s1)->ob_shash;
            hash2 = ((PyBytesObject*)s2)->ob_shash;
            if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
                return (equals == Py_NE);
            }
#endif
            result = memcmp(ps1, ps2, (size_t)length);
            return (equals == Py_EQ) ? (result == 0) : (result != 0);
        }
    } else if ((s1 == Py_None) & PyBytes_CheckExact(s2)) {
        return (equals == Py_NE);
    } else if ((s2 == Py_None) & PyBytes_CheckExact(s1)) {
        return (equals == Py_NE);
    } else {
        int result;
        PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
        if (!py_result)
            return -1;
        result = __Pyx_PyObject_IsTrue(py_result);
        Py_DECREF(py_result);
        return result;
    }
#endif
}

/* UnicodeEquals */
    static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) {
#if CYTHON_COMPILING_IN_PYPY
    return PyObject_RichCompareBool(s1, s2, equals);
#else
#if PY_MAJOR_VERSION < 3
    PyObject* owned_ref = NULL;
#endif
    int s1_is_unicode, s2_is_unicode;
    if (s1 == s2) {
        goto return_eq;
    }
    s1_is_unicode = PyUnicode_CheckExact(s1);
    s2_is_unicode = PyUnicode_CheckExact(s2);
#if PY_MAJOR_VERSION < 3
    if ((s1_is_unicode & (!s2_is_unicode)) && PyString_CheckExact(s2)) {
        owned_ref = PyUnicode_FromObject(s2);
        if (unlikely(!owned_ref))
            return -1;
        s2 = owned_ref;
        s2_is_unicode = 1;
    } else if ((s2_is_unicode & (!s1_is_unicode)) && PyString_CheckExact(s1)) {
        owned_ref = PyUnicode_FromObject(s1);
        if (unlikely(!owned_ref))
            return -1;
        s1 = owned_ref;
        s1_is_unicode = 1;
    } else if (((!s2_is_unicode) & (!s1_is_unicode))) {
        return __Pyx_PyBytes_Equals(s1, s2, equals);
    }
#endif
    if (s1_is_unicode & s2_is_unicode) {
        Py_ssize_t length;
        int kind;
        void *data1, *data2;
        if (unlikely(__Pyx_PyUnicode_READY(s1) < 0) || unlikely(__Pyx_PyUnicode_READY(s2) < 0))
            return -1;
        length = __Pyx_PyUnicode_GET_LENGTH(s1);
        if (length != __Pyx_PyUnicode_GET_LENGTH(s2)) {
            goto return_ne;
        }
#if CYTHON_USE_UNICODE_INTERNALS
        {
            Py_hash_t hash1, hash2;
        #if CYTHON_PEP393_ENABLED
            hash1 = ((PyASCIIObject*)s1)->hash;
            hash2 = ((PyASCIIObject*)s2)->hash;
        #else
            hash1 = ((PyUnicodeObject*)s1)->hash;
            hash2 = ((PyUnicodeObject*)s2)->hash;
        #endif
            if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
                goto return_ne;
            }
        }
#endif
        kind = __Pyx_PyUnicode_KIND(s1);
        if (kind != __Pyx_PyUnicode_KIND(s2)) {
            goto return_ne;
        }
        data1 = __Pyx_PyUnicode_DATA(s1);
        data2 = __Pyx_PyUnicode_DATA(s2);
        if (__Pyx_PyUnicode_READ(kind, data1, 0) != __Pyx_PyUnicode_READ(kind, data2, 0)) {
            goto return_ne;
        } else if (length == 1) {
            goto return_eq;
        } else {
            int result = memcmp(data1, data2, (size_t)(length * kind));
            #if PY_MAJOR_VERSION < 3
            Py_XDECREF(owned_ref);
            #endif
            return (equals == Py_EQ) ? (result == 0) : (result != 0);
        }
    } else if ((s1 == Py_None) & s2_is_unicode) {
        goto return_ne;
    } else if ((s2 == Py_None) & s1_is_unicode) {
        goto return_ne;
    } else {
        int result;
        PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
        #if PY_MAJOR_VERSION < 3
        Py_XDECREF(owned_ref);
        #endif
        if (!py_result)
            return -1;
        result = __Pyx_PyObject_IsTrue(py_result);
        Py_DECREF(py_result);
        return result;
    }
return_eq:
    #if PY_MAJOR_VERSION < 3
    Py_XDECREF(owned_ref);
    #endif
    return (equals == Py_EQ);
return_ne:
    #if PY_MAJOR_VERSION < 3
    Py_XDECREF(owned_ref);
    #endif
    return (equals == Py_NE);
#endif
}

/* ExtTypeTest */
    static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
    if (unlikely(!type)) {
        PyErr_SetString(PyExc_SystemError, "Missing type object");
        return 0;
    }
    if (likely(__Pyx_TypeCheck(obj, type)))
        return 1;
    PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s",
                 Py_TYPE(obj)->tp_name, type->tp_name);
    return 0;
}

/* CallUnboundCMethod1 */
    #if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg) {
    if (likely(cfunc->func)) {
        int flag = cfunc->flag;
        if (flag == METH_O) {
            return (*(cfunc->func))(self, arg);
        } else if (PY_VERSION_HEX >= 0x030600B1 && flag == METH_FASTCALL) {
            if (PY_VERSION_HEX >= 0x030700A0) {
                return (*(__Pyx_PyCFunctionFast)(void*)(PyCFunction)cfunc->func)(self, &arg, 1);
            } else {
                return (*(__Pyx_PyCFunctionFastWithKeywords)(void*)(PyCFunction)cfunc->func)(self, &arg, 1, NULL);
            }
        } else if (PY_VERSION_HEX >= 0x030700A0 && flag == (METH_FASTCALL | METH_KEYWORDS)) {
            return (*(__Pyx_PyCFunctionFastWithKeywords)(void*)(PyCFunction)cfunc->func)(self, &arg, 1, NULL);
        }
    }
    return __Pyx__CallUnboundCMethod1(cfunc, self, arg);
}
#endif
static PyObject* __Pyx__CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg){
    PyObject *args, *result = NULL;
    if (unlikely(!cfunc->func && !cfunc->method) && unlikely(__Pyx_TryUnpackUnboundCMethod(cfunc) < 0)) return NULL;
#if CYTHON_COMPILING_IN_CPYTHON
    if (cfunc->func && (cfunc->flag & METH_VARARGS)) {
        args = PyTuple_New(1);
        if (unlikely(!args)) goto bad;
        Py_INCREF(arg);
        PyTuple_SET_ITEM(args, 0, arg);
        if (cfunc->flag & METH_KEYWORDS)
            result = (*(PyCFunctionWithKeywords)(void*)(PyCFunction)cfunc->func)(self, args, NULL);
        else
            result = (*cfunc->func)(self, args);
    } else {
        args = PyTuple_New(2);
        if (unlikely(!args)) goto bad;
        Py_INCREF(self);
        PyTuple_SET_ITEM(args, 0, self);
        Py_INCREF(arg);
        PyTuple_SET_ITEM(args, 1, arg);
        result = __Pyx_PyObject_Call(cfunc->method, args, NULL);
    }
#else
    args = PyTuple_Pack(2, self, arg);
    if (unlikely(!args)) goto bad;
    result = __Pyx_PyObject_Call(cfunc->method, args, NULL);
#endif
bad:
    Py_XDECREF(args);
    return result;
}

/* dict_getitem_default */
    static PyObject* __Pyx_PyDict_GetItemDefault(PyObject* d, PyObject* key, PyObject* default_value) {
    PyObject* value;
#if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY
    value = PyDict_GetItemWithError(d, key);
    if (unlikely(!value)) {
        if (unlikely(PyErr_Occurred()))
            return NULL;
        value = default_value;
    }
    Py_INCREF(value);
    if ((1));
#else
    if (PyString_CheckExact(key) || PyUnicode_CheckExact(key) || PyInt_CheckExact(key)) {
        value = PyDict_GetItem(d, key);
        if (unlikely(!value)) {
            value = default_value;
        }
        Py_INCREF(value);
    }
#endif
    else {
        if (default_value == Py_None)
            value = __Pyx_CallUnboundCMethod1(&__pyx_umethod_PyDict_Type_get, d, key);
        else
            value = __Pyx_CallUnboundCMethod2(&__pyx_umethod_PyDict_Type_get, d, key, default_value);
    }
    return value;
}

/* GetTopmostException */
    #if CYTHON_USE_EXC_INFO_STACK
static _PyErr_StackItem *
__Pyx_PyErr_GetTopmostException(PyThreadState *tstate)
{
    _PyErr_StackItem *exc_info = tstate->exc_info;
    while ((exc_info->exc_type == NULL || exc_info->exc_type == Py_None) &&
           exc_info->previous_item != NULL)
    {
        exc_info = exc_info->previous_item;
    }
    return exc_info;
}
#endif

/* SaveResetException */
    #if CYTHON_FAST_THREAD_STATE
static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
    #if CYTHON_USE_EXC_INFO_STACK
    _PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate);
    *type = exc_info->exc_type;
    *value = exc_info->exc_value;
    *tb = exc_info->exc_traceback;
    #else
    *type = tstate->exc_type;
    *value = tstate->exc_value;
    *tb = tstate->exc_traceback;
    #endif
    Py_XINCREF(*type);
    Py_XINCREF(*value);
    Py_XINCREF(*tb);
}
static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    #if CYTHON_USE_EXC_INFO_STACK
    _PyErr_StackItem *exc_info = tstate->exc_info;
    tmp_type = exc_info->exc_type;
    tmp_value = exc_info->exc_value;
    tmp_tb = exc_info->exc_traceback;
    exc_info->exc_type = type;
    exc_info->exc_value = value;
    exc_info->exc_traceback = tb;
    #else
    tmp_type = tstate->exc_type;
    tmp_value = tstate->exc_value;
    tmp_tb = tstate->exc_traceback;
    tstate->exc_type = type;
    tstate->exc_value = value;
    tstate->exc_traceback = tb;
    #endif
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
}
#endif

/* PyErrExceptionMatches */
    #if CYTHON_FAST_THREAD_STATE
static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
    Py_ssize_t i, n;
    n = PyTuple_GET_SIZE(tuple);
#if PY_MAJOR_VERSION >= 3
    for (i=0; i<n; i++) {
        if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
    }
#endif
    for (i=0; i<n; i++) {
        if (__Pyx_PyErr_GivenExceptionMatches(exc_type, PyTuple_GET_ITEM(tuple, i))) return 1;
    }
    return 0;
}
static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) {
    PyObject *exc_type = tstate->curexc_type;
    if (exc_type == err) return 1;
    if (unlikely(!exc_type)) return 0;
    if (unlikely(PyTuple_Check(err)))
        return __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err);
    return __Pyx_PyErr_GivenExceptionMatches(exc_type, err);
}
#endif

/* GetException */
    #if CYTHON_FAST_THREAD_STATE
static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb)
#else
static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb)
#endif
{
    PyObject *local_type, *local_value, *local_tb;
#if CYTHON_FAST_THREAD_STATE
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    local_type = tstate->curexc_type;
    local_value = tstate->curexc_value;
    local_tb = tstate->curexc_traceback;
    tstate->curexc_type = 0;
    tstate->curexc_value = 0;
    tstate->curexc_traceback = 0;
#else
    PyErr_Fetch(&local_type, &local_value, &local_tb);
#endif
    PyErr_NormalizeException(&local_type, &local_value, &local_tb);
#if CYTHON_FAST_THREAD_STATE
    if (unlikely(tstate->curexc_type))
#else
    if (unlikely(PyErr_Occurred()))
#endif
        goto bad;
    #if PY_MAJOR_VERSION >= 3
    if (local_tb) {
        if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
            goto bad;
    }
    #endif
    Py_XINCREF(local_tb);
    Py_XINCREF(local_type);
    Py_XINCREF(local_value);
    *type = local_type;
    *value = local_value;
    *tb = local_tb;
#if CYTHON_FAST_THREAD_STATE
    #if CYTHON_USE_EXC_INFO_STACK
    {
        _PyErr_StackItem *exc_info = tstate->exc_info;
        tmp_type = exc_info->exc_type;
        tmp_value = exc_info->exc_value;
        tmp_tb = exc_info->exc_traceback;
        exc_info->exc_type = local_type;
        exc_info->exc_value = local_value;
        exc_info->exc_traceback = local_tb;
    }
    #else
    tmp_type = tstate->exc_type;
    tmp_value = tstate->exc_value;
    tmp_tb = tstate->exc_traceback;
    tstate->exc_type = local_type;
    tstate->exc_value = local_value;
    tstate->exc_traceback = local_tb;
    #endif
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
#else
    PyErr_SetExcInfo(local_type, local_value, local_tb);
#endif
    return 0;
bad:
    *type = 0;
    *value = 0;
    *tb = 0;
    Py_XDECREF(local_type);
    Py_XDECREF(local_value);
    Py_XDECREF(local_tb);
    return -1;
}

/* RaiseException */
    #if PY_MAJOR_VERSION < 3
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
                        CYTHON_UNUSED PyObject *cause) {
    __Pyx_PyThreadState_declare
    Py_XINCREF(type);
    if (!value || value == Py_None)
        value = NULL;
    else
        Py_INCREF(value);
    if (!tb || tb == Py_None)
        tb = NULL;
    else {
        Py_INCREF(tb);
        if (!PyTraceBack_Check(tb)) {
            PyErr_SetString(PyExc_TypeError,
                "raise: arg 3 must be a traceback or None");
            goto raise_error;
        }
    }
    if (PyType_Check(type)) {
#if CYTHON_COMPILING_IN_PYPY
        if (!value) {
            Py_INCREF(Py_None);
            value = Py_None;
        }
#endif
        PyErr_NormalizeException(&type, &value, &tb);
    } else {
        if (value) {
            PyErr_SetString(PyExc_TypeError,
                "instance exception may not have a separate value");
            goto raise_error;
        }
        value = type;
        type = (PyObject*) Py_TYPE(type);
        Py_INCREF(type);
        if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
            PyErr_SetString(PyExc_TypeError,
                "raise: exception class must be a subclass of BaseException");
            goto raise_error;
        }
    }
    __Pyx_PyThreadState_assign
    __Pyx_ErrRestore(type, value, tb);
    return;
raise_error:
    Py_XDECREF(value);
    Py_XDECREF(type);
    Py_XDECREF(tb);
    return;
}
#else
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
    PyObject* owned_instance = NULL;
    if (tb == Py_None) {
        tb = 0;
    } else if (tb && !PyTraceBack_Check(tb)) {
        PyErr_SetString(PyExc_TypeError,
            "raise: arg 3 must be a traceback or None");
        goto bad;
    }
    if (value == Py_None)
        value = 0;
    if (PyExceptionInstance_Check(type)) {
        if (value) {
            PyErr_SetString(PyExc_TypeError,
                "instance exception may not have a separate value");
            goto bad;
        }
        value = type;
        type = (PyObject*) Py_TYPE(value);
    } else if (PyExceptionClass_Check(type)) {
        PyObject *instance_class = NULL;
        if (value && PyExceptionInstance_Check(value)) {
            instance_class = (PyObject*) Py_TYPE(value);
            if (instance_class != type) {
                int is_subclass = PyObject_IsSubclass(instance_class, type);
                if (!is_subclass) {
                    instance_class = NULL;
                } else if (unlikely(is_subclass == -1)) {
                    goto bad;
                } else {
                    type = instance_class;
                }
            }
        }
        if (!instance_class) {
            PyObject *args;
            if (!value)
                args = PyTuple_New(0);
            else if (PyTuple_Check(value)) {
                Py_INCREF(value);
                args = value;
            } else
                args = PyTuple_Pack(1, value);
            if (!args)
                goto bad;
            owned_instance = PyObject_Call(type, args, NULL);
            Py_DECREF(args);
            if (!owned_instance)
                goto bad;
            value = owned_instance;
            if (!PyExceptionInstance_Check(value)) {
                PyErr_Format(PyExc_TypeError,
                             "calling %R should have returned an instance of "
                             "BaseException, not %R",
                             type, Py_TYPE(value));
                goto bad;
            }
        }
    } else {
        PyErr_SetString(PyExc_TypeError,
            "raise: exception class must be a subclass of BaseException");
        goto bad;
    }
    if (cause) {
        PyObject *fixed_cause;
        if (cause == Py_None) {
            fixed_cause = NULL;
        } else if (PyExceptionClass_Check(cause)) {
            fixed_cause = PyObject_CallObject(cause, NULL);
            if (fixed_cause == NULL)
                goto bad;
        } else if (PyExceptionInstance_Check(cause)) {
            fixed_cause = cause;
            Py_INCREF(fixed_cause);
        } else {
            PyErr_SetString(PyExc_TypeError,
                            "exception causes must derive from "
                            "BaseException");
            goto bad;
        }
        PyException_SetCause(value, fixed_cause);
    }
    PyErr_SetObject(type, value);
    if (tb) {
#if CYTHON_COMPILING_IN_PYPY
        PyObject *tmp_type, *tmp_value, *tmp_tb;
        PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb);
        Py_INCREF(tb);
        PyErr_Restore(tmp_type, tmp_value, tb);
        Py_XDECREF(tmp_tb);
#else
        PyThreadState *tstate = __Pyx_PyThreadState_Current;
        PyObject* tmp_tb = tstate->curexc_traceback;
        if (tb != tmp_tb) {
            Py_INCREF(tb);
            tstate->curexc_traceback = tb;
            Py_XDECREF(tmp_tb);
        }
#endif
    }
bad:
    Py_XDECREF(owned_instance);
    return;
}
#endif

/* None */
    static CYTHON_INLINE int __Pyx_div_int(int a, int b) {
    int q = a / b;
    int r = a - q*b;
    q -= ((r != 0) & ((r ^ b) < 0));
    return q;
}

/* CallNextTpDealloc */
    static void __Pyx_call_next_tp_dealloc(PyObject* obj, destructor current_tp_dealloc) {
    PyTypeObject* type = Py_TYPE(obj);
    while (type && type->tp_dealloc != current_tp_dealloc)
        type = type->tp_base;
    while (type && type->tp_dealloc == current_tp_dealloc)
        type = type->tp_base;
    if (type)
        type->tp_dealloc(obj);
}

/* CallNextTpTraverse */
    static int __Pyx_call_next_tp_traverse(PyObject* obj, visitproc v, void *a, traverseproc current_tp_traverse) {
    PyTypeObject* type = Py_TYPE(obj);
    while (type && type->tp_traverse != current_tp_traverse)
        type = type->tp_base;
    while (type && type->tp_traverse == current_tp_traverse)
        type = type->tp_base;
    if (type && type->tp_traverse)
        return type->tp_traverse(obj, v, a);
    return 0;
}

/* CallNextTpClear */
    static void __Pyx_call_next_tp_clear(PyObject* obj, inquiry current_tp_clear) {
    PyTypeObject* type = Py_TYPE(obj);
    while (type && type->tp_clear != current_tp_clear)
        type = type->tp_base;
    while (type && type->tp_clear == current_tp_clear)
        type = type->tp_base;
    if (type && type->tp_clear)
        type->tp_clear(obj);
}

/* TypeImport */
    #ifndef __PYX_HAVE_RT_ImportType
#define __PYX_HAVE_RT_ImportType
static PyTypeObject *__Pyx_ImportType(PyObject *module, const char *module_name, const char *class_name,
    size_t size, enum __Pyx_ImportType_CheckSize check_size)
{
    PyObject *result = 0;
    char warning[200];
    Py_ssize_t basicsize;
#ifdef Py_LIMITED_API
    PyObject *py_basicsize;
#endif
    result = PyObject_GetAttrString(module, class_name);
    if (!result)
        goto bad;
    if (!PyType_Check(result)) {
        PyErr_Format(PyExc_TypeError,
            "%.200s.%.200s is not a type object",
            module_name, class_name);
        goto bad;
    }
#ifndef Py_LIMITED_API
    basicsize = ((PyTypeObject *)result)->tp_basicsize;
#else
    py_basicsize = PyObject_GetAttrString(result, "__basicsize__");
    if (!py_basicsize)
        goto bad;
    basicsize = PyLong_AsSsize_t(py_basicsize);
    Py_DECREF(py_basicsize);
    py_basicsize = 0;
    if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred())
        goto bad;
#endif
    if ((size_t)basicsize < size) {
        PyErr_Format(PyExc_ValueError,
            "%.200s.%.200s size changed, may indicate binary incompatibility. "
            "Expected %zd from C header, got %zd from PyObject",
            module_name, class_name, size, basicsize);
        goto bad;
    }
    if (check_size == __Pyx_ImportType_CheckSize_Error && (size_t)basicsize != size) {
        PyErr_Format(PyExc_ValueError,
            "%.200s.%.200s size changed, may indicate binary incompatibility. "
            "Expected %zd from C header, got %zd from PyObject",
            module_name, class_name, size, basicsize);
        goto bad;
    }
    else if (check_size == __Pyx_ImportType_CheckSize_Warn && (size_t)basicsize > size) {
        PyOS_snprintf(warning, sizeof(warning),
            "%s.%s size changed, may indicate binary incompatibility. "
            "Expected %zd from C header, got %zd from PyObject",
            module_name, class_name, size, basicsize);
        if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad;
    }
    return (PyTypeObject *)result;
bad:
    Py_XDECREF(result);
    return NULL;
}
#endif

/* GetVTable */
    static void* __Pyx_GetVtable(PyObject *dict) {
    void* ptr;
    PyObject *ob = PyObject_GetItem(dict, __pyx_n_s_pyx_vtable);
    if (!ob)
        goto bad;
#if PY_VERSION_HEX >= 0x02070000
    ptr = PyCapsule_GetPointer(ob, 0);
#else
    ptr = PyCObject_AsVoidPtr(ob);
#endif
    if (!ptr && !PyErr_Occurred())
        PyErr_SetString(PyExc_RuntimeError, "invalid vtable found for imported type");
    Py_DECREF(ob);
    return ptr;
bad:
    Py_XDECREF(ob);
    return NULL;
}

/* PyObject_GenericGetAttrNoDict */
    #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
static PyObject *__Pyx_RaiseGenericGetAttributeError(PyTypeObject *tp, PyObject *attr_name) {
    PyErr_Format(PyExc_AttributeError,
#if PY_MAJOR_VERSION >= 3
                 "'%.50s' object has no attribute '%U'",
                 tp->tp_name, attr_name);
#else
                 "'%.50s' object has no attribute '%.400s'",
                 tp->tp_name, PyString_AS_STRING(attr_name));
#endif
    return NULL;
}
static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name) {
    PyObject *descr;
    PyTypeObject *tp = Py_TYPE(obj);
    if (unlikely(!PyString_Check(attr_name))) {
        return PyObject_GenericGetAttr(obj, attr_name);
    }
    assert(!tp->tp_dictoffset);
    descr = _PyType_Lookup(tp, attr_name);
    if (unlikely(!descr)) {
        return __Pyx_RaiseGenericGetAttributeError(tp, attr_name);
    }
    Py_INCREF(descr);
    #if PY_MAJOR_VERSION < 3
    if (likely(PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_HAVE_CLASS)))
    #endif
    {
        descrgetfunc f = Py_TYPE(descr)->tp_descr_get;
        if (unlikely(f)) {
            PyObject *res = f(descr, obj, (PyObject *)tp);
            Py_DECREF(descr);
            return res;
        }
    }
    return descr;
}
#endif

/* PyObject_GenericGetAttr */
    #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name) {
    if (unlikely(Py_TYPE(obj)->tp_dictoffset)) {
        return PyObject_GenericGetAttr(obj, attr_name);
    }
    return __Pyx_PyObject_GenericGetAttrNoDict(obj, attr_name);
}
#endif

/* SetVTable */
    static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
#if PY_VERSION_HEX >= 0x02070000
    PyObject *ob = PyCapsule_New(vtable, 0, 0);
#else
    PyObject *ob = PyCObject_FromVoidPtr(vtable, 0);
#endif
    if (!ob)
        goto bad;
    if (PyDict_SetItem(dict, __pyx_n_s_pyx_vtable, ob) < 0)
        goto bad;
    Py_DECREF(ob);
    return 0;
bad:
    Py_XDECREF(ob);
    return -1;
}

/* PyObjectGetAttrStrNoError */
    static void __Pyx_PyObject_GetAttrStr_ClearAttributeError(void) {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    if (likely(__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
        __Pyx_PyErr_Clear();
}
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name) {
    PyObject *result;
#if CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_TYPE_SLOTS && PY_VERSION_HEX >= 0x030700B1
    PyTypeObject* tp = Py_TYPE(obj);
    if (likely(tp->tp_getattro == PyObject_GenericGetAttr)) {
        return _PyObject_GenericGetAttrWithDict(obj, attr_name, NULL, 1);
    }
#endif
    result = __Pyx_PyObject_GetAttrStr(obj, attr_name);
    if (unlikely(!result)) {
        __Pyx_PyObject_GetAttrStr_ClearAttributeError();
    }
    return result;
}

/* SetupReduce */
    static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) {
  int ret;
  PyObject *name_attr;
  name_attr = __Pyx_PyObject_GetAttrStr(meth, __pyx_n_s_name_2);
  if (likely(name_attr)) {
      ret = PyObject_RichCompareBool(name_attr, name, Py_EQ);
  } else {
      ret = -1;
  }
  if (unlikely(ret < 0)) {
      PyErr_Clear();
      ret = 0;
  }
  Py_XDECREF(name_attr);
  return ret;
}
static int __Pyx_setup_reduce(PyObject* type_obj) {
    int ret = 0;
    PyObject *object_reduce = NULL;
    PyObject *object_reduce_ex = NULL;
    PyObject *reduce = NULL;
    PyObject *reduce_ex = NULL;
    PyObject *reduce_cython = NULL;
    PyObject *setstate = NULL;
    PyObject *setstate_cython = NULL;
#if CYTHON_USE_PYTYPE_LOOKUP
    if (_PyType_Lookup((PyTypeObject*)type_obj, __pyx_n_s_getstate)) goto __PYX_GOOD;
#else
    if (PyObject_HasAttr(type_obj, __pyx_n_s_getstate)) goto __PYX_GOOD;
#endif
#if CYTHON_USE_PYTYPE_LOOKUP
    object_reduce_ex = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto __PYX_BAD;
#else
    object_reduce_ex = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto __PYX_BAD;
#endif
    reduce_ex = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_ex); if (unlikely(!reduce_ex)) goto __PYX_BAD;
    if (reduce_ex == object_reduce_ex) {
#if CYTHON_USE_PYTYPE_LOOKUP
        object_reduce = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto __PYX_BAD;
#else
        object_reduce = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto __PYX_BAD;
#endif
        reduce = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce); if (unlikely(!reduce)) goto __PYX_BAD;
        if (reduce == object_reduce || __Pyx_setup_reduce_is_named(reduce, __pyx_n_s_reduce_cython)) {
            reduce_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_n_s_reduce_cython);
            if (likely(reduce_cython)) {
                ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce, reduce_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
                ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
            } else if (reduce == object_reduce || PyErr_Occurred()) {
                goto __PYX_BAD;
            }
            setstate = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate);
            if (!setstate) PyErr_Clear();
            if (!setstate || __Pyx_setup_reduce_is_named(setstate, __pyx_n_s_setstate_cython)) {
                setstate_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_n_s_setstate_cython);
                if (likely(setstate_cython)) {
                    ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate, setstate_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
                    ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
                } else if (!setstate || PyErr_Occurred()) {
                    goto __PYX_BAD;
                }
            }
            PyType_Modified((PyTypeObject*)type_obj);
        }
    }
    goto __PYX_GOOD;
__PYX_BAD:
    if (!PyErr_Occurred())
        PyErr_Format(PyExc_RuntimeError, "Unable to initialize pickling for %s", ((PyTypeObject*)type_obj)->tp_name);
    ret = -1;
__PYX_GOOD:
#if !CYTHON_USE_PYTYPE_LOOKUP
    Py_XDECREF(object_reduce);
    Py_XDECREF(object_reduce_ex);
#endif
    Py_XDECREF(reduce);
    Py_XDECREF(reduce_ex);
    Py_XDECREF(reduce_cython);
    Py_XDECREF(setstate);
    Py_XDECREF(setstate_cython);
    return ret;
}

/* Import */
    static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
    PyObject *empty_list = 0;
    PyObject *module = 0;
    PyObject *global_dict = 0;
    PyObject *empty_dict = 0;
    PyObject *list;
    #if PY_MAJOR_VERSION < 3
    PyObject *py_import;
    py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import);
    if (!py_import)
        goto bad;
    #endif
    if (from_list)
        list = from_list;
    else {
        empty_list = PyList_New(0);
        if (!empty_list)
            goto bad;
        list = empty_list;
    }
    global_dict = PyModule_GetDict(__pyx_m);
    if (!global_dict)
        goto bad;
    empty_dict = PyDict_New();
    if (!empty_dict)
        goto bad;
    {
        #if PY_MAJOR_VERSION >= 3
        if (level == -1) {
            if ((1) && (strchr(__Pyx_MODULE_NAME, '.'))) {
                module = PyImport_ImportModuleLevelObject(
                    name, global_dict, empty_dict, list, 1);
                if (!module) {
                    if (!PyErr_ExceptionMatches(PyExc_ImportError))
                        goto bad;
                    PyErr_Clear();
                }
            }
            level = 0;
        }
        #endif
        if (!module) {
            #if PY_MAJOR_VERSION < 3
            PyObject *py_level = PyInt_FromLong(level);
            if (!py_level)
                goto bad;
            module = PyObject_CallFunctionObjArgs(py_import,
                name, global_dict, empty_dict, list, py_level, (PyObject *)NULL);
            Py_DECREF(py_level);
            #else
            module = PyImport_ImportModuleLevelObject(
                name, global_dict, empty_dict, list, level);
            #endif
        }
    }
bad:
    #if PY_MAJOR_VERSION < 3
    Py_XDECREF(py_import);
    #endif
    Py_XDECREF(empty_list);
    Py_XDECREF(empty_dict);
    return module;
}

/* ImportFrom */
    static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
    PyObject* value = __Pyx_PyObject_GetAttrStr(module, name);
    if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) {
        PyErr_Format(PyExc_ImportError,
        #if PY_MAJOR_VERSION < 3
            "cannot import name %.230s", PyString_AS_STRING(name));
        #else
            "cannot import name %S", name);
        #endif
    }
    return value;
}

/* GetNameInClass */
    static PyObject *__Pyx_GetGlobalNameAfterAttributeLookup(PyObject *name) {
    PyObject *result;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    if (unlikely(!__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
        return NULL;
    __Pyx_PyErr_Clear();
    __Pyx_GetModuleGlobalNameUncached(result, name);
    return result;
}
static PyObject *__Pyx__GetNameInClass(PyObject *nmspace, PyObject *name) {
    PyObject *result;
    result = __Pyx_PyObject_GetAttrStr(nmspace, name);
    if (!result) {
        result = __Pyx_GetGlobalNameAfterAttributeLookup(name);
    }
    return result;
}

/* CLineInTraceback */
    #ifndef CYTHON_CLINE_IN_TRACEBACK
static int __Pyx_CLineForTraceback(CYTHON_NCP_UNUSED PyThreadState *tstate, int c_line) {
    PyObject *use_cline;
    PyObject *ptype, *pvalue, *ptraceback;
#if CYTHON_COMPILING_IN_CPYTHON
    PyObject **cython_runtime_dict;
#endif
    if (unlikely(!__pyx_cython_runtime)) {
        return c_line;
    }
    __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
#if CYTHON_COMPILING_IN_CPYTHON
    cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime);
    if (likely(cython_runtime_dict)) {
        __PYX_PY_DICT_LOOKUP_IF_MODIFIED(
            use_cline, *cython_runtime_dict,
            __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback))
    } else
#endif
    {
      PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback);
      if (use_cline_obj) {
        use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True;
        Py_DECREF(use_cline_obj);
      } else {
        PyErr_Clear();
        use_cline = NULL;
      }
    }
    if (!use_cline) {
        c_line = 0;
        PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False);
    }
    else if (use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) {
        c_line = 0;
    }
    __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
    return c_line;
}
#endif

/* CodeObjectCache */
    static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
    int start = 0, mid = 0, end = count - 1;
    if (end >= 0 && code_line > entries[end].code_line) {
        return count;
    }
    while (start < end) {
        mid = start + (end - start) / 2;
        if (code_line < entries[mid].code_line) {
            end = mid;
        } else if (code_line > entries[mid].code_line) {
             start = mid + 1;
        } else {
            return mid;
        }
    }
    if (code_line <= entries[mid].code_line) {
        return mid;
    } else {
        return mid + 1;
    }
}
static PyCodeObject *__pyx_find_code_object(int code_line) {
    PyCodeObject* code_object;
    int pos;
    if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
        return NULL;
    }
    pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
    if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
        return NULL;
    }
    code_object = __pyx_code_cache.entries[pos].code_object;
    Py_INCREF(code_object);
    return code_object;
}
static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
    int pos, i;
    __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
    if (unlikely(!code_line)) {
        return;
    }
    if (unlikely(!entries)) {
        entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
        if (likely(entries)) {
            __pyx_code_cache.entries = entries;
            __pyx_code_cache.max_count = 64;
            __pyx_code_cache.count = 1;
            entries[0].code_line = code_line;
            entries[0].code_object = code_object;
            Py_INCREF(code_object);
        }
        return;
    }
    pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
    if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
        PyCodeObject* tmp = entries[pos].code_object;
        entries[pos].code_object = code_object;
        Py_DECREF(tmp);
        return;
    }
    if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
        int new_max = __pyx_code_cache.max_count + 64;
        entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
            __pyx_code_cache.entries, ((size_t)new_max) * sizeof(__Pyx_CodeObjectCacheEntry));
        if (unlikely(!entries)) {
            return;
        }
        __pyx_code_cache.entries = entries;
        __pyx_code_cache.max_count = new_max;
    }
    for (i=__pyx_code_cache.count; i>pos; i--) {
        entries[i] = entries[i-1];
    }
    entries[pos].code_line = code_line;
    entries[pos].code_object = code_object;
    __pyx_code_cache.count++;
    Py_INCREF(code_object);
}

/* AddTraceback */
    #include "compile.h"
#include "frameobject.h"
#include "traceback.h"
static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
            const char *funcname, int c_line,
            int py_line, const char *filename) {
    PyCodeObject *py_code = 0;
    PyObject *py_srcfile = 0;
    PyObject *py_funcname = 0;
    #if PY_MAJOR_VERSION < 3
    py_srcfile = PyString_FromString(filename);
    #else
    py_srcfile = PyUnicode_FromString(filename);
    #endif
    if (!py_srcfile) goto bad;
    if (c_line) {
        #if PY_MAJOR_VERSION < 3
        py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
        #else
        py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
        #endif
    }
    else {
        #if PY_MAJOR_VERSION < 3
        py_funcname = PyString_FromString(funcname);
        #else
        py_funcname = PyUnicode_FromString(funcname);
        #endif
    }
    if (!py_funcname) goto bad;
    py_code = __Pyx_PyCode_New(
        0,
        0,
        0,
        0,
        0,
        __pyx_empty_bytes, /*PyObject *code,*/
        __pyx_empty_tuple, /*PyObject *consts,*/
        __pyx_empty_tuple, /*PyObject *names,*/
        __pyx_empty_tuple, /*PyObject *varnames,*/
        __pyx_empty_tuple, /*PyObject *freevars,*/
        __pyx_empty_tuple, /*PyObject *cellvars,*/
        py_srcfile,   /*PyObject *filename,*/
        py_funcname,  /*PyObject *name,*/
        py_line,
        __pyx_empty_bytes  /*PyObject *lnotab*/
    );
    Py_DECREF(py_srcfile);
    Py_DECREF(py_funcname);
    return py_code;
bad:
    Py_XDECREF(py_srcfile);
    Py_XDECREF(py_funcname);
    return NULL;
}
static void __Pyx_AddTraceback(const char *funcname, int c_line,
                               int py_line, const char *filename) {
    PyCodeObject *py_code = 0;
    PyFrameObject *py_frame = 0;
    PyThreadState *tstate = __Pyx_PyThreadState_Current;
    if (c_line) {
        c_line = __Pyx_CLineForTraceback(tstate, c_line);
    }
    py_code = __pyx_find_code_object(c_line ? -c_line : py_line);
    if (!py_code) {
        py_code = __Pyx_CreateCodeObjectForTraceback(
            funcname, c_line, py_line, filename);
        if (!py_code) goto bad;
        __pyx_insert_code_object(c_line ? -c_line : py_line, py_code);
    }
    py_frame = PyFrame_New(
        tstate,            /*PyThreadState *tstate,*/
        py_code,           /*PyCodeObject *code,*/
        __pyx_d,    /*PyObject *globals,*/
        0                  /*PyObject *locals*/
    );
    if (!py_frame) goto bad;
    __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
    PyTraceBack_Here(py_frame);
bad:
    Py_XDECREF(py_code);
    Py_XDECREF(py_frame);
}

/* CIntFromPyVerify */
    #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
    __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
#define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
    __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
#define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
    {\
        func_type value = func_value;\
        if (sizeof(target_type) < sizeof(func_type)) {\
            if (unlikely(value != (func_type) (target_type) value)) {\
                func_type zero = 0;\
                if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
                    return (target_type) -1;\
                if (is_unsigned && unlikely(value < zero))\
                    goto raise_neg_overflow;\
                else\
                    goto raise_overflow;\
            }\
        }\
        return (target_type) value;\
    }

/* CIntToPy */
    static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) {
    const int neg_one = (int) ((int) 0 - (int) 1), const_zero = (int) 0;
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(int) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(int) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
        }
    } else {
        if (sizeof(int) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
#endif
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(int),
                                     little, !is_unsigned);
    }
}

/* CIntToPy */
    static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum____pyx_t_5mpfmc_4core_5audio_20notification_message_NotificationMessage(enum __pyx_t_5mpfmc_4core_5audio_20notification_message_NotificationMessage value) {
    const enum __pyx_t_5mpfmc_4core_5audio_20notification_message_NotificationMessage neg_one = (enum __pyx_t_5mpfmc_4core_5audio_20notification_message_NotificationMessage) ((enum __pyx_t_5mpfmc_4core_5audio_20notification_message_NotificationMessage) 0 - (enum __pyx_t_5mpfmc_4core_5audio_20notification_message_NotificationMessage) 1), const_zero = (enum __pyx_t_5mpfmc_4core_5audio_20notification_message_NotificationMessage) 0;
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(enum __pyx_t_5mpfmc_4core_5audio_20notification_message_NotificationMessage) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(enum __pyx_t_5mpfmc_4core_5audio_20notification_message_NotificationMessage) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(enum __pyx_t_5mpfmc_4core_5audio_20notification_message_NotificationMessage) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
        }
    } else {
        if (sizeof(enum __pyx_t_5mpfmc_4core_5audio_20notification_message_NotificationMessage) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(enum __pyx_t_5mpfmc_4core_5audio_20notification_message_NotificationMessage) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
#endif
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(enum __pyx_t_5mpfmc_4core_5audio_20notification_message_NotificationMessage),
                                     little, !is_unsigned);
    }
}

/* CIntToPy */
    static CYTHON_INLINE PyObject* __Pyx_PyInt_From_Uint64(Uint64 value) {
    const Uint64 neg_one = (Uint64) ((Uint64) 0 - (Uint64) 1), const_zero = (Uint64) 0;
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(Uint64) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(Uint64) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(Uint64) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
        }
    } else {
        if (sizeof(Uint64) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(Uint64) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
#endif
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(Uint64),
                                     little, !is_unsigned);
    }
}

/* CIntToPy */
    static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
    const long neg_one = (long) ((long) 0 - (long) 1), const_zero = (long) 0;
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(long) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(long) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
        }
    } else {
        if (sizeof(long) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
#endif
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(long),
                                     little, !is_unsigned);
    }
}

/* CIntToPy */
    static CYTHON_INLINE PyObject* __Pyx_PyInt_From_Uint16(Uint16 value) {
    const Uint16 neg_one = (Uint16) ((Uint16) 0 - (Uint16) 1), const_zero = (Uint16) 0;
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(Uint16) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(Uint16) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(Uint16) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
        }
    } else {
        if (sizeof(Uint16) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(Uint16) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
#endif
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(Uint16),
                                     little, !is_unsigned);
    }
}

/* CIntToPy */
    static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum____pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopSetPlayerStatus(enum __pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopSetPlayerStatus value) {
    const enum __pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopSetPlayerStatus neg_one = (enum __pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopSetPlayerStatus) ((enum __pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopSetPlayerStatus) 0 - (enum __pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopSetPlayerStatus) 1), const_zero = (enum __pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopSetPlayerStatus) 0;
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(enum __pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopSetPlayerStatus) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(enum __pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopSetPlayerStatus) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(enum __pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopSetPlayerStatus) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
        }
    } else {
        if (sizeof(enum __pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopSetPlayerStatus) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(enum __pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopSetPlayerStatus) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
#endif
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(enum __pyx_t_5mpfmc_4core_5audio_16track_sound_loop_SoundLoopSetPlayerStatus),
                                     little, !is_unsigned);
    }
}

/* CIntToPy */
    static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum____pyx_t_5mpfmc_4core_5audio_16track_sound_loop_LayerStatus(enum __pyx_t_5mpfmc_4core_5audio_16track_sound_loop_LayerStatus value) {
    const enum __pyx_t_5mpfmc_4core_5audio_16track_sound_loop_LayerStatus neg_one = (enum __pyx_t_5mpfmc_4core_5audio_16track_sound_loop_LayerStatus) ((enum __pyx_t_5mpfmc_4core_5audio_16track_sound_loop_LayerStatus) 0 - (enum __pyx_t_5mpfmc_4core_5audio_16track_sound_loop_LayerStatus) 1), const_zero = (enum __pyx_t_5mpfmc_4core_5audio_16track_sound_loop_LayerStatus) 0;
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(enum __pyx_t_5mpfmc_4core_5audio_16track_sound_loop_LayerStatus) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(enum __pyx_t_5mpfmc_4core_5audio_16track_sound_loop_LayerStatus) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(enum __pyx_t_5mpfmc_4core_5audio_16track_sound_loop_LayerStatus) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
        }
    } else {
        if (sizeof(enum __pyx_t_5mpfmc_4core_5audio_16track_sound_loop_LayerStatus) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(enum __pyx_t_5mpfmc_4core_5audio_16track_sound_loop_LayerStatus) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
#endif
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(enum __pyx_t_5mpfmc_4core_5audio_16track_sound_loop_LayerStatus),
                                     little, !is_unsigned);
    }
}

/* CIntToPy */
    static CYTHON_INLINE PyObject* __Pyx_PyInt_From_gsize(gsize value) {
    const gsize neg_one = (gsize) ((gsize) 0 - (gsize) 1), const_zero = (gsize) 0;
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(gsize) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(gsize) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(gsize) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
        }
    } else {
        if (sizeof(gsize) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(gsize) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
#endif
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(gsize),
                                     little, !is_unsigned);
    }
}

/* CIntToPy */
    static CYTHON_INLINE PyObject* __Pyx_PyInt_From_Uint8(Uint8 value) {
    const Uint8 neg_one = (Uint8) ((Uint8) 0 - (Uint8) 1), const_zero = (Uint8) 0;
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(Uint8) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(Uint8) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(Uint8) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
        }
    } else {
        if (sizeof(Uint8) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(Uint8) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
#endif
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(Uint8),
                                     little, !is_unsigned);
    }
}

/* CIntToPy */
    static CYTHON_INLINE PyObject* __Pyx_PyInt_From_Uint32(Uint32 value) {
    const Uint32 neg_one = (Uint32) ((Uint32) 0 - (Uint32) 1), const_zero = (Uint32) 0;
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(Uint32) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(Uint32) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(Uint32) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
        }
    } else {
        if (sizeof(Uint32) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(Uint32) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
#endif
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(Uint32),
                                     little, !is_unsigned);
    }
}

/* CIntFromPy */
    static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
    const int neg_one = (int) ((int) 0 - (int) 1), const_zero = (int) 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(int) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (int) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (int) 0;
                case  1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
                case 2:
                    if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
                            return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
                            return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
                            return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
                        }
                    }
                    break;
            }
#endif
#if CYTHON_COMPILING_IN_CPYTHON
            if (unlikely(Py_SIZE(x) < 0)) {
                goto raise_neg_overflow;
            }
#else
            {
                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
                if (unlikely(result < 0))
                    return (int) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(int) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
#endif
            }
        } else {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (int) 0;
                case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0]))
                case  1: __PYX_VERIFY_RETURN_INT(int,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
                            return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
                            return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
                            return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
                            return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
                            return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
                            return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(int) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
#endif
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            int val;
            PyObject *v = __Pyx_PyNumber_IntOrLong(x);
 #if PY_MAJOR_VERSION < 3
            if (likely(v) && !PyLong_Check(v)) {
                PyObject *tmp = v;
                v = PyNumber_Long(tmp);
                Py_DECREF(tmp);
            }
 #endif
            if (likely(v)) {
                int one = 1; int is_little = (int)*(unsigned char *)&one;
                unsigned char *bytes = (unsigned char *)&val;
                int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                              bytes, sizeof(val),
                                              is_little, !is_unsigned);
                Py_DECREF(v);
                if (likely(!ret))
                    return val;
            }
#endif
            return (int) -1;
        }
    } else {
        int val;
        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
        if (!tmp) return (int) -1;
        val = __Pyx_PyInt_As_int(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to int");
    return (int) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to int");
    return (int) -1;
}

/* CIntFromPy */
    static CYTHON_INLINE Uint32 __Pyx_PyInt_As_Uint32(PyObject *x) {
    const Uint32 neg_one = (Uint32) ((Uint32) 0 - (Uint32) 1), const_zero = (Uint32) 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(Uint32) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(Uint32, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (Uint32) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (Uint32) 0;
                case  1: __PYX_VERIFY_RETURN_INT(Uint32, digit, digits[0])
                case 2:
                    if (8 * sizeof(Uint32) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(Uint32, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(Uint32) >= 2 * PyLong_SHIFT) {
                            return (Uint32) (((((Uint32)digits[1]) << PyLong_SHIFT) | (Uint32)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(Uint32) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(Uint32, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(Uint32) >= 3 * PyLong_SHIFT) {
                            return (Uint32) (((((((Uint32)digits[2]) << PyLong_SHIFT) | (Uint32)digits[1]) << PyLong_SHIFT) | (Uint32)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(Uint32) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(Uint32, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(Uint32) >= 4 * PyLong_SHIFT) {
                            return (Uint32) (((((((((Uint32)digits[3]) << PyLong_SHIFT) | (Uint32)digits[2]) << PyLong_SHIFT) | (Uint32)digits[1]) << PyLong_SHIFT) | (Uint32)digits[0]));
                        }
                    }
                    break;
            }
#endif
#if CYTHON_COMPILING_IN_CPYTHON
            if (unlikely(Py_SIZE(x) < 0)) {
                goto raise_neg_overflow;
            }
#else
            {
                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
                if (unlikely(result < 0))
                    return (Uint32) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(Uint32) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(Uint32, unsigned long, PyLong_AsUnsignedLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(Uint32) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(Uint32, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
#endif
            }
        } else {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (Uint32) 0;
                case -1: __PYX_VERIFY_RETURN_INT(Uint32, sdigit, (sdigit) (-(sdigit)digits[0]))
                case  1: __PYX_VERIFY_RETURN_INT(Uint32,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(Uint32) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(Uint32, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(Uint32) - 1 > 2 * PyLong_SHIFT) {
                            return (Uint32) (((Uint32)-1)*(((((Uint32)digits[1]) << PyLong_SHIFT) | (Uint32)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(Uint32) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(Uint32, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(Uint32) - 1 > 2 * PyLong_SHIFT) {
                            return (Uint32) ((((((Uint32)digits[1]) << PyLong_SHIFT) | (Uint32)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(Uint32) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(Uint32, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(Uint32) - 1 > 3 * PyLong_SHIFT) {
                            return (Uint32) (((Uint32)-1)*(((((((Uint32)digits[2]) << PyLong_SHIFT) | (Uint32)digits[1]) << PyLong_SHIFT) | (Uint32)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(Uint32) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(Uint32, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(Uint32) - 1 > 3 * PyLong_SHIFT) {
                            return (Uint32) ((((((((Uint32)digits[2]) << PyLong_SHIFT) | (Uint32)digits[1]) << PyLong_SHIFT) | (Uint32)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(Uint32) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(Uint32, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(Uint32) - 1 > 4 * PyLong_SHIFT) {
                            return (Uint32) (((Uint32)-1)*(((((((((Uint32)digits[3]) << PyLong_SHIFT) | (Uint32)digits[2]) << PyLong_SHIFT) | (Uint32)digits[1]) << PyLong_SHIFT) | (Uint32)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(Uint32) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(Uint32, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(Uint32) - 1 > 4 * PyLong_SHIFT) {
                            return (Uint32) ((((((((((Uint32)digits[3]) << PyLong_SHIFT) | (Uint32)digits[2]) << PyLong_SHIFT) | (Uint32)digits[1]) << PyLong_SHIFT) | (Uint32)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(Uint32) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(Uint32, long, PyLong_AsLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(Uint32) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(Uint32, PY_LONG_LONG, PyLong_AsLongLong(x))
#endif
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            Uint32 val;
            PyObject *v = __Pyx_PyNumber_IntOrLong(x);
 #if PY_MAJOR_VERSION < 3
            if (likely(v) && !PyLong_Check(v)) {
                PyObject *tmp = v;
                v = PyNumber_Long(tmp);
                Py_DECREF(tmp);
            }
 #endif
            if (likely(v)) {
                int one = 1; int is_little = (int)*(unsigned char *)&one;
                unsigned char *bytes = (unsigned char *)&val;
                int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                              bytes, sizeof(val),
                                              is_little, !is_unsigned);
                Py_DECREF(v);
                if (likely(!ret))
                    return val;
            }
#endif
            return (Uint32) -1;
        }
    } else {
        Uint32 val;
        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
        if (!tmp) return (Uint32) -1;
        val = __Pyx_PyInt_As_Uint32(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to Uint32");
    return (Uint32) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to Uint32");
    return (Uint32) -1;
}

/* CIntFromPy */
    static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
    const long neg_one = (long) ((long) 0 - (long) 1), const_zero = (long) 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(long) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (long) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (long) 0;
                case  1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
                case 2:
                    if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
                            return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
                            return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
                            return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
                        }
                    }
                    break;
            }
#endif
#if CYTHON_COMPILING_IN_CPYTHON
            if (unlikely(Py_SIZE(x) < 0)) {
                goto raise_neg_overflow;
            }
#else
            {
                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
                if (unlikely(result < 0))
                    return (long) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(long) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
#endif
            }
        } else {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (long) 0;
                case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
                case  1: __PYX_VERIFY_RETURN_INT(long,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                            return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                            return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                            return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                            return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                            return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                            return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(long) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
#endif
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            long val;
            PyObject *v = __Pyx_PyNumber_IntOrLong(x);
 #if PY_MAJOR_VERSION < 3
            if (likely(v) && !PyLong_Check(v)) {
                PyObject *tmp = v;
                v = PyNumber_Long(tmp);
                Py_DECREF(tmp);
            }
 #endif
            if (likely(v)) {
                int one = 1; int is_little = (int)*(unsigned char *)&one;
                unsigned char *bytes = (unsigned char *)&val;
                int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                              bytes, sizeof(val),
                                              is_little, !is_unsigned);
                Py_DECREF(v);
                if (likely(!ret))
                    return val;
            }
#endif
            return (long) -1;
        }
    } else {
        long val;
        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
        if (!tmp) return (long) -1;
        val = __Pyx_PyInt_As_long(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to long");
    return (long) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to long");
    return (long) -1;
}

/* CIntFromPy */
    static CYTHON_INLINE Uint64 __Pyx_PyInt_As_Uint64(PyObject *x) {
    const Uint64 neg_one = (Uint64) ((Uint64) 0 - (Uint64) 1), const_zero = (Uint64) 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(Uint64) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(Uint64, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (Uint64) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (Uint64) 0;
                case  1: __PYX_VERIFY_RETURN_INT(Uint64, digit, digits[0])
                case 2:
                    if (8 * sizeof(Uint64) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(Uint64, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(Uint64) >= 2 * PyLong_SHIFT) {
                            return (Uint64) (((((Uint64)digits[1]) << PyLong_SHIFT) | (Uint64)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(Uint64) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(Uint64, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(Uint64) >= 3 * PyLong_SHIFT) {
                            return (Uint64) (((((((Uint64)digits[2]) << PyLong_SHIFT) | (Uint64)digits[1]) << PyLong_SHIFT) | (Uint64)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(Uint64) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(Uint64, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(Uint64) >= 4 * PyLong_SHIFT) {
                            return (Uint64) (((((((((Uint64)digits[3]) << PyLong_SHIFT) | (Uint64)digits[2]) << PyLong_SHIFT) | (Uint64)digits[1]) << PyLong_SHIFT) | (Uint64)digits[0]));
                        }
                    }
                    break;
            }
#endif
#if CYTHON_COMPILING_IN_CPYTHON
            if (unlikely(Py_SIZE(x) < 0)) {
                goto raise_neg_overflow;
            }
#else
            {
                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
                if (unlikely(result < 0))
                    return (Uint64) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(Uint64) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(Uint64, unsigned long, PyLong_AsUnsignedLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(Uint64) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(Uint64, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
#endif
            }
        } else {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (Uint64) 0;
                case -1: __PYX_VERIFY_RETURN_INT(Uint64, sdigit, (sdigit) (-(sdigit)digits[0]))
                case  1: __PYX_VERIFY_RETURN_INT(Uint64,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(Uint64) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(Uint64, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(Uint64) - 1 > 2 * PyLong_SHIFT) {
                            return (Uint64) (((Uint64)-1)*(((((Uint64)digits[1]) << PyLong_SHIFT) | (Uint64)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(Uint64) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(Uint64, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(Uint64) - 1 > 2 * PyLong_SHIFT) {
                            return (Uint64) ((((((Uint64)digits[1]) << PyLong_SHIFT) | (Uint64)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(Uint64) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(Uint64, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(Uint64) - 1 > 3 * PyLong_SHIFT) {
                            return (Uint64) (((Uint64)-1)*(((((((Uint64)digits[2]) << PyLong_SHIFT) | (Uint64)digits[1]) << PyLong_SHIFT) | (Uint64)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(Uint64) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(Uint64, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(Uint64) - 1 > 3 * PyLong_SHIFT) {
                            return (Uint64) ((((((((Uint64)digits[2]) << PyLong_SHIFT) | (Uint64)digits[1]) << PyLong_SHIFT) | (Uint64)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(Uint64) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(Uint64, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(Uint64) - 1 > 4 * PyLong_SHIFT) {
                            return (Uint64) (((Uint64)-1)*(((((((((Uint64)digits[3]) << PyLong_SHIFT) | (Uint64)digits[2]) << PyLong_SHIFT) | (Uint64)digits[1]) << PyLong_SHIFT) | (Uint64)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(Uint64) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(Uint64, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(Uint64) - 1 > 4 * PyLong_SHIFT) {
                            return (Uint64) ((((((((((Uint64)digits[3]) << PyLong_SHIFT) | (Uint64)digits[2]) << PyLong_SHIFT) | (Uint64)digits[1]) << PyLong_SHIFT) | (Uint64)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(Uint64) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(Uint64, long, PyLong_AsLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(Uint64) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(Uint64, PY_LONG_LONG, PyLong_AsLongLong(x))
#endif
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            Uint64 val;
            PyObject *v = __Pyx_PyNumber_IntOrLong(x);
 #if PY_MAJOR_VERSION < 3
            if (likely(v) && !PyLong_Check(v)) {
                PyObject *tmp = v;
                v = PyNumber_Long(tmp);
                Py_DECREF(tmp);
            }
 #endif
            if (likely(v)) {
                int one = 1; int is_little = (int)*(unsigned char *)&one;
                unsigned char *bytes = (unsigned char *)&val;
                int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                              bytes, sizeof(val),
                                              is_little, !is_unsigned);
                Py_DECREF(v);
                if (likely(!ret))
                    return val;
            }
#endif
            return (Uint64) -1;
        }
    } else {
        Uint64 val;
        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
        if (!tmp) return (Uint64) -1;
        val = __Pyx_PyInt_As_Uint64(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to Uint64");
    return (Uint64) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to Uint64");
    return (Uint64) -1;
}

/* CIntFromPy */
    static CYTHON_INLINE Uint8 __Pyx_PyInt_As_Uint8(PyObject *x) {
    const Uint8 neg_one = (Uint8) ((Uint8) 0 - (Uint8) 1), const_zero = (Uint8) 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(Uint8) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(Uint8, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (Uint8) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (Uint8) 0;
                case  1: __PYX_VERIFY_RETURN_INT(Uint8, digit, digits[0])
                case 2:
                    if (8 * sizeof(Uint8) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(Uint8, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(Uint8) >= 2 * PyLong_SHIFT) {
                            return (Uint8) (((((Uint8)digits[1]) << PyLong_SHIFT) | (Uint8)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(Uint8) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(Uint8, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(Uint8) >= 3 * PyLong_SHIFT) {
                            return (Uint8) (((((((Uint8)digits[2]) << PyLong_SHIFT) | (Uint8)digits[1]) << PyLong_SHIFT) | (Uint8)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(Uint8) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(Uint8, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(Uint8) >= 4 * PyLong_SHIFT) {
                            return (Uint8) (((((((((Uint8)digits[3]) << PyLong_SHIFT) | (Uint8)digits[2]) << PyLong_SHIFT) | (Uint8)digits[1]) << PyLong_SHIFT) | (Uint8)digits[0]));
                        }
                    }
                    break;
            }
#endif
#if CYTHON_COMPILING_IN_CPYTHON
            if (unlikely(Py_SIZE(x) < 0)) {
                goto raise_neg_overflow;
            }
#else
            {
                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
                if (unlikely(result < 0))
                    return (Uint8) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(Uint8) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(Uint8, unsigned long, PyLong_AsUnsignedLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(Uint8) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(Uint8, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
#endif
            }
        } else {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (Uint8) 0;
                case -1: __PYX_VERIFY_RETURN_INT(Uint8, sdigit, (sdigit) (-(sdigit)digits[0]))
                case  1: __PYX_VERIFY_RETURN_INT(Uint8,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(Uint8) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(Uint8, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(Uint8) - 1 > 2 * PyLong_SHIFT) {
                            return (Uint8) (((Uint8)-1)*(((((Uint8)digits[1]) << PyLong_SHIFT) | (Uint8)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(Uint8) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(Uint8, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(Uint8) - 1 > 2 * PyLong_SHIFT) {
                            return (Uint8) ((((((Uint8)digits[1]) << PyLong_SHIFT) | (Uint8)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(Uint8) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(Uint8, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(Uint8) - 1 > 3 * PyLong_SHIFT) {
                            return (Uint8) (((Uint8)-1)*(((((((Uint8)digits[2]) << PyLong_SHIFT) | (Uint8)digits[1]) << PyLong_SHIFT) | (Uint8)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(Uint8) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(Uint8, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(Uint8) - 1 > 3 * PyLong_SHIFT) {
                            return (Uint8) ((((((((Uint8)digits[2]) << PyLong_SHIFT) | (Uint8)digits[1]) << PyLong_SHIFT) | (Uint8)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(Uint8) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(Uint8, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(Uint8) - 1 > 4 * PyLong_SHIFT) {
                            return (Uint8) (((Uint8)-1)*(((((((((Uint8)digits[3]) << PyLong_SHIFT) | (Uint8)digits[2]) << PyLong_SHIFT) | (Uint8)digits[1]) << PyLong_SHIFT) | (Uint8)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(Uint8) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(Uint8, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(Uint8) - 1 > 4 * PyLong_SHIFT) {
                            return (Uint8) ((((((((((Uint8)digits[3]) << PyLong_SHIFT) | (Uint8)digits[2]) << PyLong_SHIFT) | (Uint8)digits[1]) << PyLong_SHIFT) | (Uint8)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(Uint8) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(Uint8, long, PyLong_AsLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(Uint8) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(Uint8, PY_LONG_LONG, PyLong_AsLongLong(x))
#endif
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            Uint8 val;
            PyObject *v = __Pyx_PyNumber_IntOrLong(x);
 #if PY_MAJOR_VERSION < 3
            if (likely(v) && !PyLong_Check(v)) {
                PyObject *tmp = v;
                v = PyNumber_Long(tmp);
                Py_DECREF(tmp);
            }
 #endif
            if (likely(v)) {
                int one = 1; int is_little = (int)*(unsigned char *)&one;
                unsigned char *bytes = (unsigned char *)&val;
                int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                              bytes, sizeof(val),
                                              is_little, !is_unsigned);
                Py_DECREF(v);
                if (likely(!ret))
                    return val;
            }
#endif
            return (Uint8) -1;
        }
    } else {
        Uint8 val;
        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
        if (!tmp) return (Uint8) -1;
        val = __Pyx_PyInt_As_Uint8(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to Uint8");
    return (Uint8) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to Uint8");
    return (Uint8) -1;
}

/* CIntFromPy */
    static CYTHON_INLINE guint __Pyx_PyInt_As_guint(PyObject *x) {
    const guint neg_one = (guint) ((guint) 0 - (guint) 1), const_zero = (guint) 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(guint) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(guint, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (guint) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (guint) 0;
                case  1: __PYX_VERIFY_RETURN_INT(guint, digit, digits[0])
                case 2:
                    if (8 * sizeof(guint) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(guint, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(guint) >= 2 * PyLong_SHIFT) {
                            return (guint) (((((guint)digits[1]) << PyLong_SHIFT) | (guint)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(guint) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(guint, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(guint) >= 3 * PyLong_SHIFT) {
                            return (guint) (((((((guint)digits[2]) << PyLong_SHIFT) | (guint)digits[1]) << PyLong_SHIFT) | (guint)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(guint) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(guint, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(guint) >= 4 * PyLong_SHIFT) {
                            return (guint) (((((((((guint)digits[3]) << PyLong_SHIFT) | (guint)digits[2]) << PyLong_SHIFT) | (guint)digits[1]) << PyLong_SHIFT) | (guint)digits[0]));
                        }
                    }
                    break;
            }
#endif
#if CYTHON_COMPILING_IN_CPYTHON
            if (unlikely(Py_SIZE(x) < 0)) {
                goto raise_neg_overflow;
            }
#else
            {
                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
                if (unlikely(result < 0))
                    return (guint) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(guint) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(guint, unsigned long, PyLong_AsUnsignedLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(guint) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(guint, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
#endif
            }
        } else {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (guint) 0;
                case -1: __PYX_VERIFY_RETURN_INT(guint, sdigit, (sdigit) (-(sdigit)digits[0]))
                case  1: __PYX_VERIFY_RETURN_INT(guint,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(guint) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(guint, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(guint) - 1 > 2 * PyLong_SHIFT) {
                            return (guint) (((guint)-1)*(((((guint)digits[1]) << PyLong_SHIFT) | (guint)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(guint) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(guint, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(guint) - 1 > 2 * PyLong_SHIFT) {
                            return (guint) ((((((guint)digits[1]) << PyLong_SHIFT) | (guint)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(guint) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(guint, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(guint) - 1 > 3 * PyLong_SHIFT) {
                            return (guint) (((guint)-1)*(((((((guint)digits[2]) << PyLong_SHIFT) | (guint)digits[1]) << PyLong_SHIFT) | (guint)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(guint) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(guint, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(guint) - 1 > 3 * PyLong_SHIFT) {
                            return (guint) ((((((((guint)digits[2]) << PyLong_SHIFT) | (guint)digits[1]) << PyLong_SHIFT) | (guint)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(guint) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(guint, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(guint) - 1 > 4 * PyLong_SHIFT) {
                            return (guint) (((guint)-1)*(((((((((guint)digits[3]) << PyLong_SHIFT) | (guint)digits[2]) << PyLong_SHIFT) | (guint)digits[1]) << PyLong_SHIFT) | (guint)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(guint) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(guint, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(guint) - 1 > 4 * PyLong_SHIFT) {
                            return (guint) ((((((((((guint)digits[3]) << PyLong_SHIFT) | (guint)digits[2]) << PyLong_SHIFT) | (guint)digits[1]) << PyLong_SHIFT) | (guint)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(guint) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(guint, long, PyLong_AsLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(guint) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(guint, PY_LONG_LONG, PyLong_AsLongLong(x))
#endif
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            guint val;
            PyObject *v = __Pyx_PyNumber_IntOrLong(x);
 #if PY_MAJOR_VERSION < 3
            if (likely(v) && !PyLong_Check(v)) {
                PyObject *tmp = v;
                v = PyNumber_Long(tmp);
                Py_DECREF(tmp);
            }
 #endif
            if (likely(v)) {
                int one = 1; int is_little = (int)*(unsigned char *)&one;
                unsigned char *bytes = (unsigned char *)&val;
                int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                              bytes, sizeof(val),
                                              is_little, !is_unsigned);
                Py_DECREF(v);
                if (likely(!ret))
                    return val;
            }
#endif
            return (guint) -1;
        }
    } else {
        guint val;
        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
        if (!tmp) return (guint) -1;
        val = __Pyx_PyInt_As_guint(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to guint");
    return (guint) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to guint");
    return (guint) -1;
}

/* FastTypeChecks */
    #if CYTHON_COMPILING_IN_CPYTHON
static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
    while (a) {
        a = a->tp_base;
        if (a == b)
            return 1;
    }
    return b == &PyBaseObject_Type;
}
static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) {
    PyObject *mro;
    if (a == b) return 1;
    mro = a->tp_mro;
    if (likely(mro)) {
        Py_ssize_t i, n;
        n = PyTuple_GET_SIZE(mro);
        for (i = 0; i < n; i++) {
            if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b)
                return 1;
        }
        return 0;
    }
    return __Pyx_InBases(a, b);
}
#if PY_MAJOR_VERSION == 2
static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) {
    PyObject *exception, *value, *tb;
    int res;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&exception, &value, &tb);
    res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0;
    if (unlikely(res == -1)) {
        PyErr_WriteUnraisable(err);
        res = 0;
    }
    if (!res) {
        res = PyObject_IsSubclass(err, exc_type2);
        if (unlikely(res == -1)) {
            PyErr_WriteUnraisable(err);
            res = 0;
        }
    }
    __Pyx_ErrRestore(exception, value, tb);
    return res;
}
#else
static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) {
    int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0;
    if (!res) {
        res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2);
    }
    return res;
}
#endif
static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
    Py_ssize_t i, n;
    assert(PyExceptionClass_Check(exc_type));
    n = PyTuple_GET_SIZE(tuple);
#if PY_MAJOR_VERSION >= 3
    for (i=0; i<n; i++) {
        if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
    }
#endif
    for (i=0; i<n; i++) {
        PyObject *t = PyTuple_GET_ITEM(tuple, i);
        #if PY_MAJOR_VERSION < 3
        if (likely(exc_type == t)) return 1;
        #endif
        if (likely(PyExceptionClass_Check(t))) {
            if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type, NULL, t)) return 1;
        } else {
        }
    }
    return 0;
}
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) {
    if (likely(err == exc_type)) return 1;
    if (likely(PyExceptionClass_Check(err))) {
        if (likely(PyExceptionClass_Check(exc_type))) {
            return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type);
        } else if (likely(PyTuple_Check(exc_type))) {
            return __Pyx_PyErr_GivenExceptionMatchesTuple(err, exc_type);
        } else {
        }
    }
    return PyErr_GivenExceptionMatches(err, exc_type);
}
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) {
    assert(PyExceptionClass_Check(exc_type1));
    assert(PyExceptionClass_Check(exc_type2));
    if (likely(err == exc_type1 || err == exc_type2)) return 1;
    if (likely(PyExceptionClass_Check(err))) {
        return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2);
    }
    return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2));
}
#endif

/* CheckBinaryVersion */
    static int __Pyx_check_binary_version(void) {
    char ctversion[4], rtversion[4];
    PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
    PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
    if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
        char message[200];
        PyOS_snprintf(message, sizeof(message),
                      "compiletime version %s of module '%.100s' "
                      "does not match runtime version %s",
                      ctversion, __Pyx_MODULE_NAME, rtversion);
        return PyErr_WarnEx(NULL, message, 1);
    }
    return 0;
}

/* FunctionExport */
    static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig) {
    PyObject *d = 0;
    PyObject *cobj = 0;
    union {
        void (*fp)(void);
        void *p;
    } tmp;
    d = PyObject_GetAttrString(__pyx_m, (char *)"__pyx_capi__");
    if (!d) {
        PyErr_Clear();
        d = PyDict_New();
        if (!d)
            goto bad;
        Py_INCREF(d);
        if (PyModule_AddObject(__pyx_m, (char *)"__pyx_capi__", d) < 0)
            goto bad;
    }
    tmp.fp = f;
#if PY_VERSION_HEX >= 0x02070000
    cobj = PyCapsule_New(tmp.p, sig, 0);
#else
    cobj = PyCObject_FromVoidPtrAndDesc(tmp.p, (void *)sig, 0);
#endif
    if (!cobj)
        goto bad;
    if (PyDict_SetItemString(d, name, cobj) < 0)
        goto bad;
    Py_DECREF(cobj);
    Py_DECREF(d);
    return 0;
bad:
    Py_XDECREF(cobj);
    Py_XDECREF(d);
    return -1;
}

/* InitStrings */
    static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
    while (t->p) {
        #if PY_MAJOR_VERSION < 3
        if (t->is_unicode) {
            *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
        } else if (t->intern) {
            *t->p = PyString_InternFromString(t->s);
        } else {
            *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
        }
        #else
        if (t->is_unicode | t->is_str) {
            if (t->intern) {
                *t->p = PyUnicode_InternFromString(t->s);
            } else if (t->encoding) {
                *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
            } else {
                *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
            }
        } else {
            *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
        }
        #endif
        if (!*t->p)
            return -1;
        if (PyObject_Hash(*t->p) == -1)
            return -1;
        ++t;
    }
    return 0;
}

static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
    return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
}
static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) {
    Py_ssize_t ignore;
    return __Pyx_PyObject_AsStringAndSize(o, &ignore);
}
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
#if !CYTHON_PEP393_ENABLED
static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
    char* defenc_c;
    PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
    if (!defenc) return NULL;
    defenc_c = PyBytes_AS_STRING(defenc);
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
    {
        char* end = defenc_c + PyBytes_GET_SIZE(defenc);
        char* c;
        for (c = defenc_c; c < end; c++) {
            if ((unsigned char) (*c) >= 128) {
                PyUnicode_AsASCIIString(o);
                return NULL;
            }
        }
    }
#endif
    *length = PyBytes_GET_SIZE(defenc);
    return defenc_c;
}
#else
static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
    if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL;
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
    if (likely(PyUnicode_IS_ASCII(o))) {
        *length = PyUnicode_GET_LENGTH(o);
        return PyUnicode_AsUTF8(o);
    } else {
        PyUnicode_AsASCIIString(o);
        return NULL;
    }
#else
    return PyUnicode_AsUTF8AndSize(o, length);
#endif
}
#endif
#endif
static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
    if (
#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
            __Pyx_sys_getdefaultencoding_not_ascii &&
#endif
            PyUnicode_Check(o)) {
        return __Pyx_PyUnicode_AsStringAndSize(o, length);
    } else
#endif
#if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
    if (PyByteArray_Check(o)) {
        *length = PyByteArray_GET_SIZE(o);
        return PyByteArray_AS_STRING(o);
    } else
#endif
    {
        char* result;
        int r = PyBytes_AsStringAndSize(o, &result, length);
        if (unlikely(r < 0)) {
            return NULL;
        } else {
            return result;
        }
    }
}
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
   int is_true = x == Py_True;
   if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
   else return PyObject_IsTrue(x);
}
static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) {
    int retval;
    if (unlikely(!x)) return -1;
    retval = __Pyx_PyObject_IsTrue(x);
    Py_DECREF(x);
    return retval;
}
static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) {
#if PY_MAJOR_VERSION >= 3
    if (PyLong_Check(result)) {
        if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
                "__int__ returned non-int (type %.200s).  "
                "The ability to return an instance of a strict subclass of int "
                "is deprecated, and may be removed in a future version of Python.",
                Py_TYPE(result)->tp_name)) {
            Py_DECREF(result);
            return NULL;
        }
        return result;
    }
#endif
    PyErr_Format(PyExc_TypeError,
                 "__%.4s__ returned non-%.4s (type %.200s)",
                 type_name, type_name, Py_TYPE(result)->tp_name);
    Py_DECREF(result);
    return NULL;
}
static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
#if CYTHON_USE_TYPE_SLOTS
  PyNumberMethods *m;
#endif
  const char *name = NULL;
  PyObject *res = NULL;
#if PY_MAJOR_VERSION < 3
  if (likely(PyInt_Check(x) || PyLong_Check(x)))
#else
  if (likely(PyLong_Check(x)))
#endif
    return __Pyx_NewRef(x);
#if CYTHON_USE_TYPE_SLOTS
  m = Py_TYPE(x)->tp_as_number;
  #if PY_MAJOR_VERSION < 3
  if (m && m->nb_int) {
    name = "int";
    res = m->nb_int(x);
  }
  else if (m && m->nb_long) {
    name = "long";
    res = m->nb_long(x);
  }
  #else
  if (likely(m && m->nb_int)) {
    name = "int";
    res = m->nb_int(x);
  }
  #endif
#else
  if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) {
    res = PyNumber_Int(x);
  }
#endif
  if (likely(res)) {
#if PY_MAJOR_VERSION < 3
    if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) {
#else
    if (unlikely(!PyLong_CheckExact(res))) {
#endif
        return __Pyx_PyNumber_IntOrLongWrongResultType(res, name);
    }
  }
  else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_TypeError,
                    "an integer is required");
  }
  return res;
}
static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
  Py_ssize_t ival;
  PyObject *x;
#if PY_MAJOR_VERSION < 3
  if (likely(PyInt_CheckExact(b))) {
    if (sizeof(Py_ssize_t) >= sizeof(long))
        return PyInt_AS_LONG(b);
    else
        return PyInt_AsSsize_t(b);
  }
#endif
  if (likely(PyLong_CheckExact(b))) {
    #if CYTHON_USE_PYLONG_INTERNALS
    const digit* digits = ((PyLongObject*)b)->ob_digit;
    const Py_ssize_t size = Py_SIZE(b);
    if (likely(__Pyx_sst_abs(size) <= 1)) {
        ival = likely(size) ? digits[0] : 0;
        if (size == -1) ival = -ival;
        return ival;
    } else {
      switch (size) {
         case 2:
           if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
             return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case -2:
           if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
             return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case 3:
           if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
             return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case -3:
           if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
             return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case 4:
           if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
             return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case -4:
           if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
             return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
      }
    }
    #endif
    return PyLong_AsSsize_t(b);
  }
  x = PyNumber_Index(b);
  if (!x) return -1;
  ival = PyInt_AsSsize_t(x);
  Py_DECREF(x);
  return ival;
}
static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) {
  return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False);
}
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
    return PyInt_FromSize_t(ival);
}


#endif /* Py_PYTHON_H */
