Slightly OT - GUI front end and SDL backend design Q

Hi all,
I’m making some progress writing an ImpulseTracker clone for Linux using
Gnome+Gtk for the GUI, SDL for the audio and SDL_mixer for the music
player.
However I’m a bit wary of the next step because of a problem I have with
the mixer library. It’s not a problem with the library itself - rather
what I want to do with it :slight_smile:
There’s some structure definitions and variables in music.c and mikmod.h
that I need to be able to access directly so I can display them on the
screen in the correct places/let the user edit them etc. The problem is
those are internal to the mixer lib and the current API does just fine
exposing what a normal SDL app needs - load, stop, play, rewind and so
on. It’s not good for a tracker though because users typically want to
get in an edit patterns, samples and stuff.
So my question is this - which is the better strategy:

a) Add to the mixer library (and possibly wait for my code to break on
the next release)?
b) Rewrite music.c for my own purposes (and force a recompile of the
whole lib - and possibly a name change as well :slight_smile:
c) Write some sneaky glue functions which give me access to the
internals of the library without messing it up?
d) All of the above?
e) None of the above?

In case anyone wondered, I’m using SDL for the audio and the mixer
because it plays nicely with gtk and I’m very used to it by now :slight_smile:
If anyone has some experience with a similar challenge, I’d really
appreciate some pointers. If anyone’s interested in the project itself,
you can check it out (what there is of it) at
http://ma.verick.co.za/gtracker/. I’m also working on some 4k Linux demo
techniques at http://ma.verick.co.za/linux4k/ for the asm heads out
there.

paul.–

Have you got anything without spam in it? - Monty Python

Can’t you also just use mikmod for your needed functions? Isn’t it just a
pointer in memory that you can also pass to music.c or whatever functions
you are trying to use. So take the mikmod pointer from the SDL_mixer
struct and pass that to the functions you need.

Ofcourse, I have no idea what I am talking about because I have never used
either. But in a sense it should work, just like you can give GTK the
window pointer from SDL so you can use both. I’m sure the same would work.On Fri, 9 Jun 2000, Paul Furber wrote:

Hi all,
I’m making some progress writing an ImpulseTracker clone for Linux using
Gnome+Gtk for the GUI, SDL for the audio and SDL_mixer for the music
player.
However I’m a bit wary of the next step because of a problem I have with
the mixer library. It’s not a problem with the library itself - rather
what I want to do with it :slight_smile:
There’s some structure definitions and variables in music.c and mikmod.h
that I need to be able to access directly so I can display them on the
screen in the correct places/let the user edit them etc. The problem is
those are internal to the mixer lib and the current API does just fine
exposing what a normal SDL app needs - load, stop, play, rewind and so
on. It’s not good for a tracker though because users typically want to
get in an edit patterns, samples and stuff.
So my question is this - which is the better strategy:

a) Add to the mixer library (and possibly wait for my code to break on
the next release)?
b) Rewrite music.c for my own purposes (and force a recompile of the
whole lib - and possibly a name change as well :slight_smile:
c) Write some sneaky glue functions which give me access to the
internals of the library without messing it up?
d) All of the above?
e) None of the above?

In case anyone wondered, I’m using SDL for the audio and the mixer
because it plays nicely with gtk and I’m very used to it by now :slight_smile:
If anyone has some experience with a similar challenge, I’d really
appreciate some pointers. If anyone’s interested in the project itself,
you can check it out (what there is of it) at
http://ma.verick.co.za/gtracker/. I’m also working on some 4k Linux demo
techniques at http://ma.verick.co.za/linux4k/ for the asm heads out
there.

paul.


Have you got anything without spam in it? - Monty Python

In case anyone wondered, I’m using SDL for the audio and the mixer
because it plays nicely with gtk and I’m very used to it by now :slight_smile:
If anyone has some experience with a similar challenge, I’d really
appreciate some pointers. If anyone’s interested in the project itself,
you can check it out (what there is of it) at
http://ma.verick.co.za/gtracker/. I’m also working on some 4k Linux demo
techniques at http://ma.verick.co.za/linux4k/ for the asm heads out
there.
I seriously think you should reconsider your design. Your really just over
complicating everything by using SDL, just use mikmod.

MartinOn Fri, 9 Jun 2000, Paul Furber wrote:

Bother said Pooh, as he hid Piglet’s corpse with Roo’s.

Can’t you also just use mikmod for your needed functions? Isn’t it just a
pointer in memory that you can also pass to music.c or whatever functions
you are trying to use. So take the mikmod pointer from the SDL_mixer
struct and pass that to the functions you need.

Ofcourse, I have no idea what I am talking about because I have never used
either. But in a sense it should work, just like you can give GTK the
window pointer from SDL so you can use both. I’m sure the same would work.

Hi all,
I’m making some progress writing an ImpulseTracker clone for Linux using
Gnome+Gtk for the GUI, SDL for the audio and SDL_mixer for the music
player.
However I’m a bit wary of the next step because of a problem I have with
the mixer library. It’s not a problem with the library itself - rather
what I want to do with it :slight_smile:
There’s some structure definitions and variables in music.c and mikmod.h
that I need to be able to access directly so I can display them on the
screen in the correct places/let the user edit them etc. The problem is
those are internal to the mixer lib and the current API does just fine
exposing what a normal SDL app needs - load, stop, play, rewind and so
on. It’s not good for a tracker though because users typically want to
get in an edit patterns, samples and stuff.
So my question is this - which is the better strategy:

a) Add to the mixer library (and possibly wait for my code to break on
the next release)?
b) Rewrite music.c for my own purposes (and force a recompile of the
whole lib - and possibly a name change as well :slight_smile:
c) Write some sneaky glue functions which give me access to the
internals of the library without messing it up?
d) All of the above?
e) None of the above?

In case anyone wondered, I’m using SDL for the audio and the mixer
because it plays nicely with gtk and I’m very used to it by now :slight_smile:
If anyone has some experience with a similar challenge, I’d really
appreciate some pointers. If anyone’s interested in the project itself,
you can check it out (what there is of it) at
http://ma.verick.co.za/gtracker/. I’m also working on some 4k Linux demo
techniques at http://ma.verick.co.za/linux4k/ for the asm heads out
there.

Yes, you have to use mikmod directly

this is how you can use it:

void fill_audio(void *udata, Uint8 *stream, int len)
{
VC_WriteBytes((SBYTE *)stream, len);
}

md_mode = DMODE_STEREO;
md_mixfreq = 44100;
md_device = 0;
md_volume = 96;
md_musicvolume = 128;
md_sndfxvolume = 128;
md_pansep = 128;
md_reverb = 0;

MikMod_RegisterAllLoaders();
MikMod_RegisterAllDrivers();
MikMod_Init(NULL);

MikMod_SetNumVoices(-1,4);

SDL_AudioSpec wanted;
wanted.freq = 44100;
wanted.format = AUDIO_U8;
wanted.channels = 2;
wanted.samples = 4096;
wanted.callback = fill_audio;
wanted.userdata = NULL;
if ( SDL_OpenAudio(&wanted, NULL) < 0 )
{
printf(“Couldn’t open audio: %s\n”, SDL_GetError());
}

btw, you should also write a floating-point interpolating mixer… :slight_smile:

Gautier.

(formerly coder of Weezer (hum… not really a reference :slight_smile: ))> On Fri, 9 Jun 2000, Paul Furber wrote: