Tag Archives: node.js

Volumio: a Raspberry Pi jukebox

Volumio playing aerodynamisk neger

Last Sunday, I spent some time tinkering with my Raspberry Pi 3, trying to get some sort of jukebox software up and running.

I finally settled on something called Volumio. It is a complete distribution that you install on the Pi and then it becomes a machine that plays many audio formats and that you can control from other devices, using a web interface.

And thanks to the Raspberry Pi 3’s WiFi, I just need to connect the audio jack and the power cable, and then the little machine can hide under the table with the rest of cables and other devices I don’t want to look at generally (NAS, modem, etc).

Volumio is installed by flashing a complete distribution onto a mini SD card. I had a small 4GB one roaming around so I used that. It’s cool because I can just swap SD cards and boom! I have a completely new environment without destroying the previous one.

The “official stable” builds that you’re directed to from their website won’t work with the Pi 3. They get stuck at the colourful loading pattern. I found someone had had the same problem, and the solution was to flash another image for Volumio 2 RC2. I flashed this new version, which is very hard to locate unless you know that such a thing exists or read the forum, and the initial boot didn’t show up the device on Bonjour, but after a reboot I could see it and start using it.

I configured it using the web interface, accessible at volumio.local. I told it to use WiFi (it worked!) and also to use my NAS music library (which also worked!). Then I shut it down again, moved everything out of my desk, and turned it on again to enjoy some music.

Apparently the initial Volumio front-end was built with PHP. Now they are rebuilding everything from scratch as Volumio 2, using Node.js, Socket.IO and Angular. I was excited about the node.js bit! But although there’s plenty of documentation around, I felt like I couldn’t understand where things were in the source, in the distribution, how to get a developer environment running, etc. Maybe it’s because I came back from holidays on Saturday and I’m still pretty jetlagged and my brain is not very functional yet, but maybe it’s also for the best: I surely don’t need to contribute to yet another project.

Anyway, I have a working jukebox. It can even play modules! It’s a bit basic at points (e.g. you cannot navigate by ‘genre’ or other MP3 metatags) but it is getting the job done so I’m happy.

Polyglot tracker module data decrunching, processing and crunching

I was sorting out a bunch of old digital files and folders and was quite amused at the realisation that it seems like I have written some sort of tracker module converter or reader in pretty much every programming language I’ve ever used.

NOTE: a tracker is a music creation program, and a module is how their files are called—they’re tightly optimised compressed binary files and use all sorts of tricks to save data.

Other people write To-Do apps to learn new languages, and I guess I write tracker module conversion tools? 🙃

So, in order of creation, as far as I can remember:

2005: C++: IT to events (in XML)

I wrote a utility in C++ to pre-process and parse pattern data from Impulse Tracker’s IT files, which would then be output as an XML file with event data, and then the C++ executable would use tinyxml to load the file. I am not entirely sure of why I didn’t just incorporate this event processing and reading directly into the executable instead of doing that at build time—I think I either didn’t have enough time to finish the exporter and I ended up generating the important events with Audacity or something like that, or my parser was very slow and I didn’t want the demo to take ages to load.

I can’t find this code, but I remember it was very buggy and I wasn’t progressing very fast. I wrote about it back then! There was a lot of confusion and non-written knowledge around the tracking format that I finally understood asking other people for help (e.g. how to calculate how much time do each row and each ‘tick’ take). Also, lots of segmentation faults and time spent thinking about memory and string allocations! And I was using the wrong tool for the job.

GitHub and Google Code didn’t even exist back then and SourceForge was terrible, so this is probably collecting digital dust in some folder.

2007: Ruby: XM to events

Apparently I also wrote a Fast Tracker’s XM to timed event utility in Ruby because I was going to work with a musician that used XM (hi JosSs!) and I was so into Ruby as server side and general utility language back then—the demo was going to be built in Flash with probably ActionScript 2.

