mirror of https://github.com/AxioDL/amuse.git
Initialization fix in SongConverter as indicated by valgrind
This commit is contained in:
parent
d6b9d4fca1
commit
e99dbc7e0a
|
@ -7,10 +7,10 @@ IntrusiveAudioGroupData::~IntrusiveAudioGroupData()
|
||||||
{
|
{
|
||||||
if (m_owns)
|
if (m_owns)
|
||||||
{
|
{
|
||||||
delete m_pool;
|
delete[] m_pool;
|
||||||
delete m_proj;
|
delete[] m_proj;
|
||||||
delete m_sdir;
|
delete[] m_sdir;
|
||||||
delete m_samp;
|
delete[] m_samp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,10 +27,10 @@ IntrusiveAudioGroupData& IntrusiveAudioGroupData::operator=(IntrusiveAudioGroupD
|
||||||
{
|
{
|
||||||
if (m_owns)
|
if (m_owns)
|
||||||
{
|
{
|
||||||
delete m_pool;
|
delete[] m_pool;
|
||||||
delete m_proj;
|
delete[] m_proj;
|
||||||
delete m_sdir;
|
delete[] m_sdir;
|
||||||
delete m_samp;
|
delete[] m_samp;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_owns = other.m_owns;
|
m_owns = other.m_owns;
|
||||||
|
|
|
@ -42,8 +42,9 @@ struct PitchEvent {};
|
||||||
struct Event
|
struct Event
|
||||||
{
|
{
|
||||||
bool endEvent = false;
|
bool endEvent = false;
|
||||||
bool controlChange = false;
|
bool isNote = false;
|
||||||
bool progChange = false;
|
bool isControlChange = false;
|
||||||
|
bool isProgChange = false;
|
||||||
uint8_t channel;
|
uint8_t channel;
|
||||||
uint8_t noteOrCtrl;
|
uint8_t noteOrCtrl;
|
||||||
uint8_t velOrVal;
|
uint8_t velOrVal;
|
||||||
|
@ -54,15 +55,16 @@ struct Event
|
||||||
int pitchBend;
|
int pitchBend;
|
||||||
|
|
||||||
Event(NoteEvent, uint8_t chan, uint8_t note, uint8_t vel, uint16_t len)
|
Event(NoteEvent, uint8_t chan, uint8_t note, uint8_t vel, uint16_t len)
|
||||||
: controlChange(false), channel(chan), noteOrCtrl(note), velOrVal(vel), length(len) {}
|
: isNote(true), channel(chan), noteOrCtrl(note), velOrVal(vel), length(len) {}
|
||||||
|
|
||||||
Event(CtrlEvent, uint8_t chan, uint8_t note, uint8_t vel, uint16_t len)
|
Event(CtrlEvent, uint8_t chan, uint8_t note, uint8_t vel, uint16_t len)
|
||||||
: controlChange(true), channel(chan), noteOrCtrl(note), velOrVal(vel), length(len) {}
|
: isControlChange(true), channel(chan), noteOrCtrl(note), velOrVal(vel), length(len) {}
|
||||||
|
|
||||||
Event(ProgEvent, uint8_t chan, uint8_t prog)
|
Event(ProgEvent, uint8_t chan, uint8_t prog)
|
||||||
: progChange(true), channel(chan), program(prog) {}
|
: isProgChange(true), channel(chan), program(prog) {}
|
||||||
|
|
||||||
Event(PitchEvent, uint8_t chan, int pBend) : isPitchBend(true), channel(chan), pitchBend(pBend) {}
|
Event(PitchEvent, uint8_t chan, int pBend)
|
||||||
|
: isPitchBend(true), channel(chan), pitchBend(pBend) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
class MIDIDecoder
|
class MIDIDecoder
|
||||||
|
@ -862,7 +864,7 @@ std::vector<uint8_t> SongConverter::SongToMIDI(const unsigned char* data, Target
|
||||||
/* Resolve key-off events */
|
/* Resolve key-off events */
|
||||||
for (auto& pair : events)
|
for (auto& pair : events)
|
||||||
{
|
{
|
||||||
if (!pair.second.controlChange)
|
if (pair.second.isNote)
|
||||||
{
|
{
|
||||||
auto it = allEvents.emplace(pair.first + pair.second.length, pair.second);
|
auto it = allEvents.emplace(pair.first + pair.second.length, pair.second);
|
||||||
it->second.endEvent = true;
|
it->second.endEvent = true;
|
||||||
|
@ -877,11 +879,11 @@ std::vector<uint8_t> SongConverter::SongToMIDI(const unsigned char* data, Target
|
||||||
encoder._sendContinuedValue(pair.first - lastTime);
|
encoder._sendContinuedValue(pair.first - lastTime);
|
||||||
lastTime = pair.first;
|
lastTime = pair.first;
|
||||||
|
|
||||||
if (pair.second.controlChange)
|
if (pair.second.isControlChange)
|
||||||
{
|
{
|
||||||
encoder.controlChange(pair.second.channel, pair.second.noteOrCtrl, pair.second.velOrVal);
|
encoder.controlChange(pair.second.channel, pair.second.noteOrCtrl, pair.second.velOrVal);
|
||||||
}
|
}
|
||||||
else if (pair.second.progChange)
|
else if (pair.second.isProgChange)
|
||||||
{
|
{
|
||||||
encoder.programChange(trk->m_midiChan, pair.second.program);
|
encoder.programChange(trk->m_midiChan, pair.second.program);
|
||||||
}
|
}
|
||||||
|
@ -889,7 +891,7 @@ std::vector<uint8_t> SongConverter::SongToMIDI(const unsigned char* data, Target
|
||||||
{
|
{
|
||||||
encoder.pitchBend(trk->m_midiChan, pair.second.pitchBend);
|
encoder.pitchBend(trk->m_midiChan, pair.second.pitchBend);
|
||||||
}
|
}
|
||||||
else
|
else if (pair.second.isNote)
|
||||||
{
|
{
|
||||||
if (pair.second.endEvent)
|
if (pair.second.endEvent)
|
||||||
encoder.noteOff(pair.second.channel, pair.second.noteOrCtrl, pair.second.velOrVal);
|
encoder.noteOff(pair.second.channel, pair.second.noteOrCtrl, pair.second.velOrVal);
|
||||||
|
@ -1077,7 +1079,7 @@ std::vector<uint8_t> SongConverter::MIDIToSong(const std::vector<uint8_t>& data,
|
||||||
lastModVal = 0;
|
lastModVal = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.second.controlChange)
|
if (event.second.isControlChange)
|
||||||
{
|
{
|
||||||
if (event.second.noteOrCtrl == 1)
|
if (event.second.noteOrCtrl == 1)
|
||||||
{
|
{
|
||||||
|
@ -1114,7 +1116,7 @@ std::vector<uint8_t> SongConverter::MIDIToSong(const std::vector<uint8_t>& data,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (event.second.progChange)
|
else if (event.second.isProgChange)
|
||||||
{
|
{
|
||||||
if (target == Target::GCN)
|
if (target == Target::GCN)
|
||||||
{
|
{
|
||||||
|
@ -1148,7 +1150,7 @@ std::vector<uint8_t> SongConverter::MIDIToSong(const std::vector<uint8_t>& data,
|
||||||
EncodeContinuousRLE(region.pitchBuf, newPitch - lastPitchVal);
|
EncodeContinuousRLE(region.pitchBuf, newPitch - lastPitchVal);
|
||||||
lastPitchVal = newPitch;
|
lastPitchVal = newPitch;
|
||||||
}
|
}
|
||||||
else
|
else if (event.second.isNote)
|
||||||
{
|
{
|
||||||
if (target == Target::GCN)
|
if (target == Target::GCN)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue