libws libws
WSwan hardware library for the Wonderful toolchain
Loading...
Searching...
No Matches
Sound

Data Structures

struct  ws_sound_wave_t
struct  ws_sound_wavetable_t

Macros

#define WS_SOUND_UPDATE_HZ_TO_FREQ(hz)
 Convert a frequency in hertz to a channel frequency value, using the nearest approximation.
#define WS_SOUND_WAVE_HZ_TO_FREQ(hz, length)
 Convert a frequency in hertz to a channel frequency value for a wave sample of a given length, using the nearest approximation.
#define WS_SOUND_SWEEP_HZ_TO_FREQ(hz)
 Convert a frequency in hertz to a sweep channel update frequency value, using the nearest approximation.

Functions

void ws_sound_reset (void)
 Reset the sound system.
static void ws_sound_set_wavetable_address (const void __wf_iram *address)
 Set the base addresses of the sound wavetable.

Detailed Description

Macro Definition Documentation

◆ WS_SOUND_SWEEP_HZ_TO_FREQ

#define WS_SOUND_SWEEP_HZ_TO_FREQ ( hz)
Value:
((uint16_t) WS_HZ_TO_CLOCK_DIVIDER((hz), WS_SYSTEM_CLOCK_HZ / 8192))
#define WS_SYSTEM_CLOCK_HZ
System clock frequency, in hertz.
Definition system.h:38

Convert a frequency in hertz to a sweep channel update frequency value, using the nearest approximation.

Range: 13 .. 375 Hz

Definition at line 76 of file sound.h.

◆ WS_SOUND_UPDATE_HZ_TO_FREQ

#define WS_SOUND_UPDATE_HZ_TO_FREQ ( hz)
Value:
(-((uint16_t) WS_HZ_TO_CLOCK_DIVIDER((hz), WS_SYSTEM_CLOCK_HZ)))

Convert a frequency in hertz to a channel frequency value, using the nearest approximation.

Range: 1500 .. 3072000 Hz

Parameters
hzPlayback frequency, in hertz.

Definition at line 51 of file sound.h.

◆ WS_SOUND_WAVE_HZ_TO_FREQ

#define WS_SOUND_WAVE_HZ_TO_FREQ ( hz,
length )
Value:
(-((uint16_t) WS_HZ_TO_CLOCK_DIVIDER((hz), WS_SYSTEM_CLOCK_HZ / (length))))

Convert a frequency in hertz to a channel frequency value for a wave sample of a given length, using the nearest approximation.

Range:

2-sample wave -> 750 .. 1536000 Hz 4-sample wave -> 375 .. 768000 Hz 8-sample wave -> 188 .. 384000 Hz 16-sample wave -> 94 .. 192000 Hz 32-sample wave -> 47 .. 96000 Hz

Parameters
hzPlayback frequency, in hertz.
lengthLength, in samples (2, 4, 8, 16, 32).

Definition at line 68 of file sound.h.

Function Documentation

◆ ws_sound_reset()

void ws_sound_reset ( void )

Reset the sound system.

Clears all sound-related I/O ports, except for the wave table address.

◆ ws_sound_set_wavetable_address()

void ws_sound_set_wavetable_address ( const void __wf_iram * address)
inlinestatic

Set the base addresses of the sound wavetable.

Parameters
addressPointer to sound wavetable data.

Definition at line 100 of file sound.h.