Giter VIP home page Giter VIP logo

Comments (2)

sezero avatar sezero commented on June 20, 2024

This is the solution suggested by Thomas Neumann (in C#):

/********************************************************************/
        /// <summary>
        /// Effect L: Set envelope position
        /// </summary>
/********************************************************************/
        private int DoXmEffectL(ushort tick, ModuleFlag flags, Mp_Control a, Module mod, short channel)
        {
            byte dat = uniTrk.UniGetByte();

            if ((tick == 0) && (a.Main.I != null))
            {
                Instrument i = a.Main.I;

                Mp_Voice aOut;
                if ((aOut = a.Slave) != null)
                {
                    if (aOut.VEnv.Env != null)
                        SetEnvelopePosition(ref aOut.VEnv, i.VolEnv, dat);

                    if (aOut.PEnv.Env != null)
                    {
                        // Because of a bug in FastTracker II, only the panning envelope
                        // position is set if the volume sustain flag is set. Other players
                        // may set the panning all the time
                        if (((mod.Flags & ModuleFlag.Ft2Quirks) == 0) || ((i.VolFlg & EnvelopeFlag.Sustain) != 0))
                            SetEnvelopePosition(ref aOut.PEnv, i.PanEnv, dat);
                    }
                }
            }

            return 0;
        }

And you need this helper method:

/********************************************************************/
        /// <summary>
        /// Set the envelope tick to the position given
        /// </summary>
/********************************************************************/
        private void SetEnvelopePosition(ref EnvPr t, EnvPt[] p, short pos)
        {
            if (t.Pts > 0)
            {
                bool found = false;

                for (ushort i = 0; i < t.Pts - 1; i++)
                {
                    if ((pos >= p[i].Pos) && (pos < p[i + 1].Pos))
                    {
                        t.A = i;
                        t.B = (ushort)(i + 1);
                        t.P = pos;
                        found = true;
                        break;
                    }
                }

                // If position is after the last envelope point, just set
                // it to the last one
                if (!found)
                {
                    t.A = (ushort)(t.Pts - 1);
                    t.B = t.Pts;
                    t.P = p[t.A].Pos;
                }
            }
        }

I found the attached module here:
https://wiki.openmpt.org/Development:_Test_Cases/XM

I do not know if you know anybody who can test it in the real FastTracker II.
It cannot be run on Windows 10, but I found a clone, where the attached module
sounds the same as with my patch. But it is a clone, so I don't know if it can
be used as a real test. I found the clone here:

https://16-bits.org/ft2.php

SetEnvPos.xm.zip

Comments? @AliceLR?

from mikmod.

AliceLR avatar AliceLR commented on June 20, 2024

Fixed in #56 (f1562b1).

from mikmod.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.