Skip to content

Commit ea16c5f

Browse files
committed
Python 3 support (requires 3.7), and various modifications, included some from PR #47
1 parent f692af0 commit ea16c5f

7 files changed

Lines changed: 52 additions & 111 deletions

File tree

README.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,32 +16,36 @@ Website: [www.samplerbox.org](https://www.samplerbox.org)
1616

1717
SamplerBox works with the RaspberryPi's built-in soundcard, but it is recommended to use a USB DAC (PCM2704 USB DAC for less than 10€ on eBay is fine) for better sound quality.
1818

19-
1. Install the required dependencies (Python-related packages and audio libraries):
19+
1. Install the required dependencies (Python-related packages and audio libraries - the current version requires at least Python 3.7):
2020

2121
~~~
22-
sudo apt-get update ; sudo apt-get -y install git python-dev python-pip python-numpy cython python-smbus libportaudio2 libffi-dev
23-
sudo pip install rtmidi-python cffi sounddevice
22+
sudo apt-get update
23+
sudo apt-get -y install git python3-pip python3-smbus python3-numpy libportaudio2 raspberrypi-kernel
24+
sudo pip3 install cython rtmidi-python cffi sounddevice pyserial
2425
~~~
2526

2627
2. Download SamplerBox and build it with:
2728

2829
~~~
2930
git clone https://github.com/josephernest/SamplerBox.git
30-
cd SamplerBox ; sudo python setup.py build_ext --inplace
31+
cd SamplerBox
32+
sudo python3 setup.py build_ext --inplace
3133
~~~
3234

33-
3. Run the soft with `python samplerbox.py`.
35+
3. Run the soft with `sudo python3 samplerbox.py`.
3436

3537
4. Play some notes on the connected MIDI keyboard, you'll hear some sound!
3638

37-
*(Optional)* Modify `samplerbox.py`'s first lines if you want to change root directory for sample-sets, default soundcard, etc.
39+
*(Optional)* Modify `config.py` if you want to change root directory for sample-sets, default soundcard, etc.
3840

3941

4042
[How to use it](#howto)
4143
----
4244

4345
See the [FAQ](https://www.samplerbox.org/faq) on https://www.samplerbox.org.
4446

47+
Note: the current version also works on Windows if all the required modules are installed.
48+
4549

4650
[ISO image](#isoimage)
4751
----

config.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55

66
AUDIO_DEVICE_ID = 2 # change this number to use another soundcard
77
SAMPLES_DIR = "." # The root directory containing the sample-sets. Example: "/media/" to look for samples on a USB stick / SD card
8-
USE_SERIALPORT_MIDI = False # Set to True to enable MIDI IN via SerialPort (e.g. RaspberryPi's GPIO UART pins)
9-
USE_I2C_7SEGMENTDISPLAY = False # Set to True to use a 7-segment display via I2C
10-
USE_BUTTONS = False # Set to True to use momentary buttons (connected to RaspberryPi's GPIO pins) to change preset
118
MAX_POLYPHONY = 80 # This can be set higher, but 80 is a safe value
9+
USE_BUTTONS = False # Set to True to use momentary buttons (connected to RaspberryPi's GPIO pins) to change preset
10+
USE_I2C_7SEGMENTDISPLAY = False # Set to True to use a 7-segment display via I2C
11+
USE_SERIALPORT_MIDI = False # Set to True to enable MIDI IN via SerialPort (e.g. RaspberryPi's GPIO UART pins)
1212
USE_SYSTEMLED = False # Flashing LED after successful boot, only works on RPi/Linux

isoimage/maker.sh

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ mount -v -t ext4 -o sync /dev/mapper/loop0p2 sdcard
1919
mount -v -t vfat -o sync /dev/mapper/loop0p1 sdcard/boot
2020
echo root:root | chroot sdcard chpasswd
2121
chroot sdcard apt update
22-
chroot sdcard apt install -y build-essential python-dev python-pip cython python-smbus python-numpy python-rpi.gpio python-serial portaudio19-dev alsa-utils git libportaudio2 libffi-dev raspberrypi-kernel ntpdate
22+
chroot sdcard apt install -y build-essential python-dev python-pip cython python-smbus python-numpy python-rpi.gpio python-serial alsa-utils git libportaudio2 libffi-dev raspberrypi-kernel ntpdate
2323
chroot sdcard pip install rtmidi-python pyaudio cffi sounddevice
2424
chroot sdcard sh -c "cd /root ; git clone https://github.com/josephernest/SamplerBox.git ; cd SamplerBox ; python setup.py build_ext --inplace"
2525
cp -R root/* sdcard
@@ -29,10 +29,6 @@ chroot sdcard systemctl disable regenerate_ssh_host_keys sshswitch
2929
chroot sdcard ssh-keygen -A -v
3030
chroot sdcard systemctl enable ssh
3131
sed -i 's/ENV{pvolume}:="-20dB"/ENV{pvolume}:="-10dB"/' sdcard/usr/share/alsa/init/default
32-
sed -i 's/USE_SERIALPORT_MIDI = False/USE_SERIALPORT_MIDI = True/' sdcard/root/SamplerBox/samplerbox.py
33-
sed -i 's/USE_I2C_7SEGMENTDISPLAY = False/USE_I2C_7SEGMENTDISPLAY = True/' sdcard/root/SamplerBox/samplerbox.py
34-
sed -i 's/USE_BUTTONS = False/USE_BUTTONS = True/' sdcard/root/SamplerBox/samplerbox.py
35-
sed -i 's,SAMPLES_DIR = ".",SAMPLES_DIR = "/media/",' sdcard/root/SamplerBox/samplerbox.py
3632
echo "PermitRootLogin yes" >> sdcard/etc/ssh/sshd_config
3733
echo "alias rw=\"mount -o remount,rw /\"" >> sdcard/root/.bashrc
3834
sync

isoimage/root/boot/cmdline.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
root=/dev/mmcblk0p2 ro rootwait console=tty1 selinux=0 plymouth.enable=0 elevator=deadline bcm2708.uart_clock=3000000
1+
root=/dev/mmcblk0p2 ro rootwait console=tty1 selinux=0 plymouth.enable=0 elevator=deadline

isoimage/root/boot/config.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
dtoverlay=disable-bt
22
device_tree_param=i2c_arm=on
3-
init_uart_clock=2441406
4-
init_uart_baud=38400
53
boot_delay=0
64
disable_splash=1
75
disable_audio_dither=1
Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
[Unit]
22
Description=Starts SamplerBox
3-
DefaultDependencies=false
4-
53
[Service]
64
Type=simple
7-
ExecStart=/root/SamplerBox/samplerbox.sh
5+
ExecStart=/usr/bin/python /root/SamplerBox/samplerbox.py
86
WorkingDirectory=/root/SamplerBox/
9-
107
[Install]
11-
WantedBy=local-fs.target
8+
RequiredBy=basic.target

0 commit comments

Comments
 (0)