Skip to content

Latest commit

History

122 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

FM voice loading, saving and conversion library

Project status

Linux Build

Code for loading and saving various FM voice formats meant for the Yamaha YM series of chips (OPL, OPM, OPN etc.), format autodetection code, and conversion between the various formats.

This library is meant to be used in fmtoy and vgm2x.

File Formats

FormatTypeOpMax voices
INSOPN41
DMPOPN41
OPMOPM4unlimited
TFIOPN41
Y12OPN41
SBIOPL21
INSOPL21
BNKOPL265536
IBKOPL2128
CMFOPL2128/256/65536

Structures

OPL

FieldBitDescription
76543210
ch_fb_cnt[0]DCBAFBCNTChannel mask, feedback, connection
dam_dvb_ryt_bd_sd_tom_tc_hhAMVIBRYTBDSDTOMTCHH
am_vib_eg_ksr_mulAMVIBEGTKSRMUL
ksl_tlKSLTL
ar_drARDR
sl_rrSLRR
wsWSWaveform select

Conversion

Conversion between OPL, OPM and OPN voices is only possible in some cases, in other cases it involves approximation, and in others it is not possible.

OPM files

Reading:

uint8_t*data; // Have your data in this buffersize_tdata_len; // with this lengthstructopm_fileopm;
intr=opm_file_load(&opm, data, data_len);
if(r!=OPM_FILE_SUCCESS) {
fprintf(stderr, "Could not load file: %s (%d)\n", opm_file_error_string(r), r);
exit(1);
}

Writing:

size_twrite_fn(void*buf, size_tbufsize, void*data_ptr) {
FILE*f= (FILE*)data_ptr;
returnfwrite(buf, 1, bufsize, f);
}
structopm_fileopm;
opm_file_init(&opm);
FILE*f=fopen("out.opm", "w");
intopm_file_save(&opm, write_fn, f);
fclose(f);

Building with emscripten

emmake make libfmvoice.a

Formulae

OPM LFO

$f_{LFO} = \frac{f_{master}}{(8 \times (256 - R))}$

OPN LFO

$f_{LFO} = \frac{f_{master}}{2^{LFO\_DIV} \times (108 - LFO\_FREQ)}$

About

C library for loading, saving and converting FM sound chip voice files in various formats

Topics

Resources

Stars

9 stars

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages