forked from DhrBaksteen/ArduinoOPL2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild
More file actions
executable file
·109 lines (98 loc) · 3.93 KB
/
build
File metadata and controls
executable file
·109 lines (98 loc) · 3.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/bin/sh
if [ "$(id -u)" != "0" ]
then echo "Please run as root"
exit
fi
clear
echo "\033[1;33m ________ __________.____ ________ "
echo "\033[1;33m \\_____ \\\\______ \\ | \\_____ \\ "
echo "\033[1;32m / | \\| ___/ | / ____/ "
echo "\033[1;36m / | \\ | | |___/ \\ "
echo "\033[1;34m \\_______ /____| |_______ \\_______ \\"
echo "\033[1;33m _____ .___.__ \033[1;34m\\/\033[1;33m __________ \033[1;34m\\/ \\/\033[1;33m .___ "
echo "\033[1;33m / _ \\ __ __ __| _/|__| ___ \\______ \\ ________ _______ __| _/"
echo "\033[1;32m / /_\\ \\| | \\/ __ | | |/ __\\ | | _// __\\__ \\\\_ __ \\/ __ | "
echo "\033[1;36m / | \\ | / /_/ | | ( /_/ ) | | ( /_/ ) __ \\| | \\/ /_/ | "
echo "\033[1;34m \\____|__ /____/\\____ | |__|\\___/ |______ /\\___(____ /__| \\____ | "
echo "\033[1;34m \\/ \\/ \\/ \\/ \\/ \033[0m"
echo "Installation script for Raspberry Pi and compatibles"
echo "Library version 1.4.4, 18th of November 2018"
echo "Copyright (c) 2016-2018 Maarten Janssen, Cheerful"
echo ""
echo -n "Checking for SPI devices... "
if [ "$(ls /dev/*spi* 2>/dev/null)" != "" ]
then
echo "\033[0;32mOk\033[0m"
else
echo "\033[0;31mFailed\033[0m"
echo "\nNo SPI devices were found enabled on your Pi."
echo "Please run '\033[1;34msudo raspi-config\033[0m' and enable SPI from the 'Interfacing Options'"
echo "menu. If you are using a different board then please consult its documentation"
echo "on how to enable SPI on your board."
echo ""
exit
fi
echo -n "Checking for WiringPi... "
if ! type "gpio" > /dev/null
then
echo "\033[0;31mFailed\033[0m"
echo "\nWiringPi was not found."
echo -n "Do you want to download and install it now? "
read REPLY
REPLY=$(echo "$REPLY" | awk '{gsub(/ /, "", $0); print toupper(substr($0==""?"N":$0, 1, 1))}')
if [ $REPLY = "Y" ]
then
echo -n "Downloading and installing WiringPi... "
apt-get install -y git-core > /dev/null
rm -rf opl2_temp
mkdir opl2_temp
cd opl2_temp
git clone --quiet git://git.drogon.net/wiringPi > /dev/null
cd wiringPi
./build > /dev/null
cd ../..
rm -rf opl2_temp
# Check if WiringPi installed ok...
if ! type "gpio" > /dev/null; then
echo "\033[0;31mFailed\033[0m"
echo "WiringPi installation failed! Sorry mate, you're on your own."
echo ""
exit
fi
echo "\033[0;32mDone\033[0m"
else
echo "OPL2 Audio Board installation cannot continue without WiringPi."
echo ""
exit
fi
else
echo "\033[0;32mOk\033[0m"
fi
echo -n "Building the OPL2 library... "
sed -i 's/^\s*#define BOARD_TYPE.*/\t#define BOARD_TYPE OPL2_BOARD_TYPE_RASPBERRY_PI/' src/OPL2.h
gcc -std=c++11 -c -fPIC src/OPL2.cpp -lwiringPi
gcc -shared -o libOPL2.so OPL2.o
mv libOPL2.so /usr/lib/
cp src/OPL2.h /usr/include/
rm OPL2.o
ldconfig
echo "\033[0;32mDone\033[0m"
echo -n "Compiling examples... "
gcc -std=c++11 -Wall -o examples_pi/demotune/demotune examples_pi/demotune/demotune.cpp -lOPL2 -lwiringPi
gcc -std=c++11 -Wall -o examples_pi/drums/drums examples_pi/drums/drums.cpp -lOPL2 -lwiringPi
gcc -std=c++11 -Wall -o examples_pi/simpletone/simpletone examples_pi/simpletone/simpletone.cpp -lOPL2 -lwiringPi
gcc -std=c++11 -Wall -o examples_pi/opl2play/opl2play examples_pi/opl2play/opl2play.cpp -lOPL2 -lwiringPi -lz
gcc -std=c++11 -Wall -o examples_pi/frequency_sweep/sweep examples_pi/frequency_sweep/sweep.cpp -lOPL2 -lwiringPi -lz
echo "\033[0;32mDone\033[0m"
echo "Installation complete."
echo ""
./connecting
echo -n "Are you ready to try your OPL2 Audio Board? "
read REPLY
REPLY=$(echo "$REPLY" | awk '{gsub(/ /, "", $0); print toupper(substr($0==""?"N":$0, 1, 1))}')
if [ $REPLY = "Y" ]
then
echo "If all went successful you should hear music playing now!"
./examples_pi/demotune/demotune &
fi
echo ""