mirror of https://github.com/AxioDL/amuse.git
PC SNG decoder fixes
This commit is contained in:
parent
c7f093c5ee
commit
d6b9d4fca1
|
@ -45,7 +45,7 @@ class SongState
|
||||||
uint16_t m_unk2;
|
uint16_t m_unk2;
|
||||||
int16_t m_regionIndex;
|
int16_t m_regionIndex;
|
||||||
int16_t m_unk3;
|
int16_t m_unk3;
|
||||||
bool indexValid() const;
|
bool indexValid(bool bigEndian) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Tempo change entry */
|
/** Tempo change entry */
|
||||||
|
|
|
@ -711,7 +711,7 @@ std::vector<uint8_t> SongConverter::SongToMIDI(const unsigned char* data, Target
|
||||||
std::multimap<int, Event> allEvents;
|
std::multimap<int, Event> allEvents;
|
||||||
|
|
||||||
/* Iterate all regions */
|
/* Iterate all regions */
|
||||||
while (trk->m_nextRegion->indexValid())
|
while (trk->m_nextRegion->indexValid(song.m_bigEndian))
|
||||||
{
|
{
|
||||||
std::multimap<int, Event> events;
|
std::multimap<int, Event> events;
|
||||||
trk->advanceRegion(nullptr);
|
trk->advanceRegion(nullptr);
|
||||||
|
@ -814,30 +814,12 @@ std::vector<uint8_t> SongConverter::SongToMIDI(const unsigned char* data, Target
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
/* Load next command */
|
/* Load next command */
|
||||||
if ((song.m_bigEndian && *reinterpret_cast<const uint32_t*>(trk->m_data) == 0xffff0000) ||
|
if (*reinterpret_cast<const uint16_t*>(&trk->m_data[2]) == 0xffff)
|
||||||
(!song.m_bigEndian && *reinterpret_cast<const uint32_t*>(trk->m_data) == 0xffff))
|
|
||||||
{
|
{
|
||||||
/* End of channel */
|
/* End of channel */
|
||||||
trk->m_data = nullptr;
|
trk->m_data = nullptr;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#if 0
|
|
||||||
else if (trk->m_data[0] & 0x80 && trk->m_data[1] & 0x80)
|
|
||||||
{
|
|
||||||
/* Control change */
|
|
||||||
uint8_t val = trk->m_data[0] & 0x7f;
|
|
||||||
uint8_t ctrl = trk->m_data[1] & 0x7f;
|
|
||||||
events.emplace(regStart + trk->m_eventWaitCountdown, Event{CtrlEvent{}, trk->m_midiChan, ctrl, val, 0});
|
|
||||||
trk->m_data += 2;
|
|
||||||
}
|
|
||||||
else if (trk->m_data[0] & 0x80)
|
|
||||||
{
|
|
||||||
/* Program change */
|
|
||||||
uint8_t prog = trk->m_data[0] & 0x7f;
|
|
||||||
events.emplace(regStart + trk->m_eventWaitCountdown, Event{ProgEvent{}, trk->m_midiChan, prog});
|
|
||||||
trk->m_data += 2;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ((trk->m_data[2] & 0x80) != 0x80)
|
if ((trk->m_data[2] & 0x80) != 0x80)
|
||||||
|
|
|
@ -76,9 +76,9 @@ void SongState::Header::swapBig()
|
||||||
m_unkOff = SBig(m_unkOff);
|
m_unkOff = SBig(m_unkOff);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SongState::TrackRegion::indexValid() const
|
bool SongState::TrackRegion::indexValid(bool bigEndian) const
|
||||||
{
|
{
|
||||||
return SBig(m_regionIndex) >= 0;
|
return (bigEndian ? SBig(m_regionIndex) : m_regionIndex) >= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SongState::TempoChange::swapBig()
|
void SongState::TempoChange::swapBig()
|
||||||
|
@ -187,7 +187,7 @@ bool SongState::Track::advance(Sequencer& seq, int32_t ticks)
|
||||||
int32_t endTick = m_parent.m_curTick + ticks;
|
int32_t endTick = m_parent.m_curTick + ticks;
|
||||||
|
|
||||||
/* Advance region if needed */
|
/* Advance region if needed */
|
||||||
while (m_nextRegion->indexValid())
|
while (m_nextRegion->indexValid(m_parent.m_bigEndian))
|
||||||
{
|
{
|
||||||
uint32_t nextRegTick = (m_parent.m_bigEndian ? SBig(m_nextRegion->m_startTick) :
|
uint32_t nextRegTick = (m_parent.m_bigEndian ? SBig(m_nextRegion->m_startTick) :
|
||||||
m_nextRegion->m_startTick);
|
m_nextRegion->m_startTick);
|
||||||
|
@ -212,7 +212,7 @@ bool SongState::Track::advance(Sequencer& seq, int32_t ticks)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_data)
|
if (!m_data)
|
||||||
return !m_nextRegion->indexValid();
|
return !m_nextRegion->indexValid(m_parent.m_bigEndian);
|
||||||
|
|
||||||
/* Update continuous pitch data */
|
/* Update continuous pitch data */
|
||||||
if (m_pitchWheelData)
|
if (m_pitchWheelData)
|
||||||
|
@ -300,7 +300,7 @@ bool SongState::Track::advance(Sequencer& seq, int32_t ticks)
|
||||||
{
|
{
|
||||||
/* End of channel */
|
/* End of channel */
|
||||||
m_data = nullptr;
|
m_data = nullptr;
|
||||||
return !m_nextRegion->indexValid();
|
return !m_nextRegion->indexValid(m_parent.m_bigEndian);
|
||||||
}
|
}
|
||||||
else if (m_data[0] & 0x80 && m_data[1] & 0x80)
|
else if (m_data[0] & 0x80 && m_data[1] & 0x80)
|
||||||
{
|
{
|
||||||
|
@ -348,30 +348,12 @@ bool SongState::Track::advance(Sequencer& seq, int32_t ticks)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Load next command */
|
/* Load next command */
|
||||||
if ((m_parent.m_bigEndian && *reinterpret_cast<const uint32_t*>(m_data) == 0xffff0000) ||
|
if (*reinterpret_cast<const uint16_t*>(&m_data[2]) == 0xffff)
|
||||||
(!m_parent.m_bigEndian && *reinterpret_cast<const uint32_t*>(m_data) == 0xffff))
|
|
||||||
{
|
{
|
||||||
/* End of channel */
|
/* End of channel */
|
||||||
m_data = nullptr;
|
m_data = nullptr;
|
||||||
return !m_nextRegion->indexValid();
|
return !m_nextRegion->indexValid(m_parent.m_bigEndian);
|
||||||
}
|
}
|
||||||
# if 0
|
|
||||||
else if (m_data[0] & 0x80 && m_data[1] & 0x80)
|
|
||||||
{
|
|
||||||
/* Control change */
|
|
||||||
uint8_t val = m_data[0] & 0x7f;
|
|
||||||
uint8_t ctrl = m_data[1] & 0x7f;
|
|
||||||
seq.setCtrlValue(m_midiChan, ctrl, val);
|
|
||||||
m_data += 2;
|
|
||||||
}
|
|
||||||
else if (m_data[0] & 0x80)
|
|
||||||
{
|
|
||||||
/* Program change */
|
|
||||||
uint8_t prog = m_data[0] & 0x7f;
|
|
||||||
seq.setChanProgram(m_midiChan, prog);
|
|
||||||
m_data += 2;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ((m_data[2] & 0x80) != 0x80)
|
if ((m_data[2] & 0x80) != 0x80)
|
||||||
|
|
Loading…
Reference in New Issue