Virtual Reality (short post)

Some weeks ago I bought an Oculus Quest 2 and beginning experimenting with WebXR technologies. It’s real fun!

Two little projects I’ve put together are these:

1) Painting stuff in 3d: https://greeter.website/pagu-webxr/three/

You can also read the blog post on my company’s blog (in italian): https://blog.dmnk.cloud/index.php/2021/04/01/realta-virtuale-oculus-quest-2/

2) The cubes game: https://app.dmnk.cloud/the-cubes-game/three/

Also here we’ve posted to the company’s blog (still in italian): https://blog.dmnk.cloud/index.php/2021/04/19/the-cubes-game-un-piccolo-gioco-in-realta-virtuale/

Snooper.email (short post)

I’m going to make some really short posts to keep track of projects that I’ve done by myself or within my company in the last weeks.

The first one is about snooper.email, a service we developed to keep track of when your email is opened. It makes use of a tracking pixel (fundamentally an image hosted on your server) to detect when the email is opened, and thus the image fetched.

Snooper.email

We also posted an update on our company’s blog: https://blog.dmnk.cloud/index.php/2021/04/12/snooper-email-traccia-quando-le-tue-email-vengono-aperte/

Teenage Engineering PO-33 KO drumset loader app

While there are some projects I’ve been doing lately that I’ve not written here yet, this is one of those I want to write up while it’s still hot – I could easily forget about it.

I recently bought a PO-33 KO by Teenage Engineering, which I think is an incredible music making device. It’s basically a handheld sampler, very easy to use, even if it has some limitations. I’ve been enjoying very much playing with it lately, but that’s not the point of this post! You can go see all the videos out there if you’re interesting in what it is and what it does.

The point of this post is that if you’ve been using it, you know it has some beautiful features, among which there’s the possibility of recording samples with the microphone or the line input. Everything is really fine while recording the melodic slots, but when it comes to recording drum slots, it begins to be a bit difficult to make the PO detect the various slices correctly. There’s a bit of frustation about this in the community, as you can find various videos on Youtube giving tips and tricks on the matter. In the end, it seems to be understood that the process is somewhat buggy, and it’s become accepted that you should probably use some of the available workarounds, like recording first in the melodic slots and then copying the slices to the drum section. By the way, these workarounds are slow and kind of impractical if you want to quickly move some drumset you’ve got on your PC to the PO.

I’ve seen people already doing this in various ways, trying to tackle the problem using other hardware or software which is not specific for the PO, but still the solutions seemed to me a bit suboptimal.

That’s why I wanted to try and solve the problem with a very simple webapp which basically allows to upload a series of sounds and then plays them in a hopefully PO-friendly way. It’s still in very early developement, but I’ve already been able to use it to upload some sample drums I had on my PC to the PO.

Right know it’s still pretty raw, but you can find it here: http://app.dmnk.cloud/po33-loader/

Some quick instructions:

  1. press the buttons and select some  audio files representing your slices. You can select multiple files at once and it will place them in consecutive slots. The first sound is placed in every slot because as I understand it’s needed to play all 16 slots if you want a clean slicing.
  2. when you’re ready, press the desired destination drum slot (9-16)  plus the record button on the PO (as normally when you want to record there), and at the same time, start the playback on the app by pressing the red button (you’ll find it in the place of the record button on the PO background image of the app).
  3. you shoud hear all your sounds playing one after another and hopefully if either you’ve connected the PO with a jack-jack cable or you’re just placing it close to your speakers, the PO should be able to slice the sounds correctly.

You’ll notice that the sounds get cut in some cases, that’s because in my tests longer sounds have always been split by the PO in more slices. I decided that this tool should be only used with shorter sounds, more appropriate for the drum slots. If you need something longer, you’d better record it separately on a melodic slot and copy it manually to the drum section afterwards.

I hope this thing will be useful to someone! I may or may not make some improvements in the following days and then I may or may not update this blog post accordingly.

Radio Lockdown

