TSE3 documentation Version 0.3.0 Index API  Version  Structure 

Linux, MIDI and Anthem

This article originally appeared at the Linux MusicStation.
It appeared as a feature article for October 2000.

Pete Goodliffe talks about the Anthem project, bringing usable MIDI sequencing to the Linux community.

Introduction

The Linux and free software communities are currently enjoying rapid growth, quickly gaining in popularity. However, the music composition arena seems to lag somewhere behind this surge. In many ways this is quite normal, the musician community is much smaller than the hordes of desktop Linux users. However, we are beginning to see a critical mass of musical developers and users which is beginning to redress this balance.

There are now a number of projects devoted to bringing music composition tools to Linux (just have a quick glance at the multimedia section of sourceforge). However, they're all fairly immature, and many have not yet produced any useful code whatsoever.

There have always been audio editing tools of sorts for Linux, nothing that the average Windows user would find easy to use, though. And for a long time there have been MIDI sequencing packages - but again not up to the quality of the quality of the famous Windows sequencers.

So will we ever get there? Will any of these projects see fruition? The answer is yes - and in this article I'll describe one of our routes to the open source music paradise we seek.

The Anthem project

One of the many new projects developing MIDI sequencing functionality is Anthem.

OK, so now a disclaimer - I'm the guy who's written Anthem. I hope you don't find that this article turns into a banal marketing speil, but is able to give you a clear overview of where this project is going. In fact, I'd like to see other sequencers than just Anthem appear on Linux - the competition and choice is what will encourage computer musicians to the Linux platform.

So what of Anthem?

The aim of the project is to create a fully-fledged and top quality MIDI sequencing studio with audio capabilities, that is capable of rivalling products found on any other platform. Those are lofty goals.

Any project can claim to be something it's not, and many do. So why should we believe that this will ever happen? The most important factor should surely be, what state is Anthem in now? In a nutshell:

That is to say, a lot of Anthem is there, but it's certainly not complete yet! So if the program's not finished, why should you care about it?

So Anthem comprises two main sections, the TSE3 library and the Anthem program. Both are released under the terms of the GNU public license. Both are written in C++. But what are they and what do they mean to the open source music community?

The TSE3 library

TSE3 is a third generation sequencer engine core. That is, it handles playback, and recording. It provides an advanced object-oriented song structure. It provides real-time effects (transpose, etc) and allows you to edit music on-the-fly. However, there is not a window in sight.

All the necessary functionality has been designed in from the start, where it needs to be thought out properly:

It was developed first, before any flashy GUI stuff. It's been under development for a year and a half already. It's been carefully tweaked and honed, and is now a very powerful and rounded library. It's easy to use, fully documented and suitable for programs as simple as a MIDI file player to a fully featured MIDI sequencer (which is, of course, why it was written).

The library is mature - it's based on the TSE2 library which was in use in the original Anthem. However, it has many many improvements over TSE2 and is a complete rewrite from scratch.

So what does TSE3 give us? Here's a simple (and not comprehensive) summary:

An application can use a little or as much of this library as it requires. A few examples of using TSE3 are included at the end of this article.

TSE3 is stable and at a beta stage of development now.

About Anthem

The part of this project that most end users will be interested in is the Anthem sequencer. This is the main program. Using the TSE3 library, the Anthem sequencer delivers the power of TSE3's advanced features to the desktop in a user-friendly manner. So that sounds like a load of old marketing rubbish? Is it true?

Well, see for yourself. Many users will back up that statement.

Anthem is built using the KDE2 environment. Of course, that doesn't mean that you have to run all of KDE2 to use the program; you can just as easily run it under Gnome, or any X11 window manager as long as you install the base KDE2 libraries. However, it does fully exploit the available KDE2 facilities where available.

What state is it in now?

So I've said that Anthem isn't finished yet. I guess it will be hard to ever say when the project's finished because there will always be new features to add. However as it stands, the program allows you to create your music, arrange it, load it, save it, everything you would expect.

The low-level music editors are not all implemented, though. There is a 'list editor', but the 'piano-roll' editor is still under development. It will come! Score editing will be provided too, however this will be provided via a third-party plugin.

