/A/ /M/A/G/N/I/F/I/C/E/N/T/ /P/L/A/C/E/ 

April 2009

12:46 Tuesday 14 April 2009

XorGramana Audio Development

Please note: I'm in the process of editing this text (but I've got to go to work first)...

I'm currently working on an audio system for my game XorGramana. To begin with I tried to find a C library which would provide an API for basic audio synthesis and effects processing. After seeking advice from various online communities I settled on using SDL for audio output, and LADSPA plugins for effects processing.

I am using SDL for audio output because I am already using SDL as the graphics system. I'm using LADSPA plugins for effects, firstly because I have already used them in my modular audio synthesis program Wav Composer Not Toilet (and consequently have some code to implement with). And secondly because coding audio effects is an extremely difficult subject when you're not a math's genius.

To begin with I experimented with using SDL_mixer for the audio output, this takes care of mixing sounds for me and involves relatively little work. Despite my very experimental test code sucessfully using SDL_mixer and LADSPA plugins, there are a couple of major problems with that approach.

The first is that SDL_mixer can only mix integer audio data while LADSPA plugins work with floating point data. It was very obviously a bad design to use LADSPA plugins with SDL_mixer where time would be wasted translating the data too often. A better design would require much less data translation.

The second problem arose when applying effects to the stereo audio which SDL_mixer had already mixed (ie post-mix). An SDL_mixer audio stream is a single array where the data for each audio channel (ie the left and right channels) is interleaved. Stereo LADSPA plugins do not handle interleaved audio streams so again, more proof that using SDL_mixer with LADSPA plugins was bad design - again, requiring more translation than a good design should.

To solve these problems, I found David Olofson's SDL Examples and decided to use his 'simple mixer' as a base for my mixer which would be able to handle the LADSPA plugins with less redundant data translation as required with SDL_mixer.

However I soon discovered the 'simple mixer' was not as good a place to begin as I imagined and so I investigated Olofson's DT-42 - Drum Toy - the audio mixer of which was better implemented and also included some very basic FM synthesis.

To begin I ripped the guts of the mixer code out of DT-42 to incorporate into my own. Secondly I removed the FM synthesis code from the mixer as by that stage I had decided against any synthesis beyond effects processing.

Unfortunately the mixer from DT-42 did not work with floating point data either, so my first job was to convert it to use floating point data. This was not so straightforward either and further code was removed to make this easier due to the use of bit-shifting integer data to convert it from 16 bit to 32bit (24 bit in 32bit to give the mix some 'headroom' - floating point audio data is completely different - ie its numerical range far exceeds the values used to represent audio data).

DT-42's mixer code also had a basic tracker-style sequencer. I decided to remove this also, as I had not yet decided if I wanted to use a sequencer at all, as I was considering doing without one.

SDL can read 16bit WAV audio files, so to eliminate converting these during mixing to floating point data, I converted them as soon as they loaded and then removed the integer data from memory (ie free'd them via SDL).

My code was exhibiting plenty of strange behaviour. Some sounds would cut out all others, depending upon when I loaded them. If I loaded the sound-cutting-out sound first, it would be ok, but if I loaded after other sounds it would cut all the others out. There were also pops and clicks after a sound finished playing. After plenty of head-scratching I found several artifacts from the integer data processing of DT-42's mixer which were no longer required for floating point format (ie recalculating the sound's length for different bit-depths/data types).

I've also added the ability to cross-fade one sound over another when one is playing and the second is sent to the same 'voice'. The cross-fade length (ms) is given to the WAV reading method and calculated there.

There is still a lot to do. At the moment it is only playing a single loop with a few drum sounds and some bassy tones, and a blip for player movement. I've still got to implement a method of getting the game code to interact with the audio generating code (seperate from the mixer). I want 8 squares which surround the player to alter the hits in the sequence of the loop, (ie cut out drum hits, maybe add new hits in) aswell as having an effect upon the audio filters that are processing the mix. It sounds quite good so far (to me atleast) but is too repetitive. I want to be able to specify loops for each level - and maybe this will include some simple method of varying how the objects change the sequences - so this will involve creating a sequencer again, though a very simple sequencer.

15:35 Monday 13 April 2009

Mr Irrelevant

