|
|
1.1 root 1: /*
2: Hatari - dlgSound.c
3:
4: This file is distributed under the GNU Public License, version 2 or at
5: your option any later version. Read the file gpl.txt for details.
6: */
1.1.1.7 root 7: const char DlgSound_fileid[] = "Hatari dlgSound.c : " __DATE__ " " __TIME__;
1.1 root 8:
9: #include "main.h"
10: #include "configuration.h"
11: #include "dialog.h"
12: #include "sdlgui.h"
13: #include "file.h"
14: #include "sound.h"
15:
16:
17: #define DLGSOUND_ENABLE 3
1.1.1.7 root 18: #define DLGSOUND_11KHZ 5
19: #define DLGSOUND_12KHZ 6
20: #define DLGSOUND_16KHZ 7
21: #define DLGSOUND_22KHZ 8
22: #define DLGSOUND_25KHZ 9
23: #define DLGSOUND_32KHZ 10
24: #define DLGSOUND_44KHZ 11
25: #define DLGSOUND_48KHZ 12
26: #define DLGSOUND_50KHZ 13
1.1.1.9 ! root 27: #define DLGSOUND_TABLE 15
! 28: #define DLGSOUND_LINEAR 16
! 29: #define DLGSOUND_RECNAME 20
! 30: #define DLGSOUND_RECBROWSE 21
! 31: #define DLGSOUND_RECORD 22
! 32: #define DLGSOUND_EXIT 23
1.1 root 33:
34:
35: static char dlgRecordName[35];
36:
37:
38: /* The sound dialog: */
1.1.1.4 root 39: static SGOBJ sounddlg[] =
1.1 root 40: {
1.1.1.9 ! root 41: { SGBOX, 0,0, 0, 0, 38,24, NULL },
! 42: { SGBOX, 0,0, 1, 1, 36,11, NULL },
! 43: { SGTEXT, 0,0, 4, 2, 13,1, "SOUND" },
! 44: { SGCHECKBOX, 0,0, 14, 2, 14,1, "Enabled" },
! 45:
! 46: { SGTEXT, 0,0, 4, 4, 14,1, "Playback quality:" },
! 47: { SGRADIOBUT, 0,0, 2, 6, 10,1, "11025 Hz" },
! 48: { SGRADIOBUT, 0,0, 2, 7, 10,1, "12517 Hz" },
! 49: { SGRADIOBUT, 0,0, 2, 8, 10,1, "16000 Hz" },
! 50: { SGRADIOBUT, 0,0, 14, 6, 10,1, "22050 Hz" },
! 51: { SGRADIOBUT, 0,0, 14, 7, 10,1, "25033 Hz" },
! 52: { SGRADIOBUT, 0,0, 14, 8, 10,1, "32000 Hz" },
! 53: { SGRADIOBUT, 0,0, 26, 6, 10,1, "44100 Hz" },
! 54: { SGRADIOBUT, 0,0, 26, 7, 10,1, "48000 Hz" },
! 55: { SGRADIOBUT, 0,0, 26, 8, 10,1, "50066 Hz" },
! 56:
! 57: { SGTEXT, 0,0, 2,10, 10,1, "YM mixing:" },
! 58: { SGRADIOBUT, 0,0, 14,10, 10,1, "ST table" },
! 59: { SGRADIOBUT, 0,0, 26,10, 10,1, "Linear" },
! 60:
! 61: { SGBOX, 0,0, 1,13, 36,8, NULL },
! 62: { SGTEXT, 0,0, 13,14, 14,1, "Capture YM/WAV" },
! 63: { SGTEXT, 0,0, 2,16, 26,1, "File name (*.wav / *.ym):" },
! 64: { SGTEXT, 0,0, 2,17, 34,1, dlgRecordName },
! 65: { SGBUTTON, 0,0, 28,16, 8,1, " Browse " },
! 66: { SGBUTTON, 0,0, 12,19, 16,1, NULL },
1.1.1.4 root 67: { SGBUTTON, SG_DEFAULT, 0, 10,22, 20,1, "Back to main menu" },
68: { -1, 0, 0, 0,0, 0,0, NULL }
1.1 root 69: };
70:
71:
1.1.1.7 root 72: static const int nSoundFreqs[] =
73: {
74: 11025,
75: 12517,
76: 16000,
77: 22050,
78: 25033,
79: 32000,
80: 44100,
81: 48000,
82: 50066
83: };
84:
85:
1.1 root 86: /*-----------------------------------------------------------------------*/
1.1.1.8 root 87: /**
88: * Show and process the sound dialog.
89: */
1.1 root 90: void Dialog_SoundDlg(void)
91: {
1.1.1.7 root 92: int but, i;
1.1 root 93:
1.1.1.4 root 94: SDLGui_CenterDlg(sounddlg);
1.1 root 95:
1.1.1.4 root 96: /* Set up dialog from actual values: */
97:
1.1.1.5 root 98: if (ConfigureParams.Sound.bEnableSound)
1.1.1.4 root 99: sounddlg[DLGSOUND_ENABLE].state |= SG_SELECTED;
100: else
101: sounddlg[DLGSOUND_ENABLE].state &= ~SG_SELECTED;
102:
1.1.1.7 root 103: for (i = DLGSOUND_11KHZ; i <= DLGSOUND_50KHZ; i++)
104: sounddlg[i].state &= ~SG_SELECTED;
105:
1.1.1.8 root 106: for (i = 0; i <= DLGSOUND_50KHZ-DLGSOUND_11KHZ; i++)
1.1.1.7 root 107: {
108: if (ConfigureParams.Sound.nPlaybackFreq > nSoundFreqs[i]-500
109: && ConfigureParams.Sound.nPlaybackFreq < nSoundFreqs[i]+500)
110: {
111: sounddlg[DLGSOUND_11KHZ + i].state |= SG_SELECTED;
112: break;
113: }
114: }
1.1.1.4 root 115:
1.1.1.9 ! root 116: sounddlg[DLGSOUND_TABLE].state &= ~SG_SELECTED;
! 117: sounddlg[DLGSOUND_LINEAR].state &= ~SG_SELECTED;
! 118: if (ConfigureParams.Sound.YmVolumeMixing == YM_TABLE_MIXING)
! 119: sounddlg[DLGSOUND_TABLE].state |= SG_SELECTED;
! 120: else
! 121: sounddlg[DLGSOUND_LINEAR].state |= SG_SELECTED;
! 122:
1.1.1.5 root 123: File_ShrinkName(dlgRecordName, ConfigureParams.Sound.szYMCaptureFileName, sounddlg[DLGSOUND_RECNAME].w);
1.1.1.4 root 124:
125: if ( Sound_AreWeRecording() )
126: sounddlg[DLGSOUND_RECORD].txt = "Stop recording";
127: else
128: sounddlg[DLGSOUND_RECORD].txt = "Record sound";
129:
130: /* The sound dialog main loop */
131: do
132: {
133: but = SDLGui_DoDialog(sounddlg, NULL);
134: switch (but)
135: {
136: case DLGSOUND_RECBROWSE: /* Choose a new record file */
137: SDLGui_FileConfSelect(dlgRecordName,
1.1.1.5 root 138: ConfigureParams.Sound.szYMCaptureFileName,
1.1.1.4 root 139: sounddlg[DLGSOUND_RECNAME].w,
1.1.1.7 root 140: true);
1.1.1.4 root 141: break;
142: case DLGSOUND_RECORD:
143: if (Sound_AreWeRecording())
144: {
145: sounddlg[DLGSOUND_RECORD].txt = "Record sound";
146: Sound_EndRecording();
147: }
148: else
149: {
150: /* make sure that we have a valid file name... */
1.1.1.5 root 151: if (strlen(ConfigureParams.Sound.szYMCaptureFileName) < 4)
1.1.1.4 root 152: {
1.1.1.5 root 153: strcpy(ConfigureParams.Sound.szYMCaptureFileName, "./hatari.wav");
1.1.1.4 root 154: }
155: sounddlg[DLGSOUND_RECORD].txt = "Stop recording";
1.1.1.5 root 156: Sound_BeginRecording(ConfigureParams.Sound.szYMCaptureFileName);
1.1.1.4 root 157: }
158: break;
159: }
160: }
161: while (but != DLGSOUND_EXIT && but != SDLGUI_QUIT
162: && but != SDLGUI_ERROR && !bQuitProgram );
163:
164: /* Read values from dialog */
1.1.1.5 root 165: ConfigureParams.Sound.bEnableSound = (sounddlg[DLGSOUND_ENABLE].state & SG_SELECTED);
1.1.1.7 root 166:
167: for (i = DLGSOUND_11KHZ; i <= DLGSOUND_50KHZ; i++)
168: {
169: if (sounddlg[i].state & SG_SELECTED)
170: {
171: ConfigureParams.Sound.nPlaybackFreq = nSoundFreqs[i-DLGSOUND_11KHZ];
172: break;
173: }
174: }
1.1.1.9 ! root 175:
! 176: if (sounddlg[DLGSOUND_TABLE].state & SG_SELECTED)
! 177: ConfigureParams.Sound.YmVolumeMixing = YM_TABLE_MIXING;
! 178: else
! 179: ConfigureParams.Sound.YmVolumeMixing = YM_LINEAR_MIXING;
1.1 root 180: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.