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