Skip to content

Instantly share code, notes, and snippets.

@sfan5
Last active March 11, 2022 03:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sfan5/cc3f1552c8c1111f7674eef0d4541a4b to your computer and use it in GitHub Desktop.
Save sfan5/cc3f1552c8c1111f7674eef0d4541a4b to your computer and use it in GitHub Desktop.
Converting .xm/.mod files to .wav in batch using MilkyTracker
#!/bin/bash -e
# adjust as needed, leave encode_ext empty to keep the wav files
encode_ext="opus"
function encode_func() {
# $1: source file (wav)
# $2: destination file
opusenc --quiet --bitrate 64 "$1" "$2"
}
# delete source files after conversion
delete_src=1
# directory with the source files
src_dir="$1"
# where to find the patched milkytracker executable
milkytracker="$PWD/milkytracker/src/build/src/tracker/milkytracker"
##############
Xvfb :99 &>/dev/null &
export DISPLAY=:99
cd "$src_dir"
for file in *.xm *.mod *.it *.s3m; do
[ -f "$file" ] || continue
base="${file%.*}"
wav="$base.wav"
printf 'Processing "%s"\n\n' "$base"
WAVCONV_INPUT="$file" WAVCONV_OUTPUT="$wav" $milkytracker || :
[ -f "$wav" ] || continue # probably crashed, skip this one
if [ -n "$encode_ext" ]; then
encoded="$base.$encode_ext"
encode_func "$wav" "$encoded"
rm "$wav"
fi
[ "$delete_src" -eq 1 ] && rm "$file"
done
printf 'Finished.\n'
pkill -INT Xvfb
exit 0
--- MilkyTracker-1.02.00/src/tracker/TrackerStartUp.cpp.bak 2018-07-21 13:12:08.460649307 +0200
+++ MilkyTracker-1.02.00/src/tracker/TrackerStartUp.cpp 2018-07-21 14:29:06.504803388 +0200
@@ -37,6 +37,7 @@
#include "PlayerMaster.h"
#include "SystemMessage.h"
#include "version.h"
+#include "SectionHDRecorder.h"
// Logo picture
#if defined(__EXCLUDE_BIGLOGO__) || defined(__LOWRES__)
@@ -171,7 +172,7 @@
void Tracker::startUp(bool forceNoSplash/* = false*/)
{
- bool noSplash = forceNoSplash ? true : !getShowSplashFlagFromDatabase();
+ bool noSplash = true;
// put up splash screen if desired
pp_uint32 startTime = PPGetTickCount();
@@ -210,6 +211,10 @@
settingsDatabaseCopy = NULL;
}
+ /**** put custom settings here ****/
+ settingsDatabase->store("HDRECORDER_MIXFREQ", 48000);
+ settingsDatabase->store("HDRECORDER_INTERPOLATION", 6);
+
// apply ALL settings, not just the different ones
applySettings(settingsDatabase, NULL, true, false);
@@ -244,4 +249,15 @@
SystemMessage systemMessage(*screen, SystemMessage::MessageSoundDriverInitFailed);
systemMessage.show();
}
+
+ PPSystemString tmp = getenv("WAVCONV_INPUT");
+ bool res = loadTypeFromFile(FileTypes::FileTypeSongAllModules, tmp);
+ if(!res)
+ exit(1);
+
+ //sectionSwitcher->showUpperSection(sectionHDRecorder);
+ tmp = getenv("WAVCONV_OUTPUT");
+ sectionHDRecorder->exportWAVAsFileName(tmp);
+
+ exit(0);
}
--- MilkyTracker-1.02.00/src/milkyplay/drivers/sdl/AudioDriver_SDL.cpp.bak 2018-07-21 13:28:39.271357199 +0200
+++ MilkyTracker-1.02.00/src/milkyplay/drivers/sdl/AudioDriver_SDL.cpp 2018-07-21 13:32:30.196275672 +0200
@@ -78,6 +78,8 @@
return res;
}
+ return MP_OK;
+
wanted.freq = mixFrequency;
wanted.format = AUDIO_S16SYS;
wanted.channels = 2; /* 1 = mono, 2 = stereo */
--- MilkyTracker-1.02.00/src/tracker/TrackerInit.cpp.bak 2018-07-21 13:36:29.047590165 +0200
+++ MilkyTracker-1.02.00/src/tracker/TrackerInit.cpp 2018-07-21 14:06:27.971313330 +0200
@@ -1158,6 +1158,8 @@
void Tracker::showMessageBoxSized(pp_int32 id, const PPString& caption, MessageBoxTypes type, pp_int32 width/* = -1*/, pp_int32 height/* = -1*/, bool update/* = true*/)
{
+ printf("MessageBox: %s\n", static_cast<const char*>(caption));
+
if (messageBoxContainerGeneric)
{
delete messageBoxContainerGeneric;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment