fork of PCE focusing on macplus, supporting DaynaPort SCSI network emulation
1/*****************************************************************************
2 * pce *
3 *****************************************************************************/
4
5/*****************************************************************************
6 * File name: src/devices/speaker.h *
7 * Created: 2022-02-08 by Hampa Hug <hampa@hampa.ch> *
8 * Copyright: (C) 2022-2024 Hampa Hug <hampa@hampa.ch> *
9 *****************************************************************************/
10
11/*****************************************************************************
12 * This program is free software. You can redistribute it and / or modify it *
13 * under the terms of the GNU General Public License version 2 as published *
14 * by the Free Software Foundation. *
15 * *
16 * This program is distributed in the hope that it will be useful, but *
17 * WITHOUT ANY WARRANTY, without even the implied warranty of *
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General *
19 * Public License for more details. *
20 *****************************************************************************/
21
22
23#ifndef PCE_DEVICES_SPEAKER_H
24#define PCE_DEVICES_SPEAKER_H 1
25
26
27#include <drivers/sound/sound.h>
28
29
30#define SPEAKER_BUF 1024
31
32
33typedef struct {
34 sound_drv_t *drv;
35
36 unsigned long srate;
37 unsigned long input_clock;
38 unsigned speed_mul;
39
40 char enabled;
41
42 int speaker_inp;
43 uint16_t speaker_val;
44 uint16_t sample_acc;
45
46 uint16_t val_n;
47 uint16_t val_p;
48
49 uint16_t timeout_val;
50 unsigned long timeout_clk;
51 unsigned long timeout_max;
52
53 unsigned long clk;
54 unsigned long rem;
55
56 unsigned long lowpass_freq;
57 sound_iir2_t iir;
58
59 unsigned buf_cnt;
60 uint16_t buf[SPEAKER_BUF];
61
62 void *get_clock_ext;
63 unsigned long (*get_clock) (void *ext);
64} speaker_t;
65
66
67void spk_init (speaker_t *spk, int level);
68void spk_free (speaker_t *spk);
69
70speaker_t *_spk_new (int level);
71void spk_del (speaker_t *spk);
72
73void spk_set_clock_fct (speaker_t *spk, void *ext, void *fct);
74
75void spk_set_input_clock (speaker_t *spk, unsigned long clk);
76
77int spk_set_driver (speaker_t *spk, const char *driver, unsigned long srate);
78
79void spk_set_lowpass (speaker_t *spk, unsigned long freq);
80
81void spk_set_volume (speaker_t *spk, unsigned vol);
82
83void spk_set_input (speaker_t *spk, int val);
84
85void spk_check (speaker_t *spk);
86
87
88#endif