|
|
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.4 ! root 7: const char DlgSound_rcsid[] = "Hatari $Id: dlgSound.c,v 1.10 2008/02/23 22:16:07 thothy Exp $";
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
18: #define DLGSOUND_LOW 5
19: #define DLGSOUND_MEDIUM 6
20: #define DLGSOUND_HIGH 7
21: #define DLGSOUND_RECNAME 11
22: #define DLGSOUND_RECBROWSE 12
23: #define DLGSOUND_RECORD 13
24: #define DLGSOUND_EXIT 14
25:
26:
27: static char dlgRecordName[35];
28:
29:
30: /* The sound dialog: */
1.1.1.4 ! root 31: static SGOBJ sounddlg[] =
1.1 root 32: {
1.1.1.4 ! root 33: { SGBOX, 0, 0, 0,0, 38,24, NULL },
! 34: { SGBOX, 0, 0, 1,1, 36,11, NULL },
! 35: { SGTEXT, 0, 0, 13,2, 13,1, "Sound options" },
! 36: { SGCHECKBOX, 0, 0, 12,4, 14,1, "Enable sound" },
! 37: { SGTEXT, 0, 0, 11,6, 14,1, "Playback quality:" },
! 38: { SGRADIOBUT, 0, 0, 12,8, 15,1, "Low (11kHz)" },
! 39: { SGRADIOBUT, 0, 0, 12,9, 19,1, "Medium (22kHz)" },
! 40: { SGRADIOBUT, 0, 0, 12,10, 14,1, "High (44kHz)" },
! 41: { SGBOX, 0, 0, 1,13, 36,8, NULL },
! 42: { SGTEXT, 0, 0, 13,14, 14,1, "Capture YM/WAV" },
! 43: { SGTEXT, 0, 0, 2,16, 26,1, "File name (*.wav or *.ym):" },
! 44: { SGTEXT, 0, 0, 2,17, 34,1, dlgRecordName },
! 45: { SGBUTTON, 0, 0, 30,16, 6,1, "Browse" },
! 46: { SGBUTTON, 0, 0, 12,19, 16,1, NULL },
! 47: { SGBUTTON, SG_DEFAULT, 0, 10,22, 20,1, "Back to main menu" },
! 48: { -1, 0, 0, 0,0, 0,0, NULL }
1.1 root 49: };
50:
51:
52: /*-----------------------------------------------------------------------*/
53: /*
54: Show and process the sound dialog.
55: */
56: void Dialog_SoundDlg(void)
57: {
1.1.1.4 ! root 58: int but;
1.1 root 59:
1.1.1.4 ! root 60: SDLGui_CenterDlg(sounddlg);
1.1 root 61:
1.1.1.4 ! root 62: /* Set up dialog from actual values: */
! 63:
! 64: if (DialogParams.Sound.bEnableSound)
! 65: sounddlg[DLGSOUND_ENABLE].state |= SG_SELECTED;
! 66: else
! 67: sounddlg[DLGSOUND_ENABLE].state &= ~SG_SELECTED;
! 68:
! 69: sounddlg[DLGSOUND_LOW].state &= ~SG_SELECTED;
! 70: sounddlg[DLGSOUND_MEDIUM].state &= ~SG_SELECTED;
! 71: sounddlg[DLGSOUND_HIGH].state &= ~SG_SELECTED;
! 72: if (DialogParams.Sound.nPlaybackQuality == PLAYBACK_LOW)
! 73: sounddlg[DLGSOUND_LOW].state |= SG_SELECTED;
! 74: else if (DialogParams.Sound.nPlaybackQuality == PLAYBACK_MEDIUM)
! 75: sounddlg[DLGSOUND_MEDIUM].state |= SG_SELECTED;
! 76: else
! 77: sounddlg[DLGSOUND_HIGH].state |= SG_SELECTED;
! 78:
! 79: File_ShrinkName(dlgRecordName, DialogParams.Sound.szYMCaptureFileName, sounddlg[DLGSOUND_RECNAME].w);
! 80:
! 81: if ( Sound_AreWeRecording() )
! 82: sounddlg[DLGSOUND_RECORD].txt = "Stop recording";
! 83: else
! 84: sounddlg[DLGSOUND_RECORD].txt = "Record sound";
! 85:
! 86: /* The sound dialog main loop */
! 87: do
! 88: {
! 89: but = SDLGui_DoDialog(sounddlg, NULL);
! 90: switch (but)
! 91: {
! 92: case DLGSOUND_RECBROWSE: /* Choose a new record file */
! 93: SDLGui_FileConfSelect(dlgRecordName,
! 94: DialogParams.Sound.szYMCaptureFileName,
! 95: sounddlg[DLGSOUND_RECNAME].w,
! 96: TRUE);
! 97: break;
! 98: case DLGSOUND_RECORD:
! 99: if (Sound_AreWeRecording())
! 100: {
! 101: sounddlg[DLGSOUND_RECORD].txt = "Record sound";
! 102: Sound_EndRecording();
! 103: }
! 104: else
! 105: {
! 106: /* make sure that we have a valid file name... */
! 107: if (strlen(DialogParams.Sound.szYMCaptureFileName) < 4)
! 108: {
! 109: strcpy(DialogParams.Sound.szYMCaptureFileName, "./hatari.wav");
! 110: }
! 111: sounddlg[DLGSOUND_RECORD].txt = "Stop recording";
! 112: Sound_BeginRecording(DialogParams.Sound.szYMCaptureFileName);
! 113: }
! 114: break;
! 115: }
! 116: }
! 117: while (but != DLGSOUND_EXIT && but != SDLGUI_QUIT
! 118: && but != SDLGUI_ERROR && !bQuitProgram );
! 119:
! 120: /* Read values from dialog */
! 121: DialogParams.Sound.bEnableSound = (sounddlg[DLGSOUND_ENABLE].state & SG_SELECTED);
! 122: if (sounddlg[DLGSOUND_LOW].state & SG_SELECTED)
! 123: DialogParams.Sound.nPlaybackQuality = PLAYBACK_LOW;
! 124: else if (sounddlg[DLGSOUND_MEDIUM].state & SG_SELECTED)
! 125: DialogParams.Sound.nPlaybackQuality = PLAYBACK_MEDIUM;
! 126: else
! 127: DialogParams.Sound.nPlaybackQuality = PLAYBACK_HIGH;
1.1 root 128: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.