1a4cd9b30SMilanka RingwaldLocal copy used for A2DP Source demo in BTstack. 2a4cd9b30SMilanka Ringwald 3a4cd9b30SMilanka RingwaldGithub repository: https://github.com/jfdelnero/HxCModPlayer 4a4cd9b30SMilanka RingwaldThanks for providing this nice and compact implementation! 5a4cd9b30SMilanka Ringwald 6a4cd9b30SMilanka Ringwald-------------------------------------------------------------------------------------- 7a4cd9b30SMilanka RingwaldOriginal readme.txt 8a4cd9b30SMilanka Ringwald-------------------------------------------------------------------------------------- 9a4cd9b30SMilanka Ringwald 10a4cd9b30SMilanka Ringwald/////////////////////////////////////////////////////////////////////////////////// 11a4cd9b30SMilanka Ringwald//-------------------------------------------------------------------------------// 12a4cd9b30SMilanka Ringwald//-------------------------------------------------------------------------------// 13a4cd9b30SMilanka Ringwald//-----------H----H--X----X-----CCCCC----22222----0000-----0000------11----------// 14a4cd9b30SMilanka Ringwald//----------H----H----X-X-----C--------------2---0----0---0----0---1-1-----------// 15a4cd9b30SMilanka Ringwald//---------HHHHHH-----X------C----------22222---0----0---0----0-----1------------// 16a4cd9b30SMilanka Ringwald//--------H----H----X--X----C----------2-------0----0---0----0-----1-------------// 17a4cd9b30SMilanka Ringwald//-------H----H---X-----X---CCCCC-----222222----0000-----0000----1111------------// 18a4cd9b30SMilanka Ringwald//-------------------------------------------------------------------------------// 19a4cd9b30SMilanka Ringwald//----------------------------------------------------- http://hxc2001.free.fr --// 20a4cd9b30SMilanka Ringwald/////////////////////////////////////////////////////////////////////////////////// 21a4cd9b30SMilanka Ringwald 22a4cd9b30SMilanka Ringwald HxCMOD player 23a4cd9b30SMilanka Ringwald 24a4cd9b30SMilanka RingwaldThe HxCMOD player is a tiny music module player. 25a4cd9b30SMilanka Ringwald 26a4cd9b30SMilanka RingwaldIt currently supports the Noisetracker/Soundtracker/Protracker Module Format (*.mod) 27a4cd9b30SMilanka Ringwald 28a4cd9b30SMilanka RingwaldThe core (hxcmod.c/hxcmod.h) is designed to have the least external dependency. 29a4cd9b30SMilanka RingwaldSo it should be usable on almost all OS and systems. 30a4cd9b30SMilanka RingwaldYou can use the hxcmod.c / hxcmod.h files to add a mod replay support 31a4cd9b30SMilanka Ringwaldto a demo/game/software. 32a4cd9b30SMilanka Ringwald 33a4cd9b30SMilanka RingwaldYou are free to do what you want with this code. 34a4cd9b30SMilanka Ringwald(A credit is always appreciated if you include it into your prod ;) ) 35a4cd9b30SMilanka Ringwald 36a4cd9b30SMilanka RingwaldThe test program is into the win32 folder. Just drag and drop a mod on the main 37a4cd9b30SMilanka Ringwaldwindow to load it. Linux & Mac OS X version it planned. 38a4cd9b30SMilanka Ringwald 39a4cd9b30SMilanka RingwaldPlease note that this core was "Emscriptened" successfully and is now working in 40a4cd9b30SMilanka RingwaldJavaScript with Android, Chrome, Firefox, Edge, Safari browsers and probably 41a4cd9b30SMilanka Ringwaldwith others browsers supporting the Web Audio API support. 42a4cd9b30SMilanka Ringwald 43a4cd9b30SMilanka RingwaldYou can test it at this address : http://hxc2001.free.fr/hxcmod/ 44a4cd9b30SMilanka Ringwald 45*8201da88SMatthias RingwaldThe native Mod player demonstration video is available on youtube : 46a4cd9b30SMilanka Ringwaldhttps://www.youtube.com/watch?v=MEU9FGZzjac 47a4cd9b30SMilanka Ringwald 48*8201da88SMatthias RingwaldAnother video showing the player working on a STM32F105 microcontroller based device : 49*8201da88SMatthias Ringwaldhttps://www.youtube.com/watch?v=kiOT8-zWVkA 50*8201da88SMatthias Ringwald 51*8201da88SMatthias RingwaldAnother case, this time with an STM32 microcontroller without DAC hardware. 52*8201da88SMatthias RingwaldThe firmware implements a 1 bit delta sigma / PDM stream generator : 53*8201da88SMatthias Ringwaldhttps://www.youtube.com/watch?v=AQ--IiXPUGA 54*8201da88SMatthias Ringwald 55a4cd9b30SMilanka Ringwald-------------------------------------------------------------------------------------- 56a4cd9b30SMilanka Ringwald HxCMOD Core API 57a4cd9b30SMilanka Ringwald-------------------------------------------------------------------------------------- 58a4cd9b30SMilanka Ringwald 59a4cd9b30SMilanka Ringwaldint hxcmod_init( modcontext * modctx ) 60a4cd9b30SMilanka Ringwald 61a4cd9b30SMilanka Ringwald- Initialize the modcontext buffer. Must be called before doing anything else. 62a4cd9b30SMilanka Ringwald Return 1 if success. 0 in case of error. 63a4cd9b30SMilanka Ringwald 64*8201da88SMatthias Ringwaldint hxcmod_setcfg( modcontext * modctx, int samplerate, int stereo_separation, int filter); 65a4cd9b30SMilanka Ringwald 66a4cd9b30SMilanka Ringwald- Configure the player : 67a4cd9b30SMilanka Ringwald samplerate specify the sample rate. (44100 by default). 68a4cd9b30SMilanka Ringwald stereo_separation - Left/Right channel separation. 69a4cd9b30SMilanka Ringwald filter - if non null, the filter is applied (default) 70a4cd9b30SMilanka Ringwald 71a4cd9b30SMilanka Ringwaldint hxcmod_load( modcontext * modctx, void * mod_data, int mod_data_size ) 72a4cd9b30SMilanka Ringwald 73a4cd9b30SMilanka Ringwald- "Load" a MOD from memory (from "mod_data" with size "mod_data_size"). 74a4cd9b30SMilanka Ringwald Return 1 if success. 0 in case of error. 75a4cd9b30SMilanka Ringwald 76a4cd9b30SMilanka Ringwald 77a4cd9b30SMilanka Ringwaldvoid hxcmod_fillbuffer( modcontext * modctx, unsigned short * outbuffer, unsigned long nbsample, tracker_buffer_state * trkbuf ) 78a4cd9b30SMilanka Ringwald 79a4cd9b30SMilanka Ringwald- Generate and return the next samples chunk to outbuffer. 80a4cd9b30SMilanka Ringwald nbsample specify the number of stereo 16bits samples you want. 81*8201da88SMatthias Ringwald The default output format is signed 44100Hz 16-bit Stereo PCM samples. 82*8201da88SMatthias Ringwald The output format can be changed with the C flags HXCMOD_MONO_OUTPUT, HXCMOD_8BITS_OUTPUT and HXCMOD_UNSIGNED_OUTPUT. 83*8201da88SMatthias Ringwald The output buffer size in byte must be equal to ( nbsample * sample_size * (mono=1 or stereo=2) ). 84a4cd9b30SMilanka Ringwald The optional trkbuf parameter can be used to get detailed status of the player. Put NULL/0 if unused. 85a4cd9b30SMilanka Ringwald 86a4cd9b30SMilanka Ringwald 87a4cd9b30SMilanka Ringwaldvoid hxcmod_unload( modcontext * modctx ) 88a4cd9b30SMilanka Ringwald- "Unload" / clear the player status. 89a4cd9b30SMilanka Ringwald 90*8201da88SMatthias RingwaldCompile-time C defines options : 91a4cd9b30SMilanka Ringwald 92*8201da88SMatthias RingwaldHXCMOD_MONO_OUTPUT : Turn the output format in mono mode. 93*8201da88SMatthias RingwaldHXCMOD_8BITS_OUTPUT : Set the output wave format in 8bits. 94*8201da88SMatthias RingwaldHXCMOD_UNSIGNED_OUTPUT : Set the output wave format unsigned. 95*8201da88SMatthias RingwaldHXCMOD_MAXCHANNELS : Set the maximum supported channels (default : 32). 96*8201da88SMatthias Ringwald Reduce it to gain some RAM space. 97*8201da88SMatthias Ringwald Increase it if you want to support some specials mods 98*8201da88SMatthias Ringwald (up to 999). 99*8201da88SMatthias RingwaldHXCMOD_BIGENDIAN_MACHINE : The target machine is big endian. 100*8201da88SMatthias RingwaldHXCMOD_SLOW_TARGET : For slow targets : Disable stereo mixing and output filter. 101*8201da88SMatthias RingwaldHXCMOD_USE_PRECALC_VOLUME_TABLE : Use precalculated volume table for the mixing. 102*8201da88SMatthias Ringwald suppress the multiply operations for slow targets. 103*8201da88SMatthias Ringwald The table need 32KB of RAM. 104a4cd9b30SMilanka Ringwald-------------------------------------------------------------------------------------- 105a4cd9b30SMilanka Ringwald Files on the repository 106a4cd9b30SMilanka Ringwald-------------------------------------------------------------------------------------- 107a4cd9b30SMilanka Ringwald 108a4cd9b30SMilanka Ringwald- hxcmod.c / hxcmod.h 109a4cd9b30SMilanka RingwaldThe HxC core mod replay routines. These files don't have any dependency with others files 110a4cd9b30SMilanka Ringwaldand can be used into other project. 111a4cd9b30SMilanka Ringwald 112a4cd9b30SMilanka Ringwald- framegenerator.c / framegenerator.h 113a4cd9b30SMilanka RingwaldGenerate a 640*480 framebuffer from the player status to be displayed in real-time. 114a4cd9b30SMilanka Ringwald(not needed by the core) 115a4cd9b30SMilanka Ringwald 116a4cd9b30SMilanka Ringwald- win32/ 117a4cd9b30SMilanka RingwaldThe Windows test software. 118a4cd9b30SMilanka Ringwald(linux & Mac version planned) 119a4cd9b30SMilanka Ringwald 120a4cd9b30SMilanka Ringwald- js_emscripten/ 121a4cd9b30SMilanka RingwaldThe Web browser/JavaScript version. (Build with Emscripten) 122a4cd9b30SMilanka Ringwald 123*8201da88SMatthias Ringwald- STM32/ 124*8201da88SMatthias RingwaldSTM32 microcontroller / "Gotek" demo. 125*8201da88SMatthias Ringwald 126a4cd9b30SMilanka Ringwald- packer/ 127a4cd9b30SMilanka RingwaldData compression utility. Used to embed one mod and some graphical stuff into the executable. 128a4cd9b30SMilanka RingwaldNot directly used by the core. 129a4cd9b30SMilanka Ringwald 130a4cd9b30SMilanka Ringwald- data/ 131a4cd9b30SMilanka RingwaldSome packed data files. 132a4cd9b30SMilanka Ringwald 133a4cd9b30SMilanka Ringwald-------------------------------------------------------------------------------------- 134a4cd9b30SMilanka Ringwald 135a4cd9b30SMilanka RingwaldJean-Fran�ois DEL NERO (Jeff) / HxC2001 136a4cd9b30SMilanka Ringwald 137a4cd9b30SMilanka RingwaldEmail : jeanfrancoisdelnero <> free.fr 138a4cd9b30SMilanka Ringwald 139a4cd9b30SMilanka Ringwaldhttp://hxc2001.free.fr 140a4cd9b30SMilanka Ringwald 141a4cd9b30SMilanka Ringwald11 July 2015 142