libmsx
C library for MSX
Loading...
Searching...
No Matches

Sound data structure for SNDDRV. More...

+ Collaboration diagram for Sound data structure:

Data Structures

struct  snd_Instrument
 Instrument (timbre) table. More...
 
struct  snd_p_table
 Pitch bend table. More...
 
struct  snd_SoundAssets
 Container of list of musics, instruments, arpeggio tables, and period tables. More...
 
struct  snd_Music
 Container of a music data. More...
 
struct  snd_Track
 A fragment of single channel music score. More...
 
struct  snd_SpeedTrack
 A special track to control speed of tracks. More...
 
struct  snd_EventTrack
 A special track to control event trigger of tracks. More...
 
struct  snd_Pattern
 A track pattern, that corresponds to a sub-score of a music. More...
 
struct  snd_Pattern.specialChannels
 
struct  snd_Pattern.channels
 

Macros

#define vec(T)
 Define a type generic vector (as named struct).
 
#define vec_fields(T)
 Define fields (member variables) of a type generic vector.
 

Typedefs

typedef struct snd_Instrument snd_Instrument
 Instrument (timbre) table.
 
typedef struct snd_p_table snd_PitchBend
 Type alias for arpeggio/pitch-bend table.
 
typedef struct snd_p_table snd_PeriodBend
 Type alias for wave-length/period modification table.
 
typedef struct snd_SoundAssets snd_SoundAssets
 Container of musics, instruments, pitch-bend tables, and period-bend tables.
 
typedef struct snd_Music snd_Music
 Container of a music data.
 
typedef struct snd_Track snd_Track
 A fragment of single channel music score.
 
typedef struct snd_SpeedTrack snd_SpeedTrack
 A special track to control speed of tracks.
 
typedef struct snd_EventTrack snd_EventTrack
 A special track to control event trigger of tracks.
 
typedef struct snd_Pattern snd_Pattern
 A track pattern, that corresponds to a sub-score of a music.
 

Detailed Description

Sound data structure for SNDDRV.


Data Structure Documentation

◆ snd_Instrument

struct snd_Instrument

Instrument (timbre) table.

An instrument table defines a time series data of an instrument's sound.

An instrument table contains 3 part of data streams:

  • ad_part: Attack to Decay phase.
    That starts on NoteOn message.
  • s_part : Sustain phase. (optional)
    That starts after ad_part and loopbacks until on NoteOff message.
  • r_part : Release phase. (optional)
    That starts on NoteOff message.

Definition at line 64 of file snd_i_table.h.

Data Fields
const uint8_t wait Wait counts (ticks per data chunk).

This determines the speed to process the instrument data stream:

  • if wait = 0, data is processed every ticks.
  • if wait = 1, data is processed every 2 ticks.
  • if wait = n, data is processed every n+1 ticks.
const uint8_t * ad_part Pointer to Atack..Decay part of data stream.
const uint8_t * s_part Pointer to Sustain part of data stream.

(loop part)

const uint8_t * r_part Pointer to Release part of data stream.

◆ snd_p_table

struct snd_p_table

Pitch bend table.

A pitch bend table defines a time series data of a pitch envelope such as pitch slide (pitch bend), vibrato, arpeggio.

An pitch bend table contains 3 part of data streams:

  • ad_part: Attack to Decay phase.
    That starts on NoteOn message.
  • s_part : Sustain phase. (optional)
    That starts after ad_part and loopbacks until on NoteOff message.
  • r_part : Release phase. (optional)
    That starts on NoteOff message.

Definition at line 56 of file snd_p_table.h.

Data Fields
const uint8_t wait Wait counts (ticks per data chunk).

This determines the speed to process the pitch bend data stream:

  • if wait = 0, data is processed every ticks.
  • if wait = 1, data is processed every 2 ticks.
  • if wait = n, data is processed every n+1 ticks.
const int16_t * ad_part Pointer to Atack..Decay part of data stream.
const int16_t * s_part Pointer to Sustain part of data stream.

(loop part)

const int16_t * r_part Pointer to Release part of data stream.

◆ snd_SoundAssets

struct snd_SoundAssets

Container of list of musics, instruments, arpeggio tables, and period tables.

A snd_SoundAssets object contains:

  • one or more instruments,
  • zero or more pitch-bend tables,
  • zero or more period-bend tables, and
  • one or more musics that shares and refers the above.

Definition at line 117 of file snd_sound.h.

+ Collaboration diagram for snd_SoundAssets:
Data Fields
struct vec_snd_PitchBend pitchBendTables
struct vec_snd_PeriodBend periodBendTables
struct vec_snd_Instrument instruments
struct vec_snd_Music musics

◆ snd_Music

struct snd_Music

Container of a music data.

A snd_Music object represents one music.

A snd_Music object contains:

  • all tracks refered in the music, and
  • all special tracks refered in the music.
  • a series of patterns that defines which track is played on which channel.

Ex. Defining a music my_music as of snd_Music type.

