Skip to content

Commit

Permalink
Add flags to modify silence window tolerances
Browse files Browse the repository at this point in the history
  • Loading branch information
aaaaaaaaaaaaaaaaaxaaaaaa committed Jul 17, 2019
1 parent dd4f6b9 commit fa95ffd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
10 changes: 6 additions & 4 deletions MSD/MSD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,16 @@
#include <filesystem>
#include "args.hxx"

args::ArgumentParser parser("Miles 10 Sound Dumper by Lyxica v1.0-beta4");
args::ValueFlag<std::string> audioFolder(parser, "/audio/ship", "Folder containing Miles audio files (mprj, mbnk, mstr)", { "folder" }, { "./audio/ship" });
args::ValueFlag<std::string> outputFolder(parser, "/miles_audio", "Folder to place the audio files in", { 'o', "out" }, { "./miles_audio" });
args::Flag listBankEvents(parser, "EVENTLIST", "List all event IDs and names contained in the Mile's bank", { 'l', "list" });
args::ArgumentParser parser("Miles 10 Sound Dumper by Lyxica v1.0-beta5");
args::ValueFlag<std::string> audioFolder(parser, "/audio/ship", "Folder containing Miles audio files (mprj, mbnk, mstr).", { "folder" }, { "./audio/ship" });
args::ValueFlag<std::string> outputFolder(parser, "/miles_audio", "Folder to place the audio files in.", { 'o', "out" }, { "./miles_audio" });
args::Flag listBankEvents(parser, "EVENTLIST", "List all event IDs and names contained in the Mile's bank.", { 'l', "list" });
args::Flag muteSound(parser, "QUIET", "Mute audio while recording events", { 'm', "mute" });
args::PositionalList<int> eventIDs(parser, "EVENT IDs", "Enter either one or two event IDs. Entering only one will cause that event to be recorded. Entering two event IDs will record every event between the two event IDs.");
args::Group advancedGroup(parser, "ADVANCED");
args::ValueFlag<int> noiseFloor(advancedGroup, "0x2000", "Adjust the noise floor when detecting silence. Any samples below this value will be considered silent.", { "noise" }, 0x2000);
args::ValueFlag<int> beginningSilencePeriod(advancedGroup, "1250", "When beginning an event recording, the amount of milliseconds of silence to wait for audio before giving up.", { "start" }, 1250);
args::ValueFlag<int> endingSilencePeriod(advancedGroup, "500", "After an event has started recording, the amount of milliseconds of silence to wait before stopping the recording.", { "end" }, 500);
args::HelpFlag help(parser, "help", "Display this help menu", { 'h', "help" });
std::vector<int> queuedEvents;
Project project;
Expand Down
7 changes: 5 additions & 2 deletions MSD/Recorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ extern args::Flag muteSound;
extern args::ValueFlag<std::string> outputFolder;
extern void StopPlaying(Queue queue);
extern Project project;
extern args::ValueFlag<int> beginningSilencePeriod;
extern args::ValueFlag<int> endingSilencePeriod;


bool Recorder::IsDataSilent(unsigned short* buffer, int size) {
for (int i = 0; i < size/2; i++) { // size is bytes
Expand Down Expand Up @@ -80,15 +83,15 @@ void Recorder::Append(PVOID buffer, unsigned int length)
{
if (firstSampleReceived)
{
if (timeGetTime() - timeLastNonSilentSample > 250)
if (timeGetTime() - timeLastNonSilentSample > args::get(endingSilencePeriod))
{
Save();
return;
}
}
else
{
if (timeGetTime() - timeLastNonSilentSample > 750)
if (timeGetTime() - timeLastNonSilentSample > args::get(beginningSilencePeriod))
{
Save();
return;
Expand Down

0 comments on commit fa95ffd

Please sign in to comment.