I actually didn’t finish the demo, therefore the exporter is quite incomplete and I haven’t bothered publishing it, but it was interesting to use Ruby to process binary data from a file in a sort of stream like way.

In absence of a demo, here’s my favourite song from JosSs:

2008: PHP: IT to events (in a .h file)

Another iteration of this event list idea was to parse the data with PHP and generate a song.h file containing a big data array to be used in 64k intros, like this one.

I can’t find the code, but if I remember correctly, the nicest aspect of building this was that I could use some sort of text template to generate the .h file, and since string manipulations are way easier with PHP than with C, I got to the point where I wanted to be really quickly and without tons of segfaults.

2009: PHP: XRNS to MOD

I found another twist on my data conversion efforts: xrns2mod takes a Renoise song and converts it into an Amiga MOD file.

This is not a trivial conversion, as Renoise files are XML based and the player is significantly evolved compared to the MOD format: it can have a lot of channels, and more than one track per channel, plus arbitrary length patterns, plus a lot of instruments, and more than one sample per instrument, etc, whereas the most basic MOD files only have 4 tracks, use a limited note range, different base frequencies, less sample effects, and lesser quality samples, etc. So it’s not just moving numbers from one place to another.

I think I wanted to enter some MOD contest but I found all the MOD trackers quite uncomfortable compared to Renoise, and I wanted to have the best of both worlds: ease of use and also entering the contest. It’s incomplete and quite hardcoded in places, but it was already converting files quite decently the last time I ran it, so I put it on GitHub, just in case it maybe helps someone. Maybe.

Of course, minutes after I published it I found XRNS2XMOD, a similar tool which seems more complete as it also exports to XM in addition of MOD, but it requires Mono and what not.

~2010: Python + Lua: XRNS to events (in a .lua file)

I wrote an exporter in Python for generating a list of timed XRNS events and use them in a demo for ~~incredible synchronisation~~. The demo was run with Luisita which was my programmable graphics environment built with Lua and C++, and since the exporter generated a .lua file, it was very easy to load it all into an array like object at runtime.

This was used in this demo — as you can see the visuals are tightly related to the music:

I later tried to port this demo to WebGL, but I never finished it… perhaps I should just share the code for whoever was interested. It was a bit challenging to migrate because I was using OpenGL immediate mode in the Luisita version, so I needed to change my mental paradigms to WebGL/three.js’s and also write a shader or two to make it look as I wanted it to look… also those were a ton of events that I wanted to send to JavaScript, so my naive initial attempts were making the Garbage Collector work a lot more than it should have worked.

Funnily enough I remember being frustrated with not having tweening in the Lua version, but it could be ‘easy’ to add it to the web version using tween.js. But it’s not going to happen.

2013: node.js: XRNS to JSON

I also wrote a node.js module for extracting XRNS data into something the browser could use more easily (i.e. JSON). I guess not many people are using it or are interested in it, because 3 years later I haven’t heard of anyone improving or using it, but if you want you can install it with npm:

npm install renoise

I used this to generate the events and note data for the slides for my JSConf.EU 2013 talk in which I programmed virtual instruments to play a tracked song in the browser, built their interfaces with Web Components and also used hardware controlled/read with Open Sound Control and node.js! Yay to mixing everything together! 😎

Here’s the video starting with the actual demo:

Well, I hope you have enjoyed this tour, and remember to always use the best tool for the job 😉

 

A first for everything: Greece, Denmark, Norway

Writing this with a very slow connection in Thessaloniki, Greece (ahhh, hotel internet).

I am very excited that my Greek studies are finally coming in handy and so I can read the street signs even if they’re written using the Greek alphabet. It sort of reminded me to last year when I was in Hong Kong and couldn’t read the signs… except now I can! Yay!

I arrived yesterday after a terribly early flight–but then it was well past noon because of the +2h timezone.