static const snd_Music my_music = {
.replayRate = 60, // [Hz]
.speedTracks = {
.length = ..., // number of speed tracks
.data = ..., // pointer to an array of `snd_SpeedTrack`s
},
.eventTracks = {
.length = ..., // number of event tracks
.data = ..., // pointer to an array of `snd_EventTrack`s
},
.tracks = {
.length = ..., // number of tracks
.data = ..., // pointer to an array of `snd_Track`s
},
.patterns = {
.length = ..., // number of track patterns.
.data = ..., // pointer to an array of `snd_Pattern`s.
},
.initialSpeed = 5,
.isLoop = false,
.loopToIndex = 0,
};
const uint8_t replayRate
Default player frequency that author expecting, in [Hz].
Definition snd_sound.h:171
Container of a music data.
Definition snd_sound.h:161

Definition at line 161 of file snd_sound.h.

+ Collaboration diagram for snd_Music:
Data Fields
const uint8_t format_version Version number of this data format to be used for future compatibility.
Note
Currently not used, the format_version must be 0.
const uint8_t replayRate Default player frequency that author expecting, in [Hz].
struct vec_snd_SpeedTrack speedTracks
struct vec_snd_EventTrack eventTracks
struct vec_snd_Track tracks
struct vec_snd_Pattern patterns
const uint8_t initialSpeed default wait count per line [tick].
const uint8_t isLoop true if loopback to the loopToIndex at the end of music.
const uint8_t loopToIndex pattern index of the beggining of loop.

◆ snd_Pattern

struct snd_Pattern

A track pattern, that corresponds to a sub-score of a music.

A snd_Pattern defines which track is played on which channel.
A vector / series of snd_Patterns corresponds to a full-score of a music.

Definition at line 217 of file snd_sound.h.

Data Fields
uint8_t height Number of effective lines of track(s).
struct snd_Pattern.specialChannels specialChannels
struct snd_Pattern.channels channels[3]

◆ snd_Pattern.specialChannels

struct snd_Pattern.specialChannels

Definition at line 219 of file snd_sound.h.

Data Fields
uint8_t speedTrack Index to the speed track.
uint8_t eventTrack Index to the event track.

◆ snd_Pattern.channels

struct snd_Pattern.channels

Definition at line 223 of file snd_sound.h.

Data Fields
uint8_t track Index to the track.
int16_t detune Pitch shift [1/256 semi-note].

Macro Definition Documentation

◆ vec

#define vec (   T)
Value:
struct vec_ ## T { \
vec_fields(T); \
}

Define a type generic vector (as named struct).

Parameters
Ttypename
Note
THIS MACRO IS INTERNAL USE ONLY and it will be undefined at the last of snd_sound.h.

Definition at line 89 of file snd_sound.h.

◆ vec_fields

#define vec_fields (   T)
Value:
\
const size_t length; \
\
const T * data

Define fields (member variables) of a type generic vector.

Parameters
Ttypename
Note
THIS MACRO IS INTERNAL USE ONLY and it will be undefined at the last of snd_sound.h.

Definition at line 102 of file snd_sound.h.

Typedef Documentation

◆ snd_Instrument

Instrument (timbre) table.

An instrument table defines a time series data of an instrument's sound.

An instrument table contains 3 part of data streams:

  • ad_part: Attack to Decay phase.
    That starts on NoteOn message.
  • s_part : Sustain phase. (optional)
    That starts after ad_part and loopbacks until on NoteOff message.
  • r_part : Release phase. (optional)
    That starts on NoteOff message.

Definition at line 46 of file snd_i_table.h.

◆ snd_PitchBend

typedef struct snd_p_table snd_PitchBend

Type alias for arpeggio/pitch-bend table.

Definition at line 33 of file snd_p_table.h.

◆ snd_PeriodBend

typedef struct snd_p_table snd_PeriodBend

Type alias for wave-length/period modification table.

Definition at line 37 of file snd_p_table.h.

◆ snd_SoundAssets

Container of musics, instruments, pitch-bend tables, and period-bend tables.

A snd_SoundAssets object contains:

  • one or more instruments,
  • zero or more pitch-bend tables,
  • zero or more period-bend tables, and
  • one or more musics that shares and refers the above.

Definition at line 43 of file snd_sound.h.

◆ snd_Music

typedef struct snd_Music snd_Music

Container of a music data.

A snd_Music object represents one music.

A snd_Music object contains:

  • all tracks refered in the music, and
  • all special tracks refered in the music item.
  • a series of patterns that defines which track is played on which channel.

Definition at line 55 of file snd_sound.h.

◆ snd_Track

typedef struct snd_Track snd_Track

A fragment of single channel music score.

Definition at line 60 of file snd_sound.h.

◆ snd_SpeedTrack

A special track to control speed of tracks.

Definition at line 65 of file snd_sound.h.

◆ snd_EventTrack

A special track to control event trigger of tracks.

Note
unused yet.

Definition at line 71 of file snd_sound.h.

◆ snd_Pattern

typedef struct snd_Pattern snd_Pattern

A track pattern, that corresponds to a sub-score of a music.

A snd_Pattern defines which track is played on which channel.
A vector / series of snd_Patterns corresponds to a full-score of a music.

Definition at line 79 of file snd_sound.h.