#!/bin/bash
read_char() {
stty -icanon -echo
eval "$1=\$(dd bs=1 count=1 2>/dev/null)"
stty icanon echo
}
clear
echo "Welcome to BackupBand's source code configuration tool. This"
echo "tool allows you to customize BackupBand's source code to compile"
echo "only those features you want, and remove features you don't want."
echo "You will be presented with a series of screens, each one asking"
echo "about a particular feature. When you're done, compiling BackupBand"
echo "will produce your customized version."
echo
echo "You need to run this tool once only to customize BackupBand's source"
echo "code. If you update to the latest source code, your customization"
echo "will automatically be applied to the new version."
echo
echo "If you later decide you'd like to restore a feature that you have"
echo -e "removed now, just run \033[1mconfigure.sh\033[0m again, and answer these"
echo "questions the right way this time. Stupid git."
echo
echo "To produce a version of BackupBand with its full features/options,"
echo -e "press the \033[1mEnter\033[0m key to every question you are asked. For example,"
echo -e "press the \033[1mEnter\033[0m key right now to start... monkey."
read_char ANS
clear
SYNTH="y"
ALSAAUDIO="y"
JACK="y"
REVERB="y"
SONG="y"
MIDIIN="y"
MIDIINCLOCK="y"
MIDIOUT="y"
SEQOUT="y"
SEQIN="y"
echo "Let's cut to the chase. Do you just want a vanilla version with all"
echo "possible features enabled? If so, this is the only question you need"
echo -e "to answer. Press the \033[1mEnter\033[0m key to receive the bloatware,"
echo "and then you can go back to surfing for porn on the internet. After"
echo "evaluating BackupBand, you can later run this tool to make a custom"
echo "version. And if you're still not satisfied, you can rerun this tool,"
echo "and go back to the full version."
echo
echo "Or would you rather become an unpaid beta tester for some oddball"
echo "experimental version that will probably destroy your system (not to"
echo "say the full version won't)?"
echo
echo "Do you just want the full version? Or do you want a customized one?"
echo
echo -e "Press \033[1mEnter\033[0m for the full steaming pile, or press \033[1mN\033[0m if not."
read_char ANS
if [ "$ANS" = "n" ]; then
clear
echo "Do you use a MIDI controller to operate BackupBand, or do you"
echo "instead use only the graphical user interface? For example, you"
echo "use the mouse on the graphical piano to change chords, or"
echo "use the computer's keyboard, or use a Song Sheet, or perhaps even"
echo "use another MIDI program to operate BackupBand (such as a Virtual"
echo "Piano program)."
echo
echo -e "Press \033[1mEnter\033[0m if you use a MIDI controller, or press \033[1mN\033[0m if"
echo "you can't afford one because you deliver pizzas for a living."
read_char ANS
if [ "$ANS" = "n" ]; then
MIDIIN="n"
MIDIINCLOCK="n"
else
clear
echo "Do you intend to sync BackupBand's tempo to some external"
echo "hardware's MIDI clock?"
echo
echo -e "Press \033[1mEnter\033[0m if yes, or press \033[1mN\033[0m if no."
read_char ANS
if [ "$ANS" = "n" ]; then
MIDIINCLOCK="n"
fi
fi
clear
echo "Do you intend to use another MIDI program to operate BackupBand"
echo "(such as a Virtual Piano program)?"
echo
echo -e "Press \033[1mEnter\033[0m if yes, or press \033[1mN\033[0m if no."
read_char ANS
if [ "$ANS" = "n" ]; then
SEQIN="n"
fi
clear
echo "BackupBand's bassist, guitarist, and drummer can make their sounds"
echo "using only BackupBand's internal audio engine, along with its own"
echo "sampled instruments or instruments you create for BackupBand."
echo "BackupBand's engine tracks you reliably, offers the lowest"
echo "latency, and is easy to configure."
echo
echo "Although harder to setup, and less reliable at tracking,"
echo "BackupBand offers the option of using additional software"
echo "synths/hosts for its bass, guitar, and drum sounds. This"
echo "includes Carla, LinuxSampler, Etc."
echo
echo "BackupBand can also use external hardware synths attached to"
echo "your computer via USB or a MIDI Interface."
echo
echo "Do you want these additional options? Or are you content using"
echo "only BackupBand's internal audio engine?"
echo
echo -e "Press \033[1mEnter\033[0m if you want these options, or press \033[1mN\033[0m if not."
read_char ANS
if [ "$ANS" = "n" ]; then
MIDIOUT="n"
SEQOUT="n"
else
clear
echo "If you don't ever intend to use external MIDI hardware synths,"
echo "you can simplify BackupBand's setup if you remove this feature."
echo
echo "Do you want the option to use external hardware synths?"
echo
echo -e "Press \033[1mEnter\033[0m to keep this option, or press \033[1mN\033[0m if not."
read_char ANS
if [ "$ANS" = "n" ]; then
MIDIOUT="n"
fi
clear
echo "BackupBand's internal audio engine involves a lot of code."
echo "Although you can turn it on or off within BackupBand's settings,"
echo "you'll save memory if you remove it entirely. Since you've"
echo "already admitted you'll use other software/hardware synths (you"
echo "gutless traitor!), maybe you're plotting its demise?"
echo
echo "Do you want to keep the internal engine, or remove it?"
echo
echo -e "Press \033[1mEnter\033[0m to keep the internal audio engine, or press \033[1mN\033[0m"
echo "if not."
read_char ANS
if [ "$ANS" = "n" ]; then
SYNTH="n"
ALSAAUDIO="n"
JACK="n"
REVERB="n"
fi
fi
if [ "$SYNTH" = "y" ]; then
clear
echo "BackupBand's internal audio engine can output sound directly to"
echo "your audio card. This offers the lowest latency, and is easy to"
echo "configure."
echo
echo "Although harder to setup, and more cpu demanding, BackupBand offers"
echo "the option of using an additional software layer known as JACK."
echo "You can switch between JACK and direct output within BackupBand's"
echo "settings. But if you use only one, you'll save memory and overhead"
echo "if you remove the other entirely."
echo
echo "Do you want to keep both options? Or will you use only JACK or"
echo "direct audio (but not both)?"
echo
echo -e "Press \033[1mEnter\033[0m to keep both options, press \033[1mJ\033[0m"
echo -e "if JACK only, or press \033[1mD\033[0m if direct audio only."
if [ "$ANS" = "d" ]; then
ALSAAUDIO="n"
fi
if [ "$ANS" = "j" ]; then
JACK="n"
fi
fi
if [ "$REVERB" = "y" ]; then
clear
echo "BackupBand includes a built-in software reverb as part of its"
echo "internal audio engine. Although you can turn it on or off"
echo "within BackupBand's settings, you'll save memory if you"
echo "remove it entirely."
echo
echo "Do you want to keep the reverb, or remove it?"
echo
echo -e "Press \033[1mEnter\033[0m to keep the reverb, or press \033[1mN\033[0m if not."
read_char ANS
if [ "$ANS" = "n" ]; then
REVERB="n"
fi
fi
clear
echo "Normally, BackupBand's bassist and guitarist monitor you while"
echo "you play your MIDI controller. They will detect every chord"
echo "you play and will follow you. But BackupBand has another"
echo "option where you tell BackupBand all the chord changes (and"
echo "when to play them) before you start playing. Essentially, you're"
echo "giving the bassist/guitarist a fake sheet, which we refer to as"
echo "a songsheet. They will store this song sheet, so that if you"
echo "ever want to replay this song, you need only tell them to"
echo "use that songsheet."
echo
echo "Although you're never forced to use songsheets, if you"
echo "never do, you can save a small amount of memory/overhead"
echo "if you remove the feature entirely. It ain't much, but"
echo "if you don't need it..."
echo
echo "Do you want to keep the songsheet feature, or remove it?"
echo
echo -e "Press \033[1mEnter\033[0m to keep the songsheets, or press \033[1mN\033[0m if not."
read_char ANS
if [ "$ANS" = "n" ]; then
SONG="n"
fi
fi
clear
echo "Modifying the BackupBand source code now..."
{
echo "/* Generated by configure.sh */"
echo "#ifndef BACKUPBAND_OPTS_H"
echo "#define BACKUPBAND_OPTS_H"
if [ "$MIDIIN" = "n" ]; then
echo "#define NO_MIDI_IN_SUPPORT"
fi
if [ "$MIDIINCLOCK" = "n" ]; then
echo "#define NO_MIDICLOCK_IN"
fi
if [ "$SEQOUT" = "n" ]; then
echo "#define NO_SEQ_OUT_SUPPORT"
fi
if [ "$SEQIN" = "n" ]; then
echo "#define NO_SEQ_IN_SUPPORT"
fi
if [ "$MIDIOUT" = "n" ]; then
echo "#define NO_MIDI_OUT_SUPPORT"
fi
if [ "$JACK" = "n" ]; then
echo "#define NO_JACK_SUPPORT"
fi
if [ "$ALSAAUDIO" = "n" ]; then
echo "#define NO_ALSA_AUDIO_SUPPORT"
fi
if [ "$REVERB" = "n" ]; then
echo "#define NO_REVERB_SUPPORT"
fi
if [ "$SONG" = "n" ]; then
echo "#define NO_SONGSHEET_SUPPORT"
fi
echo "#endif"
} > ./src/Options.h
eval "rm > /dev/null -f ./src/*.o ./src/*.gch *.o ./BackupBand"
clear
echo "BackupBand's source code has been successfully modified"
echo "to your individual needs. Now that's quality service!"
if [ SYNTH="n" ]; then
echo "You're welcome, you traitorous ingrate."
else
echo "If you find a bug, it's your fault. The enduser is"
echo "always to blame."
fi
echo
echo "Do you want to compile BackupBand now?"
echo
echo -e "Press \033[1mEnter\033[0m to compile, or press \033[1mN\033[0m if not."
read_char ANS
if [ "$ANS" = "" ]; then
clear
make
fi
exit