You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
dexed/Source/PluginProcessor.h

238 lines
7.2 KiB

11 years ago
/**
*
* Copyright (c) 2013-2015 Pascal Gauthier.
11 years ago
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
11 years ago
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
11 years ago
*
*/
#ifndef PLUGINPROCESSOR_H_INCLUDED
#define PLUGINPROCESSOR_H_INCLUDED
#include "../JuceLibraryCode/JuceHeader.h"
#include "msfa/controllers.h"
#include "msfa/dx7note.h"
#include "msfa/lfo.h"
#include "msfa/synth.h"
10 years ago
#include "msfa/fm_core.h"
11 years ago
#include "PluginParam.h"
#include "PluginData.h"
#include "PluginFx.h"
#include "SysexComm.h"
10 years ago
#include "EngineMkI.h"
#include "EngineOpl.h"
11 years ago
struct ProcessorVoice {
int midi_note;
bool keydown;
bool sustained;
bool live;
Dx7Note *dx7_note;
};
enum DexedEngineResolution {
10 years ago
DEXED_ENGINE_MODERN,
DEXED_ENGINE_MARKI,
DEXED_ENGINE_OPL
};
11 years ago
//==============================================================================
/**
*/
class DexedAudioProcessor : public AudioProcessor, public AsyncUpdater, public MidiInputCallback
11 years ago
{
static const int MAX_ACTIVE_NOTES = 16;
ProcessorVoice voices[MAX_ACTIVE_NOTES];
int currentNote;
// The original DX7 had one single LFO. Later units had an LFO per note.
Lfo lfo;
bool sustain;
bool monoMode;
11 years ago
// Extra buffering for when GetSamples wants a buffer not a multiple of N
float extra_buf[N];
11 years ago
int extra_buf_size;
int currentProgram;
11 years ago
11 years ago
/**
* The last time the state was save, to be able to bypass a VST host bug.
11 years ago
*/
long lastStateSave;
11 years ago
/**
* Plugin fx (the filter)
*/
PluginFx fx;
/**
* This flag is used in the audio thread to know if the voice has changed
* and needs to be updated.
*/
bool refreshVoice;
bool normalizeDxVelocity;
bool sendSysexChange;
void processMidiMessage(const MidiMessage *msg);
void keydown(uint8_t pitch, uint8_t velo);
void keyup(uint8_t pitch);
/**
* this is called from the Audio thread to tell
* to update the UI / hostdata
*/
void handleAsyncUpdate();
11 years ago
void initCtrl();
MidiMessage* nextMidi,*midiMsg;
bool hasMidiMessage;
int midiEventPos;
bool getNextEvent(MidiBuffer::Iterator* iter,const int samplePos);
void handleIncomingMidiMessage(MidiInput* source, const MidiMessage& message);
10 years ago
uint32_t engineType;
FmCore engineMsfa;
EngineMkI engineMkI;
EngineOpl engineOpl;
char clipboard[161];
char clipboardContent;
void resolvAppDir();
public :
// in MIDI units (0x4000 is neutral)
Controllers controllers;
StringArray programNames;
Cartridge currentCart;
uint8_t data[161];
SysexComm sysexComm;
11 years ago
VoiceStatus voiceStatus;
File activeFileCartridge;
11 years ago
bool forceRefreshUI;
11 years ago
float vuSignal;
10 years ago
bool showKeyboard;
10 years ago
int getEngineType();
void setEngineType(int rs);
11 years ago
Array<Ctrl*> ctrl;
OperatorCtrl opCtrl[6];
ScopedPointer<CtrlDX> pitchEgRate[4];
ScopedPointer<CtrlDX> pitchEgLevel[4];
ScopedPointer<CtrlDX> pitchModSens;
ScopedPointer<CtrlDX> algo;
ScopedPointer<CtrlDX> oscSync;
ScopedPointer<CtrlDX> feedback;
ScopedPointer<CtrlDX> lfoRate;
ScopedPointer<CtrlDX> lfoDelay;
ScopedPointer<CtrlDX> lfoAmpDepth;
ScopedPointer<CtrlDX> lfoPitchDepth;
ScopedPointer<CtrlDX> lfoWaveform;
ScopedPointer<CtrlDX> lfoSync;
ScopedPointer<CtrlDX> transpose;
ScopedPointer<CtrlFloat> fxCutoff;
ScopedPointer<CtrlFloat> fxReso;
11 years ago
ScopedPointer<CtrlFloat> output;
//int importSysex(const char *imported);
void loadCartridge(Cartridge &cart);
void setDxValue(int offset, int v);
11 years ago
11 years ago
//==============================================================================
DexedAudioProcessor();
~DexedAudioProcessor();
//==============================================================================
void prepareToPlay (double sampleRate, int samplesPerBlock);
void releaseResources();
void processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages);
void panic();
bool isMonoMode() {
return monoMode;
}
void setMonoMode(bool mode);
void copyToClipboard(int srcOp);
void pasteOpFromClipboard(int destOp);
void pasteEnvFromClipboard(int destOp);
void sendCurrentSysexProgram();
void sendCurrentSysexCartridge();
void sendSysexCartridge(File cart);
bool hasClipboardContent();
11 years ago
//==============================================================================
AudioProcessorEditor* createEditor();
bool hasEditor() const;
11 years ago
void updateUI();
11 years ago
bool peekVoiceStatus();
11 years ago
void updateProgramFromSysex(const uint8 *rawdata);
void setupStartupCart();
11 years ago
//==============================================================================
const String getName() const;
int getNumParameters();
float getParameter (int index);
void setParameter (int index, float newValue);
const String getParameterName (int index);
const String getParameterText (int index);
const String getInputChannelName (int channelIndex) const;
const String getOutputChannelName (int channelIndex) const;
bool isInputChannelStereoPair (int index) const;
bool isOutputChannelStereoPair (int index) const;
bool acceptsMidi() const;
bool producesMidi() const;
bool silenceInProducesSilenceOut() const;
double getTailLengthSeconds() const;
//==============================================================================
int getNumPrograms();
int getCurrentProgram();
10 years ago
void setCurrentProgram(int index);
11 years ago
const String getProgramName (int index);
10 years ago
void changeProgramName(int index, const String& newName);
void resetToInitVoice();
11 years ago
//==============================================================================
void getStateInformation (MemoryBlock& destData);
void setStateInformation (const void* data, int sizeInBytes);
11 years ago
11 years ago
// this is kept up to date with the midi messages that arrive, and the UI component
// registers with it so it can represent the incoming messages
MidiKeyboardState keyboardState;
void unbindUI();
11 years ago
void loadPreference();
void savePreference();
static File dexedAppDir;
static File dexedCartDir;
11 years ago
private:
//==============================================================================
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (DexedAudioProcessor)
};
#endif // PLUGINPROCESSOR_H_INCLUDED