1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
|
/*
* PluginStructs.h
* ---------------
* Purpose: Basic plugin structs for CSoundFile.
* Notes : (currently none)
* Authors: OpenMPT Devs
* The OpenMPT source code is released under the BSD license. Read LICENSE for more details.
*/
#pragma once
#include "openmpt/all/BuildSettings.hpp"
#include "../Snd_defs.h"
#ifndef NO_PLUGINS
#include "openmpt/base/Endian.hpp"
#endif // NO_PLUGINS
OPENMPT_NAMESPACE_BEGIN
////////////////////////////////////////////////////////////////////
// Mix Plugins
using PlugParamIndex = uint32;
using PlugParamValue = float;
struct SNDMIXPLUGINSTATE;
struct SNDMIXPLUGIN;
class IMixPlugin;
class CSoundFile;
#ifndef NO_PLUGINS
struct SNDMIXPLUGININFO
{
// dwInputRouting flags
enum RoutingFlags
{
irApplyToMaster = 0x01, // Apply to master mix
irBypass = 0x02, // Bypass effect
irWetMix = 0x04, // Wet Mix (dry added)
irExpandMix = 0x08, // [0%,100%] -> [-200%,200%]
irAutoSuspend = 0x10, // Plugin will automatically suspend on silence
};
int32le dwPluginId1; // Plugin type (kEffectMagic, kDmoMagic, kBuzzMagic)
int32le dwPluginId2; // Plugin unique ID
uint8le routingFlags; // See RoutingFlags
uint8le mixMode;
uint8le gain; // Divide by 10 to get real gain
uint8le reserved;
uint32le dwOutputRouting; // 0 = send to master 0x80 + x = send to plugin x
uint32le dwReserved[4]; // Reserved for routing info
mpt::modecharbuf<32, mpt::String::nullTerminated> szName; // User-chosen plugin display name - this is locale ANSI!
mpt::modecharbuf<64, mpt::String::nullTerminated> szLibraryName; // original DLL name - this is UTF-8!
// Should only be called from SNDMIXPLUGIN::SetBypass() and IMixPlugin::Bypass()
void SetBypass(bool bypass = true) { if(bypass) routingFlags |= irBypass; else routingFlags &= uint8(~irBypass); }
};
MPT_BINARY_STRUCT(SNDMIXPLUGININFO, 128) // this is directly written to files, so the size must be correct!
struct SNDMIXPLUGIN
{
IMixPlugin *pMixPlugin = nullptr;
std::vector<std::byte> pluginData;
SNDMIXPLUGININFO Info = {};
float fDryRatio = 0;
int32 defaultProgram = 0;
int32 editorX = 0, editorY = 0;
#if defined(MPT_ENABLE_CHARSET_LOCALE)
const char * GetNameLocale() const
{
return Info.szName.buf;
}
mpt::ustring GetName() const
{
return mpt::ToUnicode(mpt::Charset::Locale, Info.szName);
}
#endif // MPT_ENABLE_CHARSET_LOCALE
mpt::ustring GetLibraryName() const
{
return mpt::ToUnicode(mpt::Charset::UTF8, Info.szLibraryName);
}
// Check if a plugin is loaded into this slot (also returns true if the plugin in this slot has not been found)
bool IsValidPlugin() const { return (Info.dwPluginId1 | Info.dwPluginId2) != 0; }
// Input routing getters
uint8 GetGain() const
{ return Info.gain; }
uint8 GetMixMode() const
{ return Info.mixMode; }
bool IsMasterEffect() const
{ return (Info.routingFlags & SNDMIXPLUGININFO::irApplyToMaster) != 0; }
bool IsWetMix() const
{ return (Info.routingFlags & SNDMIXPLUGININFO::irWetMix) != 0; }
bool IsExpandedMix() const
{ return (Info.routingFlags & SNDMIXPLUGININFO::irExpandMix) != 0; }
bool IsBypassed() const
{ return (Info.routingFlags & SNDMIXPLUGININFO::irBypass) != 0; }
bool IsAutoSuspendable() const
{ return (Info.routingFlags & SNDMIXPLUGININFO::irAutoSuspend) != 0; }
// Input routing setters
void SetGain(uint8 gain);
void SetMixMode(uint8 mixMode)
{ Info.mixMode = mixMode; }
void SetMasterEffect(bool master = true)
{ if(master) Info.routingFlags |= SNDMIXPLUGININFO::irApplyToMaster; else Info.routingFlags &= uint8(~SNDMIXPLUGININFO::irApplyToMaster); }
void SetWetMix(bool wetMix = true)
{ if(wetMix) Info.routingFlags |= SNDMIXPLUGININFO::irWetMix; else Info.routingFlags &= uint8(~SNDMIXPLUGININFO::irWetMix); }
void SetExpandedMix(bool expanded = true)
{ if(expanded) Info.routingFlags |= SNDMIXPLUGININFO::irExpandMix; else Info.routingFlags &= uint8(~SNDMIXPLUGININFO::irExpandMix); }
void SetBypass(bool bypass = true);
void SetAutoSuspend(bool suspend = true)
{ if(suspend) Info.routingFlags |= SNDMIXPLUGININFO::irAutoSuspend; else Info.routingFlags &= uint8(~SNDMIXPLUGININFO::irAutoSuspend); }
// Output routing getters
bool IsOutputToMaster() const
{ return Info.dwOutputRouting == 0; }
PLUGINDEX GetOutputPlugin() const
{ return Info.dwOutputRouting >= 0x80 ? static_cast<PLUGINDEX>(Info.dwOutputRouting - 0x80) : PLUGINDEX_INVALID; }
// Output routing setters
void SetOutputToMaster()
{ Info.dwOutputRouting = 0; }
void SetOutputPlugin(PLUGINDEX plugin)
{ if(plugin < MAX_MIXPLUGINS) Info.dwOutputRouting = plugin + 0x80; else Info.dwOutputRouting = 0; }
void Destroy();
};
bool CreateMixPluginProc(SNDMIXPLUGIN &mixPlugin, CSoundFile &sndFile);
#endif // NO_PLUGINS
OPENMPT_NAMESPACE_END
|