Just keeping track of the projects.. On the 28th of October 2020 Radio Lockdown was founded. It’s a web radio in which me and my gf talk nonsense, but unbelivably on the second day we hit almost 200 active listeners.. wow. Anyways, going back to the technical details, it was so easy to make it from scratch:

  1. install icecast2 on the server
  2. configure icecast2 following the instructions (from apt-get)
  3. install darkice on the client
  4. configure /etc/darkice.cfg specifying the device (I used ‘pulse’ which uses the system sound in ubuntu) – if you don’t have a default darkice.cfg I think you can find an example somewhere in /usr/share
  5. run darkice and speak into the mic
  6. make a simple website with an audio element sourcing from your icecast2 address

Of course there are same small tweaks you can do, like could be useful to know that the default maximum number of simultaneous listeners is set to 100, that was why we had only 99 listeners for quite some time yesterday evening. And then if you wanna have same good sound too, you should probably connect a decent microphone or equipment, but that’s a different story.

So that’s how Radio Lockdown is born. But why? As the name itself tells, because of the lockdown imposed in France starting today. We stay isolated, but radio-connected!

If you want to listen for some trash talking, we don’t have a plan but we do have an url (we speak mostly italian):

http://radiolockdown.online

JS Genetic Curve Fitter

While I was working on Coronamap.it, in the new section dedicated to analysis, I felt the need to do some curve fitting, that is I had a series of points and I wanted to find a curve which best fit the points, given some constraints. Of course I expected this to be a well known and well solved problem, only to discover that of course yes it is, but it’s actually something not necessarily easy to do. It’s a complex problem which requires to search in a large space of solutions, and as that not an easy task to be done in JS (which I required). Fortunately, I found an implementation in JS which used a genetic algorithm approach, so I decided to rewrite another one from scratch using my old project JSGenetic. If it does not make any sense to you, it’s because it does not have any – except that I love to make this kind of stuff.

So enough for the story, let’s talk about the library:

Example here

Usage:

var cf = GeneticCurveFitter(points, functionGenerator, 3, { //3 is the number parameters you need to tune to find the fitting curve
    RANGES: [
        [1, 2000], //one range for every parameter - if not specified, they fall back to [-1000,1000] which is kind of silly
        [1580000000000, 1590000000000],
        [10000000, 1000000000]
    ]
});
functionGenerator

is a function which gets the generated parameters in input and returns the function which you want to optimize. Easier to explain with an example:

//polynomial functionGenerator
function polyGen(coeffs) {
  return function(x) {
    var result = 0;
    for(var i=0; i<coeffs.length; i++) {
      result += coeffs[i]*Math.pow(x,i);
    }
    return result;
  }
}

//gaussian from the example
var gaussGen = function (coeff) {
    return function (x) {
        return coeff[0] * Math.exp(-((x - coeff[1]) * (x - coeff[1])) / (2 * coeff[2] * coeff[2]));
    }
}

After initializing the object, it can be easily run like this:

var resultFn =   cf.fit();

which returns the best fit function it could find. The process takes some seconds and the time can vary by CPU power and number of coefficients to find. The returned function also has an helper method to generate a chart from it (read: to sample it) which goes like this:

var samples = resultFn.toDataset(startX,endX,numberOfSamples);
//samples is in the form [{x:,y:}, ...]

There are also other methods to better control the evolution of the coefficients: here are the library’s returned methods:

{
        step: step, //make a single step of the genetic algoritm, or N steps if you call cf.step(N)
        fit: fit, //already described before
        getCurrentSolution: getCurrentSolution, //gets current solution
        getCurrentFitness: getCurrentFitness,//gets current error
        getCurrentCoefficients: getCurrentCoefficients //get raw coefficients as an array
}

That’s all! Enjoy.

Update on Coronamap: Coronamap analysis

We added to coronamap.it the capability of loading custom analysis coded by users in JS.

A list of the analyses can be found here.

Analysis are sorted by points, which you can give by liking them when opened. You can also fork any analysis and modify it as you wish. Everything is in beta, we’re still working on improving the system.