The audio-editing facilities have not even been began though. This will disappoint a number of readers. However, I do not want to embark on this and get it wrong. I need to coordinate my work with experts in this field to ensure that the audio facilities are as powerful and efficient as they can be. (See "How can you help", below.)

Anthem will see a 'plug-in' framework where a number of different types of editors and capabilities can be added according to taste. Audio is an example of this, perhaps we can incorporate video functionality as well.

When will it be finished?

There is no answer to this question. I guess the more important question is "when will it be usable?" To a large extent it already is. As more editors are added the usefulness of the program will increase. However, since I'm not working to a timetable and develop the program as a spare-time activity I can't answer fully.

How can you help?

So we've seen that Anthem is an ambitious and technically advanced project. It is already shown to work and is already in use. However, there are still areas needing work that volunteers may be interested in:

  1. Audio/video integration

    As I stated above, I'm not going to this on my own. Authors of HD recording systems and audio editing suites may like to coordinate our work.

  2. Use TSE3!

    A number of sequencer developers have told me that they are using TSE3. Since its so flexible TSE3 can be used in more than one way. Anthem is being developed as the sort of sequencer that I want to use. Other developers may prefer a more Cakewalk-like style of working. There is a plenty of scope for other Linux sequencers. However, TSE3 provides a solid base for them all to be built on.

    Likewise other multimedia projects which need MIDI playback support may consider using TSE3 for its stability and feature set.

  3. Use Anthem and feed back

    A self explanatory way to help - I will always need feedback to improve the program. Also a large number of good quality demonstration songs would be useful.

  4. Sponsor the project

    The last, but not the least, on this list.

    Currently TSE3 and Anthem are being developed on a machine pulled out of a skip. In bits. Literally. Processing power greater than a P100, and a soundcard with more capabilities than an old ISA AWE32 would greatly enhance what can be done.

Examples of using TSE3

I have been asked for a few simple examples of using the TSE3 library to show how easy it really is to use. So here they are...

First, this is how you load a standard MIDI file:

    void loadAMidiSong(const std::string &filename)
    {
        TSE3::MidiFileImport mfi(filename);
        TSE3::Song *song = mfi.load();
    }
    

The song variable now contains a TSE3 Song class with the contents of this MIDI file. In fact, if you just want to play the MIDI file, and don't want to work on the data in it, you don't even need to convert it to a TSE3 Song - you can just play it directly. The Transport class is used to perform playback:

    void playAMidiSong(const std::string &filename, TSE3::Transport &transport)
    {
        TSE3::MidiFileImport mfi(filename);
        transport.play(mfi);
        while (transport.status() == Playing)
        {
            transport.poll();
            // Delay for a bit here to prevent processor hogging
        }
        // Playback has now finished
    }
    

Of course, there are more elegant ways of waiting for playback to stop than a clumsy loop, and TSE3 provides them to you.

Perhaps you want to send the different channels of the MIDI file to different MIDI ports (perhaps one to an external MIDI device, and one to the internal soundcard). We can use the MidiMapper to do this easily. This is how you would set it up (baring in mind the MIDI file will by default play from port 0):

    void setUpMidiMapper(TSE3::Transport &transport)
    {
        // Set channel 0 port 0 to go to channel 1, port 2
        transport.midiMapper()->setMap(0, 0, 1, 2);

        // Set channel 1 port 0 to go to channel 0, port 1
        transport.midiMapper()->setMap(1, 0, 0, 1);
    }
    

When you next play the MIDI file, the output will be routed accordingly. Facilities exist to find out what physical port is represented by each number. You can hide the numbers from the user and work with port names, too.

These are a few very simple examples of using TSE3 - it can do a whole lot more!

Footnotes

Pete Goodliffe is a Senior Software Engineer with Pace Microsystems plc, working on TSE3 and Anthem in his <irony>"copious" spare time</irony>. He plays the keyboard, and is 'still' learning the harmonica (will someone please write a Linux device driver for it?).

You can visit the TSE3 website at TSE3.sourceforge.net and the Anthem site at anthem.sourceforge.net.

 © Pete Goodliffe, 2001-2003 Copyright Psalm 150