libws libws
WSwan hardware library for the Wonderful toolchain
Loading...
Searching...
No Matches
sound.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2023 Adrian "asie" Siekierka
3 *
4 * This software is provided 'as-is', without any express or implied
5 * warranty. In no event will the authors be held liable for any damages
6 * arising from the use of this software.
7 *
8 * Permission is granted to anyone to use this software for any purpose,
9 * including commercial applications, and to alter it and redistribute it
10 * freely, subject to the following restrictions:
11 *
12 * 1. The origin of this software must not be misrepresented; you must not
13 * claim that you wrote the original software. If you use this software
14 * in a product, an acknowledgment in the product documentation would be
15 * appreciated but is not required.
16 *
17 * 2. Altered source versions must be plainly marked as such, and must not be
18 * misrepresented as being the original software.
19 *
20 * 3. This notice may not be removed or altered from any source distribution.
21 */
22
26
27#ifndef LIBWS_SOUND_H_
28#define LIBWS_SOUND_H_
29
30#ifndef __ASSEMBLER__
31#include <stdbool.h>
32#include <stdint.h>
33#endif
34#include "ports.h"
35#include "util.h"
36#include "system.h"
37
42
51#define WS_SOUND_UPDATE_HZ_TO_FREQ(hz) (-((uint16_t) WS_HZ_TO_CLOCK_DIVIDER((hz), WS_SYSTEM_CLOCK_HZ)))
52
68#define WS_SOUND_WAVE_HZ_TO_FREQ(hz, length) (-((uint16_t) WS_HZ_TO_CLOCK_DIVIDER((hz), WS_SYSTEM_CLOCK_HZ / (length))))
69
76#define WS_SOUND_SWEEP_HZ_TO_FREQ(hz) ((uint16_t) WS_HZ_TO_CLOCK_DIVIDER((hz), WS_SYSTEM_CLOCK_HZ / 8192))
77
78#ifndef __ASSEMBLER__
79
80typedef struct {
81 uint8_t data[16];
83
87
93void ws_sound_reset(void);
94
100static inline void ws_sound_set_wavetable_address(const void __wf_iram* address) {
102}
103
104#endif
105
107
108#endif /* LIBWS_SOUND_H_ */
#define WS_SOUND_WAVE_BASE_PORT
Definition ports.h:973
#define WS_SOUND_WAVE_BASE_ADDR(n)
Definition ports.h:974
static void ws_sound_set_wavetable_address(const void __wf_iram *address)
Set the base addresses of the sound wavetable.
Definition sound.h:100
void ws_sound_reset(void)
Reset the sound system.
uint8_t data[16]
Definition sound.h:81
ws_sound_wave_t wave[4]
Definition sound.h:85