The creation of new analyses can be made frome the Coronamap Analysis Editor.

Audio 3D

A very very simple JS API to process an audio file trying to make it sound like the sound source is moving in space. Work in progress, likely never to be finished.
Link here

Instructions:
0) put on some headphones
1) press play button
2) you can try and equalize manually if you want
3) move the position of the source hovering the box with the mouse
4) press Circle to make the source circle automatically
5) refresh the page to test again

The underlying API is very simple, it accepts a simple setXY(x,y) which expects two relative coordinates ranging [-1,1]

Coronamap.it

My colleague Marco Dalle Feste and I are still quite shocked by how the Coronavirus situation has developed in Italy in the last weeks. Everything was shut down, and our families and friends were suddenly projected in this new and surreal situation of isolation. In a situation like this, where everyone feels powerless, we decided to do something, a small gesture, at least to try to give some contribution to the world in this difficult times.

We created coronamap.it, a simple webapp to show data of the spreading of the COVID-19 contagion. The app is fairly simple, as it gets some data and displays it in an interactive map providing cases information, with various levels of precision: as you might expect, the italian situation is quite accurate, showing daily updated data from our Ministry of Health, discerned to the province (county) level. For the rest of the world, we stand upon giant’s shoulders: we are relying on data from the Johns Hopkins University, and we plan to increase the level of granularity of the data soon by implementing other sources for the worst impacted zones.

The coronamap app

By a technical point of view, our approach wants to be innovative in a sense that it wants to be ready to embed various sources, and thus crawlers, of data from a growing number of reliable national authorities. We are trying to create a centralized database of the contagion information which could concentrate a decent amount of high-accuracy uniform information.

As a last note, I want to say that we are very concerned about the situation, and personally I’d like to point out that I feel that other nations are seemingly underestimating the impact that this thing will have in every part of the world. Yes, Italy was first hit and we may have responded with some delay, but the situation was like no precedent, while information from China was scarce. Now other nations in Europe are living what we experienced some days ago and they have no excuse to wait to deploy and enforce strong measures because Italy’s situation was publicly shared without censorship of any kind, the data is there to be looked at.

For now that’s all, here you can see the webapp which is updated daily in the information and functionalities. Our company website: DMNK Engineering

Changing the DNS server on Raspberry PI with default Raspbian

Since I’ve been really astonished from the difficulties I’ve had searching for this on the web lately, I’m writing this (really short) blog post hoping to save other people’s time.

If you want to change the DNS server of the default Raspbian installation on a raspberry PI – this probably goes for most of the recent linux distributions too – you just have to edit your /etc/network/interfaces file specifying, under the desired interface, this code:

dns-nameservers 8.8.8.8

Of course replace 8.8.8.8 with your desired DNS server’s IP address.

That’s all.

See you in the next very exciting post!

Agadmatorizer

Hello everyone!

Ok, lately I’ve been approaching the fine art of chess, mostly by watching youtube videos on the matter, and with some playing on lichess.org too. So I couldn’t avoid watching tons of video of the croatian youtuber Agadmator, which is really putting a lot of effort in getting people closer to chess, by publishing one or more videos every day.

So if you’ve been watching some of his videos, you might have noticed that aside the obvious personal contribute he puts in analyzing the games, the rest of the videos is generally just showing the moves and maybe adding some kind-of-predictable comments on them. When the idea came to my mind, I couldn’t help it. I *had to* do algorithmize agadmator.

Long story short, I spent three nights developing a web app which receives a PGN game in input and then generates an (fake) agadmator video for it.

I think it’s quite funny, I’ve really been enjoying the making of it and the end result, however it’s obviously improvable.

The link (for chrome or firefox only, desktop only – sorry for that, didn’t have time to optimize it) is here: Agadmatorizer

Of course I don’t think anyone will really read this, but if someone does, and if agadmator does, I hope you enjoyed this webapp, thank you for reading this post and I’ll see you soon.