VOGONS


Soundfont unknown formulas?

Topic actions

Reply 20 of 25, by superfury

User metadata
Rank l33t++
Rank
l33t++

Restored the tempo to be applied globally again.
Also improved timing by making the tempo changes be handled on the exact cycle the tempo change is requested, recalculating future cycles, if needed, when multiple cycles are timed at the same time. So timing should be improved, instead of discarded (earlier) or applied incorrectly with multiple cycles being parsed in one go during a tempo change.

Now tempo sounds okay again.

Author of the UniPCemu emulator.
UniPCemu Git repository
UniPCemu for Android, Windows, PSP, Vita and Switch on itch.io

Reply 21 of 25, by superfury

User metadata
Rank l33t++
Rank
l33t++

Managed to get the volume control working mostly now.
Adjusted the volume handling a lot, as well as modified the concave/convex curves ((-)40 becoming (-)20) and adjusted the modulator curves to behave better as well (no longer producing negative (!) values during bipolar mapping modes).

It's using the following functions now:

float MIDIconcave(float val, float maxvalue)
{
float result;
if (val <= 0.0f) //Invalid?
{
return 0.0f; //Nothing!
}
if (val >= maxvalue) //Invalid?
{
return 1.0f; //Full!
}
result = 1.0f + (20.0f / 96.0f) * log10f((maxvalue - val) / maxvalue); //Concave curve!
result = LIMITRANGE(result,0.0f,1.0f); //Limit the range!
result = 1.0f-result; //Invert!
return result; //Give the result!
}

//val needs to be a normalized input! Performs a convex from 0 to 1!
float MIDIconvex(float val, float maxvalue)
{
float result;
if (val <= 0.0f) //Invalid?
{
return 0.0f; //Nothing!
}
result = 1.0f + ((20.0 / 96.0) * log10f(val / maxvalue)); //Convert to the 0.0-0.9 range!
result = LIMITRANGE(result, 0.0f, 1.0f); //Limit the range!
return result; //Give the result!
}

Basically the same code, just flipped results and val inputs into the formula.

The type and polarity of controllers also has been changed to:

switch (type)
{
default: //Not supported?
case 0: //Linear?
if (polarity) //Bipolar?
{
i = (i * 2.0) - 1.0f; //Convert to a range of -1 to 1 for the proper input value!
}
//Unipolar is left alone(already done)!
break;
case 1: //Concave?
if (polarity) //Bipolar?
{
if (i>=0.5f) //Past half? Positive half!
{
i = 0.5f+(MIDIconcave((i-0.5)*2.0f,1.0f)*0.5f); //Positive half!
}
else //First half? Negative half?
{
i = 0.5f-(MIDIconcave((0.5-i)*2.0f,1.0f)*0.5f); //Negative half!
}
}
else //Unipolar?
{
i = MIDIconcave(i,1.0f); //Concave normally!
}
break;
case 2: //Convex?
if (polarity) //Bipolar?
{
if (i>=0.5f) //Past half? Positive half!
{
i = 0.5f+(MIDIconvex((i-0.5)*2.0f,1.0f)*0.5f); //Positive half!
}
else //First half? Negative half?
{
i = 0.5f-(MIDIconvex((0.5-i)*2.0f,1.0f)*0.5f); //Negative half!
}
}
else //Unipolar?
{
i = MIDIconvex(i,1.0f); //Concave normally!
}
break;
case 3: //Switch?
if (i >= 0.5f) //Past half?
{
i = 1.0f; //Full!
}
else //Less than half?
{
i = 0.0f; //Empty!
}
if (polarity) //Bipolar?
{
i = (i * 2.0) - 1.0f; //Convert to a range of -1 to 1 for the proper input value!
}
//Unipolar is left alone(already done)!
break;
}

Direction (reversal of the i variable using '1.0f-i') is applied before that, modifying the i variable (the normalized input scaled value, with linked values added before normalizing using the range. Not sure if this is supposed to happen though?).

Author of the UniPCemu emulator.
UniPCemu Git repository
UniPCemu for Android, Windows, PSP, Vita and Switch on itch.io

Reply 22 of 25, by superfury

User metadata
Rank l33t++
Rank
l33t++

I was thinking about MIDI volume a bit.

How does Windows 9x/NT control a MPU-401's MIDI volume for example? Can it even control it (the Master Volume SysEX for example)?

Author of the UniPCemu emulator.
UniPCemu Git repository
UniPCemu for Android, Windows, PSP, Vita and Switch on itch.io

Reply 23 of 25, by superfury

User metadata
Rank l33t++
Rank
l33t++

Improved the low-pass filters a bit.
They now use a biquad low-pass filters and apply the Q setting instead of the old simple RC IIR filter (though it's still used for reverb).

Author of the UniPCemu emulator.
UniPCemu Git repository
UniPCemu for Android, Windows, PSP, Vita and Switch on itch.io

Reply 24 of 25, by superfury

User metadata
Rank l33t++
Rank
l33t++

Oddly enough, activating the biquad low-pass filters makes some soundfonts mess up, causing any filtered audio channels rendering short bursts of random noise for any note played back (no matter the instrument)?
But it runs fine on most soundfonts?

MIDI rendering: https://bitbucket.org/superfury/unipcemu/raw/ … di/mididevice.c
Soundfont support functions: https://bitbucket.org/superfury/unipcemu/raw/ … u/support/sf2.c
Filters (the setting for filter type 2 going wrong): https://bitbucket.org/superfury/commonemufram … pport/filters.c
type 2(ishighpass parameter value) causing the odd rendering somehow. Using type 0(basic RC filter without Q support) or not filtering at all renders fine, although missing the low-pass filter effect.

Author of the UniPCemu emulator.
UniPCemu Git repository
UniPCemu for Android, Windows, PSP, Vita and Switch on itch.io

Reply 25 of 25, by superfury

User metadata
Rank l33t++
Rank
l33t++

Anyone knows why my biquad filter seems to be misbehaving? Some soundfonts produce some kind of noise output only and other soundfonts seem to render few instruments correctly (softly) with all others becoming single-tone beeps (sounds like a 1150Hz square wave)? Others, like the AWE32 soundfont seem to render correctly?

Author of the UniPCemu emulator.
UniPCemu Git repository
UniPCemu for Android, Windows, PSP, Vita and Switch on itch.io