Browse Source

Update native API for 4 byte midiData, update zyn and fix it

tags/1.9.4
falkTX 11 years ago
parent
commit
b411ef4862
11 changed files with 58 additions and 30 deletions
  1. +2
    -1
      source/backend/CarlaEngine.hpp
  2. +5
    -1
      source/backend/native/midi-sequencer.cpp
  3. +2
    -0
      source/backend/native/midi-split.c
  4. +2
    -0
      source/backend/native/midi-transpose.c
  5. +23
    -15
      source/backend/native/zynaddsubfx.cpp
  6. +4
    -3
      source/backend/native/zynaddsubfx/CMakeLists.txt
  7. +8
    -7
      source/backend/native/zynaddsubfx/Misc/Master.cpp
  8. +6
    -0
      source/backend/native/zynaddsubfx/Misc/Master.h
  9. +0
    -2
      source/backend/native/zynaddsubfx/Misc/Stereo.cpp
  10. +4
    -1
      source/backend/native/zynaddsubfx/Tests/CMakeLists.txt
  11. +2
    -0
      source/backend/plugin/NativePlugin.cpp

+ 2
- 1
source/backend/CarlaEngine.hpp View File

@@ -169,7 +169,7 @@ struct EngineControlEvent {
*/
struct EngineMidiEvent {
uint8_t port; //!< Port offset (usually 0)
uint8_t data[3]; //!< MIDI data, without channel bit
uint8_t data[4]; //!< MIDI data, without channel bit
uint8_t size; //!< Number of bytes used

#ifndef CARLA_PROPER_CPP11_SUPPORT
@@ -185,6 +185,7 @@ struct EngineMidiEvent {
data[0] = 0;
data[1] = 0;
data[2] = 0;
data[3] = 0;
size = 0;
}
};


+ 5
- 1
source/backend/native/midi-sequencer.cpp View File

@@ -20,7 +20,7 @@
#include "CarlaMutex.hpp"
#include "RtList.hpp"

#define MAX_EVENT_DATA_SIZE 3
#define MAX_EVENT_DATA_SIZE 4
#define MIN_PREALLOCATED_EVENT_COUNT 100
#define MAX_PREALLOCATED_EVENT_COUNT 1000

@@ -215,6 +215,8 @@ public:
midiEvent.data[0] = rawMidiEvent->data[0];
midiEvent.data[1] = rawMidiEvent->data[1];
midiEvent.data[2] = rawMidiEvent->data[2];
midiEvent.data[3] = rawMidiEvent->data[3];
midiEvent.size = rawMidiEvent->size;

writeMidiEvent(&midiEvent);
}
@@ -303,6 +305,8 @@ protected:
rawMidiEvent.data[0] = midiEvent->data[0];
rawMidiEvent.data[1] = midiEvent->data[1];
rawMidiEvent.data[2] = midiEvent->data[2];
rawMidiEvent.data[3] = midiEvent->data[3];
rawMidiEvent.size = midiEvent->size;
rawMidiEvent.time = timePos->frame + midiEvent->time;

fInEvents.appendRT(rawMidiEvent);


+ 2
- 0
source/backend/native/midi-split.c View File

@@ -65,6 +65,8 @@ static void midiSplit_process(PluginHandle handle, float** inBuffer, float** out
tmpEvent.data[0] = status;
tmpEvent.data[1] = midiEvent->data[1];
tmpEvent.data[2] = midiEvent->data[2];
tmpEvent.data[3] = midiEvent->data[3];
tmpEvent.size = midiEvent->size;

host->write_midi_event(host->handle, &tmpEvent);
}


+ 2
- 0
source/backend/native/midi-transpose.c View File

@@ -123,6 +123,8 @@ static void midiTranspose_process(PluginHandle handle, float** inBuffer, float**
tmpEvent.data[0] = midiEvent->data[0];
tmpEvent.data[1] = rnote;
tmpEvent.data[2] = midiEvent->data[2];
tmpEvent.data[3] = midiEvent->data[3];
tmpEvent.size = midiEvent->size;

host->write_midi_event(host->handle, &tmpEvent);
}


