ref: 1adf351ed1e05372fb886d839dda126dc85727a0
parent: 8c0c2c00f49fe7b2405395cecb4f853e891311ac
parent: 472abcff8be97ff23f8196412041624fc3e34ce4
author: Ellie <[email protected]>
date: Sun Nov 14 14:13:51 EST 2021
Merge branch 'master' into tsf-malloc-check
--- a/tml.h
+++ b/tml.h
@@ -88,8 +88,22 @@
// - pitch_bend for TML_PITCH_BEND messages
union
{
+ #ifdef _MSC_VER
+ #pragma warning(push)
+ #pragma warning(disable:4201) //nonstandard extension used: nameless struct/union
+ #elif defined(__GNUC__)
+ #pragma GCC diagnostic push
+ #pragma GCC diagnostic ignored "-Wpedantic" //ISO C++ prohibits anonymous structs
+ #endif
+
struct { union { char key, control, program, channel_pressure; }; union { char velocity, key_pressure, control_value; }; };
struct { unsigned short pitch_bend; };
+
+ #ifdef _MSC_VER
+ #pragma warning( pop )
+ #elif defined(__GNUC__)
+ #pragma GCC diagnostic pop
+ #endif
};
// The pointer to the next message in time following this event
--- a/tsf.h
+++ b/tsf.h
@@ -1316,16 +1316,9 @@
goto skipfontinit;
}
res->fontSamples = fontSamples;
- res->outSampleRate = 44100.0f;
- res->refCount = (int*)TSF_MALLOC(sizeof(int));
- if (!res->refCount)
- {
- TSF_FREE(res);
- res = TSF_NULL;
- goto skipfontinit;
- }
- *res->refCount = 1;
fontSamples = TSF_NULL; //don't free below
+ res->outSampleRate = 44100.0f;
+
if (!tsf_load_presets(res, &hydra, fontSampleCount))
{
TSF_FREE(res);
@@ -1349,8 +1342,10 @@
TSFDEF tsf* tsf_copy(tsf* f)
{
- struct tsf* res;
+ tsf* res;
if (!f) return TSF_NULL;
+ if (!f->refCount)
+ *(f->refCount = (int*)TSF_MALLOC(sizeof(int))) = 1;
res = (tsf*)TSF_MALLOC(sizeof(tsf));
if (!res) return TSF_NULL;
TSF_MEMCPY(res, f, sizeof(tsf));
@@ -1365,7 +1360,7 @@
{
struct tsf_preset *preset, *presetEnd;
if (!f) return;
- if (--(*f->refCount) == 0)
+ if (!f->refCount || !--(*f->refCount))
{
for (preset = f->presets, presetEnd = preset + f->presetNum; preset != presetEnd; preset++)
TSF_FREE(preset->regions);
@@ -1373,8 +1368,8 @@
TSF_FREE(f->fontSamples);
TSF_FREE(f->refCount);
}
+ TSF_FREE(f->channels);
TSF_FREE(f->voices);
- if (f->channels) TSF_FREE(f->channels);
TSF_FREE(f);
}
@@ -1865,9 +1860,12 @@
c->midiVolume = c->midiExpression = 16383;
c->midiPan = 8192;
c->bank = 0;
+ c->midiRPN = 0xFFFF;
+ c->midiData = 0;
tsf_channel_set_volume(f, channel, 1.0f);
tsf_channel_set_pan(f, channel, 0.5f);
tsf_channel_set_pitchrange(f, channel, 2.0f);
+ tsf_channel_set_tuning(f, channel, 0);
return 1;
}
return 1;