view win95kggui/dep/ft2play/audiodrivers/how_to_write_drivers.txt @ 132:71df0cf3aa05

add create.py this is a script to render out video files from entire albums, singles, or EPs. eventually it can be edited to be more robust (such as automatically finding discogs/musicbrainz links) but I think it's pretty damn good for now. It's basically just an ffmpeg frontend with a few hardcoded options that are suitable for this kind of thing.
author Paper <paper@tflc.us>
date Fri, 02 Jan 2026 10:35:03 -0500
parents 8e4ee43d3b81
children
line wrap: on
line source

---- How to write your own audio driver for ft2play ----

1) Include the header "../../pmp_mix.h"

2) Implement the following functions using your audio API of choice:

  void lockMixer(void); // waits for the current mixing block to finish and disables further mixing
  void unlockMixer(void); // enables mixing again
  bool openMixer(int32_t mixingFrequency, int32_t mixingBufferSize); // 8000..96000, 256..8192 (true if ok, false if fail)
  void closeMixer(void);

3) When the audio API is requesting samples, make a call to mix_UpdateBuffer(), f.ex.:

  mix_UpdateBuffer((int16_t *)stream, len / 4);
  
4) Make your own preprocessor define (f.ex. AUDIODRIVER_ALSA) and pass it to the compiler during compilation
   (also remember to add the correct driver .c file to the compilation script)

5) In "pmplay.h", insert your preprocessor define and include in the "AUDIO DRIVERS" #ifdef chain and
   include your audio driver header in there.
   
NOTE:
  lockMixer() should be implemented in a way where you wait until the mix_UpdateBuffer() call has finished (important),
  then you block further calls to mix_UpdateBuffer() until the mixer is unlocked again.
  You should not send zeroes to the audio device while it's locked, as the lock/unlock pairs are usually called within
  a very short time frame anyway.
  
-------------------------------------------------------

You can look at audiodrivers/sdl/sdldriver.c if you need some references...