-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
dashodanger
committed
Jan 5, 2024
1 parent
14adab3
commit 31bb429
Showing
37 changed files
with
12,832 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
########################################## | ||
# m4p | ||
########################################## | ||
|
||
add_library( | ||
m4p | ||
it2drivers/sb16_m.c | ||
it2drivers/sb16.c | ||
it2drivers/zerovol.c | ||
loaders/mmcmp/mmcmp.c | ||
loaders/it.c | ||
loaders/s3m.c | ||
m4p.c | ||
ft_tables.c | ||
it_d_rm.c | ||
it_m_eff.c | ||
it_music.c | ||
it_tables.c | ||
pmp_main.c | ||
pmp_mix.c | ||
pmplay.c | ||
snd_masm.c | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,13 @@ | ||
# mod4play | ||
Lightweight embeddable replayer for IT/S3M/XM/MOD modules | ||
This is a unified interface for the ft2play (https://github.com/8bitbubsy/ft2play) and it2play (https://github.com/8bitbubsy/it2play) libraries by Olav Sørensen for embedding in game engines or other applications. SDL and winmm dependencies have been removed; the library is intended to receive an in-memory IT, S3M, MOD, or XM format module and produce samples on demand. All mixing drivers other than SB16 have been removed for simplicity. | ||
|
||
# Compilation | ||
A simple example CMakeLists file has been included showing which files need to be compiled. Include `m4p.h` in the source file that you are using to handle IT/S3M/MOD/XM playback. | ||
|
||
# Usage | ||
- (Optional step, this will also be done internally when attempting to load the module) Call `m4p_TestFromData` with a pointer to a memory buffer containing the tracker module and its length as parameters to test if the module is a format that is compatible with mod4play. A result of zero indicates that it is an unknown format and should not be used. | ||
- Load a supported module with the `m4p_LoadFromData` function, passing a pointer to a memory buffer containing the module, its length, the desired frequency/sample rate, and the desired mixing buffer size as parameters. The mixing buffer size should correspond to the size of the buffer you are planning on using as output for generated samples. This function will return `false` if a replayer was not successfully initialized. | ||
- Once successfully loaded, the memory buffer that you passed to this function can be safely freed if you are not otherwise using it. | ||
- Prepare the module for playback with the `m4p_PlaySong` function. This does not require any parameters and will not generate any audio yet. | ||
- In an appropriate place in your program, call the `m4p_GenerateSamples` function, passing a pointer to an initialized buffer to store the generated samples and the number of desired samples to generate as parameters. The number of samples to generate should be no more than the size of the buffer divided by `sizeof(s16_t)`. Generated samples will be in the form of pairs of signed 16-bit integers. | ||
- When finished with playback, call the `m4p_Close` function to reset the internal replayer, and the `m4p_FreeSong` function to free the internally allocated buffer containing the module. Neither function requires any parameters. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#pragma once | ||
|
||
#include <stdint.h> | ||
|
||
#ifdef _WIN32 | ||
|
||
#ifdef _WIN64 | ||
#define CPU_32BIT 0 | ||
#define CPU_64BIT 1 | ||
#else | ||
#define CPU_32BIT 1 | ||
#define CPU_64BIT 0 | ||
#endif | ||
|
||
#else | ||
#include <limits.h> | ||
|
||
#if __WORDSIZE == 64 | ||
#define CPU_32BIT 0 | ||
#define CPU_64BIT 1 | ||
#else | ||
#define CPU_32BIT 1 | ||
#define CPU_64BIT 0 | ||
#endif | ||
|
||
#endif | ||
|
||
#if CPU_64BIT | ||
#define CPU_BITS 64 | ||
#define uintCPUWord_t uint64_t | ||
#define intCPUWord_t int64_t | ||
#else | ||
#define CPU_BITS 32 | ||
#define uintCPUWord_t uint32_t | ||
#define intCPUWord_t int32_t | ||
#endif |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#pragma once | ||
|
||
#include <stdint.h> | ||
|
||
extern const uint32_t panningTab[257]; | ||
extern const uint16_t amigaPeriods[1936]; | ||
extern const uint16_t linearPeriods[1936]; | ||
extern const int32_t logTab[768]; | ||
extern const char *MODSig[16]; | ||
extern const uint16_t amigaPeriod[96]; | ||
extern const uint8_t vibTab[32]; | ||
extern const int8_t vibSineTab[256]; | ||
extern const uint8_t arpTab[256]; |
Oops, something went wrong.