Archive

Archive for May, 2010

JACK Audio Connection Kit

Last weekend, I was trying out the JACK Audio Connection Kit on Linux Environment. They say its not limited to Linux and is/will be available for other UNIX like OS, Windows & Mac. I was lazy and involved with some HTML learning, so I could only understand and execute the basic program provided with it. Coming weekend I may try it for other programs and give you a better article. The following are a few of the things I noticed.

  • JACK is a very simple & intuitive API, for routing & processing digital audio, in realtime.
  • JACK is meant for professional audio, and not very good for very low processing power embedded sytems. May be you can do simple processings with an ARM.
  • JACK is in concept similar to analog modular synthesisers, where you connect one/more modules (eg: sound generators) to one/more other modules (eg: filters), using patch cords. The modules being replaced by software programs(like music players, your own programs etc.), and the interconnection of each module specified in the programs.
  • You can implement your own realtime Audio Processing Algorithm, in C using JACK API.
  • The API is huge and repel many amateurs. The fact is that with 10 to 12 functions, you can build fairly complex audio softwares.

You can expect more of my experiences with JACK in the weeks that follow.

Advertisements

A Musical Beginning!

This is my first blog!

I’ll be writing about the hobby project I did this Saturday and Sunday. Friday evening i had a thought of getting a bit musical. I don’t have any instrument with me. So decided on reviving one of my old project titled ‘project mozart’, which was originally written in C language for 8051 kind of microcontrollers. The 8051 I used for that couldn’t support anything more than 2MIPS. At that power only continuous notes, like that from a violin continuously bowed, could be produced. This ability alone didn’t satisfy me. So i decided to implement it in my newly bought Atmega32 controller, supporting upto 16MIPS.

I had architecture of the circuit, part in my mind, and part in the C file. The circuit is rather simple with a microcontroller, a DAC0808 digital to analog convertor, and a 741 op amp configured as a current to voltage convertor. Breadboarded it quickly. Then ported the C file to the new hardware.

My expectations out of the device were as follows. I wanted a device like a piano/synthesiser, that has 32keys (White + black). There are 12 keys per octave on a standard piano/keyboard. This touches 3 octaves, with 2 in full and one partial. For my design it stretched form 175.28Hz to 1108.7kHz. (F2 to C5). Another aim was to have a full polyphony. You can press any number of keys, you should get mixture of all that notes. In addition to this, another objective — to have the Attack-Decay-Sustain-Release sort of sound (sound similar to that of a bell, which is not continuous like a violin). The sample rate chosen was 2793.6kHz for legacy reason and because, anything more is not computationally possible on that 8 bit chip.

The working of the software is as follows (Sorry i can’t make it any simpler). The software would scan the keyboard and identify the keys pressed at approx. 10 times per second. For the keys pressed the timer ISR, would If a new key is pressed, corresponding sinusoidal signal will be played. The sinusoidal signal is made know to the program in the form of a table of size 256bytes, which together represented the values of a single cycle of a sinusoid. If I send each of the table values to the DAC in each sample interval again and again, cycling through the wavetable, I will get a sine wave of 2793.6/256 = 10.955Hz. If I send every 16th entry of the table to the DAC, i will get, 10.955*16=175.28Hz sine wave, which is almost F2. Similarly you can calculate which sample to be played with the help of a bit music theory, which you can learn from wikipedia.

By the method presented so far, we could only get continuous note like that of a violin/saxophone. I need notes like that of a piano/bell/guitar. For this I will generate an envelope based on the duration for which each key is pressed, and will multiply that envelope with the continuous signal produced. This way, I could do the Attack-Sustain-Release phases. The decay phase is yet to be implemented.

At this poor bit depth(8bit) and poor sample rate too, the sound looks pretty good. I know of some possible additions, like addition of wave tables for more real life instruments, a full attack-decay-sustain-release cycle for each instrument, better sampling rate, better bit depth for the sound etc…. Your suggestions and links to your project pages are welcome.