hxcmod-player: updated and suppressed warnings

This commit is contained in:
Matthias Ringwald 2024-12-09 11:13:02 +01:00
parent 29274966a2
commit 8201da8822
4 changed files with 1157 additions and 295 deletions

2
3rd-party/README.md vendored
View File

@ -5,7 +5,7 @@ This folder contains all third-party libraries used by BTstack. The following ta
Library | Version | License | Used | Notes
----------------------------------------------------------------------------------------------------------------|----------|---------------|------------------|----------
[Android SBC Codec](https://android.googlesource.com/platform/external/bluetooth/bluedroid/+/master/embdrv/sbc) | e8c3d75b | Apache 2.0 | HFP WBS, A2DP | optimized audio codec
[hxcmod-player](https://github.com/jfdelnero/HxCModPlayer) | 03d495c8 | Public Domain | A2DP Source Demo | mod music player
[hxcmod-player](https://github.com/jfdelnero/HxCModPlayer) | f57bc0fd | Public Domain | A2DP Source Demo | mod music player
[Google LC3 Codec](https://github.com/google/liblc3.git) | bb85f7dd | Apache 2.0 | LE Audio | audio codec
[lwIP](http://savannah.nongnu.org/projects/lwip/) | b3a93941 | BSD 3-Clause | PAN Demo | complete network stack
[md5](http://openwall.info/wiki/people/solar/software/public-domain-source-code/md5) | 1.0 | Public Domain | PBAP | cryptographic hash function

File diff suppressed because it is too large Load Diff

View File

@ -16,28 +16,59 @@
//
// Change History (most recent first):
///////////////////////////////////////////////////////////////////////////////////
#ifndef __HXCMOD_H
#define __HXCMOD_H
#if defined __cplusplus
extern "C" {
#endif
#ifndef MODPLAY_DEF
#define MODPLAY_DEF
// Basic type
typedef unsigned char muchar;
typedef signed char mchar;
typedef unsigned short muint;
typedef short mint;
typedef unsigned long mulong;
#ifdef __cplusplus
extern "C" {
#endif
#ifndef HXCMOD_SLOW_TARGET
#define HXCMOD_STATE_REPORT_SUPPORT 1
#define HXCMOD_OUTPUT_FILTER 1
#define HXCMOD_OUTPUT_STEREO_MIX 1
#define HXCMOD_CLIPPING_CHECK 1
#endif
// Warning : The following option
// required 32KB of additional RAM :
// #define HXCMOD_USE_PRECALC_VOLUME_TABLE 1
// Basic type
typedef unsigned char muchar;
typedef signed char mchar;
typedef unsigned short muint;
typedef short mint;
typedef unsigned long mulong;
#ifdef HXCMOD_16BITS_TARGET
typedef unsigned short mssize;
#else
typedef unsigned long mssize;
#endif
#ifdef HXCMOD_8BITS_OUTPUT
#ifdef HXCMOD_UNSIGNED_OUTPUT
typedef unsigned char msample;
#else
typedef signed char msample;
#endif
#else
#ifdef HXCMOD_UNSIGNED_OUTPUT
typedef unsigned short msample;
#else
typedef signed short msample;
#endif
#endif
#ifdef HXCMOD_MAXCHANNELS
#define NUMMAXCHANNELS HXCMOD_MAXCHANNELS
#else
#define NUMMAXCHANNELS 32
#endif
#define NUMMAXCHANNELS 32
#define MAXNOTES 12*12
#define SAMPLE_RATE 44100
//
// MOD file structures
//
@ -77,18 +108,47 @@ typedef struct {
//
typedef struct {
mchar * sampdata;
muint sampnum;
muint length;
muint reppnt;
muint replen;
muchar sampnum;
mchar * nxt_sampdata;
muint nxt_length;
muint nxt_reppnt;
muint nxt_replen;
muchar update_nxt_repeat;
mchar * dly_sampdata;
muint dly_length;
muint dly_reppnt;
muint dly_replen;
muchar note_delay;
mchar * lst_sampdata;
muint lst_length;
muint lst_reppnt;
muint lst_replen;
muchar retrig_cnt;
muchar retrig_param;
muint funkoffset;
mint funkspeed;
mint glissando;
mulong samppos;
mulong sampinc;
muint period;
muchar volume;
mulong ticks;
#ifdef HXCMOD_USE_PRECALC_VOLUME_TABLE
mint * volume_table;
#endif
muchar effect;
muchar parameffect;
muint effect_code;
mulong last_set_offset;
mint decalperiod;
mint portaspeed;
@ -97,7 +157,6 @@ typedef struct {
mint Arpperiods[3];
muchar ArpIndex;
mint oldk;
muchar volumeslide;
muchar vibraparam;
@ -109,32 +168,45 @@ typedef struct {
muint patternloopcnt;
muint patternloopstartpoint;
} hxcmod_channel;
} channel;
typedef struct {
module song;
mchar * sampledata[31];
note * patterndata[128];
#ifdef HXCMOD_16BITS_TARGET
muint playrate;
#else
mulong playrate;
#endif
muint tablepos;
muint patternpos;
muint patterndelay;
muint jump_loop_effect;
muchar jump_loop_effect;
muchar bpm;
#ifdef HXCMOD_16BITS_TARGET
muint patternticks;
muint patterntickse;
muint patternticksaim;
muint patternticksem;
muint tick_cnt;
#else
mulong patternticks;
mulong patterntickse;
mulong patternticksaim;
mulong patternticksem;
mulong tick_cnt;
#endif
mulong sampleticksconst;
mulong samplenb;
hxcmod_channel channels[NUMMAXCHANNELS];
channel channels[NUMMAXCHANNELS];
muint number_of_channels;
muint fullperiod[MAXNOTES * 8];
muint mod_loaded;
mint last_r_sample;
@ -145,6 +217,15 @@ typedef struct {
mint bits;
mint filter;
#ifdef EFFECTS_USAGE_STATE
int effects_event_counts[32];
#endif
#ifdef HXCMOD_USE_PRECALC_VOLUME_TABLE
mint precalc_volume_array[65*256];
mint * volume_selection_table[65];
#endif
} modcontext;
//
@ -168,7 +249,7 @@ typedef struct tracker_state_
int cur_pattern_pos;
int cur_pattern_table_pos;
unsigned int buf_index;
track_state tracks[32];
track_state tracks[NUMMAXCHANNELS];
}tracker_state;
typedef struct tracker_state_instrument_
@ -201,7 +282,7 @@ typedef struct tracker_buffer_state_
// - "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 )
// void hxcmod_fillbuffer( modcontext * modctx, unsigned short * outbuffer, mssize nbsample, tracker_buffer_state * trkbuf )
//
// - Generate and return the next samples chunk to outbuffer.
// nbsample specify the number of stereo 16bits samples you want.
@ -210,21 +291,19 @@ typedef struct tracker_buffer_state_
// 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_setcfg( modcontext * modctx, int samplerate, 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_fillbuffer( modcontext * modctx, msample * outbuffer, mssize nbsample, tracker_buffer_state * trkbuf );
void hxcmod_unload( modcontext * modctx );
#endif
#if defined __cplusplus
#ifdef __cplusplus
}
#endif
#endif // __HXCMOD_H
#endif /* MODPLAY_DEF */

View File

@ -42,9 +42,16 @@ 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 :
The native Mod player demonstration video is available on youtube :
https://www.youtube.com/watch?v=MEU9FGZzjac
Another video showing the player working on a STM32F105 microcontroller based device :
https://www.youtube.com/watch?v=kiOT8-zWVkA
Another case, this time with an STM32 microcontroller without DAC hardware.
The firmware implements a 1 bit delta sigma / PDM stream generator :
https://www.youtube.com/watch?v=AQ--IiXPUGA
--------------------------------------------------------------------------------------
HxCMOD Core API
--------------------------------------------------------------------------------------
@ -54,12 +61,10 @@ 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);
int hxcmod_setcfg( modcontext * modctx, int samplerate, 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)
@ -73,15 +78,29 @@ void hxcmod_fillbuffer( modcontext * modctx, unsigned short * outbuffer, unsigne
- 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 default output format is signed 44100Hz 16-bit Stereo PCM samples.
The output format can be changed with the C flags HXCMOD_MONO_OUTPUT, HXCMOD_8BITS_OUTPUT and HXCMOD_UNSIGNED_OUTPUT.
The output buffer size in byte must be equal to ( nbsample * sample_size * (mono=1 or stereo=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.
Compile-time C defines options :
HXCMOD_MONO_OUTPUT : Turn the output format in mono mode.
HXCMOD_8BITS_OUTPUT : Set the output wave format in 8bits.
HXCMOD_UNSIGNED_OUTPUT : Set the output wave format unsigned.
HXCMOD_MAXCHANNELS : Set the maximum supported channels (default : 32).
Reduce it to gain some RAM space.
Increase it if you want to support some specials mods
(up to 999).
HXCMOD_BIGENDIAN_MACHINE : The target machine is big endian.
HXCMOD_SLOW_TARGET : For slow targets : Disable stereo mixing and output filter.
HXCMOD_USE_PRECALC_VOLUME_TABLE : Use precalculated volume table for the mixing.
suppress the multiply operations for slow targets.
The table need 32KB of RAM.
--------------------------------------------------------------------------------------
Files on the repository
--------------------------------------------------------------------------------------
@ -101,6 +120,9 @@ The Windows test software.
- js_emscripten/
The Web browser/JavaScript version. (Build with Emscripten)
- STM32/
STM32 microcontroller / "Gotek" demo.
- packer/
Data compression utility. Used to embed one mod and some graphical stuff into the executable.
Not directly used by the core.