Introduction
A .sem file is a module for SynthEdit,
Jeff McClintock’s program for building synthesizers and effects by connecting modules.
The file is a Windows DLL (a
PE file, see also the
.EXE page) with a different extension. SynthEdit looks
in its modules folder, loads every module file it finds, asks what each one is and
which pins it has, and later runs the module’s code on blocks of audio samples. “SEM”
is explained in a forum answer as “SynthEdit Module”; the older extension for the same
kind of file, .sep, was “SynthEdit Plugin”.
A module file holds no wiring. It declares pins and has the code
behind them; which pin of which module is connected to which is saved in the SynthEdit
project (.se1 in SynthEdit 1.4 and older, .synthedit, an XML
text, from 1.5). See Where the wiring is.
A .sem dropped on any page opens in the explorer as a PE file, with its
headers, sections, imports, exports, resources and disassembled code, and a SynthEdit
tab in front of those: the kind of module, its exports, and, for the newer kind, its
XML description, its pins and a drawing of each module.
Two kinds of module
The SDK has existed in three versions, and the exports of the DLL say which one built
a file. The extension does not: SDK2’s own documentation names its output
se_gain.sem and, in another place, se_delay.sep.
| SDK1 and SDK2 | SDK3 (GMPI) | |
|---|---|---|
| Exports | getModuleProperties and makeModule, plain C names listed in the module’s .def file | MP_GetFactory (stdcall; a 32-bit Visual C++ build also exports it as _MP_GetFactory@4) |
| Where the module is described | In code: properties from getModuleProperties, one call for each pin to getPinProperties | In an XML text stored as a resource of the user-defined type GMPXML |
| Modules in a file | Several: one case for each in the switch of getModuleProperties and makeModule | Several: one <Plugin> element each in the XML, registered with the factory by its id and a sub type |
| Per block of samples | sub_process(buffer_offset, sampleFrames) | subProcess(bufferOffset, sampleFrames), with onSetPins() called between blocks when a pin value changes |
SDK1 and SDK2 share their exports and structures: the version number a module
reports is SDK_VERSION, 2240 in the last SDK2 header. The SDK’s history comment
starts at 1000 for the first numbered version, and 2000 (January 2004) added GUI
support.
Exports and loading
SynthEdit scans its modules folder when it starts (C:\Program Files\Common
Files\SynthEdit\modules for SDK3 modules), loads each file, and queries it. For
an SDK2 module it calls getModuleProperties with an index from 0 until it
gets nothing back, and makeModule with the same index to create an
object; for an SDK3 module it calls MP_GetFactory, which returns an
IMpFactory that makes plugins by their id. The module object is
created again when a project plays, and its open() is called once.
| Interface | GUID |
|---|---|
MP_IID_FACTORY | {9A7904B7-7F7F-4D61-B558-C1A6695BB638} |
MP_IID_FACTORY2 (plain constructor instantiation) | {91C3D2EE-C701-4F35-91A6-094DC7E05976} |
MP_IID_SHELLFACTORY | {72148962-F9C9-4DB1-9F71-EB80CD6469FC} |
The sub types that tell the factory which half of a module to make are
MP_SUB_TYPE_AUDIO 0, MP_SUB_TYPE_GUI 1,
MP_SUB_TYPE_GUI2 2, MP_SUB_TYPE_UNUSED 3 and
MP_SUB_TYPE_CONTROLLER 4. A module with a user interface is two plugins
with the same id: a DSP one and a GUI one.
SDK1 and SDK2: the description is code
An SDK2 module fills two structures, packed to 8 bytes. In 32-bit code the pointers
are 4 bytes and long is 4 bytes.
| SEModuleProperties | Type | Meaning |
|---|---|---|
name | char* | The name the user sees |
id | char* | The unique id |
about | char* | Text for the About box |
flags | long | Module flags (below) |
gui_flags | long | CF_CONTROL_VIEW 128, CF_STRUCTURE_VIEW 256 |
sdk_version | int | SDK_VERSION |
| SEPinProperties | Type | Meaning |
|---|---|---|
variable_address | void* | The variable or buffer pointer inside the module object that the pin writes or reads |
direction | int | 0 in, 1 out, 2 unused, 3 parameter |
datatype | int | See the data types below |
name | char* | The pin’s name |
default_value | char* | The default, as text |
datatype_extra | char* | A list of choices (Semitone=1,Octave=12), a range (range -12,12), a slider range (5,0,5,0) or, with the filename flag, a file extension |
flags | long | Pin flags (below) |
spare | long | Reserved |
The module object starts with a structure whose magic number is SepMagic,
0x5345504C (the letters “SEPL”); version 2 modules use 0x5345504D. It lives in the
object at run time, not in the file. The host talks to the object through a dispatcher
with opcodes seffOpen 0, seffClose 1,
seffSetSampleRate 2, seffSetBlockSize 3,
seffGetUniqueId 4, seffGetEffectName 5,
seffGetPinProperties 6, seffAddEvent 7,
seffResume 8, seffGetModuleProperties 9,
seffIsEventListEmpty 10, seffGetSdkVersion 11,
seffGuiNotify 12 and seffQueryDebugInfo 13.
Because the name, the id and the pins are written by code, they can be read from the file only by running that code. The strings are in the data of the DLL, but the table that ties them to pins is built by instructions.
SDK3: the description is XML
The SDK3 file holds the description as an XML text in a resource of the type
GMPXML, added by a line of the resource script such as
IDR_GMPXML1 GMPXML "Gain.xml". SynthEdit reads it from the DLL without
running any of its code. The root is <PluginList>, holding one
<Plugin> for each module of the file.
| Element | Attributes seen in the SDK’s examples |
|---|---|
<Plugin> | id (the unique id), name, category, vendor, version, helpUrl, graphicsApi (GmpiGui, HWND or none) |
<Parameters><Parameter> | id, name, datatype, default, private, ignorePatchChange, isPolyphonic, persistant, metadata |
<Audio><Pin> | The pins of the DSP half |
<GUI><Pin> | The pins of the graphics half |
Both kinds of <Pin> | id, name, direction (in or out), datatype (float, int, bool, string, enum, blob, midi), rate="audio", default, metadata, isFilename, autoDuplicate, autoRename, linearInput, private, isMinimised, isPolyphonic, ignorePatchChange, parameterId, hostConnect |
metadata carries what SDK2’s datatype_extra did: a range
such as 0,5, a list such as Host=1,MIDI File=0, the word
{AUTO}, or a file extension for a filename pin.
hostConnect ties a pin to a value the host supplies, for example
Time/BPM, Voice/Active, Polyphony or
VoiceAllocationMode. Characters such as < in an id are
written as entities.
The pins are described twice: in the XML, and in the C++ class, where each pin is tied to a member of the class. A file’s resources also include the usual version information, and any files that the module embeds for itself.
One more thing about SDK3 files: a module saved inside a VST that SynthEdit exported has its description removed. SynthEdit then shows such a module with a blank name and no plugins. The explorer reports that as a problem on the file.
Data types, directions and flags
The data type of a pin is the same enumeration in SDK2 and SDK3 (the SDK3 name is
MP_PinDatatype, which has fewer members).
| Value | SDK2 name | SDK3 name | XML |
|---|---|---|---|
| 0 | DT_ENUM | MP_ENUM | enum |
| 1 | DT_TEXT | MP_STRING | string |
| 2 | DT_MIDI2 (DT_MIDI) | MP_MIDI | midi |
| 3 | DT_DOUBLE | MP_FLOAT64 | |
| 4 | DT_BOOL | MP_BOOL | bool |
| 5 | DT_FSAMPLE | MP_AUDIO | float with rate="audio" |
| 6 | DT_FLOAT | MP_FLOAT32 | float |
| 7 | DT_VST_PARAM | ||
| 8 | DT_INT | MP_INT32 | int |
| 9 | DT_INT64 | MP_INT64 | |
| 10 | DT_BLOB | MP_BLOB | blob |
| 11 | DT_CLASS | ||
| 12 | DT_STRING_UTF8 | MP_STRING_UTF8 | |
| 13 | DT_BLOB2 | MP_BLOB2 |
The empty cells of the XML column mean only that the SDK’s examples do not use a
name for that type; they do not say it cannot be used. Directions are
DR_IN 0, DR_OUT 1, DR_UNUSED 2 and
DR_PARAMETER 3 in SDK2, MP_IN 0 and MP_OUT 1 in
SDK3. An SDK2 audio pin is a pointer to a buffer of floats in which 1.0 stands for
10 volts; an SDK2 pin of another type is a variable that the host writes.
Pin flags (SDK2, flags of SEPinProperties)
| Value | Name | Value | Name |
|---|---|---|---|
| 0x1 | IO_POLYPHONIC_ACTIVE | 0x40000 | IO_MINIMISED |
| 0x2 | IO_IGNORE_PATCH_CHANGE | 0x80000 | IO_CONTAINER_PLUG |
| 0x4 | IO_RENAME | 0x100000 | IO_OLD_STYLE_GUI_PLUG |
| 0x8 | IO_AUTODUPLICATE | 0x200000 | IO_HOST_CONTROL |
| 0x10 | IO_FILENAME | 0x400000 | IO_PAR_POLYPHONIC |
| 0x20 | IO_SETABLE_OUTPUT | 0x800000 | IO_PAR_POLYPHONIC_GATE |
| 0x40 | IO_CUSTOMISABLE (deprecated) | 0x1000000 | IO_PARAMETER_PERSISTANT |
| 0x80 | IO_ADDER | 0x2000000 | IO_AUTOCONFIGURE_PARAMETER |
| 0x100 | IO_HIDE_PIN (IO_PRIVATE) | 0x4000000 | IO_BINARY_DATA |
| 0x200 | IO_LINEAR_INPUT | 0x8000000 | IO_REDRAW_ON_CHANGE |
| 0x400 | IO_UI_COMMUNICATION | 0x10000 | IO_PATCH_STORE |
| 0x800 | IO_AUTO_ENUM | 0x20000 | IO_PAR_PRIVATE |
| 0x1000 | IO_HIDE_WHEN_LOCKED | 0x8000 | IO_UI_DUAL_FLAG |
| 0x2000 | IO_PARAMETER_SCREEN_ONLY | 0x4000 | IO_DONT_CHECK_ENUM |
Module flags (SDK2, flags of SEModuleProperties)
| Value | Name | Meaning |
|---|---|---|
| 0x2 | UGF_VOICE_MON_IGNORE | Does not take part in voice monitoring |
| 0x40 | UGF_POLYPHONIC_AGREGATOR | Sums the voices of a polyphonic signal into one |
| 0x80 | UGF_SUSPENDED | Set by the host (read only) |
| 0x100 | UGF_OPEN | Set by the host (read only) |
| 0x200 | UGF_NEVER_SUSPEND | The host never suspends the module |
| 0x800 | UGF_CLONE | Set by the host (read only) |
| 0x20000 | UGF_SEND_TIMEINFO_TO_HOST | The module sends time information to the host |
The wording in the right-hand column of the last two tables follows the names and the SDK’s comments; the flags are described in more detail in the SDK2 manual.
How a module is run
SynthEdit calls the module’s processing function once for each block of samples. SDK3
documentation says a block is typically around 96 to 100 samples and that its size
varies. The module is told which pins changed before the block, in SDK3 by
onSetPins(), and sets the function to use for the block with
SET_PROCESS. Audio is a 32-bit float, with ±1.0 standing for ±10 volts, and
the host interface has a call for a module to say that its audio output has started or
stopped (silence detection). Modules that follow a MIDI-to-CV module in a patch are
copied once for each voice by the host unless the connection goes through a pin that
has IO_LINEAR_INPUT set.
Where the wiring is
Nothing in a .sem or .sep says how modules are connected.
The connections, the values of the pins, the layout and the structure of containers
and sub-patches are in the project. SynthEdit 1.4 and earlier save it as
.se1; from 1.5 the project is a human-readable XML text,
.synthedit, though SynthEdit can still save the older form. A plugin
exported from SynthEdit as a VST is a DLL beside which the modules it uses are
unpacked as .sem or .sep files, in a folder named after the
plugin.
A container (a module that holds other modules, which the SDK refers to by the pin
flag IO_CONTAINER_PLUG) and a prefab are therefore projects, not module
files. No specification of either project format was found, so neither is described
here, and this page has no wiring diagram to show.
Also used for
The SDK3 helper builds the module for macOS as a bundle, a folder, whose extension is
also sem. The newer GMPI framework from the same author, which grew out of
SDK3, produces its own plugin files; it is not covered here.
Not described
Known, not yet covered
- Reference: the prototypes of
getModulePropertiesandmakeModule. The SDK’s own source file that defines them,SeModuleMain.cpp, is not in the published SDK. What is known is that each takes the module’s index;makeModulealso takes the host callback and a reserved pointer, as the constructor of an SDK2 module does. - Viewer: the name, id and pins of an SDK1 or SDK2 module. They are filled in by code; reading them needs the x86 code to be run.
- Viewer: modules of GMPI (
.gmpi) files.
Unknown
- Whether SynthEdit treats a
.sepand a.semfile identically today. The forum answer that explains the two extensions says it can use either; no document from the author does. - The complete list of attributes of the XML description. The SDK documents none; the explorer shows every attribute it finds and marks the ones that its examples do not use.
- How a pin without an
idis numbered. The SDK’s examples suggest the order of the file within its block, and the explorer shows it that way, marked. - The format in which a module embeds files of its own (SynthEdit’s “protected files”).
- The
.se1and.syntheditproject formats, and with them the wiring, containers and prefabs. - Whether a UPX-packed module is accepted by SynthEdit. The explorer detects the packing and does not unpack: see UPX.
Links
Software
- SynthEdit – the modular synthesizer and effect builder that loads these modules and exports VST plugins (Windows)
Developers
- SynthEdit SDK – the SDK2 and SDK3 headers with about eighty example modules (C++, BSD licence)
- GMPI – the Generalized Music Plugin Interface that succeeds SDK3 (C++, ISC licence)
Reference
- SDK version 3 documentation – the XML description, pins and the processing calls
- SDK version 2 documentation – the exports, structures and flags of the older modules, with an FAQ
- PE Format – Microsoft’s specification of the DLL that holds a module
- KVR forum: SEP and SEM – a user’s answer on the two extensions