Do you want to listen jazz all day? On the Internet you have plenty of stations to choose from, for example, http://www.listenlive.eu/jazz.html. In this project we want to listen all these radio stations in a simple Raspberry Pi project and a minimal interface. We just need to plug the Raspberry with a network cable, and connect the audio output to an amplifier. With a button we start the mpd service (Music Player Daemon) and we select up to 40 channels.

You can download from the wiki (http://wiki.joanillo.org/index.php/Raspberry_Pi:_Internet_Ràdio) the bash script, and the configuration file with the list of all stations. If you want the system to run completely unattended you can run the script at system startup. The electronics required are minimal, I think the video show clearly the required connections, and if not you have in the w0iki more information (although in Catalan).

I wish you a happy 2013 and a lot of jazz! Here’s the video:

http://youtu.be/UPrt07Z9Tmw

Sorry, this entry is only available in Español and Català.

The other day I bought in a Cash Converter a second hand Wii drumset (18 euros), with the idea to plug it in my Ubuntu box and have some fun. These drumsets were launched in 2007, five years ago. Obviously some people have interfaced these consoles into Linux, and I have benefited from the code that I found here and there. However, the coding that I found was not for my exact model (there are also versions for PS2, PS3 and X360), so I had to figure out the codes sent by the drumset (also the codes for hitting both drumsticks at the same time, or drumticks and pedal). I had no previous experience in programming the libusb library. Using this library has been the only way to detect how hard you hit the stick, and so do a little volume control, but with little resolution.

For hearing something the host code must generate and send MIDI messages to a synthesizer. I used Hydrogen as a drum box. I planned four different presets that are accessed using the Wii buttons (the typical 1, 2, A and B Wii buttons). There are two versions of the code, the first one uses ALSA, and the other is for the JACK audio server. You can download the project code:
projecte jrbdrum

Sorry, this entry is only available in Català.

Another lullaby composed by my father. But this time is and old one, written to me 42 years ago. I don’t want to put a picture of myself as a baby, so I put the first picture I caught on Google Images to illustrate this post.

The score transcription was made in Lilypond. Playback with fluidsynth and JACK, directly recorded in Audacity. it’s an easy GNU/Linux workflow for recording midi files.

Lyrics in Catalan:

Non, non, Joan, amb molta pau. Que la soneta va arribant;
Non, non, fillet, dorm ben aviat, tens la mareta al teu costat.

Les veus del dia ja s’han fos. Dorm en silenci i bon repòs;
Non, non, Joan, en el teu llit, que els dolços somnis van venint.

Non, non, Joan (cançó de bressol, lullaby) by joanillo

You can download the score: Non, non, fillet (written to me by my father 42 years ago) (JM Quintana, 1970)


Another lullaby from my father. Devoted to their grandchildren (the 10 that he has, another that is coming, and the ones that may come). Among them, Maria and Pere, mines. A sweet song and a simple tune, so is intended for sleeping the children, often not an easy job.

Dorm, infantó, la dolça son.
noneta non canta la mare;
somnis de pau t’envoltaran;
noneta non, dins del bressol,
noneta non, canta l’amor.

Canco bressol 2 (lullabye) by joanillo

Download score: lullabye (devoted to my grandchildren) (JM Quintana, 2012)

Playing with the FFT

02/03/2012

Long time ago (really long time ago) I was studying the Fourier Transform (http://en.wikipedia.org/wiki/Fourier_transform) in the faculty, and even I used the FFT (Fast Fourier Transform, http://en.wikipedia.org/wiki/Fast_Fourier_transform) algorythm in an application written in C for digital image processing. Since then I have not been worried about the FFT.

These days returned my interest for the FFT so, with the idea of learning audio programming techniques, I wanted to code a tuner or a spectral power analyzer with my Linux box (it means it should be a JACK client).

First of all you have to look what FFT algorithm could be used, GPL licenced, and googling a little bit I realise that FFTW (http://www.fftw.org/) is the election:

FFTW is a C subroutine library for computing the discrete Fourier transform (DFT) in one or more dimensions, of arbitrary input size, and of both real and complex data (as well as of even/odd data, i.e. the discrete cosine/sine transforms or DCT/DST). We believe that FFTW, which is free software, should become the FFT library of choice for most applications.

I was compiling few examples and became familiar with the calculations of the FFT. What I want to compute is the power spectral range of an audio signal, so the data will be real samples (one dimension) coming from my microphone; and the FFT output will be complex values, and both the real part and the imaginary part are important in order to compute the power spectrum of a signal.

fftPlan = fftwf_plan_dft_r2c_1d(fftSize, fftIn, fftOut, FFTW_MEASURE); //r2c_1d: real to complex, one dimension

Searching if there are open source tuners, preferably CLI and JACK compatible I found two projects that are precisely using the FFTW library:

And also it was useful for my own code the project capture_client:

I have divided the problem into two parts:

  • First of all I capture the signal coming from the microphone, and as a result I have two files: a wav file, and a text file where I write a sufficient number of samples.
  • Second: I open the sample file, apply a Hanning window to the samples for smoothing, compute the FFT, compute the power spectral range of the signal, and I write an output file ready to be processed with the graphics utility gnuplot (http://www.gnuplot.info/).

I never worked with gnuplot, the Matlab equivalent in Linux world. Running the gnuplot demo that quickly shows all the gnuplot possibilities, I was really impressed. In this case to draw the graphic is very easy:

$ gnuplot
gnuplot> plot “data_440_trumpet_output.txt”

The sample that I show was recorded with the 80′s mini keyboard Casio SK-8, choosing the trumpet sound. Here is the result:

Casio SK-8 440Hz (A) trumpet, 44100 fps by joanillo

Now I want to compare the results of my calculations with the ones obtained with Audacity and Ardour, just to verify that the calculations were correct:

My calculations and Gnuplot Audacity Ardour

Perfect! I got it!

jcapture is a small program written in C++ that records the signal from the microphone and write an audio file in wav format. Basically JACK client that automatically connects to system: capture_1, which is the physical port that represents the mic input of your sound interface, and thanks the libsndfile library, writes the input audio data to the buffer audio file.

jcapture also displays the input signal level graphically on the console (it is a console program, no graphical interface). If you are interested in the JACK API programming you are welcome to download jcapture:

Today is the 155th anniversary of the birth of Heinrich Rudolf Hertz (155 is not a special number… didn’t they anything better to tell?). To illustrate this event there is a flash movie in Google.com front page, a sine wave function really disastrous.

Everyone knows that the derivative of sine function is cosine, and therefore the slope at origin is 1,

sin ‘(0) = cos (0) = 1

If x and y axes have the same scale, it means that the slope when the sine function crosses the horizontal axis must be a line of 45 degrees. Since the cosine function takes values ​​between -1 and 1, the slope at any point can not be a vertical line!

Well, there are people drawing sine waves just linking semicircles … some mathematical background please …

Page 1 of 512345»