aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWohlstand <admin@wohlnet.ru>2017-10-21 14:37:45 +0300
committerWohlstand <admin@wohlnet.ru>2017-10-21 14:37:45 +0300
commit490bac7421b5345e5b9035f1430520c751935534 (patch)
tree727b1e6fb54439de92a3339cdb02a387cb80a47b /src
parent352660262dfd05cc75b5f2099507c9f29953a270 (diff)
downloadlibADLMIDI-490bac7421b5345e5b9035f1430520c751935534.tar.gz
libADLMIDI-490bac7421b5345e5b9035f1430520c751935534.tar.bz2
libADLMIDI-490bac7421b5345e5b9035f1430520c751935534.zip
Fixed MSVC2015 build
Diffstat (limited to 'src')
-rw-r--r--src/adlmidi.cpp28
-rw-r--r--src/adlmidi_load.cpp20
-rw-r--r--src/adlmidi_midiplay.cpp24
-rw-r--r--src/adlmidi_mus2mid.c8
-rw-r--r--src/adlmidi_private.hpp5
-rw-r--r--src/adlmidi_xmi2mid.c8
6 files changed, 47 insertions, 46 deletions
diff --git a/src/adlmidi.cpp b/src/adlmidi.cpp
index d16fab5..7f8564b 100644
--- a/src/adlmidi.cpp
+++ b/src/adlmidi.cpp
@@ -56,11 +56,11 @@ ADLMIDI_EXPORT struct ADL_MIDIPlayer *adl_init(long sample_rate)
player->opl.NumCards = midi_device->NumCards;
player->opl.AdlBank = midi_device->AdlBank;
player->opl.NumFourOps = midi_device->NumFourOps;
- player->opl.LogarithmicVolumes = (bool)midi_device->LogarithmicVolumes;
- player->opl.HighTremoloMode = (bool)midi_device->HighTremoloMode;
- player->opl.HighVibratoMode = (bool)midi_device->HighVibratoMode;
- player->opl.AdlPercussionMode = (bool)midi_device->AdlPercussionMode;
- player->opl.ScaleModulators = (bool)midi_device->ScaleModulators;
+ player->opl.LogarithmicVolumes = (midi_device->LogarithmicVolumes != 0);
+ player->opl.HighTremoloMode = (midi_device->HighTremoloMode != 0);
+ player->opl.HighVibratoMode = (midi_device->HighVibratoMode != 0);
+ player->opl.AdlPercussionMode = (midi_device->AdlPercussionMode != 0);
+ player->opl.ScaleModulators = (midi_device->ScaleModulators != 0);
player->ChooseDevice("none");
adlRefreshNumCards(midi_device);
return midi_device;
@@ -147,7 +147,7 @@ ADLMIDI_EXPORT void adl_setPercMode(ADL_MIDIPlayer *device, int percmod)
if(!device) return;
device->AdlPercussionMode = static_cast<unsigned int>(percmod);
- reinterpret_cast<MIDIplay *>(device->adl_midiPlayer)->opl.AdlPercussionMode = (bool)device->AdlPercussionMode;
+ reinterpret_cast<MIDIplay *>(device->adl_midiPlayer)->opl.AdlPercussionMode = (device->AdlPercussionMode != 0);
}
ADLMIDI_EXPORT void adl_setHVibrato(ADL_MIDIPlayer *device, int hvibro)
@@ -155,7 +155,7 @@ ADLMIDI_EXPORT void adl_setHVibrato(ADL_MIDIPlayer *device, int hvibro)
if(!device) return;
device->HighVibratoMode = static_cast<unsigned int>(hvibro);
- reinterpret_cast<MIDIplay *>(device->adl_midiPlayer)->opl.HighVibratoMode = (bool)device->HighVibratoMode;
+ reinterpret_cast<MIDIplay *>(device->adl_midiPlayer)->opl.HighVibratoMode = (device->HighVibratoMode != 0);
}
ADLMIDI_EXPORT void adl_setHTremolo(ADL_MIDIPlayer *device, int htremo)
@@ -163,7 +163,7 @@ ADLMIDI_EXPORT void adl_setHTremolo(ADL_MIDIPlayer *device, int htremo)
if(!device) return;
device->HighTremoloMode = static_cast<unsigned int>(htremo);
- reinterpret_cast<MIDIplay *>(device->adl_midiPlayer)->opl.HighTremoloMode = (bool)device->HighTremoloMode;
+ reinterpret_cast<MIDIplay *>(device->adl_midiPlayer)->opl.HighTremoloMode = (device->HighTremoloMode != 0);
}
ADLMIDI_EXPORT void adl_setScaleModulators(ADL_MIDIPlayer *device, int smod)
@@ -171,7 +171,7 @@ ADLMIDI_EXPORT void adl_setScaleModulators(ADL_MIDIPlayer *device, int smod)
if(!device) return;
device->ScaleModulators = static_cast<unsigned int>(smod);
- reinterpret_cast<MIDIplay *>(device->adl_midiPlayer)->opl.ScaleModulators = (bool)device->ScaleModulators;
+ reinterpret_cast<MIDIplay *>(device->adl_midiPlayer)->opl.ScaleModulators = (device->ScaleModulators != 0);
}
ADLMIDI_EXPORT void adl_setLoopEnabled(ADL_MIDIPlayer *device, int loopEn)
@@ -185,7 +185,7 @@ ADLMIDI_EXPORT void adl_setLogarithmicVolumes(struct ADL_MIDIPlayer *device, int
if(!device) return;
device->LogarithmicVolumes = static_cast<unsigned int>(logvol);
- reinterpret_cast<MIDIplay *>(device->adl_midiPlayer)->opl.LogarithmicVolumes = (bool)device->LogarithmicVolumes;
+ reinterpret_cast<MIDIplay *>(device->adl_midiPlayer)->opl.LogarithmicVolumes = (device->LogarithmicVolumes != 0);
}
ADLMIDI_EXPORT void adl_setVolumeRangeModel(struct ADL_MIDIPlayer *device, int volumeModel)
@@ -386,8 +386,8 @@ inline static void SendStereoAudio(ADL_MIDIPlayer *device,
size_t appendSize = inSamples - maxSamples;
memcpy(device->backup_samples + device->backup_samples_size,
maxSamples + _in, appendSize * sizeof(short));
- device->backup_samples_size += appendSize;
- device->stored_samples += appendSize;
+ device->backup_samples_size += (ssize_t)appendSize;
+ device->stored_samples += (ssize_t)appendSize;
}
}
#endif
@@ -421,7 +421,7 @@ ADLMIDI_EXPORT int adl_play(ADL_MIDIPlayer *device, int sampleCount, short *out)
ate++;
}
- left -= ate;
+ left -= (int)ate;
gotten_len += ate;
if(ate < device->backup_samples_size)
@@ -500,7 +500,7 @@ ADLMIDI_EXPORT int adl_play(ADL_MIDIPlayer *device, int sampleCount, short *out)
SendStereoAudio(device, sampleCount, in_generatedStereo, out_buf.data(), gotten_len, out);
}
- left -= in_generatedPhys;
+ left -= (int)in_generatedPhys;
gotten_len += (in_generatedPhys) - device->stored_samples;
}
diff --git a/src/adlmidi_load.cpp b/src/adlmidi_load.cpp
index c5884a5..1c0e7ef 100644
--- a/src/adlmidi_load.cpp
+++ b/src/adlmidi_load.cpp
@@ -391,11 +391,11 @@ bool MIDIplay::LoadMIDI(MIDIplay::fileReader &fr)
config->stored_samples = 0;
config->backup_samples_size = 0;
- opl.AdlPercussionMode = config->AdlPercussionMode;
- opl.HighTremoloMode = config->HighTremoloMode;
- opl.HighVibratoMode = config->HighVibratoMode;
- opl.ScaleModulators = config->ScaleModulators;
- opl.LogarithmicVolumes = config->LogarithmicVolumes;
+ opl.AdlPercussionMode = (config->AdlPercussionMode != 0);
+ opl.HighTremoloMode = (config->HighTremoloMode != 0);
+ opl.HighVibratoMode = (config->HighVibratoMode != 0);
+ opl.ScaleModulators = (config->ScaleModulators != 0);
+ opl.LogarithmicVolumes = (config->LogarithmicVolumes != 0);
opl.ChangeVolumeRangesModel(static_cast<ADLMIDI_VolumeModels>(config->VolumeModel));
if(config->VolumeModel == ADLMIDI_VolumeModel_AUTO)
@@ -596,7 +596,7 @@ riffskip:
fr.seeku(mus_start, SEEK_SET);
TrackCount = 1;
- DeltaTicks = ticks;
+ DeltaTicks = (size_t)ticks;
opl.AdlBank = ~0u; // Ignore AdlBank number, use dynamic banks instead
//std::printf("CMF deltas %u ticks %u, basictempo = %u\n", deltas, ticks, basictempo);
opl.LogarithmicVolumes = true;
@@ -648,8 +648,8 @@ InvFmt:
}
/*size_t Fmt =*/ ReadBEint(HeaderBuf + 8, 2);
- TrackCount = ReadBEint(HeaderBuf + 10, 2);
- DeltaTicks = ReadBEint(HeaderBuf + 12, 2);
+ TrackCount = (size_t)ReadBEint(HeaderBuf + 10, 2);
+ DeltaTicks = (size_t)ReadBEint(HeaderBuf + 12, 2);
}
}
@@ -661,7 +661,7 @@ InvFmt:
//Tempo = 1000000l * InvDeltaTicks;
Tempo = fraction<uint64_t>(1, static_cast<uint64_t>(DeltaTicks));
static const unsigned char EndTag[4] = {0xFF, 0x2F, 0x00, 0x00};
- int totalGotten = 0;
+ size_t totalGotten = 0;
for(size_t tk = 0; tk < TrackCount; ++tk)
{
@@ -738,7 +738,7 @@ InvFmt:
if(std::memcmp(HeaderBuf, "MTrk", 4) != 0)
goto InvFmt;
- TrackLength = ReadBEint(HeaderBuf + 4, 4);
+ TrackLength = (size_t)ReadBEint(HeaderBuf + 4, 4);
}
// Read track data
diff --git a/src/adlmidi_midiplay.cpp b/src/adlmidi_midiplay.cpp
index d473806..e10436b 100644
--- a/src/adlmidi_midiplay.cpp
+++ b/src/adlmidi_midiplay.cpp
@@ -115,7 +115,7 @@ void MIDIplay::AdlChannel::AddAge(int64_t ms)
{
if(users.empty())
koff_time_until_neglible =
- std::max(koff_time_until_neglible - ms, static_cast<int64_t>(-0x1FFFFFFFl));
+ std::max(int64_t(koff_time_until_neglible - ms), static_cast<int64_t>(-0x1FFFFFFFl));
else
{
koff_time_until_neglible = 0;
@@ -212,7 +212,7 @@ void MIDIplay::realTime_ResetState()
chan.bendsense = 2 / 8192.0;
chan.vibpos = 0.0;
chan.vibdepth = 0.5 / 127.0;
- chan.vibdelay = 0.0;
+ chan.vibdelay = 0;
chan.lastlrpn = 0;
chan.lastmrpn = 0;
chan.nrpn = false;
@@ -578,7 +578,7 @@ void MIDIplay::realTime_Controller(uint8_t channel, uint8_t type, uint8_t value)
break;
case 103:
- cmf_percussion_mode = value;
+ cmf_percussion_mode = (value != 0);
break; // CMF (ctrl 0x67) rhythm mode
default:
@@ -622,8 +622,8 @@ void MIDIplay::realTime_BankChangeMSB(uint8_t channel, uint8_t msb)
void MIDIplay::realTime_BankChange(uint8_t channel, uint16_t bank)
{
channel = channel % 16;
- Ch[channel].bank_lsb = uint8_t(bank & 0xFFFF);
- Ch[channel].bank_msb = uint8_t((bank >> 16) & 0xFFFF);
+ Ch[channel].bank_lsb = uint8_t(bank & 0xFF);
+ Ch[channel].bank_msb = uint8_t((bank >> 8) & 0xFF);
}
@@ -925,7 +925,7 @@ void MIDIplay::HandleEvent(size_t tk)
{
uint64_t length = ReadVarLen(tk);
//std::string data( length?(const char*) &TrackData[tk][CurrentPosition.track[tk].ptr]:0, length );
- CurrentPosition.track[tk].ptr += length;
+ CurrentPosition.track[tk].ptr += (size_t)length;
//UI.PrintLn("SysEx %02X: %u bytes", byte, length/*, data.c_str()*/);
return;
}
@@ -935,8 +935,8 @@ void MIDIplay::HandleEvent(size_t tk)
// Special event FF
uint8_t evtype = TrackData[tk][CurrentPosition.track[tk].ptr++];
uint64_t length = ReadVarLen(tk);
- std::string data(length ? (const char *) &TrackData[tk][CurrentPosition.track[tk].ptr] : 0, length);
- CurrentPosition.track[tk].ptr += length;
+ std::string data(length ? (const char *) &TrackData[tk][CurrentPosition.track[tk].ptr] : 0, (size_t)length);
+ CurrentPosition.track[tk].ptr += (size_t)length;
if(evtype == 0x2F)
{
@@ -1022,7 +1022,7 @@ void MIDIplay::HandleEvent(size_t tk)
CurrentPosition.track[tk].ptr-1, (unsigned)tk, byte,
TrackData[tk][CurrentPosition.track[tk].ptr]);*/
uint8_t MidCh = byte & 0x0F, EvType = byte >> 4;
- MidCh += current_device[tk];
+ MidCh += (uint8_t)current_device[tk];
CurrentPosition.track[tk].status = byte;
switch(EvType)
@@ -1105,9 +1105,9 @@ long MIDIplay::CalculateAdlChannelGoodness(unsigned c, uint16_t ins, uint16_t) c
s -= 4000;
if(!j->second.sustained)
- s -= j->second.kon_time_until_neglible;
+ s -= (long)j->second.kon_time_until_neglible;
else
- s -= j->second.kon_time_until_neglible / 2;
+ s -= (long)(j->second.kon_time_until_neglible / 2);
MIDIchannel::activenotemap_t::const_iterator
k = Ch[j->first.MidCh].activenotes.find(j->first.note);
@@ -1344,7 +1344,7 @@ void MIDIplay::SetRPN(unsigned MidCh, unsigned value, bool MSB)
case 0x010A + 1*0x10000 + 1*0x20000: // Vibrato delay in millisecons
Ch[MidCh].vibdelay =
- value ? long(0.2092 * std::exp(0.0795 * value)) : 0.0;
+ value ? int64_t(0.2092 * std::exp(0.0795 * (double)value)) : 0;
break;
default:/* UI.PrintLn("%s %04X <- %d (%cSB) (ch %u)",
diff --git a/src/adlmidi_mus2mid.c b/src/adlmidi_mus2mid.c
index 8462cd9..7d0d94e 100644
--- a/src/adlmidi_mus2mid.c
+++ b/src/adlmidi_mus2mid.c
@@ -130,7 +130,7 @@ struct mus_ctx {
#define DST_CHUNK 8192
static void resize_dst(struct mus_ctx *ctx) {
- uint32_t pos = ctx->dst_ptr - ctx->dst;
+ uint32_t pos = (uint32_t)(ctx->dst_ptr - ctx->dst);
ctx->dst = realloc(ctx->dst, ctx->dstsize + DST_CHUNK);
ctx->dstsize += DST_CHUNK;
ctx->dstrem += DST_CHUNK;
@@ -178,11 +178,11 @@ static void skipdst(struct mus_ctx *ctx, int32_t pos) {
newpos = ctx->dst_ptr - ctx->dst;
while (ctx->dstsize < newpos)
resize_dst(ctx);
- ctx->dstrem = ctx->dstsize - newpos;
+ ctx->dstrem = (uint32_t)(ctx->dstsize - newpos);
}
static uint32_t getdstpos(struct mus_ctx *ctx) {
- return (ctx->dst_ptr - ctx->dst);
+ return (uint32_t)(ctx->dst_ptr - ctx->dst);
}
/* writes a variable length integer to a buffer, and returns bytes written */
@@ -422,7 +422,7 @@ int AdlMidi_mus2midi(uint8_t *in, uint32_t insize,
if (event & 128) {
delta_time = 0;
do {
- delta_time = (delta_time * 128 + (*cur & 127)) * (140.0 / frequency);
+ delta_time = (int32_t)((delta_time * 128 + (*cur & 127)) * (140.0 / (double)frequency));
} while ((*cur++ & 128));
} else {
delta_time = 0;
diff --git a/src/adlmidi_private.hpp b/src/adlmidi_private.hpp
index c33a4d9..cb91616 100644
--- a/src/adlmidi_private.hpp
+++ b/src/adlmidi_private.hpp
@@ -44,6 +44,7 @@
#else
typedef __int32 ssize_t;
#endif
+ #define NOMINMAX //Don't override std::min and std::max
#endif
#include <windows.h>
#endif
@@ -352,7 +353,7 @@ public:
fp = std::fopen(path, "rb");
#else
wchar_t widePath[MAX_PATH];
- int size = MultiByteToWideChar(CP_UTF8, 0, path, std::strlen(path), widePath, MAX_PATH);
+ int size = MultiByteToWideChar(CP_UTF8, 0, path, (int)std::strlen(path), widePath, MAX_PATH);
widePath[size] = '\0';
fp = _wfopen(widePath, L"rb");
#endif
@@ -396,7 +397,7 @@ public:
}
}
- inline void seeku(unsigned long pos, int rel_to)
+ inline void seeku(uint64_t pos, int rel_to)
{
seek(static_cast<long>(pos), rel_to);
}
diff --git a/src/adlmidi_xmi2mid.c b/src/adlmidi_xmi2mid.c
index 9c93957..083b5ed 100644
--- a/src/adlmidi_xmi2mid.c
+++ b/src/adlmidi_xmi2mid.c
@@ -119,7 +119,7 @@ static void copy(struct xmi_ctx *ctx, char *b, uint32_t len)
#define DST_CHUNK 8192
static void resize_dst(struct xmi_ctx *ctx) {
- uint32_t pos = ctx->dst_ptr - ctx->dst;
+ uint32_t pos = (uint32_t)(ctx->dst_ptr - ctx->dst);
ctx->dst = realloc(ctx->dst, ctx->dstsize + DST_CHUNK);
ctx->dstsize += DST_CHUNK;
ctx->dstrem += DST_CHUNK;
@@ -175,7 +175,7 @@ static void skipdst(struct xmi_ctx *ctx, int32_t pos) {
newpos = ctx->dst_ptr - ctx->dst;
while (ctx->dstsize < newpos)
resize_dst(ctx);
- ctx->dstrem = ctx->dstsize - newpos;
+ ctx->dstrem = (uint32_t)(ctx->dstsize - newpos);
}
static uint32_t getsrcsize(struct xmi_ctx *ctx) {
@@ -183,11 +183,11 @@ static uint32_t getsrcsize(struct xmi_ctx *ctx) {
}
static uint32_t getsrcpos(struct xmi_ctx *ctx) {
- return (ctx->src_ptr - ctx->src);
+ return (uint32_t)(ctx->src_ptr - ctx->src);
}
static uint32_t getdstpos(struct xmi_ctx *ctx) {
- return (ctx->dst_ptr - ctx->dst);
+ return (uint32_t)(ctx->dst_ptr - ctx->dst);
}
/* This is a default set of patches to convert from MT32 to GM