1 module PixelPerfectEngine.audio.common;
2 
3 import std.bitmanip;
4 
5 /**
6  * Defines basic functions for an envelope generator.
7  */
8 public interface IEnvelopeGenerator{
9 	public @nogc uint updateEnvelopeState();
10 	public @nogc void setKeyOn();
11 	public @nogc void setKeyOff();
12 }
13 /**
14  * Stores an MICP command on 64 bits.
15  */
16 public struct MICPCommand{
17 	mixin(bitfields!(
18 		ushort, "command", 6,
19 		ushort, "channel", 10));
20 	ushort val0;		///
21 	union{
22 		ushort[2] vals;
23 		float valf;
24 		ubyte[4] midiCMD;
25 		uint val32;
26 	}
27 	/*alias note = val0;
28 	alias parameter = val0;
29 	alias velocity = val1[0];
30 	alias expr = val1[1];
31 	alias program = val1[0];
32 	alias bank = val1[1];
33 	alias valueInt = val1[0];
34 	alias valueFloat = val2;*/
35 }
36 /**
37  * Command list for MICP
38  */
39 public enum MICPCommandList : ushort{
40 	NULL	=	0,
41 	KeyOn	=	1,			///val0: Note, val1: Velocity, val2: Expression
42 	KeyOff	=	2,			///val0: Note, val1: Velocity, val2: Expression
43 	AfterTouch	=	3,		///val0: Note, val1: Velocity, val2: Expression
44 	PitchBend	=	4,		///val0: Note, val1: Corase, val2: Fine
45 	PitchBentFP	=	5,		///val0: Note, valf: Amount
46 	ProgSelect	=	6,		///val0: Prog, val1: Bank if used, val2: Unused
47 	ParamEdit	=	7,		///val0: Parameter ID, val1: New value, val2: Unused
48 	ParamEditFP	=	8,		///val0: Parameter ID, valf: New value
49 	ParamEdit32 =	9,		///val0: Parameter ID, val32: New value
50 	SysExc	=	16,			
51 	MIDIThruMICP	=	17,	///val0 is unused
52 	Wait	=	24			///val0: bits 32-47 if needed, val32: bits 0-31
53 }
54 
55 /**
56  * All PPE-FX synths and effects should be inherited from this class. 
57  */
58 abstract class AbstractPPEFX{
59 	public abstract @nogc void render(float** inputBuffers, float** outputBuffers, float samplerate, size_t bufferlength);
60 	public abstract @nogc void receiveMICPCommand(MICPCommand cmd);
61 	public abstract @nogc void loadConfig(ref void[] data);
62 	public abstract @nogc ref void[] saveConfig();
63 	public abstract @nogc PPEFXInfo* getPPEFXInfo();
64 }
65 
66 public struct PPEFXInfo{
67 	public int nOfInputs;
68 	public int nOfOutputs;
69 	public string[] inputNames;
70 	public string[] outputNames;
71 	public bool isSynth;
72 
73 }