Mr Irrelevant went to the market and purchased some brushes for combing
his hair and sleeping pills to cure his stomach ache. Mr Irrelevant
bought toothpaste to ease his aching feet and a new battery for his
Desktop Computer. Mr Irrelevant went home to go to work. Mr Irrelevant
went to work and slept all day. Mr Irrelevant slept constantly on his
feet all day long and was very tired when he awoke.

Mr Irrelevant worked tirelessly on his computer while it was turned off.
Mr Irrelevant worked irrelevantly on his computer while it was turned
off. Mr Irrelevant ground an ax on his computer all day laying in bed
asleep on his feet.

Mr Irrelevant drove to his car and went home to work cycling on his
computer. Mr Irrelevant loved working in the City in his village from
home at work tirelessly cycling on his computer axes to multi-threaded

Mr Irrelevant's unlimited intelligence stacked the odds against him of
ever succeeding in his chosen field to grow upside-down, while cycling
to work at home on his portable desktopped computer. Mr Irrelevant
worked in the field on his computer pulling a plough and a sickel. Mr
Irrelevant ploughed the database into the earth where it sprouted wings
and sank a stairwell to Hades.

Mr Irrelevant's stomach was making him feel sick so he brushed his hair
with toothpaste and ate a comb-filter to ease his constipation.

Mr Irrelevant had an epiphany for lunch, now that his stomach had paved
the way to the sun reaching midday. Mr Irrelevant sat on the toilet
thinking, and eating burnt wholemeal toast and laughing out loud, LOL.

Mr Irrelevant spoke out loud - one at a time - to the committee, who had
only limited intelligence and were unable to listen all at the same
time. Mr Irrelevant turned the committee into toothpaste to ease his
stomache and sent them to Dave Jones who looked at them.

Mr Irrelevant had his suspicions that not everything was set in salad

01:53 Wednesday 8 April 2009

cat \#deadenddef

hello, it's a beautiful lifeless boner, wrap
heckle... my namespace is _snail_churn_
hack shack return to lender crack
sappy sop bad snack,
snooper blagged, [crab apple]
blogged logged super clobber clod
sod sea-eye super shifted seagull flob
white late quite floating plot << [annoint]
subnormal territorial denormalization quantized quaintly
integer aunty juddered clattering clutter <dice shamanic cast>
gives us a nod, three-part eyed sod sintered snog
add me to your markets dress brook sprinkler small bacon villian
integer =VI= grrr ploys on cherry tory all sample-wrap
flint exploit shard raddish plughole flounder
finding founder farmer flap /*(i=0;;i++,^gra_man_a;*/
got a hobb yet lama dob? clog snatch bitter fettled grog
hamper sought toil fret debug $gdb quit dollar ^Z wire hill stomache rot
can tinker wit conquer cankered conked-out clan mess shrill clomper? 
flex it

15:03 Thursday 2 April 2009

XorGramana-0.0.8 Released!

XorGramana is a game by based upon Xor (an 8bit game circa 1990). XorGramana is a logic puzzle kind-of-word game set inside a series of mazes. It is a source-code only release, (GNU GPLv3 licensed) and should run on GNU/Linux systems with gcc, make, and the SDL development libraries installed.

What's new?

    * two new levels: 'home economics' and 'trips n tracks'.

    * several new floor, wall, and edge textures and 
      new combinations of these.

    * map display is working both for XOR and XorGramana - 
      shows where word solutions should be placed.

    * GNU GPLv3 now included, with copyright notices atop each
      source file.

    * numerous fixes, including:

        * fixed main level menu (again).

        * escape key no longer infuriatingly answers 'no' to 
          replay prompt when you least wanted it to.

        * replay error in XorGramana caused by masks.

        (for more details see CHANGES file).

XorGramana Home Page:

Direct Download:

I've also updated the documentation explaining briefly how the map display works for XorGramana and XOR. The screenshots here are showing the new floor, wall and edge textures. The second is a XOR level showing how I've used initially unintended combinations of the textures.



A page detailing new stuff and other random noise.

The journal is a general place for writing about what I am doing, or for making more official announcements concerning the things I do. It's also a place where I can write freely about my ideas, or just play with words and language.

DISCLAIMER: The opinions and attitudes of James W. Morris as expressed here in the past may or may not accurately reflect the opinions and attitudes of James W. Morris at present, moreover, they may never have.

this page last updated:29th April 2013 (C) 2003 - 2017 James W. Morris

script time:0.1805