Subversion Repositories SvarDOS

Rev

Rev 1661 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1661 mateusz.vi 1
/*
2
 * SoundBlaster routines for DSP driving
3
 *
4
 * Copyright (C) 2022 Mateusz Viste
5
 *
6
 * Permission is hereby granted, free of charge, to any person obtaining a copy
7
 * of this software and associated documentation files (the "Software"), to
8
 * deal in the Software without restriction, including without limitation the
9
 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10
 * sell copies of the Software, and to permit persons to whom the Software is
11
 * furnished to do so, subject to the following conditions:
12
 *
13
 * The above copyright notice and this permission notice shall be included in
14
 * all copies or substantial portions of the Software.
15
 *
16
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22
 * IN THE SOFTWARE.
23
 */
24
 
25
#ifndef MDR_SBDIGI_H
26
#define MDR_SBDIGI_H
27
 
28
struct sbdigi_ctx;
29
 
30
/* initializes the SoundBlaster DSP chip
31
 * blaster must point to a BLASTER environment string (like "A220 I5 D1")
32
 * returns a pointer to a context, NULL on error
33
 * NOTE: DSP's state after initialization may or may not be muted, depending
34
 *       on the exact hardware revision. use sbdigi_spkoff() to make sure it is
35
 *       unmuted */
36
struct sbdigi_ctx *sbdigi_init(const char *blaster);
37
 
38
/* unmutes the SoundBlaster DSP */
39
void sbdigi_spkon(struct sbdigi_ctx *ctx);
40
 
41
/* mutes the SoundBlaster DSP */
42
void sbdigi_spkoff(struct sbdigi_ctx *ctx);
43
 
44
/* plays a short sample
45
 * ctx - DSP context, as returned by sbdigi_init()
46
 * buf - pointer to sample data (must be PCM, 8000 Hz, mono, 8-bit unsigned
47
 * len - length of the sample, in bytes
48
 * NOTES: this routine uses DMA to transfer memory. This has two implications:
49
 *  1. the routine will return almost immediately, while the sound is playing
50
 *  2. sample data must be contained in a buffer that does NOT cross a 64K page
51
 *     because DMA transfers are unable to cross 64K boundaries */
52
void sbdigi_playsample(struct sbdigi_ctx *ctx, void *buf, unsigned short len);
53
 
54
/* shuts down the DSP and frees context memory */
55
void sbdigi_quit(struct sbdigi_ctx *ctx);
56
 
57
#endif