A few short news again:
Many people have added a lot of features to SamplerBox in the last months. Big up to Erik, HansEhv, AlexM, Pavel, Rémi, Huskypop and many others! Now it's time to merge all these great things. That's what we're gonna work on during the next weeks.
- Side project: I've just released TalkTalkTalk, a small easy-to-install web chat, that you can host on your own server.
Huskypop's Mellotron made with SamplerBox.
Summer 2016 news!
A few short news:
I'v been busy the last months with a very exciting new DSP project: DrumExtract, a VST plugin that extracts drums from an audio mix! Listen to audio examples on the YellowNoiseAudio website!
Since the beginning of the project, I thought it was impossible to use the Raspberry Pi's built-in audio chip, because it always led to stuttering sound. This is wrong, I've now been able to make SamplerBox work with the Raspberry Pi's internal sound chip. Thus, a USB DAC is no longer mandatory. It is still recommanded for better audio quality, but not mandatory. More news about this in a future update!
Technical reason: I replaced
pyaudio(which has some bugs somewhere, note: this is not the first bug I discover in this library, there's also one leading to crashes on Winows platform, when devicenames use non-standard characters such as é or à!) by the module
python-sounddevice, which is equivalent (a python wrapper for PortAudio) but cleaner.
- A RaspberryPi 3 ready-to-use ISO image is now available here.
How to power the RaspberryPi for more than 7 hours with a single 18650 battery
Get a good 18650 battery by a dealer who knows what he's speaking about (and who has done some test to be able to tell it's not fake batteries).
Maybe I was just unlucky, but the red UltraFire battery I got from eBay was just crap. The good one was a Sanyo/EVVA 3400 Protégé got from PuissanceLed:
Get this 1€ battery charging board, and use this wiring:
- Ready to run for more than 7 hours!
During this test, the SamplerBox software was constantly running (so there was a non-negligible CPU usage), and these devices were connected to the RaspberryPi, taking some power:
- a USB DAC (for better audio quality),
- a USB MIDI keyboard (Akai LPK25),
- a USB SD card reader,
- a 7-segment 4-digits display,
so this means it could even be longer without these devices! I also read somewhere that it's possible to completely disable USB hubs, this could be useful for some other project.
And some other ideas for even longer battery-life (see this discussion):
- CPU throttling (allowing to decrease from 700Mhz to as low as 100Mhz when the RaspberryPi doesn't need much power),
- disable Ethernet port,
- plus many other ideas in this discussion...
Battery-powered, good news
In previous blog posts, I shared my disappointment because I wasn't able to have a decent battery life, when trying to power the RaspberryPi with battery. I couldn't get more than 1.5 hours with a 18650 battery (for those who don't know these: it's a 3.7V battery, a bit larger and higher capacity than standard AA batteries).
I was a bit sad because this meant to have to abandon the concept of portability, of being able to play outside with SamplerBox. Or to have to go for solutions like using many batteries (2 or 4) or big USB powerbanks, and I didn't like this idea. I didn't like it for this reason: a smartphone is able to run for one day or more, also runs Linux (Android uses Linux kernel), with a very small battery, so I wanted to be able to find a similar solution in terms of battery-size and battery-life, with a RaspberryPi.
Now there's good news.
Today I did some new tests, with a new 18650 battery that I bought from PuissanceLed. Waw, this guys knows what he's speaking about, he did some extensive benchmarks before selling his batteries! I chose the Sanyo 3400 protégé, which costs 13,50€.
And the result is great: the RaspberryPi ran for a little bit more than 7 hours with a single battery, before it shut down (and tried to reboot, but the battery was empty).
Why was the result so poor (only 1.5 hours) with the previous 18650 battery that I tried? Probably because it was a cheap fake 18650 battery from eBay. My conclusions here about this subject.
What we have done and what we haven't done (yet)
After a few months on this project, a lot of feedback (thanks everyone!) and some long holidays in Italia with both sun and rain (yes this is our tent but surprisingly all was fine 2 hours later!),
it's now time to think about the big picture of the project (by the way, bigpicture.bi is another project of mine: if you like mind maps, or an infinite panning and zooming whiteboard, you're gonna like it!).
What was the initial goal of SamplerBox?
- to be able to jam anywhere with a portable instrument,
- for hours,
- without having to connect many cables and many other stuff, i.e. the goal was all-in-oneness,
- to have great sound quality, low latency, high polyphony,
- to be able to load 500MB+ piano sample sets,
- to have fast boot like on every normal synthesizer.
What is currently achived? What is not?
I think #4 and #5 are done, thanks to the RaspberryPi, a good cheap USB DAC, and my not-too-bad code (I spent some time on code optimization to allow high polyphony). After some work, #6 is now ok as well.
About #3, my dream would be to be able to build an all-in-one keyboard + SamplerBox unit, like this (or maybe 3 octaves instead?):
Let's call it SamplerBox Keyboard. I'd like to have your feedback about this! What do you think? Would you like such a unit?
Anyway, this is probably for later.
Now the main problem for me is #2 : if we want many hours of battery life, we need expensive and/or big size batteries. I don't like this idea. Maybe we need to change the whole board: RaspberryPi is cool but not for having the device run for 10+ hours with a 5.5cm x 4cm x 0.5cm battery (the size of my phone's battery):
So right now my main question is: is there a board that is able to run Linux, is small-sized, has some good CPU, and can run 10+ hours on battery? Yes smartphones are like this! Does this exist in the form of a board (in the fashion of Arduino, RaspberryPi, Teensy, etc.)? I need your help about this!
About #1, I'd need to experiment more with small-sized loudspeakers.
I'm often asked this question: “Do I really need to build the whole thing (electronic parts, etc.) to be able to use SamplerBox?” In fact, no.
The project has been designed in such a way that, you can start small, and add more parts then, if you like it. Here are various ways (that all work!) of using SamplerBox:
“I'll just use a bare RaspberryPi + SamplerBox program. No enclosure, no electronic parts for me!”
“I would like to have MIDI IN, so I'll just add the small MIDI circuit, but nothing else (no LED display, no buttons etc.)”
“I would like to build the whole thing, but without the wooden enclosure, and without the MIDI IN circuit (because all my keyboards are USB, so I won't use MIDI IN plug)”
- “I will build the whole thing and even add more features!”
Of course, we'll be happy here if you choose #4, but any other choice will work...
Help wanted for...
Some features that would be cool:
Battery-powered: the goal would be to have a really portable instrument, with which you can jam outside!
I already tried with a single 3.7V 18650 battery:
It worked well for more than 1 hour.
But in order to have a really cool user experience, we need a circuit that would automatically charge the battery when a phone charger is plugged in (case #2 below), and that automatically switches to battery-powering when the charger is removed (case #1). The switching should be done without any 1-second-power-interruption (that would reboot the Raspberry Pi)!
And a last thing: we should be able to detect "Low battery" and print it on the main display.
Help wanted on these topics!
- Loudspeaker: find a small-sized loudspeaker + an amplifier that could be embedded in the box. LM386-amp or PAM8403-amp? I already tried a bit, but not really happy with the result.
Should the headphones output also be amplified? If not, we need to turn the amp off when headphones are plugged, and turn it on when using loudspeakers (i.e. when no headphones are plugged).
Again, help wanted for this part!
How to create a sample set
Here is a picture showing how to create a sample set, and where to put it:
These are the available keywords in the
%notename: C1, C2, C3, D#3, F#4, etc.
%midinote: 36, 48, 60, 63, 78, etc.
%velocity: 1, 43, 72, 127 (maximum), etc.
... and a ready-to-use image file (containing the OS/software, that you put on a microSD card and insert into the Raspberry Pi).
Tech article: how to have a very fast boot time with Raspberry Pi
First of all, if you're into music, and not especially interested in programming / Linux, etc., don't read this article.
Is it possible to have your Raspberry Pi app running less than 8 seconds after you plugged the power cord? Or less than 3 seconds after the Linux boot has started?
How to do that?
It's simple: you need systemd, the new boot management system in Linux, instead of the previous standard
sysvinit. It has now become the new standard on recent distributions like Raspbian Jessie, ArchLinux, etc.
Here is how to create a service that will run as soon as possible.
Just create a file
[Unit] Description=Starts SamplerBox DefaultDependencies=false # Very important! Without this line, the service # would wait until networking.service # has finished initialization. This could add 10 # more seconds because of DHCP, IP attribution, etc. [Service] Type=simple ExecStart=/root/SamplerBox/samplerbox.sh WorkingDirectory=/root/SamplerBox/ [Install] WantedBy=local-fs.target
and then do:
systemctl enable samplerbox
On next reboot, it will start!
systemd has really great built-in tools to tune the boot time:
systemd-analyzewill print the boot time,
systemd-analyze blamewill print the list of the most time-consuming services in decreasing order! Just tune the first listed-services, and you will solve 80% of your boot time problem. Another great example of the Pareto principle.
systemd-analyze plot > plot.svg: this will display in a graphical way when all the services start. Really great. As it's a SVG file (you can view it in your browser), you can even CTRL+F and search where the relevant services are.
So, as a summary, if you want fast boot time on your RaspberryPi, first install a Raspbian Jessie distribution, or any other distribution using
systemd. Then start the optimization with