Rework the OS X MIDI disabling code, as SDL_mixer 1.2.11 fixes the crash. Check...
[chocolate-doom.git] / setup / sound.c
blob9e02aeec8f128419464b71edb67fff0d5921ced9
1 // Emacs style mode select -*- C++ -*-
2 //-----------------------------------------------------------------------------
3 //
4 // Copyright(C) 2006 Simon Howard
5 //
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19 // 02111-1307, USA.
22 // Sound control menu
24 #include <stdlib.h>
26 #include "textscreen.h"
28 #include "sound.h"
30 typedef enum
32 SFXMODE_DISABLED,
33 SFXMODE_PCSPEAKER,
34 SFXMODE_DIGITAL,
35 NUM_SFXMODES
36 } sfxmode_t;
38 static char *sfxmode_strings[] =
40 "Disabled",
41 "PC speaker",
42 "Digital",
45 int snd_sfxdevice = SNDDEVICE_SB;
46 int numChannels = 8;
47 int sfxVolume = 15;
49 int snd_musicdevice = SNDDEVICE_SB;
50 int musicVolume = 15;
52 int snd_samplerate = 22050;
54 int use_libsamplerate = 0;
56 static int snd_sfxmode;
57 static int snd_musicenabled;
59 static void UpdateSndDevices(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(data))
61 switch (snd_sfxmode)
63 case SFXMODE_DISABLED:
64 snd_sfxdevice = SNDDEVICE_NONE;
65 break;
66 case SFXMODE_PCSPEAKER:
67 snd_sfxdevice = SNDDEVICE_PCSPEAKER;
68 break;
69 case SFXMODE_DIGITAL:
70 snd_sfxdevice = SNDDEVICE_SB;
71 break;
74 if (snd_musicenabled)
76 snd_musicdevice = SNDDEVICE_SB;
78 else
80 snd_musicdevice = SNDDEVICE_NONE;
84 void ConfigSound(void)
86 txt_window_t *window;
87 txt_table_t *sfx_table;
88 txt_table_t *music_table;
89 txt_dropdown_list_t *sfx_mode_control;
90 txt_checkbox_t *music_enabled_control;
92 if (snd_sfxdevice == SNDDEVICE_PCSPEAKER)
94 snd_sfxmode = SFXMODE_PCSPEAKER;
96 else if (snd_sfxdevice >= SNDDEVICE_SB)
98 snd_sfxmode = SFXMODE_DIGITAL;
100 else
102 snd_sfxmode = SFXMODE_DISABLED;
105 snd_musicenabled = snd_musicdevice != SNDDEVICE_NONE;
107 window = TXT_NewWindow("Sound configuration");
109 TXT_AddWidgets(window,
110 TXT_NewSeparator("Sound effects"),
111 sfx_table = TXT_NewTable(2),
112 TXT_NewSeparator("Music"),
113 music_enabled_control = TXT_NewCheckBox("Music enabled",
114 &snd_musicenabled),
115 music_table = TXT_NewTable(2),
116 NULL);
118 TXT_SetColumnWidths(sfx_table, 20, 5);
120 TXT_AddWidgets(sfx_table,
121 TXT_NewLabel("Sound effects"),
122 sfx_mode_control = TXT_NewDropdownList(&snd_sfxmode,
123 sfxmode_strings,
124 NUM_SFXMODES),
125 TXT_NewLabel("Sound channels"),
126 TXT_NewSpinControl(&numChannels, 1, 8),
127 TXT_NewLabel("SFX volume"),
128 TXT_NewSpinControl(&sfxVolume, 0, 15),
129 NULL);
131 TXT_SetColumnWidths(music_table, 20, 5);
133 TXT_AddWidgets(music_table,
134 TXT_NewLabel("Music volume"),
135 TXT_NewSpinControl(&musicVolume, 0, 15),
136 NULL);
138 TXT_SignalConnect(sfx_mode_control, "changed",
139 UpdateSndDevices, NULL);
140 TXT_SignalConnect(music_enabled_control, "changed",
141 UpdateSndDevices, NULL);