QM816

QM816 - implements a Quadrature-Amplitude synthesizer. This technique was used in early digital FM synths, since it allowed allowed a cheap implementation of the same thing as long as the modulator was a sinusoidal waveform.

It has 16 2 operator channels that can be individually paired-up for 4 operator channels, for more complex sounds. Also all operators have the option for feedback, including carriers. 2 operator channels have 2, 4 operator channels have 3*4 algorithms.

Before use, the synth needs to be supplied with a wavetable file, in 16 bit wav format.

class QM816 : AudioModule {}

Constructors

this
this(ModuleManager handler)

Creates an instance of QM816

Members

Aliases

ChFun
alias ChFun = void delegate(int chNum, size_t length) @(nogc) pure nothrow
Undocumented in source.

Enums

ChannelParamNums
enum ChannelParamNums

Defines channel parameter numbers, within the unregistered namespace.

ChannelRegParams
enum ChannelRegParams

Defines channel parameters within the registered namespace

GlobalParamNums
enum GlobalParamNums

Defines global parameter nummbers, within the unregistered namespace

OperatorParamNums
enum OperatorParamNums

Defines operator parameter numbers, within the unregistered namespace.

Functions

midiReceive
void midiReceive(uint[4] data, uint offset)

MIDI 2.0 data received here.

prgRecall
void prgRecall(ubyte ch, ubyte prg, ubyte bank)

Recalls a program

renderFrame
void renderFrame(float*[] input, float*[] output)

Renders the current audio frame.

setChDeleg
void setChDeleg(uint chCtrl, uint chNum, uint chCtrl0)

Sets the channel delegates

setRegisteredParam
void setRegisteredParam(T val, ubyte[2] paramNum, ubyte type, ubyte chNum)

Sets a registered parameter

setUnregisteredParam
void setUnregisteredParam(T val, ubyte[2] paramNum, ubyte type, ubyte chNum)

Sets an unregistered parameter

updateChannelM00
void updateChannelM00(int chNum, size_t length)

Algorithm Mode 0/0 (Serial)

updateChannelM01
void updateChannelM01(int chNum, size_t length)

Algorithm Mode0/1 (Parallel)

updateChannelM100
void updateChannelM100(int chNum, size_t length)

Algorithm Mode1/00 (S0->S1->P0->P1)

updateChannelM101
void updateChannelM101(int chNum, size_t length)

Algorithm Mode1/01 S0->S1->P0-> P1->

updateChannelM110
void updateChannelM110(int chNum, size_t length)

Algorithm Mode1/10 S0\ ->P0->P1-> S1/

updateChannelM111
void updateChannelM111(int chNum, size_t length)

Algorithm Mode1/11 S0\ ->P0-> S1/ P1->

updateChannelM200
void updateChannelM200(int chNum, size_t length)

Algorithm Mode2/00 S0->S1\ ->P1-> P0/

updateChannelM201
void updateChannelM201(int chNum, size_t length)

Algorithm Mode2/01 /P0-> S0->S1 \P1->

updateChannelM210
void updateChannelM210(int chNum, size_t length)

Algorithm Mode2/10 S0\ S1-->P1-> P0/

updateChannelM211
void updateChannelM211(int chNum, size_t length)

Algorithm Mode2/11 S0\ /P0-> - S1/ \P1->

updateChannelM300
void updateChannelM300(int chNum, size_t length)

Algorithm Mode3/00 S0->S1-> P0->P1->

updateChannelM301
void updateChannelM301(int chNum, size_t length)

Algorithm Mode3/01 />S1-> S0->P0-> \>P1->

updateChannelM310
void updateChannelM310(int chNum, size_t length)

Algorithm Mode3/10 S0-> S1-> P0->P1->

updateChannelM311
void updateChannelM311(int chNum, size_t length)

Algorithm Mode3/11 S0-> S1-> P0-> P1->

updateChannelMD
void updateChannelMD(int chNum, size_t length)

Dummy algorithm for combined channels

updateOperator
void updateOperator(Operator op, __m128 chCtrl)

Updates an operator for a cycle chCtrl index notation: 0: velocity, 1: modulation wheel, 2: Amplitude LFO, 3: Extra Envelop Generator

waveformDataReceive
int waveformDataReceive(uint id, ubyte[] rawData, WaveFormat format)

Receives waveform data that has been loaded from disk for reading. Returns zero if successful, or a specific errorcode.

Static variables

ADSR_TIME_TABLE
float[128] ADSR_TIME_TABLE;

Contains a table to calculate Attack, Decay, and Release values.

CHNL_UPDATE_CONSTS
string CHNL_UPDATE_CONSTS;

Macro for channel update constants that need to be calculated once per frame Kept in at one place to make updates easier and more consistent

CHNL_UPDATE_CONSTS0
string CHNL_UPDATE_CONSTS0;

Macro for channel update constants that need to be calculated once per frame, for combined channels' second half Kept in at one place to make updates easier and more consistent

CHNL_UPDATE_CONSTS_CYCL
string CHNL_UPDATE_CONSTS_CYCL;

Macro for channel update constants that need to be calculated for each cycle Kept in at one place to make updates easier and more consistent

CHNL_UPDATE_CONSTS_CYCL0
string CHNL_UPDATE_CONSTS_CYCL0;

