Function Menu
Check out the New Wiki

BushidoHacks.com

You now have the power to defend the earth like never before!

20080416

The Start of Something Big!

Finally! A real program I can call really be proud of.

My audio program works!

There was some difficulty at first reguarding something about the device /dev/dsp but it turns out any program that uses KDE squats the device for KNotify or some other program. One more reason to use GNOME as Linux's GUI, I guess.

This first program I'm trying to get the computer to Play a little of Pink Floyd's "I Wish You Were Here". (About 8 notes, if I recall.) It is a simple guitar tab, and guitar is very similar to piano only the strings are spaced by about 6 notes in the G chord. (It's been a while since I've played any major musical instruments, so bear with me on the technical terms.)

Currently, the sound that I get is a little limited. I'm not exactly using a Moog.

This is the start of something big!

Labels: , ,



posted by Bushido Hacks 4/16/2008 04:51:00 PM (0) comments top

20080414

'Allo, ALUT! - Click!

I finally got around to creating my first program using sound.

While this may not be something to be excited about, it is a milestone in my opinion.

For years, I've been trying to figure out what I can use to create my own music using the computer. Then I found out a few weeks ago about MarioPaint Composer (MPC), based on the music program from the SNES game Mario Paint. The big let down of course: No version of Linux. Windows and Mac users should definely get into this easy to use program that will probably be appended to the Free Software List.

So what is there for the Linux users? Lots of softwares, mainly stuff that is still in development or requires external hardware. But this is for people with more experience in music. To them K.I.S.S. is a rock band rather than an acronym.

I'm finally on the verge of creating a program that I've been looking forward to making that does what all the other softwares other than MPC have failed to do: Create a very simple software sythesizer for the computer. No Keyboards or Drums to hook up. Nothing fancy or dumbed down. Just a program to turn the computer keyboard into a piano keyboard. If it works (and it should), then I'll think about adding all that fancy stuff.

The software that is going to help me do it will be OpenAL Utility Toolkit (ALUT), based on how the OpenGL Utility Toolkit (GLUT) was designed.

First off, there is a simple Hello, World program that they have. The one below has been modified for C++

/* helloalut.cpp */
#include
#include

int main (int argc, char **argv)
{
ALuint helloBuffer, helloSource;
alutInit (&argc, argv);
helloBuffer = alutCreateBufferHelloWorld ();
alGenSources (1, &helloSource);
alSourcei (helloSource, AL_BUFFER, helloBuffer);
alSourcePlay (helloSource);
alutSleep (1);
alutExit ();
return 0;
};


Next the saving part. I think it is time to show off how to create a simple makefile and use it. Note that TABs must be used not spaces when indenting commands. Because of this blogging software's limitations, any line thia is indendt with space should be denoted as a tab character.

# Makefile
helloalut: helloalut.o
g++ helloalut.o -lopenal -lalut -o helloalut

helloalut.o: helloalut.cpp
g++ -c helloalut.cpp -o helloalut.o


Thanks to this quick lesson in how to make Makefiles, I now know that it is unnecessary to enclose modules using -Wl--start-group and -Wl--end-group when linking modules. Ofcourse this may be limited to the Linux operating system, but it is a significant change that should be ammended to the GCC tutorial.

So what does this Makefile do? Well for starters, the default name for a Makefile is Makefile. The make program is the prgoram that used to install or remove prgrams directly from source on Linux and UNIX operating systems. Thus it is a good idea to keep the source files when you use make to install a program. Makefile can have a different name but it is probably a better idea just to use the default. Ergo, there can only be one Makefile per directory where there is a program to be installed.

The above Makefile would do this in the console:

g++ -c helloalut.cpp -o helloalut.o
g++ helloalut.o -lopenal -lalut -o helloalut


In the more fancy projects there is generally a couple lines added to removed the software that was installed which is generally make clean, but I'll have more details about that when I update the programming tutorial later. Stay tuned.

In order to use the Makefile, you should be in the directory where the Makefile is. So cd to the directory where the source is.

The fancy programs generally have a shell script called configure that is in the directory that is written to check if all the components for the software that is to be install can run. Before the Makefile is executed, run ./configure. You don't need a configure file to use make, but it is helpful if you are writing something fancy. Right now, the Makefile that is being discussed in this blog entry is sutable for just one computer.

So we've changed directories, made sure that everything is set to run, time to build the program! It is so very, very simple, If your Makefile is called Makefile, just type this command.
make

That's it. Nothing else to do execpt run that program.

But what about make install? You don't need to worry about that. That's if you are root and want to install the program in /usr/local/, and involves writing more advanced scripts such as the make clean command that undoes a make install. (Come to thing of it, I wonder how I can set up a make update when a new version of one of the fancy programs becomes available.)

Wow! I covered alot of ground today. I hope this helps everyone clear the air about how to use make as well as getting started with using ALUT.

Just remember to K.I.S.S.

Labels: , , , , ,



posted by Bushido Hacks 4/14/2008 01:46:00 PM (0) comments top

top | Some Rights ReservedRSS FeedSEND E-MAIL!bushidohacks.com © 2004-2008