Browse Source

Minor changes for type safety

tags/1.9.4
falkTX 11 years ago
parent
commit
40c7bcf58d
7 changed files with 135 additions and 88 deletions
  1. +1
    -1
      source/backend/engine/CarlaEngineNative.cpp
  2. +4
    -1
      source/modules/carla_native/bypass.c
  3. +20
    -20
      source/modules/carla_native/lfo.c
  4. +26
    -4
      source/modules/carla_native/midi-split.c
  5. +26
    -4
      source/modules/carla_native/midi-through.c
  6. +1
    -1
      source/modules/carla_native/midi-transpose.c
  7. +57
    -57
      source/plugin/Makefile

+ 1
- 1
source/backend/engine/CarlaEngineNative.cpp View File

@@ -456,7 +456,7 @@ protected:
// ---------------------------------------------------------------
// Time Info

const NativeTimeInfo* timeInfo(NativePluginClass::getTimeInfo());
const NativeTimeInfo* const timeInfo(NativePluginClass::getTimeInfo());

pData->timeInfo.playing = timeInfo->playing;
pData->timeInfo.frame = timeInfo->frame;


+ 4
- 1
source/modules/carla_native/bypass.c View File

@@ -24,7 +24,10 @@
static NativePluginHandle bypass_instantiate(const NativeHostDescriptor* host)
{
// dummy, return non-NULL
return (NativePluginHandle)host;
return (NativePluginHandle)0x1;

// unused
(void)host;
}

static void bypass_process(NativePluginHandle handle, float** inBuffer, float** outBuffer, uint32_t frames, const NativeMidiEvent* midiEvents, uint32_t midiEventCount)


+ 20
- 20
source/modules/carla_native/lfo.c View File

@@ -35,12 +35,12 @@ typedef enum {
} LfoParams;

typedef struct {
const NativeHostDescriptor* host;
int mode;
float speed;
float multiplier;
float baseStart;
float value;
const NativeHostDescriptor* host;
int mode;
double speed;
float multiplier;
float baseStart;
float value;
} LfoHandle;

