mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-08-19 21:03:42 -07:00
optimize SfxExtractor bookkeeping
This commit is contained in:
parent
6720690a18
commit
8a5e118ab7
2 changed files with 6 additions and 14 deletions
|
@ -107,14 +107,8 @@ void SfxExtractor::setup() {
|
||||||
0); // Over-allocated just a tad because otherwise we'll overrun if the last frame is short.
|
0); // Over-allocated just a tad because otherwise we'll overrun if the last frame is short.
|
||||||
tempBuffer = tempStorage.data();
|
tempBuffer = tempStorage.data();
|
||||||
|
|
||||||
// Build are master sfx extraction todo list.
|
sfxToRip = 0;
|
||||||
for (int i = 0; i < sfxCount; i++)
|
|
||||||
sfxToRip.push(sfxTable[i]);
|
|
||||||
|
|
||||||
currentStep = STEP_MAIN;
|
currentStep = STEP_MAIN;
|
||||||
for (int i = 1; i < 10; i++) {
|
|
||||||
progressMilestones[i - 1] = sfxToRip.size() - ((int)ceil(sfxToRip.size() * (i / 10.0f)));
|
|
||||||
}
|
|
||||||
archive = std::make_shared<Ship::O2rArchive>("accessibility.o2r");
|
archive = std::make_shared<Ship::O2rArchive>("accessibility.o2r");
|
||||||
archive->Open();
|
archive->Open();
|
||||||
} catch (...) { currentStep = STEP_ERROR; }
|
} catch (...) { currentStep = STEP_ERROR; }
|
||||||
|
@ -135,13 +129,12 @@ void SfxExtractor::ripNextSfx() {
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (sfxToRip.empty()) {
|
if (sfxToRip == sfxCount) {
|
||||||
currentStep = STEP_FINISHED; // Caught 'em all!
|
currentStep = STEP_FINISHED; // Caught 'em all!
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
currentSfx = sfxToRip.front();
|
currentSfx = sfxTable[sfxToRip++];
|
||||||
sfxToRip.pop();
|
|
||||||
startOfInput = 0;
|
startOfInput = 0;
|
||||||
endOfInput = 0;
|
endOfInput = 0;
|
||||||
Audio_PlaySoundGeneral(currentSfx, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale,
|
Audio_PlaySoundGeneral(currentSfx, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale,
|
||||||
|
@ -177,9 +170,9 @@ void SfxExtractor::finished() {
|
||||||
Audio_PlayFanfare(NA_BGM_ITEM_GET);
|
Audio_PlayFanfare(NA_BGM_ITEM_GET);
|
||||||
}
|
}
|
||||||
void SfxExtractor::maybeGiveProgressReport() {
|
void SfxExtractor::maybeGiveProgressReport() {
|
||||||
size_t ripsRemaining = sfxToRip.size() + 1;
|
size_t ripsRemaining = sfxCount - sfxToRip;
|
||||||
for (int i = 0; i < 9; i++) {
|
for (int i = 0; i < 9; i++) {
|
||||||
if (ripsRemaining == progressMilestones[i]) {
|
if (ripsRemaining == sfxCount - ((int)ceil(sfxCount * ((i+1) / 10.0f)))) {
|
||||||
int percentDone = (i + 1) * 10;
|
int percentDone = (i + 1) * 10;
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << percentDone << " percent complete.";
|
ss << percentDone << " percent complete.";
|
||||||
|
|
|
@ -4,13 +4,12 @@ class SfxExtractor {
|
||||||
std::shared_ptr<Ship::Archive> archive;
|
std::shared_ptr<Ship::Archive> archive;
|
||||||
int currentStep;
|
int currentStep;
|
||||||
int captureThreadState;
|
int captureThreadState;
|
||||||
std::queue<s16> sfxToRip;
|
int sfxToRip;
|
||||||
size_t startOfInput;
|
size_t startOfInput;
|
||||||
size_t endOfInput;
|
size_t endOfInput;
|
||||||
s16 currentSfx;
|
s16 currentSfx;
|
||||||
std::vector<int16_t> tempStorage; // Stores raw audio data for the sfx currently being ripped.
|
std::vector<int16_t> tempStorage; // Stores raw audio data for the sfx currently being ripped.
|
||||||
int16_t* tempBuffer; // Raw pointer to the above vector.
|
int16_t* tempBuffer; // Raw pointer to the above vector.
|
||||||
int progressMilestones[9]; // Implements progress reports after every 10 percent.
|
|
||||||
// Check if a buffer contains meaningful audio output.
|
// Check if a buffer contains meaningful audio output.
|
||||||
bool isAllZero(int16_t* buffer, size_t count);
|
bool isAllZero(int16_t* buffer, size_t count);
|
||||||
// Find the beginning of a captured signal.
|
// Find the beginning of a captured signal.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue