mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-02-20 18:40:31 +00:00
added 3rd party hxcmod player
This commit is contained in:
parent
aa8c26dbfa
commit
a4cd9b30c1
1285
3rd-party/hxcmod-player/hxcmod.c
vendored
Normal file
1285
3rd-party/hxcmod-player/hxcmod.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
215
3rd-party/hxcmod-player/hxcmod.h
vendored
Normal file
215
3rd-party/hxcmod-player/hxcmod.h
vendored
Normal file
@ -0,0 +1,215 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
//-------------------------------------------------------------------------------//
|
||||
//-------------------------------------------------------------------------------//
|
||||
//-----------H----H--X----X-----CCCCC----22222----0000-----0000------11----------//
|
||||
//----------H----H----X-X-----C--------------2---0----0---0----0--1--1-----------//
|
||||
//---------HHHHHH-----X------C----------22222---0----0---0----0-----1------------//
|
||||
//--------H----H----X--X----C----------2-------0----0---0----0-----1-------------//
|
||||
//-------H----H---X-----X---CCCCC-----222222----0000-----0000----1111------------//
|
||||
//-------------------------------------------------------------------------------//
|
||||
//----------------------------------------------------- http://hxc2001.free.fr --//
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// File : hxcmod.h
|
||||
// Contains: a tiny mod player
|
||||
//
|
||||
// Written by: Jean François DEL NERO
|
||||
//
|
||||
// Change History (most recent first):
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef MODPLAY_DEF
|
||||
#define MODPLAY_DEF
|
||||
|
||||
// Basic type
|
||||
typedef unsigned char muchar;
|
||||
typedef unsigned short muint;
|
||||
typedef short mint;
|
||||
typedef unsigned long mulong;
|
||||
|
||||
#define NUMMAXCHANNELS 32
|
||||
#define MAXNOTES 12*12
|
||||
#define SAMPLE_RATE 44100
|
||||
//
|
||||
// MOD file structures
|
||||
//
|
||||
|
||||
#pragma pack(1)
|
||||
|
||||
typedef struct {
|
||||
muchar name[22];
|
||||
muint length;
|
||||
muchar finetune;
|
||||
muchar volume;
|
||||
muint reppnt;
|
||||
muint replen;
|
||||
} sample;
|
||||
|
||||
typedef struct {
|
||||
muchar sampperiod;
|
||||
muchar period;
|
||||
muchar sampeffect;
|
||||
muchar effect;
|
||||
} note;
|
||||
|
||||
typedef struct {
|
||||
muchar title[20];
|
||||
sample samples[31];
|
||||
muchar length;
|
||||
muchar protracker;
|
||||
muchar patterntable[128];
|
||||
muchar signature[4];
|
||||
muchar speed;
|
||||
} module;
|
||||
|
||||
#pragma pack()
|
||||
|
||||
//
|
||||
// HxCMod Internal structures
|
||||
//
|
||||
typedef struct {
|
||||
char * sampdata;
|
||||
muint sampnum;
|
||||
muint length;
|
||||
muint reppnt;
|
||||
muint replen;
|
||||
mulong samppos;
|
||||
muint period;
|
||||
muchar volume;
|
||||
mulong ticks;
|
||||
muchar effect;
|
||||
muchar parameffect;
|
||||
muint effect_code;
|
||||
|
||||
|
||||
mint decalperiod;
|
||||
mint portaspeed;
|
||||
mint portaperiod;
|
||||
mint vibraperiod;
|
||||
mint Arpperiods[3];
|
||||
muchar ArpIndex;
|
||||
|
||||
mint oldk;
|
||||
muchar volumeslide;
|
||||
|
||||
muchar vibraparam;
|
||||
muchar vibrapointeur;
|
||||
|
||||
muchar finetune;
|
||||
|
||||
muchar cut_param;
|
||||
|
||||
muint patternloopcnt;
|
||||
muint patternloopstartpoint;
|
||||
} channel;
|
||||
|
||||
typedef struct {
|
||||
module song;
|
||||
char * sampledata[31];
|
||||
note * patterndata[128];
|
||||
|
||||
mulong playrate;
|
||||
muint tablepos;
|
||||
muint patternpos;
|
||||
muint patterndelay;
|
||||
muint jump_loop_effect;
|
||||
muchar bpm;
|
||||
mulong patternticks;
|
||||
mulong patterntickse;
|
||||
mulong patternticksaim;
|
||||
mulong sampleticksconst;
|
||||
|
||||
mulong samplenb;
|
||||
|
||||
channel channels[NUMMAXCHANNELS];
|
||||
|
||||
muint number_of_channels;
|
||||
|
||||
muint fullperiod[MAXNOTES * 8];
|
||||
|
||||
muint mod_loaded;
|
||||
|
||||
mint last_r_sample;
|
||||
mint last_l_sample;
|
||||
|
||||
mint stereo;
|
||||
mint stereo_separation;
|
||||
mint bits;
|
||||
mint filter;
|
||||
|
||||
} modcontext;
|
||||
|
||||
//
|
||||
// Player states structures
|
||||
//
|
||||
typedef struct track_state_
|
||||
{
|
||||
unsigned char instrument_number;
|
||||
unsigned short cur_period;
|
||||
unsigned char cur_volume;
|
||||
unsigned short cur_effect;
|
||||
unsigned short cur_parameffect;
|
||||
}track_state;
|
||||
|
||||
typedef struct tracker_state_
|
||||
{
|
||||
int number_of_tracks;
|
||||
int bpm;
|
||||
int speed;
|
||||
int cur_pattern;
|
||||
int cur_pattern_pos;
|
||||
int cur_pattern_table_pos;
|
||||
unsigned int buf_index;
|
||||
track_state tracks[32];
|
||||
}tracker_state;
|
||||
|
||||
typedef struct tracker_state_instrument_
|
||||
{
|
||||
char name[22];
|
||||
int active;
|
||||
}tracker_state_instrument;
|
||||
|
||||
typedef struct tracker_buffer_state_
|
||||
{
|
||||
int nb_max_of_state;
|
||||
int nb_of_state;
|
||||
int cur_rd_index;
|
||||
int sample_step;
|
||||
char name[64];
|
||||
tracker_state_instrument instruments[31];
|
||||
tracker_state * track_state_buf;
|
||||
}tracker_buffer_state;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// HxCMOD Core API:
|
||||
// -------------------------------------------
|
||||
// int hxcmod_init(modcontext * modctx)
|
||||
//
|
||||
// - Initialize the modcontext buffer. Must be called before doing anything else.
|
||||
// Return 1 if success. 0 in case of error.
|
||||
// -------------------------------------------
|
||||
// int hxcmod_load( modcontext * modctx, void * mod_data, int mod_data_size )
|
||||
//
|
||||
// - "Load" a MOD from memory (from "mod_data" with size "mod_data_size").
|
||||
// Return 1 if success. 0 in case of error.
|
||||
// -------------------------------------------
|
||||
// void hxcmod_fillbuffer( modcontext * modctx, unsigned short * outbuffer, unsigned long nbsample, tracker_buffer_state * trkbuf )
|
||||
//
|
||||
// - Generate and return the next samples chunk to outbuffer.
|
||||
// nbsample specify the number of stereo 16bits samples you want.
|
||||
// The output format is signed 44100Hz 16-bit Stereo PCM samples.
|
||||
// The output buffer size in byte must be equal to ( nbsample * 2 * 2 ).
|
||||
// The optional trkbuf parameter can be used to get detailed status of the player. Put NULL/0 is unused.
|
||||
// -------------------------------------------
|
||||
// void hxcmod_unload( modcontext * modctx )
|
||||
// - "Unload" / clear the player status.
|
||||
// -------------------------------------------
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int hxcmod_init( modcontext * modctx );
|
||||
int hxcmod_setcfg( modcontext * modctx, int samplerate, int bits, int stereo, int stereo_separation, int filter);
|
||||
int hxcmod_load( modcontext * modctx, void * mod_data, int mod_data_size );
|
||||
void hxcmod_fillbuffer( modcontext * modctx, unsigned short * outbuffer, unsigned long nbsample, tracker_buffer_state * trkbuf );
|
||||
void hxcmod_unload( modcontext * modctx );
|
||||
|
||||
#endif
|
||||
|
BIN
3rd-party/hxcmod-player/mods/nao-deceased_by_disease.mod
vendored
Normal file
BIN
3rd-party/hxcmod-player/mods/nao-deceased_by_disease.mod
vendored
Normal file
Binary file not shown.
119
3rd-party/hxcmod-player/readme.txt
vendored
Normal file
119
3rd-party/hxcmod-player/readme.txt
vendored
Normal file
@ -0,0 +1,119 @@
|
||||
Local copy used for A2DP Source demo in BTstack.
|
||||
|
||||
Github repository: https://github.com/jfdelnero/HxCModPlayer
|
||||
Thanks for providing this nice and compact implementation!
|
||||
|
||||
--------------------------------------------------------------------------------------
|
||||
Original readme.txt
|
||||
--------------------------------------------------------------------------------------
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
//-------------------------------------------------------------------------------//
|
||||
//-------------------------------------------------------------------------------//
|
||||
//-----------H----H--X----X-----CCCCC----22222----0000-----0000------11----------//
|
||||
//----------H----H----X-X-----C--------------2---0----0---0----0---1-1-----------//
|
||||
//---------HHHHHH-----X------C----------22222---0----0---0----0-----1------------//
|
||||
//--------H----H----X--X----C----------2-------0----0---0----0-----1-------------//
|
||||
//-------H----H---X-----X---CCCCC-----222222----0000-----0000----1111------------//
|
||||
//-------------------------------------------------------------------------------//
|
||||
//----------------------------------------------------- http://hxc2001.free.fr --//
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
HxCMOD player
|
||||
|
||||
The HxCMOD player is a tiny music module player.
|
||||
|
||||
It currently supports the Noisetracker/Soundtracker/Protracker Module Format (*.mod)
|
||||
|
||||
The core (hxcmod.c/hxcmod.h) is designed to have the least external dependency.
|
||||
So it should be usable on almost all OS and systems.
|
||||
You can use the hxcmod.c / hxcmod.h files to add a mod replay support
|
||||
to a demo/game/software.
|
||||
|
||||
You are free to do what you want with this code.
|
||||
(A credit is always appreciated if you include it into your prod ;) )
|
||||
|
||||
The test program is into the win32 folder. Just drag and drop a mod on the main
|
||||
window to load it. Linux & Mac OS X version it planned.
|
||||
|
||||
Please note that this core was "Emscriptened" successfully and is now working in
|
||||
JavaScript with Android, Chrome, Firefox, Edge, Safari browsers and probably
|
||||
with others browsers supporting the Web Audio API support.
|
||||
|
||||
You can test it at this address : http://hxc2001.free.fr/hxcmod/
|
||||
|
||||
A video demo of the native Mod player can be seen on youtube :
|
||||
https://www.youtube.com/watch?v=MEU9FGZzjac
|
||||
|
||||
--------------------------------------------------------------------------------------
|
||||
HxCMOD Core API
|
||||
--------------------------------------------------------------------------------------
|
||||
|
||||
int hxcmod_init( modcontext * modctx )
|
||||
|
||||
- Initialize the modcontext buffer. Must be called before doing anything else.
|
||||
Return 1 if success. 0 in case of error.
|
||||
|
||||
int hxcmod_setcfg( modcontext * modctx, int samplerate, int bits, int stereo, int stereo_separation, int filter);
|
||||
|
||||
- Configure the player :
|
||||
samplerate specify the sample rate. (44100 by default).
|
||||
bits specify the number of bits (16 bits only for the moment).
|
||||
stereo - if non null, the stereo mode is selected (default)
|
||||
stereo_separation - Left/Right channel separation.
|
||||
filter - if non null, the filter is applied (default)
|
||||
|
||||
int hxcmod_load( modcontext * modctx, void * mod_data, int mod_data_size )
|
||||
|
||||
- "Load" a MOD from memory (from "mod_data" with size "mod_data_size").
|
||||
Return 1 if success. 0 in case of error.
|
||||
|
||||
|
||||
void hxcmod_fillbuffer( modcontext * modctx, unsigned short * outbuffer, unsigned long nbsample, tracker_buffer_state * trkbuf )
|
||||
|
||||
- Generate and return the next samples chunk to outbuffer.
|
||||
nbsample specify the number of stereo 16bits samples you want.
|
||||
The output format is signed 44100Hz 16-bit Stereo PCM samples.
|
||||
The output buffer size in byte must be equal to ( nbsample * 2 * 2 ).
|
||||
The optional trkbuf parameter can be used to get detailed status of the player. Put NULL/0 if unused.
|
||||
|
||||
|
||||
void hxcmod_unload( modcontext * modctx )
|
||||
- "Unload" / clear the player status.
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------------
|
||||
Files on the repository
|
||||
--------------------------------------------------------------------------------------
|
||||
|
||||
- hxcmod.c / hxcmod.h
|
||||
The HxC core mod replay routines. These files don't have any dependency with others files
|
||||
and can be used into other project.
|
||||
|
||||
- framegenerator.c / framegenerator.h
|
||||
Generate a 640*480 framebuffer from the player status to be displayed in real-time.
|
||||
(not needed by the core)
|
||||
|
||||
- win32/
|
||||
The Windows test software.
|
||||
(linux & Mac version planned)
|
||||
|
||||
- js_emscripten/
|
||||
The Web browser/JavaScript version. (Build with Emscripten)
|
||||
|
||||
- packer/
|
||||
Data compression utility. Used to embed one mod and some graphical stuff into the executable.
|
||||
Not directly used by the core.
|
||||
|
||||
- data/
|
||||
Some packed data files.
|
||||
|
||||
--------------------------------------------------------------------------------------
|
||||
|
||||
Jean-François DEL NERO (Jeff) / HxC2001
|
||||
|
||||
Email : jeanfrancoisdelnero <> free.fr
|
||||
|
||||
http://hxc2001.free.fr
|
||||
|
||||
11 July 2015
|
Loading…
x
Reference in New Issue
Block a user