Skip to content

Commit

Permalink
Python 3 support (requires 3.7), and various modifications, included …
Browse files Browse the repository at this point in the history
…some from PR #47
  • Loading branch information
josephernest committed Aug 9, 2022
1 parent f692af0 commit ea16c5f
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 111 deletions.
16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,36 @@ Website: [www.samplerbox.org](https://www.samplerbox.org)

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.

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

~~~
sudo apt-get update ; sudo apt-get -y install git python-dev python-pip python-numpy cython python-smbus libportaudio2 libffi-dev
sudo pip install rtmidi-python cffi sounddevice
sudo apt-get update
sudo apt-get -y install git python3-pip python3-smbus python3-numpy libportaudio2 raspberrypi-kernel
sudo pip3 install cython rtmidi-python cffi sounddevice pyserial
~~~

2. Download SamplerBox and build it with:

~~~
git clone https://github.com/josephernest/SamplerBox.git
cd SamplerBox ; sudo python setup.py build_ext --inplace
cd SamplerBox
sudo python3 setup.py build_ext --inplace
~~~

3. Run the soft with `python samplerbox.py`.
3. Run the soft with `sudo python3 samplerbox.py`.

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

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


[How to use it](#howto)
----

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

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


[ISO image](#isoimage)
----
Expand Down
6 changes: 3 additions & 3 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

AUDIO_DEVICE_ID = 2 # change this number to use another soundcard
SAMPLES_DIR = "." # The root directory containing the sample-sets. Example: "/media/" to look for samples on a USB stick / SD card
USE_SERIALPORT_MIDI = False # Set to True to enable MIDI IN via SerialPort (e.g. RaspberryPi's GPIO UART pins)
USE_I2C_7SEGMENTDISPLAY = False # Set to True to use a 7-segment display via I2C
USE_BUTTONS = False # Set to True to use momentary buttons (connected to RaspberryPi's GPIO pins) to change preset
MAX_POLYPHONY = 80 # This can be set higher, but 80 is a safe value
USE_BUTTONS = False # Set to True to use momentary buttons (connected to RaspberryPi's GPIO pins) to change preset
USE_I2C_7SEGMENTDISPLAY = False # Set to True to use a 7-segment display via I2C
USE_SERIALPORT_MIDI = False # Set to True to enable MIDI IN via SerialPort (e.g. RaspberryPi's GPIO UART pins)
USE_SYSTEMLED = False # Flashing LED after successful boot, only works on RPi/Linux
6 changes: 1 addition & 5 deletions isoimage/maker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ mount -v -t ext4 -o sync /dev/mapper/loop0p2 sdcard
mount -v -t vfat -o sync /dev/mapper/loop0p1 sdcard/boot
echo root:root | chroot sdcard chpasswd
chroot sdcard apt update
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
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
chroot sdcard pip install rtmidi-python pyaudio cffi sounddevice
chroot sdcard sh -c "cd /root ; git clone https://github.com/josephernest/SamplerBox.git ; cd SamplerBox ; python setup.py build_ext --inplace"
cp -R root/* sdcard
Expand All @@ -29,10 +29,6 @@ chroot sdcard systemctl disable regenerate_ssh_host_keys sshswitch
chroot sdcard ssh-keygen -A -v
chroot sdcard systemctl enable ssh
sed -i 's/ENV{pvolume}:="-20dB"/ENV{pvolume}:="-10dB"/' sdcard/usr/share/alsa/init/default
sed -i 's/USE_SERIALPORT_MIDI = False/USE_SERIALPORT_MIDI = True/' sdcard/root/SamplerBox/samplerbox.py
sed -i 's/USE_I2C_7SEGMENTDISPLAY = False/USE_I2C_7SEGMENTDISPLAY = True/' sdcard/root/SamplerBox/samplerbox.py
sed -i 's/USE_BUTTONS = False/USE_BUTTONS = True/' sdcard/root/SamplerBox/samplerbox.py
sed -i 's,SAMPLES_DIR = ".",SAMPLES_DIR = "/media/",' sdcard/root/SamplerBox/samplerbox.py
echo "PermitRootLogin yes" >> sdcard/etc/ssh/sshd_config
echo "alias rw=\"mount -o remount,rw /\"" >> sdcard/root/.bashrc
sync
Expand Down
2 changes: 1 addition & 1 deletion isoimage/root/boot/cmdline.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
root=/dev/mmcblk0p2 ro rootwait console=tty1 selinux=0 plymouth.enable=0 elevator=deadline bcm2708.uart_clock=3000000
root=/dev/mmcblk0p2 ro rootwait console=tty1 selinux=0 plymouth.enable=0 elevator=deadline
2 changes: 0 additions & 2 deletions isoimage/root/boot/config.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
dtoverlay=disable-bt
device_tree_param=i2c_arm=on
init_uart_clock=2441406
init_uart_baud=38400
boot_delay=0
disable_splash=1
disable_audio_dither=1
Expand Down
7 changes: 2 additions & 5 deletions isoimage/root/etc/systemd/system/samplerbox.service
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
[Unit]
Description=Starts SamplerBox
DefaultDependencies=false

[Service]
Type=simple
ExecStart=/root/SamplerBox/samplerbox.sh
ExecStart=/usr/bin/python /root/SamplerBox/samplerbox.py
WorkingDirectory=/root/SamplerBox/

[Install]
WantedBy=local-fs.target
RequiredBy=basic.target
Loading

0 comments on commit ea16c5f

Please sign in to comment.