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-2024 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 */
22#pragma once
23
24#ifndef SOUND_H
25#define SOUND_H
26
27#include <stdbool.h>
28#include <stdint.h>
29#include <stdlib.h>
30
41#define SOUND_CHANNEL_A (1 << 0)
42
46#define SOUND_CHANNEL_B (1 << 1)
47
51#define SOUND_CHANNEL_C (1 << 2)
52
56#define SOUND_CHANNEL_ALL (SOUND_CHANNEL_A | SOUND_CHANNEL_B | SOUND_CHANNEL_C)
57
62#define SOUND_SPEED_1X (4)
63
69#define SOUND_SPEED_MIN (1)
70
76#define SOUND_SPEED_MAX (8)
77
154 uint8_t* streams[3];
155};
156
172 uint16_t priority;
185};
186
198void sound_init(void);
199
222void sound_set_speed(uint8_t multiplier);
223
229void sound_set_volume(uint8_t volume);
230
236void sound_set_repeat(bool repeat);
237
252void sound_set_mute(uint8_t mute);
253
285void sound_effect(const struct sound_clip* s);
286
292void sound_set_bgm(const struct sound_clip* s);
293
297void sound_start(void);
298
302void sound_stop(void);
303
307void sound_pause(void);
308
334void sound_player(void);
335
338#endif
uint16_t priority
Priority for using this sound clip as a sound effect.
Definition sound.h:172
struct sound_fragment ** fragments
Pointer to an array of pointers to sound fragments.
Definition sound.h:184
size_t num_fragments
Number of sound fragments.
Definition sound.h:176
uint8_t * streams[3]
A list of pointers to the sound data stream for each channel.
Definition sound.h:154
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:168
The sound fragment structure.
Definition sound.h:152