1 module pixelperfectengine.audio.base.types; 2 3 /* 4 * Copyright (C) 2015-2021, by Laszlo Szeremi under the Boost license. 5 * 6 * Pixel Perfect Engine, audio.base.types module. 7 */ 8 9 /** 10 * Designates the audio format of a wave data. 11 * 12 * These are the same codes as in the *.wav file for compatibility. 13 */ 14 public enum AudioFormat : ushort { 15 /* WAVE form wFormatTag IDs */ 16 UNKNOWN = 0x0000, /* Microsoft Corporation */ 17 PCM = 0x0001, 18 ADPCM = 0x0002, /* Microsoft Corporation */ 19 IEEE_FLOAT = 0x0003, /* Microsoft Corporation */ 20 VSELP = 0x0004, /* Compaq Computer Corp. */ 21 IBM_CVSD = 0x0005, /* IBM Corporation */ 22 ALAW = 0x0006, /* Microsoft Corporation */ 23 MULAW = 0x0007, /* Microsoft Corporation */ 24 DTS = 0x0008, /* Microsoft Corporation */ 25 OKI_ADPCM = 0x0010, /* OKI */ 26 DVI_ADPCM = 0x0011, /* Intel Corporation */ 27 IMA_ADPCM = DVI_ADPCM, /* Intel Corporation */ 28 MEDIASPACE_ADPCM = 0x0012, /* Videologic */ 29 SIERRA_ADPCM= 0x0013, /* Sierra Semiconductor Corp */ 30 G723_ADPCM = 0x0014, /* Antex Electronics Corporation */ 31 DIGISTD = 0x0015, /* DSP Solutions, Inc. */ 32 DIGIFIX = 0x0016, /* DSP Solutions, Inc. */ 33 DIALOGIC_OKI_ADPCM = 0x0017, /* Dialogic Corporation */ 34 MEDIAVISION_ADPCM = 0x0018, /* Media Vision, Inc. */ 35 CU_CODEC = 0x0019, /* Hewlett-Packard Company */ 36 YAMAHA_ADPCM= 0x0020, /* Yamaha Corporation of America */ 37 SONARC = 0x0021, /* Speech Compression */ 38 DSPGROUP_TRUESPEECH = 0x0022, /* DSP Group, Inc */ 39 ECHOSC1 = 0x0023, /* Echo Speech Corporation */ 40 AUDIOFILE_AF36 = 0x0024, /* Virtual Music, Inc. */ 41 APTX = 0x0025, /* Audio Processing Technology */ 42 AUDIOFILE_AF10 = 0x0026, /* Virtual Music, Inc. */ 43 PROSODY_1612= 0x0027, /* Aculab plc */ 44 LRC = 0x0028, /* Merging Technologies S.A. */ 45 DOLBY_AC2 = 0x0030, /* Dolby Laboratories */ 46 GSM610 = 0x0031, /* Microsoft Corporation */ 47 MSNAUDIO = 0x0032, /* Microsoft Corporation */ 48 ANTEX_ADPCME= 0x0033, /* Antex Electronics Corporation */ 49 CONTROL_RES_VQLPC = 0x0034, /* Control Resources Limited */ 50 DIGIREAL = 0x0035, /* DSP Solutions, Inc. */ 51 DIGIADPCM = 0x0036, /* DSP Solutions, Inc. */ 52 CONTROL_RES_CR10 = 0x0037, /* Control Resources Limited */ 53 NMS_VBXADPCM= 0x0038, /* Natural MicroSystems */ 54 CS_IMAADPCM = 0x0039, /* Crystal Semiconductor IMA ADPCM */ 55 ECHOSC3 = 0x003A, /* Echo Speech Corporation */ 56 ROCKWELL_ADPCM = 0x003B, /* Rockwell International */ 57 ROCKWELL_DIGITALK = 0x003C, /* Rockwell International */ 58 XEBEC = 0x003D, /* Xebec Multimedia Solutions Limited */ 59 G721_ADPCM = 0x0040, /* Antex Electronics Corporation */ 60 G728_CELP = 0x0041, /* Antex Electronics Corporation */ 61 MSG723 = 0x0042, /* Microsoft Corporation */ 62 MPEG = 0x0050, /* Microsoft Corporation */ 63 RT24 = 0x0052, /* InSoft, Inc. */ 64 PAC = 0x0053, /* InSoft, Inc. */ 65 MPEGLAYER3 = 0x0055, /* ISO/MPEG Layer3 Format Tag */ 66 LUCENT_G723 = 0x0059, /* Lucent Technologies */ 67 CIRRUS = 0x0060, /* Cirrus Logic */ 68 ESPCM = 0x0061, /* ESS Technology */ 69 VOXWARE = 0x0062, /* Voxware Inc */ 70 CANOPUS_ATRAC = 0x0063, /* Canopus, co., Ltd. */ 71 G726_ADPCM = 0x0064, /* APICOM */ 72 G722_ADPCM = 0x0065, /* APICOM */ 73 DSAT_DISPLAY= 0x0067, /* Microsoft Corporation */ 74 VOXWARE_BYTE_ALIGNED= 0x0069, /* Voxware Inc */ 75 VOXWARE_AC8 = 0x0070, /* Voxware Inc */ 76 VOXWARE_AC10= 0x0071, /* Voxware Inc */ 77 VOXWARE_AC16= 0x0072, /* Voxware Inc */ 78 VOXWARE_AC20= 0x0073, /* Voxware Inc */ 79 VOXWARE_RT24= 0x0074, /* Voxware Inc */ 80 VOXWARE_RT29= 0x0075, /* Voxware Inc */ 81 VOXWARE_RT29HW = 0x0076, /* Voxware Inc */ 82 VOXWARE_VR12= 0x0077, /* Voxware Inc */ 83 VOXWARE_VR18= 0x0078, /* Voxware Inc */ 84 VOXWARE_TQ40= 0x0079, /* Voxware Inc */ 85 SOFTSOUND = 0x0080, /* Softsound, Ltd. */ 86 VOXWARE_TQ60= 0x0081, /* Voxware Inc */ 87 MSRT24 = 0x0082, /* Microsoft Corporation */ 88 G729A = 0x0083, /* AT&T Labs, Inc. */ 89 MVI_MVI2 = 0x0084, /* Motion Pixels */ 90 DF_G726 = 0x0085, /* DataFusion Systems (Pty) (Ltd) */ 91 DF_GSM610 = 0x0086, /* DataFusion Systems (Pty) (Ltd) */ 92 ISIAUDIO = 0x0088, /* Iterated Systems, Inc. */ 93 ONLIVE = 0x0089, /* OnLive! Technologies, Inc. */ 94 SBC24 = 0x0091, /* Siemens Business Communications Sys */ 95 DOLBY_AC3_SPDIF = 0x0092, /* Sonic Foundry */ 96 MEDIASONIC_G723 = 0x0093, /* MediaSonic */ 97 PROSODY_8KBPS = 0x0094, /* Aculab plc */ 98 ZYXEL_ADPCM = 0x0097, /* ZyXEL Communications, Inc. */ 99 PHILIPS_LPCBB = 0x0098, /* Philips Speech Processing */ 100 PACKED = 0x0099, /* Studer Professional Audio AG */ 101 MALDEN_PHONYTALK = 0x00A0, /* Malden Electronics Ltd. */ 102 RHETOREX_ADPCM = 0x0100, /* Rhetorex Inc. */ 103 IRAT = 0x0101, /* BeCubed Software Inc. */ 104 VIVO_G723 = 0x0111, /* Vivo Software */ 105 VIVO_SIREN = 0x0112, /* Vivo Software */ 106 DIGITAL_G723= 0x0123, /* Digital Equipment Corporation */ 107 SANYO_LD_ADPCM = 0x0125, /* Sanyo Electric Co., Ltd. */ 108 SIPROLAB_ACEPLNET = 0x0130, /* Sipro Lab Telecom Inc. */ 109 SIPROLAB_ACELP4800 = 0x0131, /* Sipro Lab Telecom Inc. */ 110 SIPROLAB_ACELP8V3 = 0x0132, /* Sipro Lab Telecom Inc. */ 111 SIPROLAB_G729 = 0x0133, /* Sipro Lab Telecom Inc. */ 112 SIPROLAB_G729A = 0x0134, /* Sipro Lab Telecom Inc. */ 113 SIPROLAB_KELVIN = 0x0135, /* Sipro Lab Telecom Inc. */ 114 G726ADPCM = 0x0140, /* Dictaphone Corporation */ 115 QUALCOMM_PUREVOICE = 0x0150, /* Qualcomm, Inc. */ 116 QUALCOMM_HALFRATE = 0x0151, /* Qualcomm, Inc. */ 117 TUBGSM = 0x0155, /* Ring Zero Systems, Inc. */ 118 MSAUDIO1 = 0x0160, /* Microsoft Corporation */ 119 CREATIVE_ADPCM = 0x0200, /* Creative Labs, Inc */ 120 CREATIVE_FASTSPEECH8= 0x0202, /* Creative Labs, Inc */ 121 CREATIVE_FASTSPEECH10 = 0x0203, /* Creative Labs, Inc */ 122 UHER_ADPCM = 0x0210, /* UHER informatic GmbH */ 123 QUARTERDECK = 0x0220, /* Quarterdeck Corporation */ 124 ILINK_VC = 0x0230, /* I-link Worldwide */ 125 RAW_SPORT = 0x0240, /* Aureal Semiconductor */ 126 IPI_HSX = 0x0250, /* Interactive Products, Inc. */ 127 IPI_RPELP = 0x0251, /* Interactive Products, Inc. */ 128 CS2 = 0x0260, /* Consistent Software */ 129 SONY_SCX = 0x0270, /* Sony Corp. */ 130 FM_TOWNS_SND= 0x0300, /* Fujitsu Corp. */ 131 BTV_DIGITAL = 0x0400, /* Brooktree Corporation */ 132 QDESIGN_MUSIC = 0x0450, /* QDesign Corporation */ 133 VME_VMPCM = 0x0680, /* AT&T Labs, Inc. */ 134 TPC = 0x0681, /* AT&T Labs, Inc. */ 135 OLIGSM = 0x1000, /* Ing C. Olivetti & C., S.p.A. */ 136 OLIADPCM = 0x1001, /* Ing C. Olivetti & C., S.p.A. */ 137 OLICELP = 0x1002, /* Ing C. Olivetti & C., S.p.A. */ 138 OLISBC = 0x1003, /* Ing C. Olivetti & C., S.p.A. */ 139 OLIOPR = 0x1004, /* Ing C. Olivetti & C., S.p.A. */ 140 LH_CODEC = 0x1100, /* Lernout & Hauspie */ 141 WAVE_FORMAT_NORRIS = 0x1400, /* Norris Communications, Inc. */ 142 SOUNDSPACE_MUSICOMPRESS = 0x1500, /* AT&T Labs, Inc. */ 143 DVM = 0x2000, /* FAST Multimedia AG */ 144 } 145 /** 146 * Defines the the format of a waveform data. 147 */ 148 public struct WaveFormat { 149 public uint samplerate; ///Base playback frequency. Actual playback can ignore this for pitching, etc. 150 public uint bytesPerSecond; ///Bytes per second at base playback frequency. 151 public ushort format; ///The audio format, compatible with the *.wav format 152 public ushort channels; ///The number of audio channels 153 public ushort bytesPerSample; ///Bytes per sample 154 public ushort bitsPerSample; ///Bits per sample 155 } 156 /** 157 * Defines errorcodes for sample loading. 158 * Negative numbers indicate specific issues, positive numbers indicate issues with sample length, format, etc. 159 */ 160 public enum SampleLoadErrorCode : int { 161 none = 0, 162 SampleLoadingNotSupported = -1, 163 SampleSlotNotExist = -2, 164 SampleBankFull = -3, 165 FileFormatNotSupported = -4, 166 FileNotFound = -5, 167 //sample format issues 168 //should be OR-ed together 169 FormatNotSupported = 0x1, 170 BitdepthNotSupported = 0x2, 171 SampleRateNotSupported = 0x4, 172 ChNumNotSupported = 0x8, 173 SampleLenghtNotSupported = 0x10, //Should be only used if a specific sample length was requested 174 } 175 public enum IIRType : ubyte { 176 none, 177 LPF, 178 HPF, 179 BPF0, 180 BPF1, 181 Notch, 182 } 183 /** 184 * Defines a workpad for many simple audio codecs 185 */ 186 public struct DecoderWorkpad { 187 size_t pos; ///Position of the decoder 188 int outn1; ///Previous output sample 189 int pred; ///Predictor for ADPCM 190 } 191 /** 192 * Defines a workpad for sample stretching algorithms 193 */ 194 public struct WavemodWorkpad { 195 ulong lookupVal; ///Current nearest-lookup position 196 ///Substracts from the offset for the next wavechunk. 197 ///Returns the new lookupVal 198 ulong sub(size_t amount) @nogc @safe pure nothrow { 199 return lookupVal - (amount<<24); 200 } 201 } 202 /** 203 * Stores Biquad filter values for audio. 204 */ 205 struct BiquadFilterValues { 206 float a0; 207 float a1; 208 float a2; 209 float b0; 210 float b1; 211 float b2; 212 } 213 /** 214 * Defines the type of a module parameter. 215 */ 216 public enum MValueType : ubyte { 217 init, 218 String, 219 Int32, 220 Int64, 221 Float, ///Set in the form of a double 222 Boolean, ///Set in the form of a 32 bit integer 223 } 224 /** 225 * Defines the type and the name of a module's parameters. 226 */ 227 public struct MValue { 228 MValueType type; 229 ubyte idType; ///0 if ID is hash of the name, 1 if not. 230 int id; ///Ideally the MurMurHashV3/32 value of the name, but other numbers also can be used if needed, e.g. it's too complex to rely on hash values 231 string name; 232 this (MValueType type, uint id, string name) @nogc @safe pure nothrow { 233 this.type = type; 234 this.id = id; 235 this.name = name; 236 idType = 1; 237 } 238 this (MValueType type, string name) @nogc @safe pure nothrow { 239 import pixelperfectengine.system.etc : hashCalc; 240 this.type = type; 241 this.id = hashCalc(name); 242 this.name = name; 243 } 244 }