maug
Quick and dirty C mini-augmentation library.
Loading...
Searching...
No Matches
RetroSound API

Abstraction layer header for sound on retro systems. More...

Collaboration diagram for RetroSound API:

Topics

 RetroSound State Flags
 Flags indicating global state for the RETROSND_STATE::flags field.

Files

file  retrosnd.h
 Abstraction layer header for sound on retro systems.

Data Structures

struct  RETROSND_CHANNEL
struct  RETROSND_TUNE
 Simple tune designed to be played on the software synthesizer. More...

Macros

#define RETROSND_CHANNEL_CT_MAX   4
#define RETROSND_TRACE_LVL   0
#define RETROSND_REG_TRACE_LVL   0
#define RETROSND_SAMPLES_CT   2048
#define RETROSND_VOICE_BREATH   122
#define RETROSND_VOICE_SEASHORE   123
#define RETROSND_VOICE_BIRD_TWEET   124
#define RETROSND_VOICE_PHONE_RING   125
#define RETROSND_VOICE_HELICOPTER   126
#define RETROSND_VOICE_APPLAUSE   127
#define RETROSND_VOICE_GUNSHOT   128
 Parameter for retrosnd_set_voice() indicating a gunshot sound effect.
#define RETROSND_CONTROL_VOL   7
#define retrosnd_tune_get_note(tune, channel, idx)
#define RETROSND_TUNE_NOTE_DISABLED   (255)
#define RETROSND_NOTES_START   (36)
#define RETROSND_NOTES_OCTAVE_SZ   (12)
#define RETROSND_NOTES_SZ   (RETROSND_NOTES_OCTAVE_SZ * 3)
#define RETROSND_NOTES_OCTAVE_MIDDLE   (48)
#define RETROSND_NOTES_TABLE(f)

Functions

MERROR_RETVAL retrosnd_init (struct RETROFLAT_ARGS *args)
 Initialize retrosnd engine.
void retrosnd_set_sf_bank (const char *filename_in)
 Set the name of the voice bank filename to use.
void retrosnd_set_voice (uint8_t channel, uint8_t voice)
void retrosnd_set_control (uint8_t channel, uint8_t key, uint8_t val)
void retrosnd_note_on (uint8_t channel, uint8_t pitch, uint8_t vel)
void retrosnd_note_off (uint8_t channel, uint8_t pitch, uint8_t vel)
void retrosnd_shutdown (void)
void retrosnd_pump (void)
void retrosnd_note_on_deadline (uint8_t channel, uint8_t pitch, retroflat_ms_t after)
MERROR_RETVAL retrosnd_tune_init (MAUG_MHANDLE *p_tune_h, size_t notes_ct, uint16_t ms_per_note)
MERROR_RETVAL retrosnd_tune_update (struct RETROSND_TUNE *tune)
 Update the currently playing note in the given tune.
void retrosnd_tune_seek (struct RETROSND_TUNE *tune, int8_t idx)
MERROR_RETVAL retrosnd_tune_set_note (struct RETROSND_TUNE *, int channel, int index, int8_t note)
int16_t _retrosnd_generate_note (struct RETROSND_CHANNEL *channels)
 Increment synthesizer phase based on its instrument and system settings.
MERROR_RETVAL _retrosnd_set_control (struct RETROSND_CHANNEL *channel, uint8_t key, uint8_t val)
 Set controls for the software synthesizer.

Detailed Description

Abstraction layer header for sound on retro systems.

Macro Definition Documentation

◆ retrosnd_tune_get_note

#define retrosnd_tune_get_note ( tune,
channel,
idx )
Value:
((tune)->notes[idx][channel])

Function Documentation

◆ _retrosnd_generate_note()

int16_t _retrosnd_generate_note ( struct RETROSND_CHANNEL * channels)

Increment synthesizer phase based on its instrument and system settings.

Note
This should only be called by the API-specific implementation, and not a client program.

◆ _retrosnd_set_control()

MERROR_RETVAL _retrosnd_set_control ( struct RETROSND_CHANNEL * channel,
uint8_t key,
uint8_t val )

Set controls for the software synthesizer.

Note
This should only be called by the API-specific implementation, and not a client program.

◆ retrosnd_init()

MERROR_RETVAL retrosnd_init ( struct RETROFLAT_ARGS * args)

Initialize retrosnd engine.

Parameters
argsA pointer to the RETROSND_ARGS struct initialized by the calling program.

The RETROSND_ARGS::snd_io_base field must be initialized with the address or other platform-specific indicator of the MIDI device to use.

◆ retrosnd_tune_update()

MERROR_RETVAL retrosnd_tune_update ( struct RETROSND_TUNE * tune)

Update the currently playing note in the given tune.

Returns
MERROR_OVERFLOW if the tune is finished playing (runs out of notes) or MERROR_OK otherwise. If it is done playing, RETROSND_TUNE::current_note_idx will be reset to 0 automatically so that it will loop.

This should be called once per frame with the same tune.