HomSpace Forum
Accessing the /samples/ partition, etc. - Printable Version

+- HomSpace Forum (https://homspace.nl/forum)
+-- Forum: SamplerBox (https://homspace.nl/forum/forum-1.html)
+--- Forum: Community (https://homspace.nl/forum/forum-2.html)
+--- Thread: Accessing the /samples/ partition, etc. (/thread-10.html)

Pages: 1 2


Accessing the /samples/ partition, etc. - Ryan Steinbruner - 15-02-21

Hello,

I'm a musician who is trying to build a sampler for my M-Audio USB MIDI keyboard using my Raspberry Pi 3B, a 32GB SD card with the latest version of the SamplerBox image flashed to it, and an audio hat called AUDIO+ from RaspiAudio.  I would like to store all my samples on this SD card, and I would rather not have to use a screen or thumbdrives in order to make this work.  I am also aware that I can control which MIDI triggers switch samples or alter effects by editing the code.

Problem #1) 
I don't know how to set up my audio hat on SamplerBox, as the instructions are for a normal copy of Raspi.
The audio hat I'm using is called AUDIO+ from RaspiAudio. It uses GPIO, and it uses the following pins:
GPIO21, GPIO19, GPIO18, Grnd, 3.3v
The installation instructions tell me to run this on the command line:
Code:
sudo wget -O - script(dot)raspiaudio(dot)com | bash

If I type that without the sudo in SampleBox's terminal, will it add functionality to this external soundcard?



Problem #2)
I cannot figure out how to add samples without using the thumbdrive.  I reserved a 32GB SD card specifically for this project specifically so I wouldn't have to use a thumbdrive, as to have a more compact setup.  I would like to know how to access the /samples/ partition, make it RW, and expanding the partition. I bought a 32GB SD card just for this project, and I really don't want to mess with thumb drives, because there's only a few instruments I'll need for my live performances.

I am grateful and appreciative of any help.  Thank you so much. Smile

- Ryan


RE: Accessing the /samples/ partition, etc. - hdoa - 15-02-21

This is Ryan.  I just registered an account so I can follow this thread and get notifications.  Really grateful for the help and all of the work you've put into this site.

EDIT: Since this site allows links, here are the installation instructions for a normal Pi running on Raspian:
https://pinout.xyz/pinout/raspiaudio_audio#


RE: Accessing the /samples/ partition, etc. - hansehv - 15-02-21

Hi Ryan,
Welcome and thanks for your kind words.
As promised I will try to be of help.

First of all: editing the code itself should almost never be necessary.
Most things should be done via the configuration files. I admit this can look so intimidating that it seems like "changing the code".
But editing should normally be limited to one-time editing of *.txt and *.csv files as indicated in the docs.
I tried seriously to take out the need of editing *.py or *.cpp and such. If however there is good reason for doing so, I appreciate to be informed as this may indicate a missing feature worth adding.

Problem#1
That's right, the missing driver has to be installed in such a way. However as samplerbox is very basic, somewhat more care is needed than with an ordinary linux desktop.
As samplerbox is currently single user=root-only, sudo cannot be used for root privileges as they are default.

This also means caution and making sure to have backups or other means for rollback.
You need to have both boot and root parttions writable (see Commandline access and debugging) and you need to have the box connected (wired/wireless) to a network with an internet connection. Attaching to home network normally does the trick.

I expect that there will be an extra include in /boot/overlays and some changes in /boot/config.txt.
If this works as expected, then in best case scenario samplerbox will recognize the card an pick the right option for routing the sound (high quality cards always have several options).
I expect the the onboard IO (bcm2835) will replaced and not be present anymore.

When starting up by hand, you should see the discovery messages in the console log; points of attention are next messages:
  • Available audio devices: and the "sub"lines following
  • Opened audio device <details> and the "sub"lines following
  • Opened Alsamixer: <details>
As startup is multi-thread, messages of MIDI opening and starting HTTP gui may interfere, that's normal.

Problem#2
For enlarging, the "Can I use the internal sample space..." FAQ points to the build page to which I have nothing to add here except for "yes, this is DIY".  Rolleyes
The FAQ also has guidelines on how to access it

Last remark: allowing links is a bit of an experiment. If it attracks spammers I might turn it of. As for this link, you may have recognized the pin illustrations as I took "connecting peripherals" illustration on the build page from there.


RE: Accessing the /samples/ partition, etc. - hdoa - 16-02-21

Hans, thank you so much for your attention and help on the matter.

When I try to make the boot partition rw from the SamplerBox CLI, I get the message "mount: can't find /boot in /etc/fstab".  Same with the samples partition.  What am I missing? Confused

Also, when I try to install the driver for the audio hat, I get "wget: unable to resolve host address 'script.raspiaudio.com'
I have my pi hooked up directly to my router via ethernet and can access it from my PC, but I am wondering if the pi itself is connected to the internet?


RE: Accessing the /samples/ partition, etc. - noek - 17-02-21

Hi hdoa,
What command did you use, with me it works as documented:
Code:
root@samplerbox:~# ls /samples
0 Demo    1 MidiPlayer  2 Saw  lost+found
root@samplerbox:~# touch /samples/test
touch: cannot touch '/samples/test': Read-only file system
root@samplerbox:~# mount -o remount,rw /samples
root@samplerbox:~# touch /samples/test
root@samplerbox:~# ls /samples
0 Demo    1 MidiPlayer  2 Saw  lost+found  test
Same results for /boot.

As for the internet connection, I'm experiencing the same. In older versions it worked - guess we have to wait for Hans - or someone else who knows.


RE: Accessing the /samples/ partition, etc. - hdoa - 18-02-21

I was apparently using the wrong version of SamplerBox. 

I was using an old 2017 distro from the official site. 

I just downloaded the 2020 one featured on homspace and I am currently attempting to resize the samples partition using fdisk.  However, it's not letting me delete because it says "no partition is defined yet".  Currently working on it.

As for the internet / external soundcard thing, I hope we can get that figured out soon.


RE: Accessing the /samples/ partition, etc. - Ken - 18-02-21

(18-02-21, 01:25)hdoa Wrote: As for the internet / external soundcard thing, I hope we can get that figured out soon.

If you don't have internet access on your Samplerbox, you can save the script in a personal folder on your SD card once you've got read/write control working.  This is also true for any files you might need on that system in the future.

Code:
#!/bin/bash

: <<'DISCLAIMER'

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

This script is licensed under the terms of the MIT license.
Unless otherwise noted, code reproduced herein
was written for this script.

- The PiZeroAudio Crew -

DISCLAIMER

# script control variables

productname="RASPIAUDIO DAC+ and SPEAKER+ models" # the name of the product to install
scriptname="pizeroaudio" # the name of this script
spacereq=1 # minimum size required on root partition in MB
debugmode="no" # whether the script should use debug routines
debuguser="none" # optional test git user to use in debug mode
debugpoint="none" # optional git repo branch or tag to checkout
forcesudo="no" # whether the script requires to be ran with root privileges
promptreboot="no" # whether the script should always prompt user to reboot
mininstall="no" # whether the script enforces minimum install routine
customcmd="yes" # whether to execute commands specified before exit
armhfonly="yes" # whether the script is allowed to run on other arch
armv6="yes" # whether armv6 processors are supported
armv7="yes" # whether armv7 processors are supported
armv8="yes" # whether armv8 processors are supported
raspbianonly="no" # whether the script is allowed to run on other OSes
osreleases=( "Raspbian" ) # list os-releases supported
oswarning=( "Debian" "Kano" "Mate" "PiTop" "Ubuntu" ) # list experimental os-releases
osdeny=( "Darwin" "Kali" ) # list os-releases specifically disallowed

FORCE=$1
DEVICE_TREE=true
ASK_TO_REBOOT=false
CURRENT_SETTING=false
UPDATE_DB=false

BOOTCMD=/boot/cmdline.txt
CONFIG=/boot/config.txt
APTSRC=/etc/apt/sources.list
INITABCONF=/etc/inittab
BLACKLIST=/etc/modprobe.d/raspi-blacklist.conf
LOADMOD=/etc/modules
DTBODIR=/boot/overlays

# function define

confirm() {
    if [ "$FORCE" == '-y' ]; then
        true
    else
        read -r -p "$1 [y/N] " response < /dev/tty
        if [[ $response =~ ^(yes|y|Y)$ ]]; then
            true
        else
            false
        fi
    fi
}

prompt() {
        read -r -p "$1 [y/N] " response < /dev/tty
        if [[ $response =~ ^(yes|y|Y)$ ]]; then
            true
        else
            false
        fi
}

success() {
    echo -e "$(tput setaf 2)$1$(tput sgr0)"
}

inform() {
    echo -e "$(tput setaf 6)$1$(tput sgr0)"
}

warning() {
    echo -e "$(tput setaf 1)$1$(tput sgr0)"
}

newline() {
    echo ""
}

progress() {
    count=0
    until [ $count -eq $1 ]; do
        echo -n "..." && sleep 1
        ((count++))
    done
    echo
}
sudocheck() {
    if [ $(id -u) -ne 0 ]; then
        echo -e "Install must be run as root. Try 'sudo ./$scriptname'\n"
        exit 1
    fi
}

sysclean() {
    sudo apt-get clean && sudo apt-get autoclean
    sudo apt-get -y autoremove &> /dev/null
}

sysupdate() {
    if ! $UPDATE_DB; then
        echo "Updating apt indexes..." && progress 3 &
        sudo apt-get update 1> /dev/null || { warning "Apt failed to update indexes!" && exit 1; }
        echo "Reading package lists..."
        progress 3 && UPDATE_DB=true
    fi
}

sysupgrade() {
    sudo apt-get upgrade
    sudo apt-get clean && sudo apt-get autoclean
    sudo apt-get -y autoremove &> /dev/null
}

sysreboot() {
    warning "Some changes made to your system require"
    warning "your computer to reboot to take effect."
    newline
    if prompt "Would you like to reboot now?"; then
        sync && sudo reboot
    fi
}

arch_check() {
    IS_ARMHF=false
    IS_ARMv6=false

    if uname -m | grep "armv.l" > /dev/null; then
        IS_ARMHF=true
        if uname -m | grep "armv6l" > /dev/null; then
            IS_ARMv6=true
        fi
    fi
}

os_check() {
    IS_RASPBIAN=false
    IS_MACOSX=false
    IS_SUPPORTED=false
    IS_EXPERIMENTAL=false

    if [ -f /etc/os-release ]; then
        if cat /etc/os-release | grep "Raspbian" > /dev/null; then
            IS_RASPBIAN=true && IS_SUPPORTED=true
        fi
        if command -v apt-get > /dev/null; then
            for os in ${osreleases[@]}; do
                if cat /etc/os-release | grep $os > /dev/null; then
                    IS_SUPPORTED=true && IS_EXPERIMENTAL=false
                fi
            done
            for os in ${oswarning[@]}; do
                if cat /etc/os-release | grep $os > /dev/null; then
                    IS_SUPPORTED=false && IS_EXPERIMENTAL=true
                fi
            done
            for os in ${osdeny[@]}; do
                if cat /etc/os-release | grep $os > /dev/null; then
                    IS_SUPPORTED=false && IS_EXPERIMENTAL=false
                fi
            done
        fi
    fi
    if [ -d ~/.kano-settings ] || [ -d ~/.kanoprofile ]; then
        IS_RASPBIAN=false
        for os in ${oswarning[@]}; do
            if [ $os == "Kano" ]; then
                IS_SUPPORTED=false && IS_EXPERIMENTAL=true
            fi
        done
        for os in ${osdeny[@]}; do
            if [ $os == "Kano" ]; then
                IS_SUPPORTED=false && IS_EXPERIMENTAL=false
            fi
        done
    fi
    if [ -f ~/.pt-dashboard-config ] || [ -d ~/.pt-dashboard ]; then
        IS_RASPBIAN=false
        for os in ${oswarning[@]}; do
            if [ $os == "PiTop" ]; then
                IS_SUPPORTED=false && IS_EXPERIMENTAL=true
            fi
        done
        for os in ${osdeny[@]}; do
            if [ $os == "PiTop" ]; then
                IS_SUPPORTED=false && IS_EXPERIMENTAL=false
            fi
        done
    fi
    if [ -d ~/.config/ubuntu-mate ]; then
        for os in ${osdeny[@]}; do
            if [ $os == "Mate" ]; then
                IS_SUPPORTED=false && IS_EXPERIMENTAL=false
            fi
        done
    fi
    if uname -s | grep "Darwin" > /dev/null; then
        IS_MACOSX=true
        for os in ${osdeny[@]}; do
            if [ $os == "Darwin" ]; then
                IS_SUPPORTED=false && IS_EXPERIMENTAL=false
            fi
        done
    fi
}

raspbian_check() {
    IS_SUPPORTED=false
    IS_EXPERIMENTAL=false

    if [ -f /etc/os-release ]; then
        if cat /etc/os-release | grep "/sid" > /dev/null; then
            IS_SUPPORTED=true && IS_EXPERIMENTAL=false
        elif cat /etc/os-release | grep "stretch" > /dev/null; then
            IS_SUPPORTED=true && IS_EXPERIMENTAL=false
        elif cat /etc/os-release | grep "jessie" > /dev/null; then
            IS_SUPPORTED=true && IS_EXPERIMENTAL=false
        elif cat /etc/os-release | grep "wheezy" > /dev/null; then
            IS_SUPPORTED=true && IS_EXPERIMENTAL=false
        else
            IS_SUPPORTED=true && IS_EXPERIMENTAL=false
        fi
    fi
}

: <<'MAINSTART'

Perform all global variables declarations as well as function definition
above this section for clarity, thanks!

MAINSTART

# checks and init

arch_check
os_check

if [ $debugmode != "no" ]; then
    echo "USER_HOME is $USER_HOME" && newline
    echo "IS_RASPBIAN is $IS_RASPBIAN"
    echo "IS_MACOSX is $IS_MACOSX"
    echo "IS_SUPPORTED is $IS_SUPPORTED"
    echo "IS_EXPERIMENTAL is $IS_EXPERIMENTAL"
    newline
fi

if ! $IS_ARMHF; then
    warning "This hardware is not supported, sorry!"
    warning "Config files have been left untouched"
    newline && exit 1
fi

if $IS_ARMv8 && [ $armv8 == "no" ]; then
    warning "Sorry, your CPU is not supported by this installer"
    newline && exit 1
elif $IS_ARMv7 && [ $armv7 == "no" ]; then
    warning "Sorry, your CPU is not supported by this installer"
    newline && exit 1
elif $IS_ARMv6 && [ $armv6 == "no" ]; then
    warning "Sorry, your CPU is not supported by this installer"
    newline && exit 1
fi

if [ $raspbianonly == "yes" ] && ! $IS_RASPBIAN;then
        warning "This script is intended for Raspbian on a Raspberry Pi!"
        newline && exit 1
fi

if $IS_RASPBIAN; then
    raspbian_check
    if ! $IS_SUPPORTED && ! $IS_EXPERIMENTAL; then
        newline && warning "--- Warning ---" && newline
        echo "The $productname installer"
        echo "does not work on this version of Raspbian."
        echo "Check https://github.com/$gitusername/$gitreponame"
        echo "for additional information and support"
        newline && exit 1
    fi
fi

if ! $IS_SUPPORTED && ! $IS_EXPERIMENTAL; then
        warning "Your operating system is not supported, sorry!"
        newline && exit 1
fi

if $IS_EXPERIMENTAL; then
    warning "Support for your operating system is experimental. Please visit"

    newline
fi

if [ $forcesudo == "yes" ]; then
    sudocheck
fi

newline
echo "This script will install everything needed to use"
echo "$productname"
newline


if confirm "Do you wish to continue?"; then

    newline
    echo "Checking hardware requirements..."

    if [ -e $CONFIG ] && grep -q "^device_tree=$" $CONFIG; then
        DEVICE_TREE=false
    fi

    if $DEVICE_TREE; then

        newline
        echo "Adding Device Tree Entry to $CONFIG"

        if [ -e $CONFIG ] && grep -q "^dtoverlay=hifiberry-dac$" $CONFIG; then
            echo "dtoverlay already active"
        else
            echo "dtoverlay=hifiberry-dac" | sudo tee -a $CONFIG
            ASK_TO_REBOOT=true
        fi

        if [ -e $BLACKLIST ]; then
            newline
            echo "Commenting out Blacklist entry in "
            echo "$BLACKLIST"
            sudo sed -i -e "s|^blacklist[[:space:]]*i2c-bcm2708.*|#blacklist i2c-bcm2708|" \
                        -e "s|^blacklist[[:space:]]*snd-soc-pcm512x.*|#blacklist snd-soc-pcm512x|" \
                        -e "s|^blacklist[[:space:]]*snd-soc-wm8804.*|#blacklist snd-soc-wm8804|" $BLACKLIST &> /dev/null
        fi
    else
        newline
        echo "No Device Tree Detected, not supported"
        newline
        exit 1
    fi

    if [ -e $CONFIG ] && grep -q -E "^dtparam=audio=on$" $CONFIG; then
        bcm2835off="no"
        newline
        echo "Disabling default sound driver"
        sudo sed -i "s|^dtparam=audio=on$|#dtparam=audio=on|" $CONFIG &> /dev/null
        if [ -e $LOADMOD ] && grep -q "^snd-bcm2835" $LOADMOD; then
            sudo sed -i "s|^snd-bcm2835|#snd-bcm2835|" $LOADMOD &> /dev/null
        fi
        ASK_TO_REBOOT=true
    elif [ -e $LOADMOD ] && grep -q "^snd-bcm2835" $LOADMOD; then
        bcm2835off="no"
        newline
        echo "Disabling default sound module"
        sudo sed -i "s|^snd-bcm2835|#snd-bcm2835|" $LOADMOD &> /dev/null
        ASK_TO_REBOOT=true
    else
        newline
        echo "Default sound driver currently not loaded"
        bcm2835off="yes"
    fi

    echo "Configuring sound output"
    if [ -e /etc/asound.conf ]; then
        if [ -e /etc/asound.conf.old ]; then
            sudo rm -f /etc/asound.conf.old
        fi
        sudo mv /etc/asound.conf /etc/asound.conf.old
    fi
    sudo echo -e "pcm.raspiaudio{\ntype softvol\n" > ~/asound.conf
    sudo echo -e "slave.pcm \042plughw:0\042\n " >> ~/asound.conf
    sudo echo -e "control.name \042Master\042\n " >> ~/asound.conf
    sudo echo -e "control.card 0 }" >>~/asound.conf
    sudo echo -e " pcm.!default { \n" >>~/asound.conf
    sudo echo -e "type plug \n" >>~/asound.conf
    sudo echo -e "slave.pcm  \042raspiaudio\042 \n}\n" >>~/asound.conf

    sudo mv ~/asound.conf /etc/asound.conf

    if [ $bcm2835off == "yes" ]; then
        newline
        echo "We can now test your $productname"
        warning "Set your speakers at a low volume!"
        if confirm "Do you wish to test your system now?"; then
            echo "Testing..."
            speaker-test -l5 -c2 -t wav
        fi
    fi
    newline && success "All done!" && newline
    echo "Enjoy your new $productname!" && newline

    if [ $promptreboot == "yes" ] || $ASK_TO_REBOOT; then
        sysreboot
    fi
else
    newline
    echo "Aborting..."
    newline
fi

exit 0



RE: Accessing the /samples/ partition, etc. - noek - 18-02-21

(18-02-21, 01:25)hdoa Wrote: As for the internet / external soundcard thing, I hope we can get that figured out soon.

I think Hans answered internet thing in your separate thread on this.


RE: Accessing the /samples/ partition, etc. - hansehv - 18-02-21

Thanks noek.
Ryan, I finally found some time to look at the installation script.
Conclusion: it might fail on samplerbox but no matter.....
...you don't need it, as the raspaudio+ is HifiBerry DAC compatible which comes with the image.
Only thing you have to do is adapt the /boot/config.txt, I've snipped the applicable part:
Code:
# for onboard, hdmi or usb dacs uncomment next parm:
dtparam=audio=on
#
# for hifiberry (compatible) dacs uncomment appropriate parm:
#dtoverlay=hifiberry-dac
#dtoverlay=hifiberry-dacplus

should be changed for disabling onboard and enabling the proper hifiberry compatible:
Code:
# for onboard, hdmi or usb dacs uncomment next parm:
#dtparam=audio=on
#
# for hifiberry (compatible) dacs uncomment appropriate parm:
dtoverlay=hifiberry-dac
#dtoverlay=hifiberry-dacplus
and reboot for testing....


RE: Accessing the /samples/ partition, etc. - hdoa - 19-02-21

Okay, so I accessed the SD card from my Linux machine. 

I made the changes you listed in the configuration file.  Commented out the "dtparam" one, and un-commented the "hifi" one.

I also used GParted to delete the old samples partition and create a new one with the correct settings described in the guide.  However, I used FAT32 instead of EXT4 because I wanted to be able to access my samples folder in Windows. 

I believe I set everything up correctly, but upon booting, I got the following errors:

Failed to start Update UTMP about System Boot/Shutdown
Failed to start Load/Save Random Seed
Failed to start Various fixups to make systemmd work better on Debian.
Failed to mount /samples
Failed to start Update UTMP about System Boot/Shutdown

When I try to run to run speaker-test, it says "Playback open error: -16,Device or resource busy"

When I try to play MIDI notes, naturally, nothing happens.

Really sad right now.  I thought I was finally breaking ground, but now I feel even more lost than before.  Really appreciate all the help and comments, you guys are great.  I hope we can get this working.