Browse Source

Some fixes to gen_dsp, now buildable with mingw too

pull/2/merge
falkTX 9 years ago
parent
commit
497506cea1
6 changed files with 33 additions and 100 deletions
  1. +1
    -1
      plugins/Makefile.mk
  2. +15
    -9
      plugins/common/gen_dsp/genlib.cpp
  3. +13
    -38
      plugins/common/gen_dsp/genlib.h
  4. +3
    -5
      plugins/common/gen_dsp/genlib_common.h
  5. +0
    -43
      plugins/common/gen_dsp/genlib_common_win.h
  6. +1
    -4
      plugins/common/gen_dsp/genlib_ops.h

+ 1
- 1
plugins/Makefile.mk View File

@@ -18,7 +18,7 @@ endif
TARGET_DIR = ../../bin

BUILD_C_FLAGS += -I.
BUILD_CXX_FLAGS += -I. -I../common -I../common/gen_dsp -I../../dpf/distrho -I../../dpf/dgl
BUILD_CXX_FLAGS += -I. -I../common -I../common/gen_dsp -I../../dpf/distrho -I../../dpf/dgl -Wno-unused-parameter

ifeq ($(HAVE_DGL),true)
BASE_FLAGS += -DHAVE_DGL


+ 15
- 9
plugins/common/gen_dsp/genlib.cpp View File

@@ -24,13 +24,16 @@ OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "stdio.h"
#include "string.h"

#ifdef pow
#undef pow
#endif
#include <cmath>
#include <malloc.h>

#define malloc_size malloc_usable_size
#if ! DISTRHO_OS_MAC
# include <malloc.h>
# if DISTRHO_OS_WINDOWS
# define malloc_size _msize
# else
# define malloc_size malloc_usable_size
# endif
#endif

// DATA_MAXIMUM_ELEMENTS * 8 bytes = 256 mb limit
#define DATA_MAXIMUM_ELEMENTS (33554432)
@@ -63,7 +66,7 @@ t_ptr sysmem_resizeptr(void *ptr, t_ptr_size newsize)

t_ptr sysmem_resizeptrclear(void *ptr, t_ptr_size newsize)
{
long oldsize = malloc_size(ptr);
t_ptr_size oldsize = malloc_size(ptr);
t_ptr p = (t_ptr)realloc(ptr, newsize);
if (p) {
@@ -170,6 +173,7 @@ t_genlib_err genlib_buffer_perform_begin(t_genlib_buffer *b)
{
return 0; // to be implemented
}

void genlib_buffer_perform_end(t_genlib_buffer *b)
{
// to be implemented
@@ -177,7 +181,7 @@ void genlib_buffer_perform_end(t_genlib_buffer *b)

t_sample gen_msp_pow(t_sample value, t_sample power)
{
return pow(value, power);
return powf(value, power);
}

void genlib_data_setbuffer(t_genlib_data *b, void *ref) {
@@ -186,8 +190,8 @@ void genlib_data_setbuffer(t_genlib_data *b, void *ref) {

typedef struct {
t_genlib_data_info info;
t_sample cursor; // used by Delay
//t_symbol * name;
t_sample cursor; // used by Delay
//t_symbol * name;
} t_dsp_gen_data;

t_genlib_data * genlib_obtain_data_from_reference(void *ref)
@@ -352,3 +356,5 @@ void genlib_data_resize(t_genlib_data *b, long s, long c) {
}

void genlib_reset_complete(void *data) {}



+ 13
- 38
plugins/common/gen_dsp/genlib.h View File

@@ -26,26 +26,7 @@ OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//////////// genlib.h ////////////
// genlib.h -- max (gen~) version

#ifndef GEN_WINDOWS
#ifndef _SIZE_T
#define _SIZE_T
typedef __typeof__(sizeof(int)) size_t;
#endif
#endif

#ifndef __INT32_TYPE__
#define __INT32_TYPE__ int
#endif

#ifdef MSP_ON_CLANG
// gen~ hosted:
typedef unsigned __INT32_TYPE__ uint32_t;
typedef unsigned __INT64_TYPE__ uint64_t;
#else
#ifdef __GNUC__
#include <stdint.h>
#endif
#endif
#include "DistrhoUtils.hpp"

#define inf (__DBL_MAX__)
#define GEN_UINT_MAX (4294967295)
@@ -54,27 +35,21 @@ typedef __typeof__(sizeof(int)) size_t;
#define C74_CONST const

// max_types.h:
// #ifdef C74_X64
// typedef unsigned long long t_ptr_uint;
// typedef long long t_ptr_int;
// typedef double t_atom_float;
// typedef t_ptr_uint t_getbytes_size;
// #else
typedef unsigned long t_ptr_uint;
typedef long t_ptr_int;
typedef float t_atom_float;
typedef short t_getbytes_size;
// #endif
typedef uintptr_t t_ptr_uint;
typedef intptr_t t_ptr_int;
typedef float t_atom_float;
typedef t_ptr_uint t_getbytes_size;

typedef uint32_t t_uint32;
typedef t_ptr_int t_atom_long; // the type that is an A_LONG in an atom

typedef t_ptr_int t_int; ///< an integer @ingroup misc
typedef t_ptr_int t_int; ///< an integer @ingroup misc
typedef t_ptr_uint t_ptr_size; ///< unsigned pointer-sized value for counting (like size_t) @ingroup misc
typedef t_ptr_int t_atom_long; ///< the type that is an A_LONG in a #t_atom @ingroup misc
typedef t_atom_long t_max_err; ///< an integer value suitable to be returned as an error code @ingroup misc

extern "C" {

// string reference handling:
void * genlib_obtain_reference_from_string(const char * name);
char *genlib_reference_getname(void *ref);
@@ -99,12 +74,12 @@ extern "C" {
// other notification:
void genlib_reset_complete(void *data);
// get/set state of parameters
size_t genlib_getstatesize(CommonState *cself, getparameter_method getmethod);
short genlib_getstate(CommonState *cself, char *state, getparameter_method getmethod);
short genlib_setstate(CommonState *cself, const char *state, setparameter_method setmethod);
// get/set state of parameters
size_t genlib_getstatesize(CommonState *cself, getparameter_method getmethod);
short genlib_getstate(CommonState *cself, char *state, getparameter_method getmethod);
short genlib_setstate(CommonState *cself, const char *state, setparameter_method setmethod);
}; // extern "C"
#define genlib_sysmem_newptr(s) sysmem_newptr(s)


+ 3
- 5
plugins/common/gen_dsp/genlib_common.h View File

@@ -21,17 +21,15 @@ OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#ifndef GENLIB_COMMON_H
#define GENLIB_COMMON_H 1

#include "genlib_common_win.h"

//////////// genlib_common.h ////////////
// common data structure header file -- this is the stuff required by the
// common code and accessed by the export and max code
#define DSP_GEN_MAX_SIGNALS 16
#define DSP_GEN_MAX_SIGNALS 16

typedef float t_sample;
typedef float t_param;
typedef char *t_ptr;
typedef char *t_ptr;
typedef long t_genlib_err;
typedef enum {


+ 0
- 43
plugins/common/gen_dsp/genlib_common_win.h View File

@@ -1,43 +0,0 @@
/*******************************************************************************************************************
Copyright (c) 2012 Cycling '74

Permission is hereby granted, free of charge, to any person obtaining a copy of this software
and associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies
or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*******************************************************************************************************************/

#ifndef GENLIB_COMMON_WIN_H
#define GENLIB_COMMON_WIN_H

#ifdef _MSC_VER
#define GEN_WINDOWS
#endif

#ifdef GEN_WINDOWS

#include <malloc.h>
#include <limits>

typedef __int32 int32_t;
typedef unsigned __int32 uint32_t;
typedef __int64 int64_t;
typedef unsigned __int64 uint64_t;
#define malloc_size _msize
#define __DBL_EPSILON__ (DBL_EPSILON)

#endif

#endif


+ 1
- 4
plugins/common/gen_dsp/genlib_ops.h View File

@@ -35,10 +35,7 @@ OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define GENLIB_PI_OVER_4 (0.785398163397448309615660845819875721f)
#define GENLIB_1_OVER_LOG_2 (1.442695040888963f)

// denormal numbers cannot occur when hosted in MSP:
// #ifdef MSP_ON_CLANG
#define GENLIB_NO_DENORM_TEST 1
// #endif
#define GENLIB_NO_DENORM_TEST 1

// assumes v is a 64-bit double:
#define GENLIB_IS_NAN_DOUBLE(v) (((((uint32_t *)&(v))[1])&0x7fe00000)==0x7fe00000)


Loading…
Cancel
Save