From 7294b9163f52a019297aa44f12991d8aa914c5bc Mon Sep 17 00:00:00 2001 From: Werner Schweer Date: Sat, 28 Oct 2006 10:00:17 +0000 Subject: fixes for zynaddsubfx port --- muse/CMakeLists.txt | 6 ++-- muse/muse/synth.cpp | 4 +-- muse/synti/libsynti/gui.cpp | 30 +++++++++--------- muse/synti/zynaddsubfx/CMakeLists.txt | 17 +++------- muse/synti/zynaddsubfx/Misc/Master.C | 15 +++++---- muse/synti/zynaddsubfx/main.cpp | 60 +++++++++++++++++++++++------------ 6 files changed, 73 insertions(+), 59 deletions(-) diff --git a/muse/CMakeLists.txt b/muse/CMakeLists.txt index a0394030..f8e3b5bc 100644 --- a/muse/CMakeLists.txt +++ b/muse/CMakeLists.txt @@ -30,7 +30,7 @@ set(CMAKE_BUILD_TYPE debug) # set(CMAKE_BUILD_TYPE release) # for debugging the make system uncomment next line: -set(CMAKE_VERBOSE_MAKEFILE ON) +# set(CMAKE_VERBOSE_MAKEFILE ON) set(CMAKE_CXX_FLAGS "-Wall -Wextra -Winvalid-pch -fno-exceptions") set(CMAKE_CXX_FLAGS_RELEASE "-O2") @@ -119,7 +119,9 @@ endif (APPLE) ## ## find packages for zyaddsubfx ## -## PKGCONFIG (fftw3 +## fftw3 +## mxml +## fltk + fluid if (ENABLE_ZYNADDSUBFX) find_path( FLTK_FLUID_EXECUTABLE fluid ) diff --git a/muse/muse/synth.cpp b/muse/muse/synth.cpp index 693ad92c..5babcbe3 100644 --- a/muse/muse/synth.cpp +++ b/muse/muse/synth.cpp @@ -140,8 +140,8 @@ void* MessSynth::instantiate(const QString& instanceName) // load Synti dll if (debugMsg) printf(" load synti <%s>\n", path); - // void* handle = dlopen(path, RTLD_NOW); - void* handle = dlopen(path, RTLD_LAZY); + void* handle = dlopen(path, RTLD_NOW); + // void* handle = dlopen(path, RTLD_LAZY); if (handle == 0) { fprintf(stderr, "Synth::instantiate: dlopen(%s) failed: %s\n", path, dlerror()); diff --git a/muse/synti/libsynti/gui.cpp b/muse/synti/libsynti/gui.cpp index a983bf94..092b094e 100644 --- a/muse/synti/libsynti/gui.cpp +++ b/muse/synti/libsynti/gui.cpp @@ -59,21 +59,6 @@ void MessGui::readMessage() } } -//--------------------------------------------------------- -// sendEvent -//--------------------------------------------------------- - -void MessGui::sendEvent(const MidiEvent& ev) - { - if (wFifoSize == EVENT_FIFO_SIZE) { - printf("event gui->synti fifo overflow\n"); - return; - } - wFifo[wFifoWindex] = ev; - wFifoWindex = (wFifoWindex + 1) % EVENT_FIFO_SIZE; - ++wFifoSize; - } - //--------------------------------------------------------- // sendController //--------------------------------------------------------- @@ -115,6 +100,21 @@ void MessGui::writeEvent(const MidiEvent& ev) write(writeFd, "x", 1); // wakeup GUI } +//--------------------------------------------------------- +// sendEvent +//--------------------------------------------------------- + +void MessGui::sendEvent(const MidiEvent& ev) + { + if (wFifoSize == EVENT_FIFO_SIZE) { + printf("event gui->synti fifo overflow\n"); + return; + } + wFifo[wFifoWindex] = ev; + wFifoWindex = (wFifoWindex + 1) % EVENT_FIFO_SIZE; + ++wFifoSize; + } + //--------------------------------------------------------- // readEvent // read event from synti gui diff --git a/muse/synti/zynaddsubfx/CMakeLists.txt b/muse/synti/zynaddsubfx/CMakeLists.txt index a0f095a2..8776a3d5 100644 --- a/muse/synti/zynaddsubfx/CMakeLists.txt +++ b/muse/synti/zynaddsubfx/CMakeLists.txt @@ -49,6 +49,8 @@ FLTK_WRAP_UI ( fltk_ui # ${fltk_ui_FLTK_UI_SRCS} # Output/JACKaudiooutput.C # Input/MidiIn.C +# Input/ALSAMidiIn.C +# Input/NULLMidiIn.C add_library ( zynaddsubfx SHARED ${fltk_ui_FLTK_UI_SRCS} @@ -68,8 +70,6 @@ add_library ( zynaddsubfx SHARED Effects/EffectMgr.C Effects/Phaser.C Effects/Reverb.C - Input/ALSAMidiIn.C - Input/NULLMidiIn.C Output/Recorder.C Misc/Bank.C Misc/Config.C @@ -107,19 +107,12 @@ add_library ( zynaddsubfx SHARED set_target_properties ( zynaddsubfx PROPERTIES PREFIX "" - COMPILE_FLAGS "-fvisibility=hidden -DOS_LINUX -DNONEMIDIIN -DFFTW_VERSION_3 -DASM_F2I_YES -DNONEAUDIOOUT" + COMPILE_FLAGS "-O6 -fvisibility=hidden -DASM_F2I_YES -DOS_LINUX -DFFTW_VERSION_3" ) target_link_libraries( zynaddsubfx - synti - jack - asound - pthread - fftw3 - mxml - m - z - fltk + synti jack asound pthread fftw3 mxml + m z fltk ) install_targets ( /${CMAKE_INSTALL_LIBDIR}/${MusE_INSTALL_NAME}/synthi/ zynaddsubfx ) diff --git a/muse/synti/zynaddsubfx/Misc/Master.C b/muse/synti/zynaddsubfx/Misc/Master.C index 7d697418..87142c09 100644 --- a/muse/synti/zynaddsubfx/Misc/Master.C +++ b/muse/synti/zynaddsubfx/Misc/Master.C @@ -414,17 +414,18 @@ void Master::AudioOut(REALTYPE* outl, REALTYPE* outr) void Master::GetAudioOutSamples(int nsamples, REALTYPE* outl, REALTYPE* outr) { + int dstOffset = 0; while (nsamples) { - if (ksoundbuffersamples == 0) { + if (ksoundbuffersamples <= 0) { AudioOut(audiooutl, audiooutr); ksoundbuffersamples = SOUND_BUFFER_SIZE; } - int n = nsamples > ksoundbuffersamples ? ksoundbuffersamples : nsamples; - memcpy(outl, audiooutl + SOUND_BUFFER_SIZE - ksoundbuffersamples, - n * sizeof(REALTYPE)); - memcpy(outr, audiooutr + SOUND_BUFFER_SIZE - ksoundbuffersamples, - n * sizeof(REALTYPE)); - nsamples -= n; + int n = nsamples > ksoundbuffersamples ? ksoundbuffersamples : nsamples; + int srcOffset = SOUND_BUFFER_SIZE - ksoundbuffersamples; + memcpy(outl + dstOffset, audiooutl + srcOffset, n * sizeof(REALTYPE)); + memcpy(outr + dstOffset, audiooutr + srcOffset, n * sizeof(REALTYPE)); + nsamples -= n; + dstOffset += n; ksoundbuffersamples -= n; } } diff --git a/muse/synti/zynaddsubfx/main.cpp b/muse/synti/zynaddsubfx/main.cpp index 30844f01..70c56415 100644 --- a/muse/synti/zynaddsubfx/main.cpp +++ b/muse/synti/zynaddsubfx/main.cpp @@ -20,25 +20,16 @@ */ -#include #include #include -#include - #include #include #include "Misc/Master.h" #include "Misc/Util.h" -#include "Misc/Dump.h" -extern Dump dump; - -#include "Input/NULLMidiIn.h" #include "MasterUI.h" -int swaplr=0; //1 for left-right swapping -MidiIn *Midi; -int Pexitprogram = 0;//if the UI set this to 1, the program will exit +int swaplr = 0; //1 for left-right swapping //========================================================= // MESS interface @@ -90,7 +81,6 @@ void* guiThread(void *arg) Zynadd::Zynadd() : Mess(2) { instances++; - SAMPLE_RATE = sampleRate(); swaplr = config.cfg.SwapStereo; Pexitprogram = 0; @@ -139,26 +129,54 @@ void Zynadd::process(float** outputs, int offset, int n) bool Zynadd::processEvent(const MidiEvent& e) { + int ch = e.channel(); pthread_mutex_lock(&vmaster->mutex); switch(e.type()) { case 0x80: // note off - vmaster->NoteOff(e.channel(), e.dataA()); + vmaster->NoteOff(ch, e.dataA()); break; case 0x90: // note on if (e.dataB() == 0) - vmaster->NoteOff(e.channel(), e.dataA()); + vmaster->NoteOff(ch, e.dataA()); else - vmaster->NoteOn(e.channel(), e.dataA(), e.dataB()); + vmaster->NoteOn(ch, e.dataA(), e.dataB()); break; case 0xb0: // controller - if (e.dataA() == 0x4000) - // vmaster->setcontroller(e.channel(), C_pitchwheel, data[1]+data[2]*(long int) 128-8192); - vmaster->SetController(e.channel(), C_pitchwheel, e.dataB()); - else { - int cntl = Midi->getcontroller(e.dataA()); - vmaster->SetController(e.channel(), cntl, e.dataB()); + switch(e.dataA()) { + case 0x4000: + vmaster->SetController(ch, C_pitchwheel, e.dataB()); + break; + default: + { + int ctl; + switch (e.dataA()) { + case 1: ctl = C_modwheel; break; + case 7: ctl = C_volume; break; + case 10: ctl = C_panning; break; + case 11: ctl = C_expression; break; + case 64: ctl = C_sustain; break; + case 65: ctl = C_portamento; break; + case 71: ctl = C_filterq; break; + case 74: ctl = C_filtercutoff; break; + case 75: ctl = C_bandwidth; break; + case 76: ctl = C_fmamp; break; + case 77: ctl = C_resonance_center; break; + case 78: ctl = C_resonance_bandwidth; break; + case 120: ctl = C_allsoundsoff; break; + case 121: ctl = C_resetallcontrollers; break; + case 123: ctl = C_allnotesoff; break; + case 0x06: ctl = C_dataentryhi; break; + case 0x26: ctl = C_dataentrylo; break; + case 99: ctl = C_nrpnhi; break; + case 98: ctl = C_nrpnlo; break; + default: ctl = C_NULL; break; + } + vmaster->SetController(ch, ctl, e.dataB()); + } + break; } break; + case 0xf0: pthread_mutex_unlock(&vmaster->mutex); vmaster->putalldata((char*)e.data(), e.len()); @@ -179,11 +197,11 @@ static Mess* instantiate(int sr, QWidget*, const char*) { if (instances == -1) { config.init(); - Midi = new NULLMidiIn(); instances = 0; srand(time(0)); SOUND_BUFFER_SIZE = 256; OSCIL_SIZE = 512; // config.cfg.OscilSize; + SAMPLE_RATE = sr; denormalkillbuf = new REALTYPE [SOUND_BUFFER_SIZE]; for (int i = 0; i < SOUND_BUFFER_SIZE; i++) denormalkillbuf[i] = (RND - 0.5) * 1e-16; -- cgit v1.2.3