Hi,

> Can anyone (Lars? Rickard?) please help with documenting the sci0_soundserver
> function in soundserver.c? Particularly the aspects to do with timing and what
> ticks, wait_tv, last_played, etc... do?

I'm to blame for most of the code in there, so I had a look at it and
commented some of the places that were marked appropriately.

I know that this part of the code is quite ugly, one of the most
evil things out there. Sorry- it should've been thoroughly cleansed and
split up long ago.

> This needs doing so an event-driven model can be tried for Windows.
> Unfortunately it seems that event-driven models are The Microsoft Way.
> Before attempting that, I'd really like as much info on the sound server
> as possible.

The sound server could be ported to an event-driven model indeed. Since
multi-threading or multi-processing environments can easily be made to
provide events in the way we need them, I don't have any conceptional
problem with moving the entire sound server to this.
There'd be two types of server events:
a) next-event: Need to handle the next MIDI event in the song
b) command: client->server: Execute this command (start song, stop song,
etc)
and we'd have to make sure that at most one event was being executed at a
time.
There are more requirements that could be put down, but it's getting late
over here and I don't want to emit too much nonsense.


However, I'd like to point out the possibility of an alternative approach
(which may have been suggested in the past): Separating the song playing
from the actual song and event control (akin to what the DOS sound server
used to do). This would mean:


SCI sound API <--->     Internal on-demand song position counter,
                        event calculator etc. (song logic)
                         ^      ^
                         |      \____--> General MIDI file creation
                         |
                         v
                        Sound server API (start, stop, set_options,
                        get_type (GM/MT-32(*)/Adlib(*) etc.), set_patch,
                        set_callback)
                         ^              ^               ^
                         |              |               |
                         |              |               |
                         v              v               v
                External sound    Native OS     soundserver_unix
                player (play-     sound API     soundserver_sdl
                midi, timidity)   (MacOS)               ^
                                                        |
                                                        |
         _______________________________________________/
        |               
        +-> midi_mt32   <--->   midiout_unixraw, midiout_alsaraw, ...
        |
        +-> midi_gm     <--->   midiout_win32mci, midiout_unixraw, ...
        |
        +-> midi_adlib  <--->   midiout_ossseq, midiout_opl3emu, ...
        |                                               ^
        .                                               |
        .                                               |
        .                                               |
                                                        v
                                                PCM sound driver
                                                subsystem


(*): Using Sierra's MIDI format


This, ladies and gentlemen, is the Master Plan. Well, it could be,
anyway...

Essentially, this would involve stripping out the logic from
sci0_soundserver() and putting it into the part marked as the "song logic"
part on the slide. Everything else would be pretty much unchanged, except
for the sound_server_t API being cleaned up to the bare necessities and
GM data generation being fixed for non-GNU useage.
Although I might be missing something.


llap,
 Christoph


Reply via email to