Kostas, one of the organisers of DEVit, helped me get a SIM card and he was OK with me telling the world that it took us an hour and a half to get it working with data, because all of the processes they require. I think we did three queues and had time to go for lunch and go back. We also had to enable the Greek keyboard on my phone in order to send a text to the operator containing the Greek ‘y’ (which is not the same as the English keyboard ‘y’), and then it would send me 5 texts in response, confirming whatever it is the ‘y’ meant (I mentally read it as “why?”) with a lot of ALL UPPERCASE Greek paragraphs.

I will just say that in London you can turn up at a shop and buy a SIM with pre-paid credit in 5 minutes, so if I didn’t come from Spain where these processes are similarly ridiculous, I would have been wildly amused.

I re-learnt the most important sentences:

  • παρακαλω = parakalo = please
  • ευχαριστωσ = eucharistos = thanks

and last but not least: χαχαχα = hahaha = jajaja 😃

This is also my first time in Greece so I don’t quite know what to expect, but so far it seems welcoming, nice and sunny, full of interesting things to look at, and also very busy. I did try a gyros and I’m looking forward to trying out the Greek coffee: “cooked!”. Will report.

Side note: for a Spanish speaker, hearing spoken Greek in the background is funny: your brain thinks it can understand it because the cadence is very similar to Spanish and many Spanish words are of Greek origin, but then it starts to pay attention and realises it actually can’t.

I’ll attend the NodeJS/Ruby synergy meetup this evening… be sure to say hi and bring all your synergies and thoughts out of the box!

Next week I’ll be in Denmark for AtTheFrontEnd and the following week will see me in Norway for WebRebels. I’ve not been in either country before, so those will be another two first times for me, but if they’re anything like Sweden or Finland I’ll be more than happy.

I’ll be talking about MediaRecorder and how you can now generate video in the browser, natively, without plug-ins. If you are interested in real time audio or video processing, my talk will be relevant to you 🙂

Securing your self-hosted website with Let’s Encrypt, part 7: a workflow to migrate from HTTP to HTTPS

If you’ve followed along the previous posts you will have noticed that I didn’t get into details when mentioning how to migrate–I just assumed that you knew how to do that and eventually your site would be serving HTTPS using a certificate from Let’s Encrypt.

But turns out that finding a good workflow to do this was one of the things that consumed most of my time initially! That, and the sheer fear of repetition.

Continue reading Securing your self-hosted website with Let’s Encrypt, part 7: a workflow to migrate from HTTP to HTTPS

And the NodeBots from London assembled

I attended today’s NodeBots London event. The theme (?) was “NodeBots of London… Assemble!” and so we did. Compared to the last event I went to in July, which was way more informal, this was considerably bigger (within the venue allowances, of course) with more people and more things to look at and talk about!

First Oli made an introduction to NodeBots (essentially a place where people program hardware using JavaScript, but everything is allowed if you want to), what Johnny Five is and its relationship to node-serial, same for Firmata, and then some interesting tips for software people turned amateur hardware people I hadn’t heard of before, such as:

the case of the generous motor, in which you can fry Arduinos connected to motors without diodes, when the motor keeps spinning even after you stop applying input voltage, and so it becomes a dynamo which feeds current back into the circuit and so… bye bye Arduino which didn’t have any protection
the flappy servo, when you sequence value changes too fast and that results in just some feeble erratic movements instead of the dramatic ones you expected

Then Alex made an introduction to electricity, in general, which was a good refresher for people like me who studied some electrical engineering at uni/school but haven’t used it for reals since then. He explained the basics (V = IxR) and also insisted again on the importance of putting the right resistors in the right place to prevent things getting fried. He used this online circuit.js utility to depict circuits and the flow of current, the voltages at each point of the circuit (in the subcircuits perhaps?)–super useful and I so wish I had had this when I was taking these subjects. Makes things way more intuitive!