Macro for channel update constants that need to be calculated for each cycle for combined channels' second half Kept in at one place to make updates easier and more consistent

CHNL_UPDATE_MIX
string CHNL_UPDATE_MIX;

Macro for output mixing

CHNL_UPDATE_MIX0
string CHNL_UPDATE_MIX0;

Macro for output mixing in case of combo modes

SUSTAIN_CONTROL_TIME_TABLE
float[63] SUSTAIN_CONTROL_TIME_TABLE;

Contains a table to calculate Sustain control values.

Structs

ChControllers
struct ChControllers

Stores channel controller values (modwheel, velocity, etc.)

Channel
struct Channel

Defines channel common parameters.

Operator
struct Operator

Implements a single operator.

Preset
struct Preset

Defines a preset.

Variables

aLFOBuf
float[] aLFOBuf;

Amplitude LFO buffer. Values are between 0.0 and 1.0

aLFOPos
uint aLFOPos;

Stores ALFO position

aLFORate
uint aLFORate;

Stores ALFO rate

bankNum
ubyte[16] bankNum;

Bank numbers per channels.

chCtrls
ChControllers[16] chCtrls;

Channel control data.

chDeleg
ChFun[16] chDeleg;

Channel update delegates

channels
Channel[16] channels;

Channel data. See rendering function on updating.

dummyBuf
float[] dummyBuf;

Dummy buffer Only used if one or more outputs haven't been defined

filterCtrl
float[8] filterCtrl;

Stores control values of the output values. Layout: [LF, LQ, RF, RQ, AF, AQ, BF, BQ]

filterVals
__m128[10] filterVals;

Stores output filter values. 0: a0; 1: a1; 2: a2; 3: b0; 4: b1; 5: b2; 6: x[n-1]; 7: x[n-2]; 8: y[n-1] 9: y[n-2]

initBuffers
float[] initBuffers;

Initial mixing buffers Output is directed there before filtering Layout is: LRAB

lfoWaveform
ubyte[2] lfoWaveform;

Stores LFO waveform selection. 1: Amplitude; 0: Pitch

mixdownVal
float mixdownVal;

Mixdown value. Used for final mixing.

operators
Operator[32] operators;

Operator data. See rendering function on updating.

pLFOOut
float pLFOOut;

Pitch LFO output. Values are between -1.0 and 1.0

pLFOPos
uint pLFOPos;

Stores PLFO position

pLFORate
uint pLFORate;

Stores PLFO rate

paramNum
ubyte[2] paramNum;

Keeps the registered/unregistered parameter positions (LSB = 0).

paramTemp
ubyte[4] paramTemp;

Stores temporary parameter values

presetNum
ubyte[16] presetNum;

Preset numbers per channels.

soundBank
Preset[128][8] soundBank;

Stores presets. 8 banks of 128 presets are available for a total of 1024. If a channel combination is being used, then bank pairs (0-1, 2-3, etc) will store their primary and secondary halves, and calling either will load both halves.

wavetables
short[1024][128] wavetables;

Contains the wavetables for the operators and LFOs. Value might be divided to limit the values between 2047 and -2048 via bitshifting, otherwise the full range can be used for audio output, etc. Loaded from a 16 bit wave file.

Inherited Members

From AudioModule

ModuleInfo
struct ModuleInfo

Contains all data related to module info.

bufferSize
size_t bufferSize;

The size of the output buffers (must kept as a constant)

sampleRate
int sampleRate;

The sample rate that the audio subsystem runs at

info
ModuleInfo info;

Basic info about the plugin

handler
ModuleManager handler;

The main audio handler, also MIDI outs can be passed there

StreamIDSet
alias StreamIDSet = SortedList!(ubyte, "a < b", false)
Undocumented in source.
enabledInputs
StreamIDSet enabledInputs;

List of enabled input channel numbers

enabledOutputs
StreamIDSet enabledOutputs;

List of enabled output channel numbers

midiOut
void delegate(uint[4] data, uint offset) midiOut;

A delegate where MIDI messages are being routed

getInfo
ModuleInfo getInfo()

Returns the basic informations about this module.

getSamplerate
int getSamplerate()

Returns the current sample rate.

moduleSetup
void moduleSetup(ubyte[] inputs, ubyte[] outputs, int sampleRate, size_t bufferSize)

Sets the module up.

midiReceive
void midiReceive(uint[4] data, uint offset)

MIDI 2.0 data received here.

renderFrame
void renderFrame(float*[] input, float*[] output)

Renders the current audio frame.

waveformDataReceive
int waveformDataReceive(uint id, ubyte[] rawData, WaveFormat format)

Receives waveform data that has been loaded from disk for reading. Returns zero if successful, or a specific errorcode.

recallParam_int
int recallParam_int(uint presetID, uint paramID, int value)

Restores a parameter to the given preset. Returns an errorcode on failure.

recallParam_uint
int recallParam_uint(uint presetID, uint paramID, uint value)

Restores a parameter to the given preset. Returns an errorcode on failure.

recallParam_double
int recallParam_double(uint presetID, uint paramID, double value)

Restores a parameter to the given preset. Returns an errorcode on failure.

recallParam_string
int recallParam_string(uint presetID, uint paramID, string value)

Restores a parameter to the given preset. Returns an errorcode on failure.

Meta