// -----------------------------------------------------------------------
@@ -173,7 +173,7 @@ static float lfo_get_parameter_value(NativePluginHandle handle, uint32_t index)
case PARAM_MODE:
return (float)handlePtr->mode;
case PARAM_SPEED:
return handlePtr->speed;
return (float)handlePtr->speed;
case PARAM_MULTIPLIER:
return handlePtr->multiplier;
case PARAM_BASE_START:
@@ -215,42 +215,42 @@ static void lfo_process(NativePluginHandle handle, float** inBuffer, float** out
if (! timeInfo->playing)
return;

const float bpm = timeInfo->bbt.valid ? timeInfo->bbt.beatsPerMinute : 120.0;
const float sampleRate = host->get_sample_rate(host->handle);
const double bpm = timeInfo->bbt.valid ? timeInfo->bbt.beatsPerMinute : 120.0;
const double sampleRate = host->get_sample_rate(host->handle);

const float speedRate = handlePtr->speed/(bpm/60.0f/sampleRate);
const uint speedRatei = speedRate;
const double speedRate = handlePtr->speed/(bpm/60.0/sampleRate);
const uint speedRatei = (uint)speedRate;

float value = 0.0f;
double value = 0.0;

switch (handlePtr->mode)
{
case 1: // Triangle
value = fabs(1.0f-(float)(timeInfo->frame % speedRatei)/(speedRate/2.0f));
value = fabs(1.0-(double)(timeInfo->frame % speedRatei)/(speedRate/2.0));
break;
case 2: // Sawtooth
value = (float)(timeInfo->frame % speedRatei)/speedRate;
value = (double)(timeInfo->frame % speedRatei)/speedRate;
break;
case 3: // Sawtooth (inverted)
value = 1.0f - (float)(timeInfo->frame % speedRatei)/speedRate;
value = 1.0 - (double)(timeInfo->frame % speedRatei)/speedRate;
break;
case 4: // Sine -- TODO!
value = 0.0f;
value = 0.0;
break;
case 5: // Square
value = (timeInfo->frame % speedRatei <= speedRatei/2) ? 1.0f : 0.0f;
value = (timeInfo->frame % speedRatei <= speedRatei/2) ? 1.0 : 0.0;
break;
}

value *= handlePtr->multiplier;
value += handlePtr->baseStart;

if (value <= 0.0f)
if (value <= 0.0)
handlePtr->value = 0.0f;
else if (value >= 1.0f)
else if (value >= 1.0)
handlePtr->value = 1.0f;
else
handlePtr->value = value;
handlePtr->value = (float)value;

return;



+ 26
- 4
source/modules/carla_native/midi-split.c View File

@@ -18,17 +18,37 @@
#include "CarlaNative.h"
#include "CarlaMIDI.h"

#include <stdlib.h>

// -----------------------------------------------------------------------

typedef struct {
const NativeHostDescriptor* host;
} MidiSplitHandle;

// -----------------------------------------------------------------------

static NativePluginHandle midiSplit_instantiate(const NativeHostDescriptor* host)
{
// use HostDescriptor as PluginHandle
return (NativePluginHandle)host;
MidiSplitHandle* const handle = (MidiSplitHandle*)malloc(sizeof(MidiSplitHandle));

if (handle == NULL)
return NULL;

handle->host = host;
return handle;
}

#define handlePtr ((MidiSplitHandle*)handle)

static void midiSplit_cleanup(NativePluginHandle handle)
{
free(handlePtr);
}

static void midiSplit_process(NativePluginHandle handle, float** inBuffer, float** outBuffer, uint32_t frames, const NativeMidiEvent* midiEvents, uint32_t midiEventCount)
{
const NativeHostDescriptor* const host = (const NativeHostDescriptor*)handle;
const NativeHostDescriptor* const host = handlePtr->host;
NativeMidiEvent tmpEvent;

for (uint32_t i=0; i < midiEventCount; ++i)
@@ -60,6 +80,8 @@ static void midiSplit_process(NativePluginHandle handle, float** inBuffer, float
(void)frames;
}

#undef handlePtr

// -----------------------------------------------------------------------

static const NativePluginDescriptor midiSplitDesc = {
@@ -78,7 +100,7 @@ static const NativePluginDescriptor midiSplitDesc = {
.copyright = "GNU GPL v2+",

.instantiate = midiSplit_instantiate,
.cleanup = NULL,
.cleanup = midiSplit_cleanup,

.get_parameter_count = NULL,
.get_parameter_info = NULL,


+ 26
- 4
source/modules/carla_native/midi-through.c View File

@@ -18,17 +18,37 @@
#include "CarlaNative.h"
#include "CarlaMIDI.h"

#include <stdlib.h>

// -----------------------------------------------------------------------

typedef struct {
const NativeHostDescriptor* host;
} MidiThroughHandle;

// -----------------------------------------------------------------------

static NativePluginHandle midiThrough_instantiate(const NativeHostDescriptor* host)
{
// use HostDescriptor as PluginHandle
return (NativePluginHandle)host;
MidiThroughHandle* const handle = (MidiThroughHandle*)malloc(sizeof(MidiThroughHandle));

if (handle == NULL)
return NULL;

handle->host = host;
return handle;
}

#define handlePtr ((MidiThroughHandle*)handle)

static void midiThrough_cleanup(NativePluginHandle handle)
{
free(handlePtr);
}

static void midiThrough_process(NativePluginHandle handle, float** inBuffer, float** outBuffer, uint32_t frames, const NativeMidiEvent* midiEvents, uint32_t midiEventCount)
{
const NativeHostDescriptor* const host = (const NativeHostDescriptor*)handle;
const NativeHostDescriptor* const host = handlePtr->host;

for (uint32_t i=0; i < midiEventCount; ++i)
host->write_midi_event(host->handle, &midiEvents[i]);
@@ -41,6 +61,8 @@ static void midiThrough_process(NativePluginHandle handle, float** inBuffer, flo
(void)frames;
}

#undef handlePtr

// -----------------------------------------------------------------------

static const NativePluginDescriptor midiThroughDesc = {
@@ -59,7 +81,7 @@ static const NativePluginDescriptor midiThroughDesc = {
.copyright = "GNU GPL v2+",

.instantiate = midiThrough_instantiate,
.cleanup = NULL,
.cleanup = midiThrough_cleanup,

.get_parameter_count = NULL,
.get_parameter_info = NULL,


+ 1
- 1
source/modules/carla_native/midi-transpose.c View File

@@ -120,7 +120,7 @@ static void midiTranspose_process(NativePluginHandle handle, float** inBuffer, f
tmpEvent.port = midiEvent->port;
tmpEvent.time = midiEvent->time;
tmpEvent.data[0] = midiEvent->data[0];
tmpEvent.data[1] = newnote;
tmpEvent.data[1] = (uint8_t)newnote;
tmpEvent.data[2] = midiEvent->data[2];
tmpEvent.data[3] = midiEvent->data[3];
tmpEvent.size = midiEvent->size;


+ 57
- 57
source/plugin/Makefile View File

@@ -6,25 +6,25 @@

include ../Makefile.mk

BUILD_CXX_FLAGS += -I../includes -I../modules -I../utils
BUILD_CXX_FLAGS += -I../includes -I../utils -isystem ../modules

# --------------------------------------------------------------

ifeq ($(HAVE_OPENGL),true)
BUILD_CXX_FLAGS += -DWANT_OPENGL
endif
ifeq ($(HAVE_AF_DEPS),true)
BUILD_CXX_FLAGS += -DWANT_AUDIOFILE
endif
ifeq ($(HAVE_MF_DEPS),true)
BUILD_CXX_FLAGS += -DWANT_MIDIFILE
endif
ifeq ($(HAVE_ZYN_DEPS),true)
BUILD_CXX_FLAGS += -DWANT_ZYNADDSUBFX
endif
# ifeq ($(HAVE_OPENGL),true)
# BUILD_CXX_FLAGS += -DWANT_OPENGL
# endif
#
# ifeq ($(HAVE_AF_DEPS),true)
# BUILD_CXX_FLAGS += -DWANT_AUDIOFILE
# endif
#
# ifeq ($(HAVE_MF_DEPS),true)
# BUILD_CXX_FLAGS += -DWANT_MIDIFILE
# endif
#
# ifeq ($(HAVE_ZYN_DEPS),true)
# BUILD_CXX_FLAGS += -DWANT_ZYNADDSUBFX
# endif

# --------------------------------------------------------------
# Common
@@ -45,61 +45,61 @@ endif
# --------------------------------------------------------------
# Native

ifeq ($(HAVE_AF_DEPS),true)
LINK_FLAGS += $(shell pkg-config --libs sndfile)
ifeq ($(HAVE_FFMPEG),true)
LINK_FLAGS += $(shell pkg-config --libs libavcodec libavformat libavutil)
endif
endif
ifeq ($(HAVE_MF_DEPS),true)
LINK_FLAGS += $(shell pkg-config --libs smf)
endif
ifeq ($(HAVE_ZYN_DEPS),true)
LINK_FLAGS += $(shell pkg-config --libs fftw3 mxml zlib)
ifeq ($(HAVE_ZYN_UI_DEPS),true)
LINK_FLAGS += $(shell pkg-config --libs ntk_images ntk)
endif
endif
# ifeq ($(HAVE_AF_DEPS),true)
# LINK_FLAGS += $(shell pkg-config --libs sndfile)
# ifeq ($(HAVE_FFMPEG),true)
# LINK_FLAGS += $(shell pkg-config --libs libavcodec libavformat libavutil)
# endif
# endif
#
# ifeq ($(HAVE_MF_DEPS),true)
# LINK_FLAGS += $(shell pkg-config --libs smf)
# endif
#
# ifeq ($(HAVE_ZYN_DEPS),true)
# LINK_FLAGS += $(shell pkg-config --libs fftw3 mxml zlib)
# ifeq ($(HAVE_ZYN_UI_DEPS),true)
# LINK_FLAGS += $(shell pkg-config --libs ntk_images ntk)
# endif
# endif

# --------------------------------------------------------------
# Libs

LINK_FLAGS += $(JUCE_AUDIO_BASICS_LIBS)
LINK_FLAGS += $(JUCE_CORE_LIBS)
LINK_FLAGS += $(JUCE_DATA_STRUCTURES_LIBS)
LINK_FLAGS += $(JUCE_EVENTS_LIBS)
LINK_FLAGS += $(JUCE_GRAPHICS_LIBS)
LINK_FLAGS += $(JUCE_GUI_BASICS_LIBS)
# LINK_FLAGS += $(JUCE_AUDIO_BASICS_LIBS)
# LINK_FLAGS += $(JUCE_CORE_LIBS)
# LINK_FLAGS += $(JUCE_DATA_STRUCTURES_LIBS)
# LINK_FLAGS += $(JUCE_EVENTS_LIBS)
# LINK_FLAGS += $(JUCE_GRAPHICS_LIBS)
# LINK_FLAGS += $(JUCE_GUI_BASICS_LIBS)
LINK_FLAGS += $(RTMEMPOOL_LIBS)

ifeq ($(HAVE_OPENGL),true)
LINK_FLAGS += $(DGL_LIBS)
endif
# ifeq ($(HAVE_OPENGL),true)
# LINK_FLAGS += $(DGL_LIBS)
# endif

ifeq ($(CARLA_PLUGIN_SUPPORT),true)
LINK_FLAGS += $(LILV_LIBS)
endif
# ifeq ($(CARLA_PLUGIN_SUPPORT),true)
# LINK_FLAGS += $(LILV_LIBS)
# endif

# --------------------------------------------------------------

LIBS = ../modules/carla_native.a
LIBS += ../modules/juce_audio_basics.a
LIBS += ../modules/juce_core.a
LIBS += ../modules/juce_data_structures.a
LIBS += ../modules/juce_events.a
LIBS += ../modules/juce_graphics.a
LIBS += ../modules/juce_gui_basics.a
# LIBS += ../modules/juce_audio_basics.a
# LIBS += ../modules/juce_core.a
# LIBS += ../modules/juce_data_structures.a
# LIBS += ../modules/juce_events.a
# LIBS += ../modules/juce_graphics.a
# LIBS += ../modules/juce_gui_basics.a
LIBS += ../modules/rtmempool.a

ifeq ($(HAVE_OPENGL),true)
LIBS += ../modules/dgl.a
endif
# ifeq ($(HAVE_OPENGL),true)
# LIBS += ../modules/dgl.a
# endif

ifeq ($(CARLA_PLUGIN_SUPPORT),true)
LIBS += ../modules/lilv.a
endif
# ifeq ($(CARLA_PLUGIN_SUPPORT),true)
# LIBS += ../modules/lilv.a
# endif

# --------------------------------------------------------------



Loading…
Cancel
Save