[Moeng-cvs] BBRpg/src rpg.cpp,1.8,1.8.2.1 sound.cpp,1.8,1.8.2.1 sound.h,1.6,1.6.2.1
Status: Alpha
Brought to you by:
b_lindeijer
From: <b_l...@us...> - 2004-01-06 23:16:37
|
Update of /cvsroot/moeng/BBRpg/src In directory sc8-pr-cvs1:/tmp/cvs-serv2502/src Modified Files: Tag: bbrpg rpg.cpp sound.cpp sound.h Log Message: Done some MIDI stuff (not finished) Index: rpg.cpp =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/rpg.cpp,v retrieving revision 1.8 retrieving revision 1.8.2.1 diff -C2 -d -r1.8 -r1.8.2.1 *** rpg.cpp 3 Jan 2004 22:41:02 -0000 1.8 --- rpg.cpp 6 Jan 2004 23:16:33 -0000 1.8.2.1 *************** *** 108,115 **** bVSync = get_config_int("Video", "VSync", 0); ! sound_enabled = (get_config_int("Sound", "EnableMusic", 1)) ? 1 : 0; ! sfx_enabled = (get_config_int("Sound", "EnableSfx", 1)) ? 1 : 0; music_vol = get_config_int("Sound", "MusicVolume", 255); sfx_vol = get_config_int("Sound", "SfxVolume", 255); // Screen initialisation --- 108,116 ---- bVSync = get_config_int("Video", "VSync", 0); ! sound_enabled = (get_config_int("Sound", "MusicEnabled", 1)) ? 1 : 0; ! sfx_enabled = (get_config_int("Sound", "SfxEnabled", 1)) ? 1 : 0; music_vol = get_config_int("Sound", "MusicVolume", 255); sfx_vol = get_config_int("Sound", "SfxVolume", 255); + music_format = (strcmp(get_config_string("Sound", "MusicFormat", "MIDI"), "MIDI") == 0) ? MUSIC_MIDI : MUSIC_OGG; // Screen initialisation *************** *** 170,181 **** } - // Lua initialisation - console.log(CON_LOG, CON_ALWAYS, "Initialising Lua scripting environment..."); - initScripting(); - if (sound_enabled || sfx_enabled) { console.log(CON_LOG, CON_ALWAYS, "Initialising sound..."); init_sound(); } console.log(CON_LOG, CON_ALWAYS, "Installing timers..."); --- 171,182 ---- } if (sound_enabled || sfx_enabled) { console.log(CON_LOG, CON_ALWAYS, "Initialising sound..."); init_sound(); } + + // Lua initialisation + console.log(CON_LOG, CON_ALWAYS, "Initialising Lua scripting environment..."); + initScripting(); console.log(CON_LOG, CON_ALWAYS, "Installing timers..."); Index: sound.cpp =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/sound.cpp,v retrieving revision 1.8 retrieving revision 1.8.2.1 diff -C2 -d -r1.8 -r1.8.2.1 *** sound.cpp 3 Jan 2004 22:41:02 -0000 1.8 --- sound.cpp 6 Jan 2004 23:16:33 -0000 1.8.2.1 *************** *** 28,31 **** --- 28,32 ---- int sfx_vol = 255; int music_vol = 255; + int music_format = 0; *************** *** 46,53 **** void init_sound() { - // Read config variables - //ChunkSize = (get_config_int("Sound", "StreamChunkSize", 1<<15)); - //BufferSize = (get_config_int("Sound", "BufferSize", 1<<16)); - // To achieve the max possible volume set_volume_per_voice(0); --- 47,50 ---- *************** *** 58,63 **** #endif // Install sound driver ! if (install_sound(DIGI_AUTODETECT, MIDI_NONE, NULL) != 0) { console.log(CON_LOG, CON_ALWAYS, "Error initialising sound system: %s", allegro_error); return; --- 55,70 ---- #endif + int midi_driver = MIDI_NONE; + int sound_driver = DIGI_NONE; + + if (music_format == MUSIC_MIDI) { + midi_driver = MIDI_AUTODETECT; + } + if (sfx_enabled || (sound_enabled && music_format != MUSIC_MIDI)) { + sound_driver = DIGI_AUTODETECT; + } + // Install sound driver ! if (install_sound(sound_driver, midi_driver, NULL) != 0) { console.log(CON_LOG, CON_ALWAYS, "Error initialising sound system: %s", allegro_error); return; *************** *** 89,111 **** if (sound_enabled) { ! // Stop currently playing music ! stop_music(channel); ! ! if (channel < 0 || channel > CHANNELS) {error = "invalid channel";} ! else if (!exists(filename)) {error = "file does not exist";} ! ! if (error == NULL) { ! /* ! channels[channel].sample = alogg_load_ogg(filename); ! if (!channels[channel].sample) { ! fprintf(stderr,"Error loading %s (%d)\n", filename, alogg_error_code); ! alogg_exit(); ! exit(1); } ! */ strncpy(channels[channel].filename, filename, 128); channels[channel].stream = alogg_start_streaming(channels[channel].filename, BLOCK_SIZE); if (!channels[channel].stream) { ! fprintf(stderr,"Error opening %s\n", filename); alogg_exit(); exit(1); --- 96,120 ---- if (sound_enabled) { ! if (music_format == MUSIC_MIDI) { ! replace_extension(channels[channel].filename, get_filename(filename), "mid", 128); ! ! DATAFILE *found_object = find_datafile_object(bitmap_data, channels[channel].filename); ! if (found_object) { ! play_looped_midi((MIDI*)found_object->dat, 0, -1); ! } else { ! console.log(CON_QUIT, CON_ALWAYS, "Could not find MIDI file in datafile (%s)", channels[channel].filename); } ! } else { ! // Stop currently playing music ! stop_music(channel); ! ! if (channel < 0 || channel > CHANNELS) {error = "invalid channel";} ! else if (!exists(filename)) {error = "file does not exist";} ! strncpy(channels[channel].filename, filename, 128); + channels[channel].stream = alogg_start_streaming(channels[channel].filename, BLOCK_SIZE); if (!channels[channel].stream) { ! fprintf(stderr,"Error opening %s\n", channels[channel].filename); alogg_exit(); exit(1); *************** *** 114,139 **** voice_set_volume(channels[channel].ass->voice, music_vol); } - - /* - channels[channel].voice = allocate_voice(channels[channel].sample); - if (channels[channel].voice == -1) { - error = "unable to allocate a voice"; - } - */ - - if (error == NULL) { - /* - voice_start(channels[channel].voice); - release_voice(channels[channel].voice); - channels[channel].voice = 0; - channels[channel].sample = NULL; - */ - console.log(CON_LOG | CON_CONSOLE, CON_ALWAYS, "Playing OGG file (%s)", filename); - } - else { - console.log(CON_LOG | CON_CONSOLE, CON_ALWAYS, "Error playing OGG file \"%s\" (%s)", filename, error); - } } ! return 0; } --- 123,135 ---- voice_set_volume(channels[channel].ass->voice, music_vol); } } ! ! if (error == NULL) { ! console.log(CON_LOG | CON_CONSOLE, CON_ALWAYS, "Playing music file (%s)", filename); ! } ! else { ! console.log(CON_LOG | CON_CONSOLE, CON_ALWAYS, "Error playing music file \"%s\" (%s)", filename, error); ! } ! return 0; } *************** *** 243,252 **** if (sfx_enabled) { - console.log(CON_LOG, CON_ALWAYS, "Trying to play sample: %s", name); - DATAFILE *found_object = find_datafile_object(bitmap_data, name); if (found_object) { ! //int play_sample(const SAMPLE *spl, int vol, int pan, int freq, int loop); play_sample((SAMPLE*)found_object->dat, sfx_vol, 128, 1000, 0); } else { --- 239,246 ---- if (sfx_enabled) { DATAFILE *found_object = find_datafile_object(bitmap_data, name); if (found_object) { ! console.log(CON_LOG, CON_ALWAYS, "Playing sample: %s", name); play_sample((SAMPLE*)found_object->dat, sfx_vol, 128, 1000, 0); } else { Index: sound.h =================================================================== RCS file: /cvsroot/moeng/BBRpg/src/sound.h,v retrieving revision 1.6 retrieving revision 1.6.2.1 diff -C2 -d -r1.6 -r1.6.2.1 *** sound.h 3 Jan 2004 22:41:02 -0000 1.6 --- sound.h 6 Jan 2004 23:16:33 -0000 1.6.2.1 *************** *** 25,28 **** --- 25,33 ---- extern int sfx_vol; extern int music_vol; + extern int music_format; + + #define MUSIC_MIDI 0 + #define MUSIC_OGG 1 + //#define DATASZ (1 << 15) /* (32768) amount of data to read from disk each time */ |