mirror of https://github.com/AxioDL/amuse.git
Merge pull request #11 from lioncash/shadow
General: Eliminate instances of shadowing
This commit is contained in:
commit
82d1a8d214
|
@ -332,8 +332,8 @@ void SoundMacro::readCmds(athena::io::IStreamReader& r, uint32_t size) {
|
|||
for (uint32_t i = 0; i < numCmds; ++i) {
|
||||
uint32_t data[2];
|
||||
athena::io::Read<athena::io::PropType::None>::Do<decltype(data), DNAE>({}, data, r);
|
||||
athena::io::MemoryReader r(data, 8);
|
||||
m_cmds.push_back(CmdDo<MakeCmdOp, std::unique_ptr<SoundMacro::ICmd>>(r));
|
||||
athena::io::MemoryReader mr(data, sizeof(data));
|
||||
m_cmds.push_back(CmdDo<MakeCmdOp, std::unique_ptr<ICmd>>(mr));
|
||||
}
|
||||
}
|
||||
template void SoundMacro::readCmds<athena::Big>(athena::io::IStreamReader& r, uint32_t size);
|
||||
|
@ -343,7 +343,7 @@ template <athena::Endian DNAE>
|
|||
void SoundMacro::writeCmds(athena::io::IStreamWriter& w) const {
|
||||
for (const auto& cmd : m_cmds) {
|
||||
uint32_t data[2];
|
||||
athena::io::MemoryWriter mw((uint8_t*)data, 8);
|
||||
athena::io::MemoryWriter mw(reinterpret_cast<uint8_t*>(data), sizeof(data));
|
||||
mw.writeUByte(uint8_t(cmd->Isa()));
|
||||
cmd->write(mw);
|
||||
athena::io::Write<athena::io::PropType::None>::Do<decltype(data), DNAE>({}, data, w);
|
||||
|
|
|
@ -161,11 +161,11 @@ AudioGroup* Engine::_addAudioGroup(const AudioGroupData& data, std::unique_ptr<A
|
|||
m_audioGroups.emplace(std::make_pair(&data, std::move(grp)));
|
||||
|
||||
/* setup SFX index for contained objects */
|
||||
for (const auto& grp : ret->getProj().sfxGroups()) {
|
||||
const SFXGroupIndex& sfxGroup = *grp.second;
|
||||
for (const auto& [groupID, groupIndex] : ret->getProj().sfxGroups()) {
|
||||
const SFXGroupIndex& sfxGroup = *groupIndex;
|
||||
m_sfxLookup.reserve(m_sfxLookup.size() + sfxGroup.m_sfxEntries.size());
|
||||
for (const auto& ent : sfxGroup.m_sfxEntries)
|
||||
m_sfxLookup[ent.first] = std::make_tuple(ret, grp.first, &ent.second);
|
||||
m_sfxLookup[ent.first] = std::make_tuple(ret, groupID, &ent.second);
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -218,8 +218,9 @@ void Engine::removeAudioGroup(const AudioGroupData& data) {
|
|||
/* teardown SFX index for contained objects */
|
||||
for (const auto& pair : grp->getProj().sfxGroups()) {
|
||||
const SFXGroupIndex& sfxGroup = *pair.second;
|
||||
for (const auto& pair : sfxGroup.m_sfxEntries)
|
||||
m_sfxLookup.erase(pair.first);
|
||||
for (const auto& sfxEntry : sfxGroup.m_sfxEntries) {
|
||||
m_sfxLookup.erase(sfxEntry.first);
|
||||
}
|
||||
}
|
||||
|
||||
m_audioGroups.erase(search);
|
||||
|
|
|
@ -611,9 +611,10 @@ std::vector<uint8_t> SongConverter::SongToMIDI(const unsigned char* data, int& v
|
|||
encoder.getResult().push_back(0x51);
|
||||
encoder.getResult().push_back(3);
|
||||
|
||||
uint32_t tempo24 = SBig(60000000 / (song.m_header.m_initialTempo & 0x7fffffff));
|
||||
for (int i = 1; i < 4; ++i)
|
||||
encoder.getResult().push_back(reinterpret_cast<uint8_t*>(&tempo24)[i]);
|
||||
const uint32_t initialTempo24 = SBig(60000000 / (song.m_header.m_initialTempo & 0x7fffffff));
|
||||
for (size_t i = 1; i < 4; ++i) {
|
||||
encoder.getResult().push_back(reinterpret_cast<const uint8_t*>(&initialTempo24)[i]);
|
||||
}
|
||||
|
||||
/* Write out tempo changes */
|
||||
int lastTick = 0;
|
||||
|
@ -631,9 +632,10 @@ std::vector<uint8_t> SongConverter::SongToMIDI(const unsigned char* data, int& v
|
|||
encoder.getResult().push_back(0x51);
|
||||
encoder.getResult().push_back(3);
|
||||
|
||||
uint32_t tempo24 = SBig(60000000 / (change.m_tempo & 0x7fffffff));
|
||||
for (int i = 1; i < 4; ++i)
|
||||
encoder.getResult().push_back(reinterpret_cast<uint8_t*>(&tempo24)[i]);
|
||||
const uint32_t tempo24 = SBig(60000000 / (change.m_tempo & 0x7fffffff));
|
||||
for (size_t i = 1; i < 4; ++i) {
|
||||
encoder.getResult().push_back(reinterpret_cast<const uint8_t*>(&tempo24)[i]);
|
||||
}
|
||||
|
||||
++tempoPtr;
|
||||
}
|
||||
|
@ -974,9 +976,9 @@ std::vector<uint8_t> SongConverter::MIDIToSong(const std::vector<uint8_t>& data,
|
|||
if (tempos.size() == 1)
|
||||
initTempo = tempos.begin()->second;
|
||||
else if (tempos.size() > 1) {
|
||||
auto it = tempos.begin();
|
||||
initTempo = it->second;
|
||||
++it;
|
||||
auto iter = tempos.begin();
|
||||
initTempo = iter->second;
|
||||
++iter;
|
||||
for (auto& pair : tempos) {
|
||||
if (big)
|
||||
tempoBuf.emplace_back(SBig(uint32_t(pair.first * 384 / header.div)), SBig(uint32_t(pair.second)));
|
||||
|
@ -1046,15 +1048,17 @@ std::vector<uint8_t> SongConverter::MIDIToSong(const std::vector<uint8_t>& data,
|
|||
region.eventBuf.push_back(0x80 | event.second.noteOrCtrl);
|
||||
} else {
|
||||
if (big) {
|
||||
uint32_t tickBig = SBig(uint32_t(eventTick - startTick));
|
||||
for (int i = 0; i < 4; ++i)
|
||||
region.eventBuf.push_back(reinterpret_cast<const uint8_t*>(&tickBig)[i]);
|
||||
const uint32_t tickBig = SBig(uint32_t(eventTick - startTick));
|
||||
for (size_t j = 0; j < 4; ++j) {
|
||||
region.eventBuf.push_back(reinterpret_cast<const uint8_t*>(&tickBig)[j]);
|
||||
}
|
||||
region.eventBuf.push_back(0x80 | event.second.velOrVal);
|
||||
region.eventBuf.push_back(0x80 | event.second.noteOrCtrl);
|
||||
} else {
|
||||
uint32_t tick = uint32_t(eventTick - startTick);
|
||||
for (int i = 0; i < 4; ++i)
|
||||
region.eventBuf.push_back(reinterpret_cast<const uint8_t*>(&tick)[i]);
|
||||
const uint32_t tick = uint32_t(eventTick - startTick);
|
||||
for (size_t j = 0; j < 4; ++j) {
|
||||
region.eventBuf.push_back(reinterpret_cast<const uint8_t*>(&tick)[j]);
|
||||
}
|
||||
region.eventBuf.push_back(0x80 | event.second.velOrVal);
|
||||
region.eventBuf.push_back(0x80 | event.second.noteOrCtrl);
|
||||
}
|
||||
|
@ -1070,15 +1074,17 @@ std::vector<uint8_t> SongConverter::MIDIToSong(const std::vector<uint8_t>& data,
|
|||
region.eventBuf.push_back(0);
|
||||
} else {
|
||||
if (big) {
|
||||
uint32_t tickBig = SBig(uint32_t(eventTick - startTick));
|
||||
for (int i = 0; i < 4; ++i)
|
||||
region.eventBuf.push_back(reinterpret_cast<const uint8_t*>(&tickBig)[i]);
|
||||
const uint32_t tickBig = SBig(uint32_t(eventTick - startTick));
|
||||
for (size_t j = 0; j < 4; ++j) {
|
||||
region.eventBuf.push_back(reinterpret_cast<const uint8_t*>(&tickBig)[j]);
|
||||
}
|
||||
region.eventBuf.push_back(0x80 | event.second.program);
|
||||
region.eventBuf.push_back(0);
|
||||
} else {
|
||||
uint32_t tick = uint32_t(eventTick - startTick);
|
||||
for (int i = 0; i < 4; ++i)
|
||||
region.eventBuf.push_back(reinterpret_cast<const uint8_t*>(&tick)[i]);
|
||||
const uint32_t tick = uint32_t(eventTick - startTick);
|
||||
for (size_t j = 0; j < 4; ++j) {
|
||||
region.eventBuf.push_back(reinterpret_cast<const uint8_t*>(&tick)[j]);
|
||||
}
|
||||
region.eventBuf.push_back(0x80 | event.second.program);
|
||||
region.eventBuf.push_back(0);
|
||||
}
|
||||
|
@ -1099,24 +1105,26 @@ std::vector<uint8_t> SongConverter::MIDIToSong(const std::vector<uint8_t>& data,
|
|||
lastEventTick = eventTick;
|
||||
region.eventBuf.push_back(event.second.noteOrCtrl);
|
||||
region.eventBuf.push_back(event.second.velOrVal);
|
||||
uint16_t lenBig = SBig(uint16_t(lenTicks));
|
||||
const uint16_t lenBig = SBig(uint16_t(lenTicks));
|
||||
region.eventBuf.push_back(reinterpret_cast<const uint8_t*>(&lenBig)[0]);
|
||||
region.eventBuf.push_back(reinterpret_cast<const uint8_t*>(&lenBig)[1]);
|
||||
} else {
|
||||
if (big) {
|
||||
uint32_t tickBig = SBig(uint32_t(eventTick - startTick));
|
||||
for (int i = 0; i < 4; ++i)
|
||||
region.eventBuf.push_back(reinterpret_cast<const uint8_t*>(&tickBig)[i]);
|
||||
uint16_t lenBig = SBig(uint16_t(lenTicks));
|
||||
const uint32_t tickBig = SBig(uint32_t(eventTick - startTick));
|
||||
for (size_t j = 0; j < 4; ++j) {
|
||||
region.eventBuf.push_back(reinterpret_cast<const uint8_t*>(&tickBig)[j]);
|
||||
}
|
||||
const uint16_t lenBig = SBig(uint16_t(lenTicks));
|
||||
region.eventBuf.push_back(reinterpret_cast<const uint8_t*>(&lenBig)[0]);
|
||||
region.eventBuf.push_back(reinterpret_cast<const uint8_t*>(&lenBig)[1]);
|
||||
region.eventBuf.push_back(event.second.noteOrCtrl);
|
||||
region.eventBuf.push_back(event.second.velOrVal);
|
||||
} else {
|
||||
uint32_t tick = uint32_t(eventTick - startTick);
|
||||
for (int i = 0; i < 4; ++i)
|
||||
region.eventBuf.push_back(reinterpret_cast<const uint8_t*>(&tick)[i]);
|
||||
uint16_t len = uint16_t(lenTicks);
|
||||
const uint32_t tick = uint32_t(eventTick - startTick);
|
||||
for (size_t j = 0; j < 4; ++j) {
|
||||
region.eventBuf.push_back(reinterpret_cast<const uint8_t*>(&tick)[j]);
|
||||
}
|
||||
const uint16_t len = uint16_t(lenTicks);
|
||||
region.eventBuf.push_back(reinterpret_cast<const uint8_t*>(&len)[0]);
|
||||
region.eventBuf.push_back(reinterpret_cast<const uint8_t*>(&len)[1]);
|
||||
region.eventBuf.push_back(event.second.noteOrCtrl);
|
||||
|
@ -1152,21 +1160,23 @@ std::vector<uint8_t> SongConverter::MIDIToSong(const std::vector<uint8_t>& data,
|
|||
region.eventBuf.push_back(0xff);
|
||||
} else {
|
||||
if (big) {
|
||||
uint32_t selTick =
|
||||
const uint32_t selTick =
|
||||
std::max(std::max(lastEventTick - startTick, lastPitchTick - startTick), lastModTick - startTick);
|
||||
uint32_t tickBig = SBig(uint32_t(selTick));
|
||||
for (int i = 0; i < 4; ++i)
|
||||
region.eventBuf.push_back(reinterpret_cast<const uint8_t*>(&tickBig)[i]);
|
||||
const uint32_t tickBig = SBig(uint32_t(selTick));
|
||||
for (size_t j = 0; j < 4; ++j) {
|
||||
region.eventBuf.push_back(reinterpret_cast<const uint8_t*>(&tickBig)[j]);
|
||||
}
|
||||
region.eventBuf.push_back(0);
|
||||
region.eventBuf.push_back(0);
|
||||
region.eventBuf.push_back(0xff);
|
||||
region.eventBuf.push_back(0xff);
|
||||
} else {
|
||||
uint32_t selTick =
|
||||
const uint32_t selTick =
|
||||
std::max(std::max(lastEventTick - startTick, lastPitchTick - startTick), lastModTick - startTick);
|
||||
uint32_t tick = uint32_t(selTick);
|
||||
for (int i = 0; i < 4; ++i)
|
||||
region.eventBuf.push_back(reinterpret_cast<const uint8_t*>(&tick)[i]);
|
||||
const uint32_t tick = uint32_t(selTick);
|
||||
for (size_t j = 0; j < 4; ++j) {
|
||||
region.eventBuf.push_back(reinterpret_cast<const uint8_t*>(&tick)[j]);
|
||||
}
|
||||
region.eventBuf.push_back(0);
|
||||
region.eventBuf.push_back(0);
|
||||
region.eventBuf.push_back(0xff);
|
||||
|
|
|
@ -253,14 +253,14 @@ int SongState::DetectVersion(const unsigned char* ptr, bool& isBig) {
|
|||
const unsigned char* expectedEnd =
|
||||
ptr + (isBig ? SBig(regionIdxTable[regionIdx + 1]) : regionIdxTable[regionIdx + 1]);
|
||||
|
||||
Track::Header header = *reinterpret_cast<const Track::Header*>(data);
|
||||
auto header2 = *reinterpret_cast<const Track::Header*>(data);
|
||||
if (isBig)
|
||||
header.swapBig();
|
||||
header2.swapBig();
|
||||
data += 12;
|
||||
|
||||
/* continuous pitch data */
|
||||
if (header.m_pitchOff) {
|
||||
const unsigned char* dptr = ptr + header.m_pitchOff;
|
||||
if (header2.m_pitchOff) {
|
||||
const unsigned char* dptr = ptr + header2.m_pitchOff;
|
||||
while (dptr[0] != 0x80 || dptr[1] != 0x00)
|
||||
DecodeDelta(dptr);
|
||||
dptr += 2;
|
||||
|
@ -269,8 +269,8 @@ int SongState::DetectVersion(const unsigned char* ptr, bool& isBig) {
|
|||
}
|
||||
|
||||
/* continuous modulation data */
|
||||
if (header.m_modOff) {
|
||||
const unsigned char* dptr = ptr + header.m_modOff;
|
||||
if (header2.m_modOff) {
|
||||
const unsigned char* dptr = ptr + header2.m_modOff;
|
||||
while (dptr[0] != 0x80 || dptr[1] != 0x00)
|
||||
DecodeDelta(dptr);
|
||||
dptr += 2;
|
||||
|
|
Loading…
Reference in New Issue