And with that—we hacked a bit! Jerome Loï (who had travelled all the way from Paris!) tried to resuscitate my pseudo fried Duemilanove with a shield and a thingy to mount the ATMega168 only, but turns out that it’s such an old board/chip combination that the bootloader firmware is not distributed anymore! So I left it aside and focused on my next task for the day: find out what the components in the kits I have are! With Jerome’s and Alex’s help, and some image searching, all the components were identified in a matter of minutes. Yay!

Then I was not sure of what I wanted to do—I didn’t really want to start a new project although I have a practical idea, and I was also hungry and Oli’s marvelous cooking skills didn’t help to stop making my stomach rumble. Whenever I tried to focus on hardware or research for my idea, a new wave of delicious slow-cooked stew would reach my nose. Ahhh!

Fortunately Charles made a lightning talk describing how he goes from thought to execution using a sketchbook and Autocad instead of thinking by executing as it’s advised in many environments (something like “you don’t want to waste time and effort on build something expensive that might not work, it’s better to think on a sketchbook first”).

Also someone (whose name totally escaped me, ahh, sorry) gave a little intro about a somewhat related event about which I heard about aeons ago but which seemed to have faded out, Dorkbot. It’s been revived, but I’m sad it is held in a) a quite remote location b) at a time I can’t go, because it sounds like the kind of thing I’d like to attend. SAD FACE.

And then it was finally time for lunch. As expected by the opening flavour, it was so yummy! It gave the day a sort of lovely family reunion for Sunday lunch, except we didn’t argue about silly things, but just used the time to catch up on what we had been up to since the last time I visited their maker space, or talk about what we were building today.

After lunch, I spoke to various people such as Andrew Nesbitt of manythings-fame, and learnt new cool things. Such as:

  • Platform.io which is an IDE for “things”, built on Electron… which can work with Arduino and also has code completion! so if you don’t like the Arduino IDE you can use this instead
  • The Arduino board clones such as the Funduino are interesting not only because they might be cheaper than the originals, but also because sometimes they offer cool features such as additional pins for +5 or +GND, which sometimes can make it easier to build something by connecting the wires directly to the board instead of using a breadboard to ‘multiply’ the pins. Or has a toggle to switch between 3.3 and 5V, etc. This very interesting tip came from Jerome, who also told me about this French shop called HackSpark which not only have a lot of those Arduino compatible boards on stock, but also might seem convenient for folks in the UK. And also have a physical shop in Paris! Wow!
  • The Espruino is small. Like… really small! It also transpiles JavaScript to Lua (if I understood this correctly). You write JavaScript instead of Arduino C flavour, and you can get really quick feedback. Sounds like a cool idea for prototyping without having to tether as with Johnny Five—most useful for wearables!

But my super favourite thing I learnt about today is that pencil lead is a conductor! Jerome built a quick and fun pencil based resistor which controlled the speed of a 555 timer connected to a speaker. So effectively he was changing the frequency of an oscillator, and changed the pitch of the sound as he moved the pencil tip closer or further away from the banana connector clipped to the paper. The other end of the pencil had a drawing pin inserted on it and a wire too, effectively closing the circuit! You can see all this in action in this little vine:

We also talked about how I should use an accelerometer and not tilt sensors for my idea (to avoid false positives), and ways to use Web Audio with hardware stuff, and ways to make things that made noise, even how to make a leslie / hammond! So many things that we can make! So exciting!

And there were many other things I learnt but I can’t recall now (hopefully my brain will retain them). Do join one of these NodeBots groups if you can—great things to learn and a very welcoming environment!

It was also cool to devirtualize people I apparently had met already but totally didn’t remember (hi Jerome… sorry), and meet new people! Hopefully next time I will remember 😀

Oh and Jerome, who was one of the main instigators of the NodeBots cat mesmerizer workshop at LXJS 2014, happened to still have a workshop kit in his travelling suitcase and gave it to me… which means I have a laser in my possession!

PEW PEW PEW LASERSSSSS!!!!!!