On Feb 5, 1:17 pm, "Jason Burgon" <jayn...@[EMAIL PROTECTED]
> wrote:
> You should definately have different objects for the player and the song
> because:
>
> (1) The song object encapsulates a data element -TSong.
> (2) The Playback object represents [an interface to] a device driver -
> TPlayer.
Actually, there are basic song handling routines that are common to
playing *any* song, such as "slide this note upward each tick for a
****tamento", etc. The device-specific routines would come later, so
that's why I was leaning toward something like:
song = object
player = object(song)
playSpk = object(player)
playAdlib = object(player)
playGMIDI = object(player)
That sort of thing. If you're familiar with PC MOD players/trackers,
that's the same idea; there are song maintenance operations to be done
on every interrupt tick, but those operations are independent of the
actual output device used.
> TSong might also want to be an abstract type
> as well, so that different song types can be played by the same player
type.
While that's a good design decision, it is quite out of scope for this
project :) The goal was to create an editor/player for very low-
resource machines, so the song data format is actually a big part of
the design -- I'll explain later in this post.
> Now you have to decide what the interface ("contract") between the TSong
and
> the TPlayer is going to be. Ideally, only one of them at most should
"know"
> about the other. It might be better for both to be ignorant of each
other,
> and use a third object to trans****t the data from the TSong to the
TPlayer.
> Some sort of stream object comes mind for this role.
If I didn't care about performance, I would agree this is the most
proper way to do it. However, the target platform for this project is
-- don't get mad -- an original IBM PC, which is a 4.77MHz 8088.
(Most people hit *DELETE* after reading that, but I like challenges in
my hobby...) Not only that, but the music must play at the same time
many other things are going on, so player performance is extremely
im****tant. It's im****tant enough that I started this project with the
song data format, because I wanted to be able to retrieve a note in a
single data access (if you're curious, each note+effects is only 2
bytes, which I plan to fetch with LODSW and then do all processing in
registers).
This is why I was trying to figure out the most efficient way to pass
data between objects -- ideally, there would be no passing at all (ie.
the generic player object would be able to read the song data
directory without passing it on the stack or through a stream). So,
with this in mind, do you think my idea (see above) is the best
compromise?


|