libmsx
C library for MSX
Loading...
Searching...
No Matches
sound.h
Go to the documentation of this file.
1// -*- coding: utf-8-unix -*-
2/*
3 * Copyright (c) 2021-2025 Daishi Mori (mori0091)
4 *
5 * This software is released under the MIT License.\n
6 * See https://github.com/mori0091/libmsx/blob/main/LICENSE
7 *
8 * GitHub libmsx project\n
9 * https://github.com/mori0091/libmsx
10 */
23#pragma once
24
25#ifndef SOUND_H
26#define SOUND_H
27
28#include <stdbool.h>
29#include <stdint.h>
30#include <stdlib.h>
31
42#define SOUND_CHANNEL_A (1 << 0)
43
47#define SOUND_CHANNEL_B (1 << 1)
48
52#define SOUND_CHANNEL_C (1 << 2)
53
57#define SOUND_CHANNEL_ALL (SOUND_CHANNEL_A | SOUND_CHANNEL_B | SOUND_CHANNEL_C)
58
63#define SOUND_SPEED_1X (4)
64
70#define SOUND_SPEED_MIN (1)
71
77#define SOUND_SPEED_MAX (8)
78
155 uint8_t* streams[3];
156};
157
173 uint16_t priority;
186};
187
199void sound_init(void);
200
223void sound_set_speed(uint8_t multiplier);
224
230void sound_set_volume(uint8_t volume);
231
237void sound_set_repeat(bool repeat);
238
253void sound_set_mute(uint8_t mute);
254
286void sound_effect(const struct sound_clip* s);
287
293void sound_set_bgm(const struct sound_clip* s);
294
298void sound_start(void);
299
303void sound_stop(void);
304
308void sound_pause(void);
309
335void sound_player(void);
336
339#endif
uint16_t priority
Priority for using this sound clip as a sound effect.
Definition sound.h:173
struct sound_fragment ** fragments
Pointer to an array of pointers to sound fragments.
Definition sound.h:185
size_t num_fragments
Number of sound fragments.
Definition sound.h:177
uint8_t * streams[3]
A list of pointers to the sound data stream for each channel.
Definition sound.h:155
void sound_stop(void)
MSX Stop the BGM.
void sound_set_speed(uint8_t multiplier)
MSX Sets the playback speed multiplier for background music.
void sound_set_volume(uint8_t volume)
MSX Set main volume level.
void sound_start(void)
MSX Start the BGM.
void sound_init(void)
MSX This function initializes the PSG and the sound driver.
void sound_effect(const struct sound_clip *s)
MSX Plays the specified music clip as sound effect.
void sound_pause(void)
MSX Pause the BGM.
void sound_set_mute(uint8_t mute)
MSX Mute/unmute for each sound channel.
void sound_player(void)
MSX Main routine of the sound driver.
void sound_set_repeat(bool repeat)
MSX Turn on/off the auto-repeat of the BGM.
void sound_set_bgm(const struct sound_clip *s)
MSX Sets the specified music clip as BGM in the sound driver.
The sound clip structure.
Definition sound.h:169
The sound fragment structure.
Definition sound.h:153