Skip to content

Instantly share code, notes, and snippets.

@cosinekitty
Created November 27, 2022 00:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cosinekitty/2e3ec921c51f974e507867a256d52337 to your computer and use it in GitHub Desktop.
Save cosinekitty/2e3ec921c51f974e507867a256d52337 to your computer and use it in GitHub Desktop.
Build VCV Rack with and without audio glitch fix
#!/bin/bash
#-------------------------------------------------------------------------------
#
# glitchfix.sh - Don Cross <cosinekitty@gmail.com>
#
# Script that builds two copies of VCV Rack 2.2.0,
# one from original source code, another with the
# following fix for a glitching issue when sending
# output audio to PulseAudio on Linux:
#
# https://github.com/cosinekitty/rtaudio/commit/effb23d8c64efe00c741ed746ca0e0f4e983f17a
#
#-------------------------------------------------------------------------------
Fail()
{
echo "glitchfix.sh: $1"
exit 1
}
CloneVcv()
{
git clone https://github.com/VCVRack/Rack.git $1 || Fail "Could not clone VCV Rack source into: $1"
git clone https://github.com/VCVRack/Fundamental.git $1/plugins/Fundamental || Fail "Could not clone VCV Fundamental repo into: $1/plugins/Fundamental"
pushd $1 > /dev/null || Fail "CloneVcv - error changing directory to: $1"
git submodule update --init --recursive || Fail "Could not fetch submodules into: $1"
popd > /dev/null || Fail "CloneVcv - popd"
}
ApplyGlitchFix()
{
pushd "$1/dep/rtaudio" > /dev/null || Fail "ApplyGlitchFix cannot change to directory: $1/dep/rtaudio"
cat > fix.patch << EOF
diff --git a/RtAudio.cpp b/RtAudio.cpp
index e59a8ed..8d39e46 100644
--- a/RtAudio.cpp
+++ b/RtAudio.cpp
@@ -9264,20 +9264,7 @@ bool RtApiPulse::probeDeviceOpen( unsigned int device, StreamMode mode,
}
break;
case OUTPUT: {
- pa_buffer_attr * attr_ptr;
-
- if ( options && options->numberOfBuffers > 0 ) {
- // pa_buffer_attr::fragsize is recording-only.
- // Hopefully PortAudio won't access uninitialized fields.
- buffer_attr.maxlength = bufferBytes * options->numberOfBuffers;
- buffer_attr.minreq = -1;
- buffer_attr.prebuf = -1;
- buffer_attr.tlength = -1;
- attr_ptr = &buffer_attr;
- } else {
- attr_ptr = nullptr;
- }
-
+ pa_buffer_attr * attr_ptr = nullptr;
pah->s_play = pa_simple_new( NULL, streamName.c_str(), PA_STREAM_PLAYBACK,
dev_output, "Playback", &ss, NULL, attr_ptr, &error );
if ( !pah->s_play ) {
EOF
git apply fix.patch || Fail "Error applying patch."
rm -f fix.patch
popd > /dev/null || Fail "ApplyGlitchFix - popd"
}
BuildVcv()
{
pushd "$1/$2" > /dev/null || Fail "BuildVcv - error changing directory to: $1/$2"
make dep || Fail "BuildVcv - error making dependencies"
make || Fail "BuildVcv - error making Rack"
cd plugins/Fundamental || "BuildVcv - error changing directory to: $1/$2/plugins/Fundamental"
make || Fail "BuildVcv - error making Fundamental"
make dist || Fail "BuildVcv error making Fundamental dist"
cd ../.. || "BuildVcv - error changing back to ../.."
make dist || Fail "BuildVcv - error making Rack dist"
popd > /dev/null || Fail "BuildVcv - popd"
}
#-------------------------------------------------------------------------------
# Nuke and re-create directory for building Rack from source.
GLITCHFIXDIR=${PWD}/buildglitchfix
rm -rf "${GLITCHFIXDIR}"
[[ -e "${GLITCHFIXDIR}" ]] && Fail "Cannot delete existing build directory"
mkdir -pv "${GLITCHFIXDIR}" || Fail "Could not create build directory"
CloneVcv "${GLITCHFIXDIR}/original"
CloneVcv "${GLITCHFIXDIR}/patched"
ApplyGlitchFix "${GLITCHFIXDIR}/patched"
BuildVcv "${GLITCHFIXDIR}" original
BuildVcv "${GLITCHFIXDIR}" patched
echo "glitchfix.sh: SUCCESS"
exit 0
#!/bin/bash
#-------------------------------------------------------------------------------
#
# glitchfix.sh - Don Cross <cosinekitty@gmail.com>
#
# After running the companion script glitchfix.sh, this script
# extracts the zipped VCV Rack `dist` packages and places them in
# the directories:
#
# install/original/
# install/patched/
#
#-------------------------------------------------------------------------------
Fail()
{
echo "glitchinst.sh: $1"
exit 1
}
InstallRack()
{
unzip -q buildglitchfix/$1/dist/RackFree-2.2.0-lin-x64.zip || exit 1
mv -v Rack2Free install/$1
}
rm -rf install
[[ -e install ]] && Fail "Could not delete existing install directory"
mkdir -pv install || exit 1
InstallRack original
InstallRack patched
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment