mirror of
https://github.com/vsariola/sointu.git
synced 2025-07-22 23:14:59 -04:00
retro commit for released version 3.0.1
This commit is contained in:
131
4klang_source/Go4kVSTi/source/GoSynth/Go4kVSTi.cpp
Normal file
131
4klang_source/Go4kVSTi/source/GoSynth/Go4kVSTi.cpp
Normal file
@ -0,0 +1,131 @@
|
||||
#include <stdio.h>
|
||||
#include <windows.h>
|
||||
#ifndef __Go4kVSTi__
|
||||
#include "Go4kVSTi.h"
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------------------
|
||||
// Go4kVSTi
|
||||
//-----------------------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------------------
|
||||
Go4kVSTi::Go4kVSTi (audioMasterCallback audioMaster) : AudioEffectX (audioMaster, 0, 0)
|
||||
{
|
||||
if (audioMaster)
|
||||
{
|
||||
setNumInputs (0); // no inputs
|
||||
setNumOutputs (2); // 2 outputs, stereo
|
||||
canProcessReplacing ();
|
||||
hasVu (false);
|
||||
hasClip (false);
|
||||
isSynth ();
|
||||
setUniqueID ('4klg');
|
||||
}
|
||||
initProcess ();
|
||||
suspend ();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------
|
||||
Go4kVSTi::~Go4kVSTi ()
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------
|
||||
void Go4kVSTi::setProgram (long program)
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------
|
||||
void Go4kVSTi::setProgramName (char *name)
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------
|
||||
void Go4kVSTi::getProgramName (char *name)
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------
|
||||
void Go4kVSTi::getParameterLabel (long index, char *label)
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------
|
||||
void Go4kVSTi::getParameterDisplay (long index, char *text)
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------
|
||||
void Go4kVSTi::getParameterName (long index, char *label)
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------
|
||||
void Go4kVSTi::setParameter (long index, float value)
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------
|
||||
float Go4kVSTi::getParameter (long index)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------
|
||||
bool Go4kVSTi::getOutputProperties (long index, VstPinProperties* properties)
|
||||
{
|
||||
if (index < 2)
|
||||
{
|
||||
sprintf (properties->label, "Vstx %1d", index + 1);
|
||||
properties->flags = kVstPinIsActive;
|
||||
properties->flags |= kVstPinIsStereo; // test, make channel 1+2 stereo
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------
|
||||
bool Go4kVSTi::getProgramNameIndexed (long category, long index, char* text)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------
|
||||
bool Go4kVSTi::copyProgram (long destination)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------
|
||||
bool Go4kVSTi::getEffectName (char* name)
|
||||
{
|
||||
strcpy (name, "4klang");
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------
|
||||
bool Go4kVSTi::getVendorString (char* text)
|
||||
{
|
||||
strcpy (text, "Alcatraz");
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------
|
||||
bool Go4kVSTi::getProductString (char* text)
|
||||
{
|
||||
strcpy (text, "4klang");
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------
|
||||
long Go4kVSTi::canDo (char* text)
|
||||
{
|
||||
if (!strcmp (text, "receiveVstEvents"))
|
||||
return 1;
|
||||
if (!strcmp (text, "receiveVstMidiEvent"))
|
||||
return 1;
|
||||
if (!strcmp (text, "receiveVstTimeInfo"))
|
||||
return 1;
|
||||
return -1; // explicitly can't do; 0 => don't know
|
||||
}
|
||||
|
51
4klang_source/Go4kVSTi/source/GoSynth/Go4kVSTi.h
Normal file
51
4klang_source/Go4kVSTi/source/GoSynth/Go4kVSTi.h
Normal file
@ -0,0 +1,51 @@
|
||||
#ifndef __Go4kVSTi__
|
||||
#define __Go4kVSTi__
|
||||
|
||||
#include <string.h>
|
||||
#include <vector>
|
||||
|
||||
#ifndef __AudioEffectX__
|
||||
#include "audioeffectx.h"
|
||||
#endif
|
||||
|
||||
//------------------------------------------------------------------------------------------
|
||||
class Go4kVSTi : public AudioEffectX
|
||||
{
|
||||
public:
|
||||
Go4kVSTi(audioMasterCallback audioMaster);
|
||||
~Go4kVSTi();
|
||||
|
||||
virtual void process(float **inputs, float **outputs, long sampleframes);
|
||||
virtual void processReplacing(float **inputs, float **outputs, long sampleframes);
|
||||
void processAnyhow(float **inputs, float **outputs, long sampleFrames);
|
||||
virtual long processEvents(VstEvents* events);
|
||||
|
||||
virtual void setProgram(long program);
|
||||
virtual void setProgramName(char *name);
|
||||
virtual void getProgramName(char *name);
|
||||
virtual void setParameter(long index, float value);
|
||||
virtual float getParameter(long index);
|
||||
virtual void getParameterLabel(long index, char *label);
|
||||
virtual void getParameterDisplay(long index, char *text);
|
||||
virtual void getParameterName(long index, char *text);
|
||||
virtual void setSampleRate(float sampleRate);
|
||||
virtual void setBlockSize(long blockSize);
|
||||
virtual void suspend();
|
||||
virtual void resume();
|
||||
virtual bool getOutputProperties (long index, VstPinProperties* properties);
|
||||
virtual bool getProgramNameIndexed (long category, long index, char* text);
|
||||
virtual bool copyProgram (long destination);
|
||||
virtual bool getEffectName (char* name);
|
||||
virtual bool getVendorString (char* text);
|
||||
virtual bool getProductString (char* text);
|
||||
virtual long getVendorVersion () {return 1;}
|
||||
virtual long canDo (char* text);
|
||||
|
||||
private:
|
||||
void initProcess();
|
||||
void ApplyEvent(VstMidiEvent *event);
|
||||
|
||||
std::vector<VstMidiEvent*> m_currentEvents;
|
||||
};
|
||||
|
||||
#endif
|
3009
4klang_source/Go4kVSTi/source/GoSynth/Go4kVSTiCore.cpp
Normal file
3009
4klang_source/Go4kVSTi/source/GoSynth/Go4kVSTiCore.cpp
Normal file
File diff suppressed because it is too large
Load Diff
294
4klang_source/Go4kVSTi/source/GoSynth/Go4kVSTiCore.h
Normal file
294
4klang_source/Go4kVSTi/source/GoSynth/Go4kVSTiCore.h
Normal file
@ -0,0 +1,294 @@
|
||||
#include "windows.h"
|
||||
|
||||
// init synth
|
||||
void Go4kVSTi_Init();
|
||||
|
||||
// clear instrument slot
|
||||
void Go4kVSTi_ClearInstrumentSlot(char channel, int slot);
|
||||
// clear instrument workspace
|
||||
void Go4kVSTi_ClearInstrumentWorkspace(char channel);
|
||||
// clear global slot
|
||||
void Go4kVSTi_ClearGlobalSlot(int slot);
|
||||
// clear global workspace
|
||||
void Go4kVSTi_ClearGlobalWorkspace();
|
||||
|
||||
// reset instrument to default values
|
||||
void Go4kVSTi_ResetInstrument(char channel);
|
||||
// reset global to default values
|
||||
void Go4kVSTi_ResetGlobal();
|
||||
// reset the synth to default values
|
||||
void Go4kVSTi_ResetPatch();
|
||||
|
||||
// flip 2 neighbour instrument slots
|
||||
void Go4kVSTi_FlipInstrumentSlots(char channel, int a, int b);
|
||||
// flip 2 neighbour global slots
|
||||
void Go4kVSTi_FlipGlobalSlots(int a, int b);
|
||||
|
||||
// init a slot with given type with default values
|
||||
void Go4kVSTi_InitSlot(BYTE* slot, int channel, int type);
|
||||
// init a instrument slot
|
||||
void Go4kVSTi_InitInstrumentSlot(char channel, int s, int type);
|
||||
// init a global slot
|
||||
void Go4kVSTi_InitGlobalSlot(int s, int type);
|
||||
|
||||
// set global bpm
|
||||
void Go4kVSTi_SetBPM(float bpm);
|
||||
float Go4kVSTi_GetBPM();
|
||||
|
||||
// activate solo mode
|
||||
void Go4kVSTi_Solo(int channel, int solo);
|
||||
// stream recording activation/deactivation
|
||||
void Go4kVSTi_Record(bool record, int patternsize, float patternquant);
|
||||
// panic
|
||||
void Go4kVSTi_Panic();
|
||||
// update dll times (e.g. sync to current bpm)
|
||||
void Go4kVSTi_UpdateDelayTimes();
|
||||
// clear delay lines
|
||||
void Go4kVSTi_ClearDelayLines();
|
||||
|
||||
// one tick the whole synth pipeline. results are left and right output sample
|
||||
void Go4kVSTi_Tick(float *oleft, float *oright, int samples);
|
||||
// add a voice with given parameters to synth
|
||||
void Go4kVSTi_AddVoice(int channel, int note);
|
||||
// stop a voice with given parameters in synth
|
||||
void Go4kVSTi_StopVoice(int channel, int note);
|
||||
|
||||
// load binary patch data
|
||||
void Go4kVSTi_LoadPatch(char *filename);
|
||||
// save binary patch data
|
||||
void Go4kVSTi_SavePatch(char *filename);
|
||||
// load instrumen data to specified channel
|
||||
void Go4kVSTi_LoadInstrument(char* filename, char channel);
|
||||
// save instrument data from current channel
|
||||
void Go4kVSTi_SaveInstrument(char* filename, char channel);
|
||||
// load unit data into specified slot
|
||||
void Go4kVSTi_LoadUnit(char* filename, BYTE* slot);
|
||||
// save unit date from specified slot
|
||||
void Go4kVSTi_SaveUnit(char* filename, BYTE* slot);
|
||||
|
||||
#define EXPORT_OBJECT_FILE_
|
||||
void Go4kVSTi_SaveByteStream(HINSTANCE hInst, char* filename, int useenvlevels, int useenotevalues, int clipoutput, int undenormalize, int objformat, int output16);
|
||||
|
||||
#define MAX_POLYPHONY 2
|
||||
#define MAX_INSTRUMENTS 16
|
||||
#define MAX_SLOT_VALUES 32
|
||||
|
||||
#define MAX_SLOTS 32
|
||||
|
||||
enum UnitID
|
||||
{
|
||||
M_NONE = 0,
|
||||
M_ENV,
|
||||
M_VCO,
|
||||
M_VCF,
|
||||
M_DST,
|
||||
M_DLL,
|
||||
M_FOP,
|
||||
M_FST,
|
||||
M_PAN,
|
||||
M_OUT,
|
||||
M_ACC,
|
||||
M_FLD,
|
||||
NUM_MODULES
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
// value definitions
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#define ENV_STATE_ATTAC 0
|
||||
#define ENV_STATE_DECAY 1
|
||||
#define ENV_STATE_SUSTAIN 2
|
||||
#define ENV_STATE_RELEASE 3
|
||||
#define ENV_STATE_OFF 4
|
||||
|
||||
typedef struct ENV_val
|
||||
{
|
||||
BYTE id;
|
||||
BYTE attac;
|
||||
BYTE decay;
|
||||
BYTE sustain;
|
||||
BYTE release;
|
||||
BYTE gain;
|
||||
// GUI STUFF
|
||||
} *ENV_valP;
|
||||
|
||||
#define VCO_SINE 0x01
|
||||
#define VCO_TRISAW 0x02
|
||||
#define VCO_PULSE 0x04
|
||||
#define VCO_NOISE 0x08
|
||||
#define VCO_LFO 0x10
|
||||
#define VCO_GATE 0x20
|
||||
typedef struct VCO_val
|
||||
{
|
||||
BYTE id;
|
||||
BYTE transpose;
|
||||
BYTE detune;
|
||||
BYTE phaseofs;
|
||||
BYTE gate;
|
||||
BYTE color;
|
||||
BYTE shape;
|
||||
BYTE gain;
|
||||
BYTE flags;
|
||||
// GUI STUFF
|
||||
} *VCO_valP;
|
||||
|
||||
typedef struct VCO11_val
|
||||
{
|
||||
BYTE id;
|
||||
BYTE transpose;
|
||||
BYTE detune;
|
||||
BYTE phaseofs;
|
||||
BYTE color;
|
||||
BYTE shape;
|
||||
BYTE gain;
|
||||
BYTE flags;
|
||||
// GUI STUFF
|
||||
} *VCO11_valP;
|
||||
|
||||
#define VCF_LOWPASS 0x1
|
||||
#define VCF_HIGHPASS 0x2
|
||||
#define VCF_BANDPASS 0x4
|
||||
#define VCF_BANDSTOP 0x3
|
||||
#define VCF_ALLPASS 0x7
|
||||
#define VCF_PEAK 0x8
|
||||
typedef struct VCF_val
|
||||
{
|
||||
BYTE id;
|
||||
BYTE freq;
|
||||
BYTE res;
|
||||
BYTE type;
|
||||
// GUI STUFF
|
||||
} *VCF_valP;
|
||||
|
||||
typedef struct DST_val
|
||||
{
|
||||
BYTE id;
|
||||
BYTE drive;
|
||||
BYTE snhfreq;
|
||||
// GUI STUFF
|
||||
} *DST_valP;
|
||||
|
||||
typedef struct DLL_val
|
||||
{
|
||||
BYTE id;
|
||||
BYTE pregain;
|
||||
BYTE dry;
|
||||
BYTE feedback;
|
||||
BYTE damp;
|
||||
BYTE freq;
|
||||
BYTE depth;
|
||||
BYTE delay;
|
||||
BYTE count;
|
||||
// GUI STUFF
|
||||
BYTE guidelay;
|
||||
BYTE synctype;
|
||||
BYTE leftreverb;
|
||||
BYTE reverb;
|
||||
} *DLL_valP;
|
||||
|
||||
typedef struct DLL10_val
|
||||
{
|
||||
BYTE id;
|
||||
BYTE pregain;
|
||||
BYTE dry;
|
||||
BYTE feedback;
|
||||
BYTE damp;
|
||||
BYTE delay;
|
||||
BYTE count;
|
||||
// GUI STUFF
|
||||
BYTE guidelay;
|
||||
BYTE synctype;
|
||||
BYTE leftreverb;
|
||||
BYTE reverb;
|
||||
} *DLL10_valP;
|
||||
|
||||
#define FOP_POP 0x1
|
||||
#define FOP_ADDP 0x2
|
||||
#define FOP_MULP 0x3
|
||||
#define FOP_PUSH 0x4
|
||||
#define FOP_XCH 0x5
|
||||
#define FOP_ADD 0x6
|
||||
#define FOP_MUL 0x7
|
||||
#define FOP_ADDP2 0x8
|
||||
#define FOP_LOADNOTE 0x9
|
||||
typedef struct FOP_val
|
||||
{
|
||||
BYTE id;
|
||||
BYTE flags;
|
||||
} *FOP_valP;
|
||||
|
||||
typedef struct FST_val
|
||||
{
|
||||
BYTE id;
|
||||
BYTE amount;
|
||||
BYTE dest;
|
||||
// GUI STUFF
|
||||
char dest_stack;
|
||||
char dest_unit;
|
||||
char dest_slot;
|
||||
char dest_id;
|
||||
} *FST_valP;
|
||||
|
||||
typedef struct PAN_val
|
||||
{
|
||||
BYTE id;
|
||||
BYTE panning;
|
||||
// GUI STUFF
|
||||
} *PAN_valP;
|
||||
|
||||
typedef struct OUT_val
|
||||
{
|
||||
BYTE id;
|
||||
BYTE gain;
|
||||
BYTE auxsend;
|
||||
// GUI STUFF
|
||||
} *OUT_valP;
|
||||
|
||||
#define ACC_OUT 0
|
||||
#define ACC_AUX 8
|
||||
typedef struct ACC_val
|
||||
{
|
||||
BYTE id;
|
||||
BYTE flags;
|
||||
} *ACC_valP;
|
||||
|
||||
typedef struct FLD_val
|
||||
{
|
||||
BYTE id;
|
||||
BYTE value;
|
||||
// GUI STUFF
|
||||
} *FLD_valP;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
// workspace definitions
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef struct InstrumentWorkspace
|
||||
{
|
||||
DWORD release;
|
||||
DWORD note;
|
||||
float workspace[256];
|
||||
float dlloutl;
|
||||
float dlloutr;
|
||||
float outl;
|
||||
float outr;
|
||||
} *InstrumentWorkspaceP;
|
||||
|
||||
typedef struct SynthObject
|
||||
{
|
||||
DWORD Polyphony;
|
||||
char InstrumentNames[MAX_INSTRUMENTS][64];
|
||||
BYTE InstrumentValues[MAX_INSTRUMENTS][MAX_SLOTS][MAX_SLOT_VALUES]; // 16 instruments a 32 slots a 32 dowrds
|
||||
BYTE GlobalValues[MAX_SLOTS][MAX_SLOT_VALUES]; // 32 slots a 32 dwords
|
||||
InstrumentWorkspace InstrumentWork[MAX_INSTRUMENTS*MAX_POLYPHONY];
|
||||
InstrumentWorkspace GlobalWork;
|
||||
DWORD InstrumentSignalValid[MAX_INSTRUMENTS];
|
||||
DWORD GlobalSignalValid;
|
||||
float SignalTrace[MAX_INSTRUMENTS];
|
||||
int ControlInstrument[MAX_INSTRUMENTS];
|
||||
int VoiceIndex[MAX_INSTRUMENTS];
|
||||
} *SynthObjectP;
|
||||
|
||||
SynthObjectP Go4kVSTi_GetSynthObject();
|
3003
4klang_source/Go4kVSTi/source/GoSynth/Go4kVSTiGUI.cpp
Normal file
3003
4klang_source/Go4kVSTi/source/GoSynth/Go4kVSTiGUI.cpp
Normal file
File diff suppressed because it is too large
Load Diff
182
4klang_source/Go4kVSTi/source/GoSynth/Go4kVSTiGUI.h
Normal file
182
4klang_source/Go4kVSTi/source/GoSynth/Go4kVSTiGUI.h
Normal file
@ -0,0 +1,182 @@
|
||||
#include <windows.h>
|
||||
|
||||
#define ButtonGroupChanged(btn_firstid, btn_lastid, test_id, seltab, result_index) \
|
||||
{ \
|
||||
result_index = 0; \
|
||||
if (LOWORD(test_id) >= btn_firstid && \
|
||||
LOWORD(test_id) <= btn_lastid) \
|
||||
{ \
|
||||
for (WORD bgci = btn_firstid; bgci <= btn_lastid; bgci++) \
|
||||
{ \
|
||||
if (LOWORD(test_id) == bgci) \
|
||||
{ \
|
||||
EnableWindow(GetDlgItem(ModuleWnd[seltab], bgci), false); \
|
||||
result_index = bgci; \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
EnableWindow(GetDlgItem(ModuleWnd[seltab], bgci), true); \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
#define EnableButtonGroup(btn_firstid, btn_lastid, seltab, btn_show) \
|
||||
{ \
|
||||
for (WORD bgci = btn_firstid; bgci <= btn_lastid; bgci++) \
|
||||
{ \
|
||||
EnableWindow(GetDlgItem(ModuleWnd[seltab], bgci), btn_show); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define SetCheckboxGroupBitmask(btn_firstid, btn_lastid, seltab, input_bits) \
|
||||
{ \
|
||||
WORD curbitsel = 0x0001; \
|
||||
for (WORD bgci = btn_firstid; bgci <= btn_lastid; bgci++,curbitsel*=2) \
|
||||
{ \
|
||||
SendDlgItemMessage(ModuleWnd[seltab], bgci, BM_SETCHECK, input_bits & curbitsel, 0); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define GetCheckboxGroupBitmask(btn_firstid, btn_lastid, test_id, seltab, result_bits, result_index) \
|
||||
{ \
|
||||
result_index = 0; \
|
||||
result_bits = 0; \
|
||||
WORD curbitsel = 0x0001; \
|
||||
if (LOWORD(test_id) >= btn_firstid && \
|
||||
LOWORD(test_id) <= btn_lastid) \
|
||||
{ \
|
||||
for (WORD bgci = btn_firstid; bgci <= btn_lastid; bgci++,curbitsel*=2) \
|
||||
{ \
|
||||
if (LOWORD(test_id) == bgci) \
|
||||
{ \
|
||||
result_index = bgci; \
|
||||
} \
|
||||
if (SendDlgItemMessage(ModuleWnd[seltab], bgci, BM_GETCHECK, 0, 0)==BST_CHECKED) \
|
||||
{ \
|
||||
result_bits |= curbitsel; \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
result_bits &= ~curbitsel; \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
#define InitSlider(tab_id, slider_id, slider_low, slider_hi, slider_pos) \
|
||||
{ \
|
||||
SendDlgItemMessage(tab_id, slider_id, TBM_SETRANGE, true, MAKELONG(slider_low, slider_hi)); \
|
||||
SendDlgItemMessage(tab_id, slider_id, TBM_SETPOS, true, slider_pos); \
|
||||
SendDlgItemMessage(tab_id, slider_id, TBM_SETLINESIZE, 0, 1); \
|
||||
SendDlgItemMessage(tab_id, slider_id, TBM_SETPAGESIZE, 0, 1); \
|
||||
sprintf(SliderValTxt, "%d", slider_pos); \
|
||||
SetWindowText(GetDlgItem(tab_id, slider_id ## _VAL), SliderValTxt); \
|
||||
}
|
||||
|
||||
#define InitSliderCenter(tab_id, slider_id, slider_low, slider_hi, slider_pos) \
|
||||
{ \
|
||||
SendDlgItemMessage(tab_id, slider_id, TBM_SETRANGE, true, MAKELONG(slider_low, slider_hi)); \
|
||||
SendDlgItemMessage(tab_id, slider_id, TBM_SETPOS, true, slider_pos); \
|
||||
SendDlgItemMessage(tab_id, slider_id, TBM_SETLINESIZE, 0, 1); \
|
||||
SendDlgItemMessage(tab_id, slider_id, TBM_SETPAGESIZE, 0, 1); \
|
||||
sprintf(SliderValTxt, "%d", slider_pos-64); \
|
||||
SetWindowText(GetDlgItem(tab_id, slider_id ## _VAL), SliderValTxt); \
|
||||
}
|
||||
|
||||
#define InitSliderCenter2(tab_id, slider_id, slider_low, slider_hi, slider_pos) \
|
||||
{ \
|
||||
SendDlgItemMessage(tab_id, slider_id, TBM_SETRANGE, true, MAKELONG(slider_low, slider_hi)); \
|
||||
SendDlgItemMessage(tab_id, slider_id, TBM_SETPOS, true, slider_pos); \
|
||||
SendDlgItemMessage(tab_id, slider_id, TBM_SETLINESIZE, 0, 1); \
|
||||
SendDlgItemMessage(tab_id, slider_id, TBM_SETPAGESIZE, 0, 1); \
|
||||
sprintf(SliderValTxt, "%d", (slider_pos-64)*2); \
|
||||
SetWindowText(GetDlgItem(tab_id, slider_id ## _VAL), SliderValTxt); \
|
||||
}
|
||||
|
||||
#define InitSliderNoGUI(tab_id, slider_id, slider_low, slider_hi, slider_pos) \
|
||||
{ \
|
||||
SendDlgItemMessage(tab_id, slider_id, TBM_SETRANGE, true, MAKELONG(slider_low, slider_hi)); \
|
||||
SendDlgItemMessage(tab_id, slider_id, TBM_SETPOS, true, slider_pos); \
|
||||
SendDlgItemMessage(tab_id, slider_id, TBM_SETLINESIZE, 0, 1); \
|
||||
SendDlgItemMessage(tab_id, slider_id, TBM_SETPAGESIZE, 0, 1); \
|
||||
}
|
||||
|
||||
#define DisableButtonGroup(btn_firstid, btn_lastid, seltab) \
|
||||
{ \
|
||||
for (WORD bgci = btn_firstid; bgci <= btn_lastid; bgci++) \
|
||||
{ \
|
||||
EnableWindow(GetDlgItem(ModuleWnd[seltab], bgci), true); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define InterleavedButtonGroupChanged(btn_firstid, btn_count, test_id, result_index)\
|
||||
{ \
|
||||
result_index = -1; \
|
||||
if (((LOWORD(test_id)-btn_firstid) % 6) == 0) \
|
||||
{ \
|
||||
for (WORD bgci = 0; bgci < btn_count; bgci++) \
|
||||
{ \
|
||||
WORD ibtn = btn_firstid+bgci*6; \
|
||||
if (LOWORD(test_id) == ibtn) \
|
||||
{ \
|
||||
EnableWindow(GetDlgItem(TabWnd[SelectedTab], ibtn), false); \
|
||||
result_index = bgci; \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
EnableWindow(GetDlgItem(TabWnd[SelectedTab], ibtn), true); \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
#define DisableInterleavedButtonGroup(btn_firstid, btn_count, seltab) \
|
||||
{ \
|
||||
for (WORD bgci = 0; bgci < btn_count; bgci++) \
|
||||
{ \
|
||||
EnableWindow(GetDlgItem(TabWnd[seltab], btn_firstid+bgci*6), true); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define UpdateSliderValue(usv_id, usv_v) \
|
||||
{ \
|
||||
usv_v = SendMessage(GetDlgItem(ModuleWnd[uid], usv_id), TBM_GETPOS, 0, 0); \
|
||||
sprintf(SliderValTxt, "%d", usv_v); \
|
||||
SetWindowText(GetDlgItem(ModuleWnd[uid], usv_id ## _VAL), SliderValTxt); \
|
||||
}
|
||||
|
||||
#define UpdateSliderValueCenter(usv_id, usv_v) \
|
||||
{ \
|
||||
usv_v = SendMessage(GetDlgItem(ModuleWnd[uid], usv_id), TBM_GETPOS, 0, 0); \
|
||||
sprintf(SliderValTxt, "%d", usv_v-64); \
|
||||
SetWindowText(GetDlgItem(ModuleWnd[uid], usv_id ## _VAL), SliderValTxt); \
|
||||
}
|
||||
|
||||
#define UpdateSliderValueCenter2(usv_id, usv_v) \
|
||||
{ \
|
||||
usv_v = SendMessage(GetDlgItem(ModuleWnd[uid], usv_id), TBM_GETPOS, 0, 0); \
|
||||
sprintf(SliderValTxt, "%d", (usv_v-64)*2); \
|
||||
SetWindowText(GetDlgItem(ModuleWnd[uid], usv_id ## _VAL), SliderValTxt); \
|
||||
}
|
||||
|
||||
void Go4kVSTiGUI_Create(HINSTANCE hInst);
|
||||
void Go4kVSTiGUI_Show(int showCommand);
|
||||
void Go4kVSTiGUI_Destroy();
|
||||
|
||||
bool InitTabDlg();
|
||||
|
||||
bool ButtonPressed(WPARAM id, LPARAM lParam);
|
||||
bool ScrollbarChanged(HWND hwndDlg, WPARAM wParam, LPARAM lParam);
|
||||
bool StackButtonPressed(WPARAM id);
|
||||
void TabChanged(int index);
|
||||
|
||||
void UpdateSignalCount(int channel);
|
||||
void UpdateControls(int channel);
|
||||
void UpdateModuleParamWindow(int tab, int unit);
|
||||
void UpdateVoiceDisplay(int i);
|
||||
|
||||
void GetStreamFileName();
|
||||
|
||||
|
||||
|
60
4klang_source/Go4kVSTi/source/GoSynth/Go4kVSTimain.cpp
Normal file
60
4klang_source/Go4kVSTi/source/GoSynth/Go4kVSTimain.cpp
Normal file
@ -0,0 +1,60 @@
|
||||
#include <windows.h>
|
||||
#include <stddef.h>
|
||||
#include "Go4kVSTi.h"
|
||||
#include "Go4kVSTiGUI.h"
|
||||
|
||||
static AudioEffect *effect = 0;
|
||||
bool oome = false;
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// prototype of the export function main
|
||||
int main (audioMasterCallback audioMaster);
|
||||
|
||||
int main (audioMasterCallback audioMaster)
|
||||
{
|
||||
// get vst version
|
||||
if(!audioMaster (0, audioMasterVersion, 0, 0, 0, 0))
|
||||
return 0; // old version
|
||||
|
||||
effect = new Go4kVSTi (audioMaster);
|
||||
if (!effect)
|
||||
return 0;
|
||||
if (oome)
|
||||
{
|
||||
delete effect;
|
||||
return 0;
|
||||
}
|
||||
return (int)effect->getAeffect();
|
||||
}
|
||||
|
||||
void* hInstance;
|
||||
BOOL WINAPI DllMain (HINSTANCE hInst, DWORD dwReason, LPVOID lpvReserved)
|
||||
{
|
||||
switch (dwReason)
|
||||
{
|
||||
// wird aufgerufen, wenn zum ersten mal das plugin aktiviert wird
|
||||
// also hier init f<>r den synth
|
||||
case DLL_PROCESS_ATTACH:
|
||||
//MessageBox(NULL, "DLL_PROCESS_ATTACH", "DllMain", MB_OK);
|
||||
Go4kVSTiGUI_Create(hInst);
|
||||
Go4kVSTiGUI_Show(SW_SHOW);
|
||||
break;
|
||||
// wird aufgerufen, wenn das plugin nicht mehr verwendet wird
|
||||
// entweder bei entfernen des letzten, schliessen des songs oder
|
||||
// des programms. Also hier Deinit und zerst<73>rung des Synths
|
||||
case DLL_PROCESS_DETACH:
|
||||
//MessageBox(NULL, "DLL_PROCESS_DETACH", "DllMain", MB_OK);
|
||||
Go4kVSTiGUI_Destroy();
|
||||
effect = 0;
|
||||
break;
|
||||
// die beiden brauchts wohl nicht
|
||||
case DLL_THREAD_ATTACH:
|
||||
//MessageBox(NULL, "DLL_THREAD_ATTACH", "DllMain", MB_OK);
|
||||
break;
|
||||
case DLL_THREAD_DETACH:
|
||||
//MessageBox(NULL, "DLL_THREAD_DETACH", "DllMain", MB_OK);
|
||||
break;
|
||||
}
|
||||
hInstance = hInst;
|
||||
return 1;
|
||||
}
|
158
4klang_source/Go4kVSTi/source/GoSynth/Go4kVSTiproc.cpp
Normal file
158
4klang_source/Go4kVSTi/source/GoSynth/Go4kVSTiproc.cpp
Normal file
@ -0,0 +1,158 @@
|
||||
#ifndef __Go4kVSTi__
|
||||
#include "Go4kVSTi.h"
|
||||
#include "Go4kVSTiCore.h"
|
||||
#include "stdio.h"
|
||||
#endif
|
||||
|
||||
#include "math.h"
|
||||
|
||||
//-----------------------------------------------------------------------------------------
|
||||
void Go4kVSTi::setSampleRate (float sampleRate)
|
||||
{
|
||||
AudioEffectX::setSampleRate (sampleRate);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------
|
||||
void Go4kVSTi::setBlockSize (long blockSize)
|
||||
{
|
||||
AudioEffectX::setBlockSize (blockSize);
|
||||
// you may need to have to do something here...
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------
|
||||
void Go4kVSTi::suspend ()
|
||||
{
|
||||
m_currentEvents.clear();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------
|
||||
void Go4kVSTi::resume ()
|
||||
{
|
||||
wantEvents ();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------
|
||||
void Go4kVSTi::initProcess ()
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------
|
||||
void Go4kVSTi::process (float **inputs, float **outputs, long sampleFrames)
|
||||
{
|
||||
processAnyhow(inputs, outputs, sampleFrames);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------
|
||||
void Go4kVSTi::processReplacing (float **inputs, float **outputs, long sampleFrames)
|
||||
{
|
||||
processAnyhow(inputs, outputs, sampleFrames);
|
||||
}
|
||||
|
||||
void Go4kVSTi::processAnyhow(float **inputs, float **outputs, long sampleFrames)
|
||||
{
|
||||
float* outl = outputs[0];
|
||||
float* outr = outputs[1];
|
||||
static int bpmCheck = 0;
|
||||
if ( bpmCheck <= 0 )
|
||||
{
|
||||
VstTimeInfo* myTime = getTimeInfo ( kVstTempoValid );
|
||||
Go4kVSTi_SetBPM(myTime->tempo);
|
||||
bpmCheck = 20; // only check every 20th call of this function (bpm shouldnt change that often)
|
||||
}
|
||||
bpmCheck--;
|
||||
|
||||
int start = 0;
|
||||
// midi events will occur this frame, so render partially
|
||||
if (m_currentEvents.size() > 0)
|
||||
{
|
||||
// for all events
|
||||
for (unsigned int i = 0; i < m_currentEvents.size(); i++)
|
||||
{
|
||||
// process samples until next event
|
||||
int todo = m_currentEvents[i]->deltaFrames - start;
|
||||
Go4kVSTi_Tick(outl+start, outr+start, todo);
|
||||
start = m_currentEvents[i]->deltaFrames;
|
||||
// apply changes due to event
|
||||
ApplyEvent(m_currentEvents[i]);
|
||||
}
|
||||
}
|
||||
Go4kVSTi_Tick(outl+start, outr+start, sampleFrames - start);
|
||||
|
||||
// clear event list (old event pointer wont be valid next frame anyway)
|
||||
m_currentEvents.clear();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------
|
||||
long Go4kVSTi::processEvents(VstEvents* ev)
|
||||
{
|
||||
for (long i = 0; i < ev->numEvents; i++)
|
||||
{
|
||||
if ((ev->events[i])->type != kVstMidiType)
|
||||
continue;
|
||||
VstMidiEvent* event = (VstMidiEvent*)ev->events[i];
|
||||
m_currentEvents.push_back(event);
|
||||
}
|
||||
return 1; // want more
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------
|
||||
void Go4kVSTi::ApplyEvent(VstMidiEvent *event)
|
||||
{
|
||||
char* midiData = event->midiData;
|
||||
byte status = midiData[0] & 0xf0; // status
|
||||
byte channel = midiData[0] & 0x0f; // channel
|
||||
|
||||
// note on/off events
|
||||
if (status == 0x90 || status == 0x80)
|
||||
{
|
||||
byte note = midiData[1] & 0x7f;
|
||||
byte velocity = midiData[2] & 0x7f;
|
||||
if (status == 0x80)
|
||||
velocity = 0;
|
||||
// note off
|
||||
if (!velocity)
|
||||
{
|
||||
Go4kVSTi_StopVoice(channel, note);
|
||||
}
|
||||
// note on
|
||||
else
|
||||
{
|
||||
Go4kVSTi_AddVoice(channel, note);
|
||||
}
|
||||
}
|
||||
/* // polyphonic aftertouch
|
||||
else if (status == 0xA)
|
||||
{
|
||||
byte note = midiData[1] & 0x7f;
|
||||
byte pressure = midiData[2] & 0x7f;
|
||||
Go4kVSTi_PolyAftertouch(channel, note, pressure);
|
||||
}
|
||||
// channel aftertouch
|
||||
else if (status == 0xD)
|
||||
{
|
||||
byte pressure = midiData[1] & 0x7f;
|
||||
Go4kVSTi_ChannelAftertouch(channel, pressure);
|
||||
}
|
||||
// Controller Change
|
||||
else if (status == 0xB0)
|
||||
{
|
||||
byte number = midiData[1] & 0x7f;
|
||||
byte value = midiData[2] & 0x7f;
|
||||
// Go4kVSTi_ControllerChange(channel, number, value, event->deltaFrames);
|
||||
}
|
||||
// Pitch Bend
|
||||
else if (status == 0xE0)
|
||||
{
|
||||
byte lsb = midiData[1] & 0x7f;
|
||||
byte msb = midiData[2] & 0x7f;
|
||||
int value = (((int)(msb)) << 7) + lsb;
|
||||
// Go4kVSTi_PitchBend(channel, value); // 0 - 16383, center 8192
|
||||
// dont use full precision for the sake of equally sized streams
|
||||
// Go4kVSTi_PitchBend(channel, value >> 7, event->deltaFrames); // 0 - 127, center 64
|
||||
}*/
|
||||
// all notes off (dont seem to come anyway
|
||||
else if (status == 0xb0 && midiData[1] == 0x7e) // all notes off
|
||||
{
|
||||
Go4kVSTi_StopVoice(channel, 0);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user