atsushieno / augene-ng

MML + MIDI + Tracktion Engine XML manipulation tool for real production
GNU General Public License v3.0
9 stars 2 forks source link

support automation tracks #1

Closed atsushieno closed 3 years ago

atsushieno commented 3 years ago

(inherited from https://github.com/atsushieno/augene/issues/9)

This time I go forward and drafting specification on how we achieve support for automation tracks.

In *.tracktionedit files, an automation track is represented as an <AUTOMATIONCURVE> element in the target <PLUGIN> element within the <TRACK> element, and the <TRACK> element at the same time contains a corresponding <AUTOMATIONTRACK> element that specifies currentAutoParamPluginID attribute that indicates <PLUGIN>'s id and currentAutoParamTag attribute that indicates the <AUTOMATIONTRACK>'s paramID (which is also the actual parameter ID of the plugin).

The actual AUTOMATIONCURVE looks like:

      <AUTOMATIONCURVE paramID="0">
        <POINT t="1.25" v="0.304347813129425" c="0.0"/>
        <POINT t="1.5" v="0.717391312122345" c="0.0"/>
        <POINT t="5.5" v="0.239130437374115" c="0.0"/>
        <POINT t="6.25" v="0.739130437374115" c="0.0"/>
        <POINT t="8.75" v="0.260869562625885" c="0.0"/>
      </AUTOMATIONCURVE>

... and AUTONATIONTRACK looks like:

    <AUTOMATIONTRACK id="1004" colour="ffff0000" currentAutoParamPluginID="1136" currentAutoParamTag="0">
      <MACROPARAMETERS id="1010"/>
      <MODIFIERS/>
    </AUTOMATIONTRACK>

Since we human beings don't recognize plugin parameter IDs, we'll need some comprehensive mapping from each parameter name to the parameter ID. It is not available on AudioPluginHost, so we will have to create some mapping generator tool that can then be consumed by AugeneProject and AugeneModel in augene-project.

The most probable candidate MIDI messages that are mapped to automation parameters are NRPNs. But since any MIDI messages can be also consumed by the target MIDI plugin, occupying NRPNs is not a very safe idea. It should be at least an optional feature, and desirably there should be other supported mappings e.g. SysEx messages with certain manufacturer IDs.

atsushieno commented 3 years ago

Another issue with the "use NRPN" idea is that unless we switch to MIDI2 model the actual parameter values are bound to the range within 0..127, which does not match audio plugin parameters capability (usually 32-bit float, can be even 64-bit). Maybe it is inevitable unless we use our very own sysex with enough data size.

It is impossible to map double to MIDI2 (32bit data with assignable controllers or NRPNs) anyways, so we can safely(?) dump the idea of supporting double.

atsushieno commented 3 years ago

For plugin parameter definitions like this (generated from augene-player "Export Plugin Metadata" feature):

  {"type": "VST3", "name": "OPNplug", "unique-id": "-1472549978",
   "file": "/home/atsushi/.vst3/OPNplug.vst3", "parameters": [
    {"index": "0", "name": "Master volume"},
    {"index": "1", "name": "Emulator"},
    {"index": "2", "name": "Chip count"},
    {"index": "3", "name": "Chip type"},
   ... (can be up to 16383 in theory)

define / generate / use MML like:

// define
#macro AUDIO_PLUGIN_PARAMETER parameterID: number, val:number { NRPN $parameterID % #80, $parameterID / #80 DTE $val % #80, $val / #80 } 
// generate
#macro OPNPLUG { __MIDI #F0 7D len xxxxxxxxxx F7 } // specify unique-id in UTF-8 string in sysex
#macro OPNPLUG_CHIPTYPE val { AUDIO_PLUGIN_PARAMETER 3, $val }
// use
1     OPNPLUG_CHIPTYPE 1

Then Midi2TracktionConverter picks up those MIDI events and convert to <AUTOMATIONTRACK>s.

Along with this way, we don't really have to make changes to AugeneProject model. Everything is done only in Midi2TracktionEditConverter, and we can write a plugin-to-MML generator later, or those MMLs can be done manually. The generated MMLs work like nrpn-gs-xg.mml in our default macros.

atsushieno commented 3 years ago

I made some changes to mugene-ng so that __MIDI primitive operators can take string arguments too, so the plugin designation macro can be:

#macro OPNPLUG { __MIDI #F0, #7D, "augene-ng", 11, "-1472549978", #F7 } // specify unique-id in UTF-8 string in sysex

It also adds implicit identifier augene-ng after 7Dh so that we can mostly avoid any other system exclusive messages that are being sent as 7Dh (research / dev purpose manufacturer ID).

atsushieno commented 3 years ago

Revamped NRPN based idea with SYSEX-based idea. After "augene-ng", add 00h, parameter-index LSB, MSB, parameter-value LSB, MSB, then F7h. It's not difficult.

atsushieno commented 3 years ago

current compilation result https://gist.github.com/atsushieno/443aca35527d23e2e5717cefe029b1f2

It still needs to adjust/unify track plugins, but pretty good progress.

atsushieno commented 3 years ago

As of 484db39, it should be done.