From 47a10173ea203de2036dd00791fe5c24fb673135 Mon Sep 17 00:00:00 2001 From: Robert Jonsson Date: Fri, 15 Apr 2011 18:52:45 +0000 Subject: removing unnecessary duplication --- attic/muse2-oom/muse2/synti/organ/CMakeLists.txt | 90 -- attic/muse2-oom/muse2/synti/organ/organ.cpp | 716 ----------- attic/muse2-oom/muse2/synti/organ/organ.h | 198 --- attic/muse2-oom/muse2/synti/organ/organgui.cpp | 185 --- attic/muse2-oom/muse2/synti/organ/organgui.h | 45 - attic/muse2-oom/muse2/synti/organ/organguibase.ui | 1351 --------------------- 6 files changed, 2585 deletions(-) delete mode 100644 attic/muse2-oom/muse2/synti/organ/CMakeLists.txt delete mode 100644 attic/muse2-oom/muse2/synti/organ/organ.cpp delete mode 100644 attic/muse2-oom/muse2/synti/organ/organ.h delete mode 100644 attic/muse2-oom/muse2/synti/organ/organgui.cpp delete mode 100644 attic/muse2-oom/muse2/synti/organ/organgui.h delete mode 100644 attic/muse2-oom/muse2/synti/organ/organguibase.ui (limited to 'attic/muse2-oom/muse2/synti/organ') diff --git a/attic/muse2-oom/muse2/synti/organ/CMakeLists.txt b/attic/muse2-oom/muse2/synti/organ/CMakeLists.txt deleted file mode 100644 index 0d8dda90..00000000 --- a/attic/muse2-oom/muse2/synti/organ/CMakeLists.txt +++ /dev/null @@ -1,90 +0,0 @@ -#============================================================================= -# MusE -# Linux Music Editor -# $Id:$ -# -# Copyright (C) 2002-2006 by Werner Schweer and others -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License version 2. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -#============================================================================= - -## -## Expand Qt macros in source files -## -QT4_WRAP_CPP ( organ_mocs - organgui.h - ) - -## -## UI files -## -file (GLOB organ_ui_files - organguibase.ui - ) -QT4_WRAP_UI ( organ_uis ${organ_ui_files} ) - -## -## List of source files to compile -## -file (GLOB organ_source_files - organ.cpp - organgui.cpp - # reverb.cpp - # routing.cpp - ) - -## -## Define target -## -add_library ( organ SHARED - ${PROJECT_SOURCE_DIR}/muse/xml.cpp - ${organ_source_files} - ${organ_mocs} - ${organ_uis} - ) - -## -## Append to the list of translations -## -set (FILES_TO_TRANSLATE - ${FILES_TO_TRANSLATE} - ${organ_source_files} - ${organ_ui_files} - CACHE INTERNAL "" - ) - -# - tell cmake to name target organ.so instead of -# liborgan.so -# - use precompiled header files -# -set_target_properties ( organ - PROPERTIES PREFIX "" - COMPILE_FLAGS "-fvisibility=hidden -O2 -include ${PROJECT_BINARY_DIR}/all-pic.h" - ) - -## -## Linkage -## -target_link_libraries(organ - synti - # awl - ${QT_LIBRARIES} - ) - -## -## Install location -## -install( TARGETS organ - DESTINATION ${MusE_SYNTHI_DIR} - ) - diff --git a/attic/muse2-oom/muse2/synti/organ/organ.cpp b/attic/muse2-oom/muse2/synti/organ/organ.cpp deleted file mode 100644 index 1aa87742..00000000 --- a/attic/muse2-oom/muse2/synti/organ/organ.cpp +++ /dev/null @@ -1,716 +0,0 @@ -//========================================================= -// MusE -// Linux Music Editor -// $Id: organ.cpp,v 1.15.2.8 2009/12/06 10:05:00 terminator356 Exp $ -// -// Parts of this file taken from: -// Organ - Additive Organ Synthesizer Voice -// Copyright (c) 1999, 2000 David A. Bartold -// -// (C) Copyright 2001-2004 Werner Schweer (ws@seh.de) -//========================================================= - -#include -#include - -#include "muse/midi.h" -//#include "libsynti/mpevent.h" -#include "muse/mpevent.h" - -#include "organ.h" -#include "organgui.h" - -//#define ORGAN_DEBUG - -SynthCtrl Organ::synthCtrl[] = { - { "harm0", HARM0, 0 }, - { "harm1", HARM1, 0 }, - { "harm2", HARM2, 0 }, - { "harm3", HARM3, 0 }, - { "harm4", HARM4, 0 }, - { "harm5", HARM5, 0 }, - { "attackLo", ATTACK_LO, 20 }, - { "decayLo", DECAY_LO, 20 }, - { "sustainLo", SUSTAIN_LO, 0 }, - { "releaseLo", RELEASE_LO, 20 }, - { "attackHi", ATTACK_HI, 10 }, - { "decayHi", DECAY_HI, 10 }, - { "sustainHi", SUSTAIN_HI, 0 }, - { "releaseHi", RELEASE_HI, 10 }, - { "brass", BRASS, 1 }, - { "flute", FLUTE, 1 }, - { "reed", REED, 1 }, - { "velocity", VELO, 0 }, - // next controller not send as init data - { "volume", CTRL_VOLUME, 100 }, - }; - -static int NUM_CONTROLLER = sizeof(Organ::synthCtrl)/sizeof(*(Organ::synthCtrl)); -static int NUM_INIT_CONTROLLER = NUM_CONTROLLER - 1; - -float* Organ::sine_table; -float* Organ::g_triangle_table; -float* Organ::g_pulse_table; -int Organ::useCount = 0; -double Organ::cb2amp_tab[MAX_ATTENUATION]; -unsigned Organ::freq256[128]; - -//--------------------------------------------------------- -// cb2amp -// convert centibel to amplification (0 - 96dB) -//--------------------------------------------------------- - -double Organ::cb2amp(int cb) - { - if (cb < 0) - return 1.0; - if (cb >= MAX_ATTENUATION) - return 0.0; - return cb2amp_tab[cb]; - } - -//--------------------------------------------------------- -// Organ -//--------------------------------------------------------- - -Organ::Organ(int sr) - : Mess(1) - { - idata = new int[NUM_CONTROLLER]; - setSampleRate(sr); - gui = 0; - - ++useCount; - if (useCount > 1) - return; - - // centibels to amplitude conversion - for (int i = 0; i < MAX_ATTENUATION; i++) - cb2amp_tab[i] = pow(10.0, double(i) / -200.0); - - for (int i = 0; i < 128; ++i) { - double freq = 8.176 * exp(double(i)*log(2.0)/12.0); - freq256[i] = (int) (freq * ((double) RESOLUTION) / sr * 256.0); - } - int size = RESOLUTION; - int half = size / 2; - int slope = size / 10; - int i; - - // Initialize sine table. - sine_table = new float[size]; - for (i = 0; i < size; i++) - sine_table[i] = sin ((i * 2.0 * M_PI) / size) / 6.0; - - // Initialize triangle table. - g_triangle_table = new float[size]; - for (i = 0; i < half; i++) - g_triangle_table[i] = (4.0 / size * i - 1.0) / 6.0; - for (; i < size; i++) - g_triangle_table[i] = (4.0 / size * (size - i) - 1.0) / 6.0; - - // Initialize pulse table. - g_pulse_table = new float[size]; - for (i = 0; i < slope; i++) - g_pulse_table[i] = (((double) -i) / slope) / 6.0; - for (; i < half - slope; i++) - g_pulse_table[i] = -1.0 / 6.0; - for (; i < half + slope; i++) - g_pulse_table[i] = (((double) i - half) / slope) / 6.0; - for (; i < size - slope; i++) - g_pulse_table[i] = 1.0 / 6.0; - for (; i < size; i++) - g_pulse_table[i] = (((double) size - i) / slope) / 6.0; - } - -//--------------------------------------------------------- -// ~Organ -//--------------------------------------------------------- - -Organ::~Organ() - { - if (gui) - delete gui; - delete idata; - --useCount; - if (useCount == 0) { - delete[] g_pulse_table; - delete[] g_triangle_table; - delete[] sine_table; - } - } - -//--------------------------------------------------------- -// table_pos -//--------------------------------------------------------- - -static inline float table_pos (float* table, unsigned long freq_256, unsigned *accum) - { - *accum += freq_256; - while (*accum >= RESOLUTION * 256) - *accum -= RESOLUTION * 256; - return table[*accum >> 8]; - } - -//--------------------------------------------------------- -// init -//--------------------------------------------------------- - -bool Organ::init(const char* name) - { - gui = new OrganGui; - gui->setWindowTitle(QString(name)); - gui->show(); - - for (int i = 0; i < NUM_CONTROLLER; ++i) - setController(0, synthCtrl[i].num, synthCtrl[i].val); - - for (int i = 0; i < VOICES; ++i) - voices[i].isOn = false; - return false; - } - -//--------------------------------------------------------- -// processMessages -// Called from host always, even if output path is unconnected. -//--------------------------------------------------------- - -void Organ::processMessages() -{ - //Process messages from the gui - // - // get and process all pending events from the - // synthesizer GUI - // - while (gui->fifoSize()) - { - MidiPlayEvent ev = gui->readEvent(); - if (ev.type() == ME_CONTROLLER) - { - // process local? - setController(ev.dataA(), ev.dataB()); - sendEvent(ev); - } - else - printf("Organ::process(): unknown event\n"); - } -} - -//--------------------------------------------------------- -// process -// Called from host, ONLY if output path is connected. -//--------------------------------------------------------- - -void Organ::process(float** ports, int offset, int sampleCount) - { - /* - // - // get and process all pending events from the - // synthesizer GUI - // - while (gui->fifoSize()) { - MidiPlayEvent ev = gui->readEvent(); - if (ev.type() == ME_CONTROLLER) { - // process local? - setController(ev.dataA(), ev.dataB()); - sendEvent(ev); - } - else - printf("Organ::process(): unknown event\n"); - } - */ - - float* buffer = *ports + offset; - for (int i = 0; i < VOICES; ++i) { - Voice* v = &voices[i]; - if (!v->isOn) - continue; - double vol = velo ? v->velocity : 1.0; - vol *= volume; - - unsigned freq_256 = freq256[v->pitch]; - unsigned* harm0_accum = &(v->harm0_accum); - unsigned* harm1_accum = &(v->harm1_accum); - unsigned* harm2_accum = &(v->harm2_accum); - unsigned* harm3_accum = &(v->harm3_accum); - unsigned* harm4_accum = &(v->harm4_accum); - unsigned* harm5_accum = &(v->harm5_accum); - - unsigned long freq_256_harm2, freq_256_harm3; - unsigned long freq_256_harm4, freq_256_harm5; - - float* reed_table = reed ? g_pulse_table : sine_table; - float* flute_table = flute ? g_triangle_table : sine_table; - - unsigned freq_256_harm0 = freq_256 / 2; - unsigned freq_256_harm1 = freq_256; - - if (brass) { - freq_256_harm2 = freq_256 * 2; - freq_256_harm3 = freq_256_harm2 * 2; - freq_256_harm4 = freq_256_harm3 * 2; - freq_256_harm5 = freq_256_harm4 * 2; - for (int i = 0; i < sampleCount; i++) { - int a1=0, a2=0; //prevent compiler warning: unitialized usage of vars a1 & a2 - switch(v->state1) { - case ATTACK: - if (v->envL1.step(&a1)) - break; - v->state1 = DECAY; - case DECAY: - if (v->envL2.step(&a1)) - break; - v->state1 = SUSTAIN; - case SUSTAIN: - a1 = sustain0; - break; - case RELEASE: - if (v->envL3.step(&a1)) - break; - v->state1 = OFF; - a1 = MAX_ATTENUATION; - break; - } - switch(v->state2) { - case ATTACK: - if (v->envH1.step(&a2)) - break; - v->state2 = DECAY; - case DECAY: - if (v->envH2.step(&a2)) - break; - v->state2 = SUSTAIN; - case SUSTAIN: - a2 = sustain1; - break; - case RELEASE: - if (v->envH3.step(&a2)) - break; - v->state2 = OFF; - a1 = MAX_ATTENUATION; - break; - } - if (v->state1 == OFF && v->state2 == OFF) { - v->isOn = false; - break; - } - buffer[i] += - (table_pos (sine_table, freq_256_harm0, harm0_accum) * harm0 - + table_pos (sine_table, freq_256_harm1, harm1_accum) * harm1 - + table_pos (reed_table, freq_256_harm2, harm2_accum) * harm2) - * cb2amp(a1) * vol - + (table_pos (sine_table, freq_256_harm3, harm3_accum) * harm3 - + table_pos (flute_table, freq_256_harm4, harm4_accum) * harm4 - + table_pos (flute_table, freq_256_harm5, harm5_accum) * harm5) - * cb2amp(a2) * vol; - } - } - else { - freq_256_harm2 = freq_256 * 3 / 2; - freq_256_harm3 = freq_256 * 2; - freq_256_harm4 = freq_256 * 3; - freq_256_harm5 = freq_256_harm3 * 2; - for (int i = 0; i < sampleCount; i++) { - int a1=0, a2=0;//prevent compiler warning: unitialized usage of vars a1 & a2 - switch(v->state1) { - case ATTACK: - if (v->envL1.step(&a1)) - break; - v->state1 = DECAY; - case DECAY: - if (v->envL2.step(&a1)) - break; - v->state1 = SUSTAIN; - case SUSTAIN: - a1 = sustain0; - break; - case RELEASE: - if (v->envL3.step(&a1)) - break; - v->state1 = OFF; - a1 = MAX_ATTENUATION; - break; - } - switch(v->state2) { - case ATTACK: - if (v->envH1.step(&a2)) - break; - v->state2 = DECAY; - case DECAY: - if (v->envH2.step(&a2)) - break; - v->state2 = SUSTAIN; - case SUSTAIN: - a2 = sustain1; - break; - case RELEASE: - if (v->envH3.step(&a2)) - break; - v->state2 = OFF; - a1 = MAX_ATTENUATION; - break; - } - if (v->state1 == OFF && v->state2 == OFF) { - v->isOn = false; - break; - } - buffer[i] += - (table_pos (sine_table, freq_256_harm0, harm0_accum) * harm0 - + table_pos (sine_table, freq_256_harm1, harm1_accum) * harm1 - + table_pos (sine_table, freq_256_harm2, harm2_accum) * harm2) - * cb2amp(a1) * vol - + (table_pos (reed_table, freq_256_harm3, harm3_accum) * harm3 - + table_pos (sine_table, freq_256_harm4, harm4_accum) * harm4 - + table_pos (flute_table, freq_256_harm5, harm5_accum) * harm5) - * cb2amp(a2) * vol; - } - } - } - } - -//--------------------------------------------------------- -// playNote -//--------------------------------------------------------- - -bool Organ::playNote(int channel, int pitch, int velo) - { - if (velo == 0) { - noteoff(channel, pitch); - return false; - } - for (int i = 0; i < VOICES; ++i) { - if (voices[i].isOn) - continue; - voices[i].isOn = true; - voices[i].pitch = pitch; - voices[i].channel = channel; - // velo is never 0 - voices[i].velocity = cb2amp(int(200 * log10((127.0 * 127)/(velo*velo)))); - voices[i].state1 = ATTACK; - voices[i].state2 = ATTACK; - voices[i].envL1.set(attack0, MAX_ATTENUATION, 0); - voices[i].envL2.set(decay0, MAX_ATTENUATION, sustain0); - voices[i].envL3.set(release0, sustain0, MAX_ATTENUATION); - - voices[i].envH1.set(attack1, MAX_ATTENUATION, 0); - voices[i].envH2.set(decay1, MAX_ATTENUATION, sustain1); - voices[i].envH3.set(release1, sustain1, MAX_ATTENUATION); - - voices[i].harm0_accum = 0; - voices[i].harm1_accum = 0; - voices[i].harm2_accum = 0; - voices[i].harm3_accum = 0; - voices[i].harm4_accum = 0; - voices[i].harm5_accum = 0; - return false; - } - printf("organ: voices overflow!\n"); - return false; - } - -//--------------------------------------------------------- -// noteoff -//--------------------------------------------------------- - -void Organ::noteoff(int channel, int pitch) - { - bool found = false; - for (int i = 0; i < VOICES; ++i) { - if (voices[i].isOn && (voices[i].pitch == pitch) - && (voices[i].channel == channel)) { - found = true; - voices[i].state1 = RELEASE; - voices[i].state2 = RELEASE; - } - } - if (!found) - printf("Organ: noteoff %d:%d not found\n", channel, pitch); - } - -//--------------------------------------------------------- -// setController -//--------------------------------------------------------- - -void Organ::setController(int ctrl, int data) - { - int sr = sampleRate(); - - // Changed By T356. - // Because of muse's auto-bias controllers, some of these negative-range - // controls need to apply the auto-bias correction. - - switch (ctrl) { - case HARM0: - //harm0 = cb2amp(-data); - harm0 = cb2amp(-data + 8192); - break; - case HARM1: - //harm1 = cb2amp(-data); - harm1 = cb2amp(-data + 8192); - break; - case HARM2: - //harm2 = cb2amp(-data); - harm2 = cb2amp(-data + 8192); - break; - case HARM3: - //harm3 = cb2amp(-data); - harm3 = cb2amp(-data + 8192); - break; - case HARM4: - //harm4 = cb2amp(-data); - harm4 = cb2amp(-data + 8192); - break; - case HARM5: - //harm5 = cb2amp(-data); - harm5 = cb2amp(-data + 8192); - break; - case ATTACK_LO: // maxval -> 500msec - attack0 = (data * sr) / 1000; - break; - case DECAY_LO: // maxval -> 5000msec - decay0 = (data * sr) / 1000; - break; - case SUSTAIN_LO: - //sustain0 = -data; - sustain0 = -data + 8192; - break; - case RELEASE_LO: - release0 = (data * sr) / 1000; - break; - case ATTACK_HI: - attack1 = (data * sr) / 1000; - break; - case DECAY_HI: - decay1 = (data * sr) / 1000; - break; - case SUSTAIN_HI: - //sustain1 = -data; - sustain1 = -data + 8192; - break; - case RELEASE_HI: - release1 = (data * sr) / 1000; - break; - case BRASS: - brass = data; - break; - case FLUTE: - flute = data; - break; - case REED: - reed = data; - break; - case VELO: - velo = data; - break; - case CTRL_VOLUME: - data &= 0x7f; - volume = data == 0 ? 0.0 : cb2amp(int(200 * log10((127.0 * 127)/(data*data)))); - break; - case CTRL_ALL_SOUNDS_OFF: - for (int i = 0; i < VOICES; ++i) - voices[i].isOn = false; - break; - case CTRL_RESET_ALL_CTRL: - for (int i = 0; i < NUM_CONTROLLER; ++i) - setController(0, synthCtrl[i].num, synthCtrl[i].val); - break; - default: - fprintf(stderr, "Organ:set unknown Ctrl 0x%x to 0x%x\n", ctrl, data); - return; - } - for (int i = 0; i < NUM_CONTROLLER; ++i) { - if (synthCtrl[i].num == ctrl) { - synthCtrl[i].val = data; - break; - } - } - } - -//--------------------------------------------------------- -// setController -//--------------------------------------------------------- - -bool Organ::setController(int channel, int ctrl, int data) - { - setController(ctrl, data); - - switch (ctrl) { - case HARM0: - case HARM1: - case HARM2: - case HARM3: - case HARM4: - case HARM5: - case ATTACK_LO: - case DECAY_LO: - case SUSTAIN_LO: - case RELEASE_LO: - case ATTACK_HI: - case DECAY_HI: - case SUSTAIN_HI: - case RELEASE_HI: - case BRASS: - case FLUTE: - case REED: - case VELO: - { - MidiPlayEvent ev(0, 0, channel, ME_CONTROLLER, ctrl, data); - #ifdef ORGAN_DEBUG - fprintf(stderr, "OrganGui:setController before gui->writeEvent ctrl:%d data:%d\n", ctrl, data); - #endif - - gui->writeEvent(ev); - } - break; - default: - break; - } - return false; - } - -//--------------------------------------------------------- -// sysex -//--------------------------------------------------------- - -bool Organ::sysex(int n, const unsigned char* data) - { - #ifdef ORGAN_DEBUG - printf("Organ: sysex\n"); - #endif - if (unsigned(n) != (NUM_INIT_CONTROLLER * sizeof(int))) { - printf("Organ: unknown sysex\n"); - return false; - } - int* s = (int*) data; - for (int i = 0; i < NUM_INIT_CONTROLLER; ++i) { - int val = *s++; - #ifdef ORGAN_DEBUG - printf("Organ: sysex before setController num:%d val:%d\n", synthCtrl[i].num, val); - #endif - setController(0, synthCtrl[i].num, val); - } - return false; - } - -//--------------------------------------------------------- -// getInitData -//--------------------------------------------------------- - -void Organ::getInitData(int* n, const unsigned char**p) const - { - int* d = idata; - for (int i = 0; i < NUM_INIT_CONTROLLER; ++i) - *d++ = synthCtrl[i].val; - *n = NUM_INIT_CONTROLLER * sizeof(int); // sizeof(idata); - *p = (unsigned char*)idata; - } - -//--------------------------------------------------------- -// MESS -//--------------------------------------------------------- - -//--------------------------------------------------------- -// getControllerInfo -//--------------------------------------------------------- - -int Organ::getControllerInfo(int id, const char** name, int* controller, - int* min, int* max, int* initval) const - { - if (id >= NUM_CONTROLLER) - return 0; - *controller = synthCtrl[id].num; - *name = synthCtrl[id].name; - *initval = synthCtrl[id].val; - - if(synthCtrl[id].num == CTRL_VOLUME) - { - *min = 0; - *max = 127; - } - else - gui->getControllerMinMax(id,min,max); - - //*min = 0; - //*max = 128*128-1; - return ++id; - } - -//--------------------------------------------------------- -// guiVisible -//--------------------------------------------------------- - -bool Organ::guiVisible() const - { - return gui->isVisible(); - } - -//--------------------------------------------------------- -// showGui -//--------------------------------------------------------- - -void Organ::showGui(bool val) - { - gui->setVisible(val); - } - -//--------------------------------------------------------- -// getGeometry -//--------------------------------------------------------- - -void Organ::getGeometry(int* x, int* y, int* w, int* h) const - { - QPoint pos(gui->pos()); - QSize size(gui->size()); - *x = pos.x(); - *y = pos.y(); - *w = size.width(); - *h = size.height(); - } - -//--------------------------------------------------------- -// setGeometry -//--------------------------------------------------------- - -void Organ::setGeometry(int x, int y, int w, int h) - { - gui->resize(QSize(w, h)); - gui->move(QPoint(x, y)); - } - -//--------------------------------------------------------- -// instantiate -// construct a new synthesizer instance -//--------------------------------------------------------- - -static Mess* instantiate(int sr, QWidget*, QString* /*projectPathPtr*/, const char* name) - { - Organ* synth = new Organ(sr); - if (synth->init(name)) { - delete synth; - synth = 0; - } - return synth; - } - -//--------------------------------------------------------- -// msynth_descriptor -// Return a descriptor of the requested plugin type. -//--------------------------------------------------------- - -extern "C" { - static MESS descriptor = { - "Organ", - "Organ based on David A. Bartold's LADSPA plugin", - "0.1", // version string - MESS_MAJOR_VERSION, MESS_MINOR_VERSION, - instantiate, - }; - // We must compile with -fvisibility=hidden to avoid namespace - // conflicts with global variables. - // Only visible symbol is "mess_descriptor". - // (TODO: all plugins should be compiled this way) - - __attribute__ ((visibility("default"))) - const MESS* mess_descriptor() { return &descriptor; } - } - diff --git a/attic/muse2-oom/muse2/synti/organ/organ.h b/attic/muse2-oom/muse2/synti/organ/organ.h deleted file mode 100644 index 308646e1..00000000 --- a/attic/muse2-oom/muse2/synti/organ/organ.h +++ /dev/null @@ -1,198 +0,0 @@ -//========================================================= -// MusE -// Linux Music Editor -// $Id: organ.h,v 1.5.2.3 2009/11/19 04:20:33 terminator356 Exp $ -// -// Parts of this file taken from: -// Organ - Additive Organ Synthesizer Voice -// Copyright (c) 1999, 2000 David A. Bartold -// -// (C) Copyright 2001-2004 Werner Schweer (ws@seh.de) -//========================================================= - -#ifndef __ORGAN_H__ -#define __ORGAN_H__ - -#include "muse/midictrl.h" -#include "libsynti/mess.h" - -#define RESOLUTION (16384*2) -#define VOICES 128 // max polyphony - -class OrganGui; - -static const int MAX_ATTENUATION = 960; - -enum EnvelopeState { - ATTACK, - DECAY, - SUSTAIN, - RELEASE, - OFF - }; - -//--------------------------------------------------------- -// Envelope -//--------------------------------------------------------- - -struct Envelope { - int ticks; // len of segment - int error, delta, schritt; - int y, yinc; - - void set(int t, int y1, int y2) { - ticks = t; - y = y1; - int dy = y2 - y1; - int dx = t; - error = -dx; - schritt = 2*dx; - if (dy < 0) { - yinc = -1; - delta = -2 * dy; - } - else { - yinc = 1; - delta = 2 * dy; - } - } - - // return false on envelope end - bool step(int* a) { - *a = y; - if (ticks == 0) - return false; - error += delta; - while (error > 0) { - y += yinc; - error -= schritt; - } - --ticks; - return true; - } - }; - -static const int HARM0 = 0 + CTRL_RPN14_OFFSET; -static const int HARM1 = 1 + CTRL_RPN14_OFFSET; -static const int HARM2 = 2 + CTRL_RPN14_OFFSET; -static const int HARM3 = 3 + CTRL_RPN14_OFFSET; -static const int HARM4 = 4 + CTRL_RPN14_OFFSET; -static const int HARM5 = 5 + CTRL_RPN14_OFFSET; -static const int ATTACK_LO = 6 + CTRL_RPN14_OFFSET; -static const int DECAY_LO = 7 + CTRL_RPN14_OFFSET; -static const int SUSTAIN_LO = 8 + CTRL_RPN14_OFFSET; -static const int RELEASE_LO = 9 + CTRL_RPN14_OFFSET; -static const int ATTACK_HI = 10 + CTRL_RPN14_OFFSET; -static const int DECAY_HI = 11 + CTRL_RPN14_OFFSET; -static const int SUSTAIN_HI = 12 + CTRL_RPN14_OFFSET; -static const int RELEASE_HI = 13 + CTRL_RPN14_OFFSET; -static const int BRASS = 14 + CTRL_RPN14_OFFSET; -static const int FLUTE = 15 + CTRL_RPN14_OFFSET; -static const int REED = 16 + CTRL_RPN14_OFFSET; -static const int VELO = 17 + CTRL_RPN14_OFFSET; - -//--------------------------------------------------------- -// SynthCtrl -//--------------------------------------------------------- - -struct SynthCtrl { - const char* name; - int num; - int val; - }; - -//--------------------------------------------------------- -// Voice -//--------------------------------------------------------- - -struct Voice { - bool isOn; - int pitch; - int channel; - - double velocity; - - int state1, state2; - Envelope envL1, envL2, envL3; - Envelope envH1, envH2, envH3; - - unsigned harm0_accum; - unsigned harm1_accum; - unsigned harm2_accum; - unsigned harm3_accum; - unsigned harm4_accum; - unsigned harm5_accum; - }; - -//--------------------------------------------------------- -// Preset -//--------------------------------------------------------- - -struct Preset { - char* name; - bool brass, flute, reed; - int attack0, attack1; - int release0, release1; - int decay0, decay1; - double harm0, harm1, harm2, harm3, harm4, harm5; - bool velo; - }; - -//--------------------------------------------------------- -// Organ -//--------------------------------------------------------- - -class Organ : public Mess { - static int useCount; - - static double cb2amp_tab[MAX_ATTENUATION]; - static unsigned freq256[128]; - static double cb2amp(int cb); - - int* idata; // buffer for init data - - bool brass, flute, reed; - int attack0, attack1; - int release0, release1; - int decay0, decay1; // ticks - int sustain0, sustain1; // centibel - bool velo; - double volume; - - double harm0, harm1, harm2, harm3, harm4, harm5; - - Voice voices[VOICES]; - - static float* sine_table; - static float* g_triangle_table; - static float* g_pulse_table; - - void noteoff(int channel, int pitch); - void setController(int ctrl, int val); - - - OrganGui* gui; - - public: - virtual void processMessages(); - virtual void process(float**, int, int); - virtual bool playNote(int channel, int pitch, int velo); - virtual bool setController(int channel, int ctrl, int val); - - virtual int getControllerInfo(int, const char**, int*, int*, int*, int*) const; - virtual void getInitData(int*, const unsigned char**) const; - - virtual bool guiVisible() const; - virtual void showGui(bool); - virtual bool hasGui() const { return true; } - virtual void getGeometry(int* x, int* y, int* w, int* h) const; - virtual void setGeometry(int x, int y, int w, int h); - virtual bool sysex(int, const unsigned char*); - static SynthCtrl synthCtrl[]; - Organ(int sampleRate); - ~Organ(); - bool init(const char* name); - }; - -#endif - diff --git a/attic/muse2-oom/muse2/synti/organ/organgui.cpp b/attic/muse2-oom/muse2/synti/organ/organgui.cpp deleted file mode 100644 index 9b763fd6..00000000 --- a/attic/muse2-oom/muse2/synti/organ/organgui.cpp +++ /dev/null @@ -1,185 +0,0 @@ -//========================================================= -// MusE -// Linux Music Editor -// $Id: organgui.cpp,v 1.16.2.3 2009/11/16 04:30:46 terminator356 Exp $ -// -// This is a simple GUI implemented with QT for -// organ software synthesizer. -// -// (C) Copyright 2001-2004 Werner Schweer (ws@seh.de) -//========================================================= - -#include -#include -#include - -#include -#include -#include -#include -#include - -#include "organgui.h" -#include "muse/midi.h" -#include "muse/midictrl.h" - -//#define ORGANGUI_DEBUG - -//--------------------------------------------------------- -// OrganGui -//--------------------------------------------------------- - -OrganGui::OrganGui() - : QWidget(0, Qt::Window), MessGui() - { - QSocketNotifier* s = new QSocketNotifier(readFd, QSocketNotifier::Read); - connect(s, SIGNAL(activated(int)), SLOT(readMessage(int))); - - dctrl[0] = SynthGuiCtrl(p1, lcd1, SynthGuiCtrl::SLIDER); - dctrl[1] = SynthGuiCtrl(p2, lcd2, SynthGuiCtrl::SLIDER); - dctrl[2] = SynthGuiCtrl(p3, lcd3, SynthGuiCtrl::SLIDER); - dctrl[3] = SynthGuiCtrl(p4, lcd4, SynthGuiCtrl::SLIDER); - dctrl[4] = SynthGuiCtrl(p5, lcd5, SynthGuiCtrl::SLIDER); - dctrl[5] = SynthGuiCtrl(p6, lcd6, SynthGuiCtrl::SLIDER); - dctrl[6] = SynthGuiCtrl(p7, lcd7, SynthGuiCtrl::SLIDER); - dctrl[7] = SynthGuiCtrl(p8, lcd8, SynthGuiCtrl::SLIDER); - dctrl[8] = SynthGuiCtrl(p9, lcd9, SynthGuiCtrl::SLIDER); - dctrl[9] = SynthGuiCtrl(p10, lcd10, SynthGuiCtrl::SLIDER); - dctrl[10] = SynthGuiCtrl(p11, lcd11, SynthGuiCtrl::SLIDER); - dctrl[11] = SynthGuiCtrl(p12, lcd12, SynthGuiCtrl::SLIDER); - dctrl[12] = SynthGuiCtrl(p13, lcd13, SynthGuiCtrl::SLIDER); - dctrl[13] = SynthGuiCtrl(p14, lcd14, SynthGuiCtrl::SLIDER); - dctrl[14] = SynthGuiCtrl(sw1, 0, SynthGuiCtrl::SWITCH); - dctrl[15] = SynthGuiCtrl(sw3, 0, SynthGuiCtrl::SWITCH); - dctrl[16] = SynthGuiCtrl(sw2, 0, SynthGuiCtrl::SWITCH); - dctrl[17] = SynthGuiCtrl(sw4, 0, SynthGuiCtrl::SWITCH); - - map = new QSignalMapper(this); - for (int i = 0; i < NUM_GUI_CONTROLLER; ++i) { - map->setMapping(dctrl[i].editor, i); - if (dctrl[i].type == SynthGuiCtrl::SLIDER) - connect((QSlider*)(dctrl[i].editor), SIGNAL(valueChanged(int)), map, SLOT(map())); - else if (dctrl[i].type == SynthGuiCtrl::SWITCH) - connect((QCheckBox*)(dctrl[i].editor), SIGNAL(toggled(bool)), map, SLOT(map())); - } - connect(map, SIGNAL(mapped(int)), this, SLOT(ctrlChanged(int))); - - // work around for probable QT/WM interaction bug. - // for certain window managers, e.g xfce, this window is - // is displayed although not specifically set to show(); - // bug: 2811156 Softsynth GUI unclosable with XFCE4 (and a few others) - show(); - hide(); - } - -//--------------------------------------------------------- -// ctrlChanged -//--------------------------------------------------------- - -void OrganGui::ctrlChanged(int idx) - { - SynthGuiCtrl* ctrl = &dctrl[idx]; - int val = 0; - if (ctrl->type == SynthGuiCtrl::SLIDER) { - QSlider* slider = (QSlider*)(ctrl->editor); - val = slider->value(); - // By T356. Apply auto-bias center value. - if(slider->minimum() < 0) - val += 8192; - } - else if (ctrl->type == SynthGuiCtrl::SWITCH) { - val = ((QCheckBox*)(ctrl->editor))->isChecked(); - } - sendController(0, idx + CTRL_RPN14_OFFSET, val); - } - -//--------------------------------------------------------- -// getControllerInfo -// return min max values for controllers -//--------------------------------------------------------- -int OrganGui::getControllerMinMax(int id, int* min, int* max) const - { - if (id >= NUM_GUI_CONTROLLER) - return 0; - - const SynthGuiCtrl* ctrl = (const SynthGuiCtrl*)&dctrl[id]; - //int val = 0; - if (ctrl->type == SynthGuiCtrl::SLIDER) { - QSlider* slider = (QSlider*)(ctrl->editor); - *max = slider->maximum(); - *min = slider->minimum(); - //val = (slider->value() * 16383 + max/2) / max; - - //val = 16383 + 1/2 - } - else if (ctrl->type == SynthGuiCtrl::SWITCH) { - //val = ((QCheckBox*)(ctrl->editor))->isOn(); - *min=0; - *max=1; - } - return ++id; - } - -//--------------------------------------------------------- -// setParam -// set param in gui -//--------------------------------------------------------- - -void OrganGui::setParam(int param, int val) - { - #ifdef ORGANGUI_DEBUG - fprintf(stderr, "OrganGui:setParam param:%d val:%d\n", param, val); - #endif - - param &= 0xfff; - if (param >= int(sizeof(dctrl)/sizeof(*dctrl))) { - fprintf(stderr, "OrganGui: set unknown Ctrl 0x%x to 0x%x\n", param, val); - return; - } - SynthGuiCtrl* ctrl = &dctrl[param]; - ctrl->editor->blockSignals(true); - if (ctrl->type == SynthGuiCtrl::SLIDER) { - QSlider* slider = (QSlider*)(ctrl->editor); -// int max = slider->maximum(); -// if(val < 0) val = (val * max + 8191) / 16383 - 1; -// else val = (val * max + 8191) / 16383; - - // By T356. Apply auto-bias center value. - if(slider->minimum() < 0) - val -= 8192; - - #ifdef ORGANGUI_DEBUG - fprintf(stderr, "OrganGui:setParam setting slider val:%d\n", val); - #endif - - slider->setValue(val); - if (ctrl->label) - ((QSpinBox*)(ctrl->label))->setValue(val); - } - else if (ctrl->type == SynthGuiCtrl::SWITCH) { - ((QCheckBox*)(ctrl->editor))->setChecked(val); - } - ctrl->editor->blockSignals(false); - } - -//--------------------------------------------------------- -// processEvent -//--------------------------------------------------------- - -void OrganGui::processEvent(const MidiPlayEvent& ev) - { - if (ev.type() == ME_CONTROLLER) - setParam(ev.dataA(), ev.dataB()); - else - printf("OrganGui::illegal event type received\n"); - } - -//--------------------------------------------------------- -// readMessage -//--------------------------------------------------------- - -void OrganGui::readMessage(int) - { - MessGui::readMessage(); - } - diff --git a/attic/muse2-oom/muse2/synti/organ/organgui.h b/attic/muse2-oom/muse2/synti/organ/organgui.h deleted file mode 100644 index f246198d..00000000 --- a/attic/muse2-oom/muse2/synti/organ/organgui.h +++ /dev/null @@ -1,45 +0,0 @@ -//========================================================= -// MusE -// Linux Music Editor -// $Id: organgui.h,v 1.6.2.1 2005/12/29 23:33:50 spamatica Exp $ -// -// (C) Copyright 2001-2004 Werner Schweer (ws@seh.de) -//========================================================= - -#ifndef __ORGANGUI_H__ -#define __ORGANGUI_H__ - -#include "ui_organguibase.h" -#include "organ.h" -#include "libsynti/gui.h" -//#include "libsynti/mpevent.h" -#include "muse/mpevent.h" - -class QWidget; -class QSignalMapper; - -#define NUM_GUI_CONTROLLER 18 - -//--------------------------------------------------------- -// OrganGui -//--------------------------------------------------------- - -class OrganGui : public QWidget, public Ui::OrganGuiBase, public MessGui { - Q_OBJECT - - QSignalMapper* map; - SynthGuiCtrl dctrl[NUM_GUI_CONTROLLER]; - void setParam(int, int); - - private slots: - void ctrlChanged(int idx); - void readMessage(int); - - public: - virtual void processEvent(const MidiPlayEvent&); - int getControllerMinMax(int id, int* min, int* max) const; - OrganGui(); - }; - -#endif - diff --git a/attic/muse2-oom/muse2/synti/organ/organguibase.ui b/attic/muse2-oom/muse2/synti/organ/organguibase.ui deleted file mode 100644 index d3ed5c5f..00000000 --- a/attic/muse2-oom/muse2/synti/organ/organguibase.ui +++ /dev/null @@ -1,1351 +0,0 @@ - - - OrganGuiBase - - - - 0 - 0 - 534 - 366 - - - - - 0 - 0 - - - - MusE: Organ - - - - 4 - - - 6 - - - - - - 0 - 0 - - - - Drawbars - - - - 6 - - - 2 - - - - - 16' - - - false - - - - - - - 4' - - - false - - - - - - - 2 2/3' - - - false - - - - - - - 2' - - - false - - - - - - - 5 1/3' - - - false - - - - - - - 8' - - - false - - - - - - - -960 - - - 0 - - - 1 - - - Qt::Horizontal - - - QSlider::NoTicks - - - 10 - - - - - - - -960 - - - 0 - - - 1 - - - Qt::Horizontal - - - QSlider::NoTicks - - - 10 - - - - - - - -960 - - - 0 - - - 1 - - - Qt::Horizontal - - - QSlider::NoTicks - - - 10 - - - - - - - -960 - - - 0 - - - 1 - - - Qt::Horizontal - - - QSlider::NoTicks - - - 10 - - - - - - - -960 - - - 0 - - - 1 - - - Qt::Horizontal - - - QSlider::NoTicks - - - 10 - - - - - - - - 0 - 0 - - - - -960 - - - 0 - - - 1 - - - Qt::Horizontal - - - QSlider::NoTicks - - - 10 - - - - - - - -960 - - - 0 - - - - - - - -960 - - - 0 - - - 10 - - - - - - - -960 - - - 0 - - - 10 - - - - - - - -960 - - - 0 - - - 10 - - - - - - - -960 - - - 0 - - - 10 - - - - - - - -960 - - - 0 - - - 10 - - - - - - - - - - - 0 - 0 - - - - Envelope Hi - - - - 11 - - - 2 - - - - - Release - - - false - - - - - - - Sustain - - - false - - - - - - - Decay - - - false - - - - - - - - 0 - 0 - - - - Attack - - - false - - - - - - - 500 - - - 1 - - - Qt::Horizontal - - - QSlider::NoTicks - - - 50 - - - - - - - -960 - - - 0 - - - 1 - - - Qt::Horizontal - - - QSlider::NoTicks - - - 10 - - - - - - - 5000 - - - 1 - - - Qt::Horizontal - - - QSlider::NoTicks - - - 500 - - - - - - - - 0 - 0 - - - - ms - - - 500 - - - - - - - - 0 - 0 - - - - 500 - - - 1 - - - Qt::Horizontal - - - QSlider::NoTicks - - - 50 - - - - - - - - 0 - 0 - - - - ms - - - 5000 - - - - - - - - 0 - 0 - - - - cB - - - -960 - - - 0 - - - - - - - - 0 - 0 - - - - ms - - - 500 - - - - - - - - - - - 0 - 0 - - - - Envelope Lo - - - Qt::AlignLeading - - - - 11 - - - 2 - - - - - Attack - - - false - - - - - - - Decay - - - false - - - - - - - Sustain - - - false - - - - - - - Release - - - false - - - - - - - - 0 - 0 - - - - - 80 - 0 - - - - 500 - - - 1 - - - Qt::Horizontal - - - QSlider::NoTicks - - - 50 - - - - - - - 5000 - - - 1 - - - Qt::Horizontal - - - QSlider::NoTicks - - - 500 - - - - - - - -960 - - - 0 - - - 1 - - - Qt::Horizontal - - - QSlider::NoTicks - - - 10 - - - - - - - 500 - - - 1 - - - Qt::Horizontal - - - QSlider::NoTicks - - - 50 - - - - - - - - 0 - 0 - - - - ms - - - 500 - - - - - - - - 0 - 0 - - - - ms - - - 5000 - - - - - - - - 0 - 0 - - - - cB - - - -960 - - - 0 - - - 0 - - - - - - - - 0 - 0 - - - - ms - - - 500 - - - - - - - - - - - - - 0 - 0 - - - - - 48 - - - - O-1 - - - Qt::AlignCenter - - - false - - - - - - - - 0 - 0 - - - - Oscillator - - - - 2 - - - 11 - - - - - - 0 - 0 - - - - Brass - - - - - - - - 0 - 0 - - - - Reed - - - - - - - - 0 - 0 - - - - Flute - - - - - - - Qt::Vertical - - - QSizePolicy::Expanding - - - - 20 - 20 - - - - - - - - Velocity - - - - - - - - - - - - - p1 - p3 - p2 - p4 - p5 - p6 - p7 - p8 - p9 - p10 - p11 - p12 - p13 - p14 - sw1 - sw2 - sw3 - - - - - p11 - valueChanged(int) - lcd11 - setValue(int) - - - 20 - 20 - - - 20 - 20 - - - - - p12 - valueChanged(int) - lcd12 - setValue(int) - - - 20 - 20 - - - 20 - 20 - - - - - p13 - valueChanged(int) - lcd13 - setValue(int) - - - 20 - 20 - - - 20 - 20 - - - - - p14 - valueChanged(int) - lcd14 - setValue(int) - - - 20 - 20 - - - 20 - 20 - - - - - p7 - valueChanged(int) - lcd7 - setValue(int) - - - 20 - 20 - - - 20 - 20 - - - - - p8 - valueChanged(int) - lcd8 - setValue(int) - - - 20 - 20 - - - 20 - 20 - - - - - p9 - valueChanged(int) - lcd9 - setValue(int) - - - 20 - 20 - - - 20 - 20 - - - - - p10 - valueChanged(int) - lcd10 - setValue(int) - - - 20 - 20 - - - 20 - 20 - - - - - p1 - valueChanged(int) - lcd1 - setValue(int) - - - 20 - 20 - - - 20 - 20 - - - - - p2 - valueChanged(int) - lcd2 - setValue(int) - - - 20 - 20 - - - 20 - 20 - - - - - p3 - valueChanged(int) - lcd3 - setValue(int) - - - 20 - 20 - - - 20 - 20 - - - - - p4 - valueChanged(int) - lcd4 - setValue(int) - - - 20 - 20 - - - 20 - 20 - - - - - p5 - valueChanged(int) - lcd5 - setValue(int) - - - 20 - 20 - - - 20 - 20 - - - - - p6 - valueChanged(int) - lcd6 - setValue(int) - - - 20 - 20 - - - 20 - 20 - - - - - lcd1 - valueChanged(int) - p1 - setValue(int) - - - 20 - 20 - - - 20 - 20 - - - - - lcd2 - valueChanged(int) - p2 - setValue(int) - - - 20 - 20 - - - 20 - 20 - - - - - lcd3 - valueChanged(int) - p3 - setValue(int) - - - 20 - 20 - - - 20 - 20 - - - - - lcd4 - valueChanged(int) - p4 - setValue(int) - - - 20 - 20 - - - 20 - 20 - - - - - lcd5 - valueChanged(int) - p5 - setValue(int) - - - 20 - 20 - - - 20 - 20 - - - - - lcd6 - valueChanged(int) - p6 - setValue(int) - - - 20 - 20 - - - 20 - 20 - - - - - lcd7 - valueChanged(int) - p7 - setValue(int) - - - 20 - 20 - - - 20 - 20 - - - - - lcd8 - valueChanged(int) - p8 - setValue(int) - - - 20 - 20 - - - 20 - 20 - - - - - lcd9 - valueChanged(int) - p9 - setValue(int) - - - 20 - 20 - - - 20 - 20 - - - - - lcd10 - valueChanged(int) - p10 - setValue(int) - - - 20 - 20 - - - 20 - 20 - - - - - lcd11 - valueChanged(int) - p11 - setValue(int) - - - 20 - 20 - - - 20 - 20 - - - - - lcd12 - valueChanged(int) - p12 - setValue(int) - - - 20 - 20 - - - 20 - 20 - - - - - lcd13 - valueChanged(int) - p13 - setValue(int) - - - 20 - 20 - - - 20 - 20 - - - - - lcd14 - valueChanged(int) - p14 - setValue(int) - - - 20 - 20 - - - 20 - 20 - - - - - -- cgit v1.2.3