Music Playing
and Beat Detection
Because Aria is an experience based on music, there needs to be a music
source. There are a number of possible sources, but we limited ourselves to
MIDI and digital audio. The primary consideration for choosing a music choice
was our beat detection requirement. The MIDI format offered us the ability
to extract just the beat track from a MIDI score and use that supply the simulation
with beat information, so that's where we started. The first approach to reading MIDI tracks focused on the Allegro library,
from Carnegie Mellon's Computer Music
Group. After some re-engineering, this approach was scrapped because it
involves too many low-level details related to playing MIDI files. We were
effectively building a custom MIDI sequencer for the sole purpose of extracting
a single MIDI track from the score. The second approach used the DirectMusic component of Microsoft's DirectX
library. DirectMusic already contains support for firing event notifications
on beat and meter events, so a lot of the hard work was already done. However, problems arose when the DirectMusic code was integrated with the
LithTech system. Apparently, the LithTech engine creates its own DirectMusic
instance, which conflicted with our custom DirectMusic code. Discussions with
LithTech's technical support team yielded no feasible work around for our
time frame, so an alternative method of using DirectMusic was explored. The obvious solution to this immediate problem was to perform the DirectMusic
work outside of the LithTech process. This proved trivial. The remaining problem
was communicating the beat events back to the simulation, which lives inside
of the LithTech process. The winning solution involved using Windows named
pipes to build a bidirectional communications channel between the two processes.
As the project progressed, it became clear that the MIDI file format was
becoming limiting (both in terms of the audio quality and selection of available
music). Digital audio sources (e.g. MP3 or CD audio) were desirable. The WinAMP
plugin system was investigated, and it was discovered that WinAMP could provide
its plugins with its internal beat detection information. A plugin for WinAMP's Advanced Visualization Studio was written, but the
problem of communicating the beat events back to the LithTech process still
existed. To make matters worse, the named pipe approach did not seem to work
correctly when executed from within WinAMP's plugin architecture. The solution to this problem was to build a simple UDP client and server
system that communicated over the local network interface. This approach,
while not exactly light, proved effective.