Swadge 2024 2.0.0
APIs to develop games for the Magfest Swadge
Loading...
Searching...
No Matches
drums.c File Reference

Macros

#define FREQ_HZ(whole)   (((whole) & 0xFFFFu) << 16)
 
#define FREQ_HZ_FRAC(flhz)   ((((uint32_t)(flhz)) << 16) | ((uint32_t)(((flhz) - ((float)((uint32_t)(flhz)))) * 65536.0)))
 
#define TOM(idx, len, noiseVol, sineVol, freq, done)
 
#define DONUT_SAMPLE_RATE_HZ   8192
 
#define SAMPLE_FACTOR   (DAC_SAMPLE_RATE_HZ / DONUT_SAMPLE_RATE_HZ)
 

Functions

int8_t defaultDrumkitFunc (percussionNote_t drum, uint32_t idx, bool *done, uint32_t scratch[4], void *data)
 Produces sounds for a standard drumkit according to the General MIDI standard.
 
int8_t donutDrumkitFunc (percussionNote_t drum, uint32_t idx, bool *done, uint32_t scratch[4], void *data)
 Produces sounds for the drumkit that was included on the King Donut synth swadge.
 

Macro Definition Documentation

◆ FREQ_HZ

#define FREQ_HZ ( whole)    (((whole) & 0xFFFFu) << 16)

◆ FREQ_HZ_FRAC

#define FREQ_HZ_FRAC ( flhz)    ((((uint32_t)(flhz)) << 16) | ((uint32_t)(((flhz) - ((float)((uint32_t)(flhz)))) * 65536.0)))

◆ TOM

#define TOM ( idx,
len,
noiseVol,
sineVol,
freq,
done )
Value:
adrLerp(idx, (len) / 2, (len) / 2, noiseVol, 0) * swSynthSampleWave(NOISE, idx & 0xFF) / 256 \
+ adrLerp(idx, 128, ((len)-128), sineVol, 0) * sampleWaveAt(idx, SHAPE_SINE, freq) / 256 \
+ finishAt(len, idx, done)
@ NOISE
Definition midiPlayer.h:137
int8_t swSynthSampleWave(oscillatorShape_t shape, uint8_t idx)
Definition swSynth.c:353
@ SHAPE_SINE
A sine wave.
Definition swSynth.h:66

◆ DONUT_SAMPLE_RATE_HZ

#define DONUT_SAMPLE_RATE_HZ   8192

◆ SAMPLE_FACTOR

#define SAMPLE_FACTOR   (DAC_SAMPLE_RATE_HZ / DONUT_SAMPLE_RATE_HZ)

Function Documentation

◆ defaultDrumkitFunc()

int8_t defaultDrumkitFunc ( percussionNote_t drum,
uint32_t idx,
bool * done,
uint32_t scratch[4],
void * data )

Produces sounds for a standard drumkit according to the General MIDI standard.

Parameters
drumThe MIDI note corresponding to the drum to play
idxThe sample index, which should start at 0 for each note and increase by one every sample
doneA pointer to a boolean which will be set to true when the drum is finished sounding
scratchNot used by this drumkit
dataNot used by this drumkit
Returns
int8_t The signed 8-bit sample generated for this tick of the drumkit

◆ donutDrumkitFunc()

int8_t donutDrumkitFunc ( percussionNote_t drum,
uint32_t idx,
bool * done,
uint32_t scratch[4],
void * data )

Produces sounds for the drumkit that was included on the King Donut synth swadge.

This drumkit does not use the General MIDI drum note numbers

Parameters
drumThe drum index, between ACOUSTIC_BASS_DRUM_OR_LOW_BASS_DRUM and HIGH_BONGO, inclusive
idxThe sample index
doneA pointer to a boolean which will be set to true when the drum is finished sounding
scratchScratch space which is used to faithfully reproduce the drum sounds
dataNot used by this drumkit
Returns
int8_t The signed 8-bit sample generated for this tick of the drumkit