Mercurial > codedump
comparison win95kggui/dep/ft2play/audiodrivers/how_to_write_drivers.txt @ 126:8e4ee43d3b81
remove submodules
| author | Paper <mrpapersonic@gmail.com> |
|---|---|
| date | Sun, 01 Oct 2023 03:48:43 -0400 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 125:5cc85ef3a675 | 126:8e4ee43d3b81 |
|---|---|
| 1 ---- How to write your own audio driver for ft2play ---- | |
| 2 | |
| 3 1) Include the header "../../pmp_mix.h" | |
| 4 | |
| 5 2) Implement the following functions using your audio API of choice: | |
| 6 | |
| 7 void lockMixer(void); // waits for the current mixing block to finish and disables further mixing | |
| 8 void unlockMixer(void); // enables mixing again | |
| 9 bool openMixer(int32_t mixingFrequency, int32_t mixingBufferSize); // 8000..96000, 256..8192 (true if ok, false if fail) | |
| 10 void closeMixer(void); | |
| 11 | |
| 12 3) When the audio API is requesting samples, make a call to mix_UpdateBuffer(), f.ex.: | |
| 13 | |
| 14 mix_UpdateBuffer((int16_t *)stream, len / 4); | |
| 15 | |
| 16 4) Make your own preprocessor define (f.ex. AUDIODRIVER_ALSA) and pass it to the compiler during compilation | |
| 17 (also remember to add the correct driver .c file to the compilation script) | |
| 18 | |
| 19 5) In "pmplay.h", insert your preprocessor define and include in the "AUDIO DRIVERS" #ifdef chain and | |
| 20 include your audio driver header in there. | |
| 21 | |
| 22 NOTE: | |
| 23 lockMixer() should be implemented in a way where you wait until the mix_UpdateBuffer() call has finished (important), | |
| 24 then you block further calls to mix_UpdateBuffer() until the mixer is unlocked again. | |
| 25 You should not send zeroes to the audio device while it's locked, as the lock/unlock pairs are usually called within | |
| 26 a very short time frame anyway. | |
| 27 | |
| 28 ------------------------------------------------------- | |
| 29 | |
| 30 You can look at audiodrivers/sdl/sdldriver.c if you need some references... |