+ 23
- 15
source/backend/native/zynaddsubfx.cpp View File

@@ -58,15 +58,6 @@ public:
kSampleRate(getSampleRate())
{
_maybeInitPrograms(kMaster);

// pre-run to create static data
{
const size_t bufSize = getBufferSize();
float out[bufSize];
carla_stdout("BEFORE %li %i", bufSize, kSampleRate);
//kMaster->GetAudioOutSamples(bufSize, kSampleRate, out, out);
carla_stdout("AFTER %li %i", bufSize, kSampleRate);
}
}

~ZynAddSubFxPlugin()
@@ -206,15 +197,13 @@ protected:

void process(float**, float** const outBuffer, const uint32_t frames, const uint32_t midiEventCount, const MidiEvent* const midiEvents)
{
//if (pthread_mutex_trylock(&kMaster->mutex) != 0)
if (pthread_mutex_trylock(&kMaster->mutex) != 0)
{
carla_zeroFloat(outBuffer[0], frames);
carla_zeroFloat(outBuffer[1], frames);
return;
}

pthread_mutex_lock(&kMaster->mutex);

for (uint32_t i=0; i < midiEventCount; i++)
{
const MidiEvent* const midiEvent = &midiEvents[i];
@@ -349,11 +338,10 @@ public:

if (! doSearch)
return;

doSearch = false;

pthread_mutex_lock(&master->mutex);
#if 0
// refresh banks
master->bank.rescanforbanks();

@@ -374,16 +362,36 @@ public:
sPrograms.append(new ProgramInfo(i, instrument, insName.c_str()));
}
}
#endif
pthread_mutex_unlock(&master->mutex);
}

static void _clearPrograms()
{
for (auto it = sPrograms.begin(); it.valid(); it.next())
{
ProgramInfo* const programInfo(*it);
delete programInfo;
}

sPrograms.clear();
}

private:
CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ZynAddSubFxPlugin)
};

int ZynAddSubFxPlugin::sInstanceCount = 0;
NonRtList<ZynAddSubFxPlugin::ProgramInfo*> ZynAddSubFxPlugin::sPrograms;

struct ProgramsDestructor {
ProgramsDestructor() {}
~ProgramsDestructor()
{
ZynAddSubFxPlugin::_clearPrograms();
}
} programsDestructor;

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

static const PluginDescriptor zynAddSubFxDesc = {


+ 4
- 3
source/backend/native/zynaddsubfx/CMakeLists.txt View File

@@ -303,9 +303,6 @@ add_subdirectory(Synth)
add_subdirectory(Effects)
add_subdirectory(Params)
add_subdirectory(DSP)
if(CompileTests)
add_subdirectory(Tests)
endif(CompileTests)
add_subdirectory(Nio)

add_library(zynaddsubfx_core STATIC
@@ -323,6 +320,10 @@ target_link_libraries(zynaddsubfx_core
${OS_LIBRARIES}
pthread)

if(CompileTests)
add_subdirectory(Tests)
endif(CompileTests)

message(STATUS "using link directories: ${AUDIO_LIBRARY_DIRS} ${ZLIB_LIBRARY_DIRS} ${FFTW_LIBRARY_DIRS} ${MXML_LIBRARY_DIRS} ${FLTK_LIBRARY_DIRS}")




+ 8
- 7
source/backend/native/zynaddsubfx/Misc/Master.cpp View File

@@ -50,6 +50,10 @@ static Master* masterInstance = NULL;
Master::Master()
{
swaplr = 0;
off = 0;
smps = 0;
bufl = new float[synth->buffersize];
bufr = new float[synth->buffersize];

pthread_mutex_init(&mutex, NULL);
pthread_mutex_init(&vumutex, NULL);
@@ -482,11 +486,6 @@ void Master::GetAudioOutSamples(size_t nsamples,
float *outl,
float *outr)
{
static float *bufl = new float[synth->buffersize],
*bufr = new float[synth->buffersize];
static off_t off = 0;
static size_t smps = 0;

off_t out_off = 0;

//Fail when resampling rather than doing a poor job
@@ -505,9 +504,8 @@ void Master::GetAudioOutSamples(size_t nsamples,
//generate samples
AudioOut(bufl, bufr);
off = 0;
smps = synth->buffersize;

out_off += smps;
smps = synth->buffersize;
}
else { //use some samples
memcpy(outl + out_off, bufl + off, sizeof(float) * nsamples);
@@ -521,6 +519,9 @@ void Master::GetAudioOutSamples(size_t nsamples,

Master::~Master()
{
delete []bufl;
delete []bufr;

for(int npart = 0; npart < NUM_MIDI_PARTS; ++npart)
delete part[npart];
for(int nefx = 0; nefx < NUM_INS_EFX; ++nefx)


+ 6
- 0
source/backend/native/zynaddsubfx/Misc/Master.h View File

@@ -171,6 +171,12 @@ class Master
float sysefxvol[NUM_SYS_EFX][NUM_MIDI_PARTS];
float sysefxsend[NUM_SYS_EFX][NUM_SYS_EFX];
int keyshift;

//information relevent to generating plugin audio samples
float *bufl;
float *bufr;
off_t off;
size_t smps;
};

#endif

+ 0
- 2
source/backend/native/zynaddsubfx/Misc/Stereo.cpp View File

@@ -19,8 +19,6 @@
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

#include "Stereo.h"

template<class T>
Stereo<T>::Stereo(const T &left, const T &right)
:l(left), r(right)


+ 4
- 1
source/backend/native/zynaddsubfx/Tests/CMakeLists.txt View File

@@ -12,6 +12,7 @@ CXXTEST_ADD_TEST(SUBnoteTest SubNoteTest.cpp ${CMAKE_CURRENT_SOURCE_DIR}/SubNote
CXXTEST_ADD_TEST(OscilGenTest OscilGenTest.cpp ${CMAKE_CURRENT_SOURCE_DIR}/OscilGenTest.h)
CXXTEST_ADD_TEST(RandTest RandTest.cpp ${CMAKE_CURRENT_SOURCE_DIR}/RandTest.h)
CXXTEST_ADD_TEST(PADnoteTest PadNoteTest.cpp ${CMAKE_CURRENT_SOURCE_DIR}/PadNoteTest.h)
CXXTEST_ADD_TEST(PluginTest PluginTest.cpp ${CMAKE_CURRENT_SOURCE_DIR}/PluginTest.h)

#Extra libraries added to make test and full compilation use the same library
#links for quirky compilers
@@ -26,5 +27,7 @@ target_link_libraries(MicrotonalTest ${test_lib})
target_link_libraries(OscilGenTest ${test_lib})
target_link_libraries(XMLwrapperTest ${test_lib})
target_link_libraries(RandTest ${test_lib})
target_link_libraries(PADnoteTest ${test_lib})
target_link_libraries(PADnoteTest ${test_lib})
target_link_libraries(PluginTest zynaddsubfx_core zynaddsubfx_nio
${OS_LIBRARIES} ${AUDIO_LIBRARIES})


+ 2
- 0
source/backend/plugin/NativePlugin.cpp View File

@@ -1468,10 +1468,12 @@ public:

fMidiEvents[fMidiEventCount].port = 0;
fMidiEvents[fMidiEventCount].time = sampleAccurate ? startTime : time;
fMidiEvents[fMidiEventCount].size = 3; // FIXME

fMidiEvents[fMidiEventCount].data[0] = status + channel;
fMidiEvents[fMidiEventCount].data[1] = midiEvent.data[1];
fMidiEvents[fMidiEventCount].data[2] = midiEvent.data[2];
fMidiEvents[fMidiEventCount].data[3] = midiEvent.data[3];

fMidiEventCount += 1;



Loading…
Cancel
Save