mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-08-14 02:27:21 -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.
|
||||
tempBuffer = tempStorage.data();
|
||||
|
||||
// Build are master sfx extraction todo list.
|
||||
for (int i = 0; i < sfxCount; i++)
|
||||
sfxToRip.push(sfxTable[i]);
|
||||
|
||||
sfxToRip = 0;
|
||||
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->Open();
|
||||
} catch (...) { currentStep = STEP_ERROR; }
|
||||
|
@ -135,13 +129,12 @@ void SfxExtractor::ripNextSfx() {
|
|||
|
||||
return;
|
||||
}
|
||||
if (sfxToRip.empty()) {
|
||||
if (sfxToRip == sfxCount) {
|
||||
currentStep = STEP_FINISHED; // Caught 'em all!
|
||||
return;
|
||||
}
|
||||
|
||||
currentSfx = sfxToRip.front();
|
||||
sfxToRip.pop();
|
||||
currentSfx = sfxTable[sfxToRip++];
|
||||
startOfInput = 0;
|
||||
endOfInput = 0;
|
||||
Audio_PlaySoundGeneral(currentSfx, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale,
|
||||
|
@ -177,9 +170,9 @@ void SfxExtractor::finished() {
|
|||
Audio_PlayFanfare(NA_BGM_ITEM_GET);
|
||||
}
|
||||
void SfxExtractor::maybeGiveProgressReport() {
|
||||
size_t ripsRemaining = sfxToRip.size() + 1;
|
||||
size_t ripsRemaining = sfxCount - sfxToRip;
|
||||
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;
|
||||
std::stringstream ss;
|
||||
ss << percentDone << " percent complete.";
|
||||
|
|
|
@ -4,13 +4,12 @@ class SfxExtractor {
|
|||
std::shared_ptr<Ship::Archive> archive;
|
||||
int currentStep;
|
||||
int captureThreadState;
|
||||
std::queue<s16> sfxToRip;
|
||||
int sfxToRip;
|
||||
size_t startOfInput;
|
||||
size_t endOfInput;
|
||||
s16 currentSfx;
|
||||
std::vector<int16_t> tempStorage; // Stores raw audio data for the sfx currently being ripped.
|
||||
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.
|
||||
bool isAllZero(int16_t* buffer, size_t count);
|
||||
// Find the beginning of a captured signal.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue