ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/bin/cfplus
(Generate patch)

Comparing deliantra/Deliantra-Client/bin/cfplus (file contents):
Revision 1.227 by root, Sun Sep 2 09:48:42 2007 UTC vs.
Revision 1.228 by root, Mon Oct 8 16:10:14 2007 UTC

408} 408}
409 409
410sub audio_init { 410sub audio_init {
411 if ($CFG->{audio_enable}) { 411 if ($CFG->{audio_enable}) {
412 $ENV{MIX_EFFECTSMAXSPEED} = 1; 412 $ENV{MIX_EFFECTSMAXSPEED} = 1;
413 $SDL_MIXER = !CFPlus::Mix_OpenAudio; 413 $SDL_MIXER = !CFPlus::Mix_OpenAudio
414 $CFG->{audio_hw_frequency},
415 CFPlus::MIX_DEFAULT_FORMAT,
416 $CFG->{audio_hw_channels},
417 $CFG->{audio_hw_chunksize};
414 418
415 unless ($SDL_MIXER) { 419 if ($SDL_MIXER) {
420 CFPlus::Mix_AllocateChannels $CFG->{audio_mix_channels};
421
422 audio_music_finished;
423 } else {
416 status "Unable to open sound device: there will be no sound"; 424 status "Unable to open sound device: there will be no sound";
417 return;
418 } 425 }
419
420 CFPlus::Mix_AllocateChannels 16;
421
422 audio_music_finished;
423 } else { 426 } else {
424 undef $SDL_MIXER; 427 undef $SDL_MIXER;
425 } 428 }
429
430 sub audio_tab_update;
431 audio_tab_update;
426} 432}
427 433
428sub audio_shutdown { 434sub audio_shutdown {
429 undef $MUSIC_PLAYER; 435 undef $MUSIC_PLAYER;
430 undef $MUSIC_PLAYING_META; 436 undef $MUSIC_PLAYING_META;
890 ); 896 );
891 897
892 $vbox 898 $vbox
893} 899}
894 900
901our $AUDIO_HW_CHUNKSIZE;
902our $AUDIO_INFO;
903
904sub audio_tab_update {
905 my ($freq, $format, $chans) = CFPlus::Mix_QuerySpec;
906
907 $AUDIO_HW_CHUNKSIZE->set_options ([
908 map {
909 my $ms = sprintf "%dms", 1000 * $_ / $CFG->{audio_hw_frequency};
910 [$_, $ms, "$ms ($_ samples)"],
911 } 256, 512, 1024, 2048, 4096, 8192, 16384, 32768
912 ]);
913
914 my $text = !$freq
915 ? "audio is off"
916 : "Frequency (Hz): $freq\n"
917 . "Channels: $chans";
918
919 $AUDIO_INFO->set_text ($text);
920}
921
895sub audio_setup { 922sub audio_setup {
896 my $vbox = new CFPlus::UI::VBox; 923 my $vbox = new CFPlus::UI::VBox;
897 924
898 $vbox->add (my $table = new CFPlus::UI::Table expand => 1, col_expand => [0, 0, 1]); 925 $vbox->add (my $table = new CFPlus::UI::Table expand => 1, col_expand => [0, 0, 1]);
899 926
901 928
902 $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Audio Enable"); 929 $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Audio Enable");
903 $table->add_at (1, $row++, new CFPlus::UI::CheckBox 930 $table->add_at (1, $row++, new CFPlus::UI::CheckBox
904 state => $CFG->{audio_enable}, 931 state => $CFG->{audio_enable},
905 tooltip => "<b>Master Audio Enable.</b> If enabled, sound effects and music will be played. If disabled, no audio will be used and the soundcard will not be opened.", 932 tooltip => "<b>Master Audio Enable.</b> If enabled, sound effects and music will be played. If disabled, no audio will be used and the soundcard will not be opened.",
906 on_changed => sub { $CFG->{audio_enable} = $_[1]; 0 } 933 on_changed => sub { $CFG->{audio_enable} = $_[1]; 1 }
907 ); 934 );
908# $table->add_at (0, 9, new CFPlus::UI::Label valign => 0, align => 1, text => "Effects Volume");
909# $table->add_at (1, 8, new CFPlus::UI::Slider range => [$CFG->{effects_volume}, 0, 128, 1], on_changed => sub {
910# $CFG->{effects_volume} = $_[1];
911# });
912 935
913 $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Sound Effects"); 936 $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Sound Effects");
914 $table->add_at (1, $row, new CFPlus::UI::CheckBox 937 $table->add_at (1, $row, new CFPlus::UI::CheckBox
915 expand => 1, state => $CFG->{effects_enable}, 938 expand => 1, state => $CFG->{effects_enable},
916 tooltip => "If enabled, sound effects are enabled. If disabled, no sound effects will be played.", 939 tooltip => "If enabled, sound effects are enabled. If disabled, no sound effects will be played.",
917 on_changed => sub { 940 on_changed => sub {
918 $CFG->{effects_enable} = $_[1]; 941 $CFG->{effects_enable} = $_[1];
919 $CONN->update_fx_want if $CONN; 942 $CONN->update_fx_want if $CONN;
920 0 943 1
921 } 944 }
922 ); 945 );
923 $table->add_at (2, $row++, new CFPlus::UI::Slider 946 $table->add_at (2, $row++, new CFPlus::UI::Slider
924 expand => 1, range => [$CFG->{effects_volume}, 0, 1, 0, 1/128], 947 expand => 1, range => [$CFG->{effects_volume}, 0, 1, 0, 1/128],
925 tooltip => "The relative volume of sound effects. Best audio quality is achieved if this " 948 tooltip => "The relative volume of sound effects. Best audio quality is achieved if this "
926 . "is set highest (rightmost) and you use your operating system volume setting. Changes are instant.", 949 . "is set highest (rightmost) and you use your operating system volume setting. Changes are instant.",
927 on_changed => sub { $CFG->{effects_volume} = $_[1]; 0 } 950 on_changed => sub { $CFG->{effects_volume} = $_[1]; 1 }
928 ); 951 );
929 952
930 $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Background Music"); 953 $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Background Music");
931 $table->add_at (1, $row, new CFPlus::UI::CheckBox 954 $table->add_at (1, $row, new CFPlus::UI::CheckBox
932 expand => 1, state => $CFG->{bgm_enable}, 955 expand => 1, state => $CFG->{bgm_enable},
933 tooltip => "If enabled, playing of background music is enabled. If disabled, no background music will be played.", 956 tooltip => "If enabled, playing of background music is enabled. If disabled, no background music will be played.",
934 on_changed => sub { 957 on_changed => sub {
935 $CFG->{bgm_enable} = $_[1]; 958 $CFG->{bgm_enable} = $_[1];
936 $CONN->update_fx_want if $CONN; 959 $CONN->update_fx_want if $CONN;
937 audio_music_push; 960 audio_music_push;
938 0 961 1
939 } 962 }
940 ); 963 );
941 $table->add_at (2, $row++, new CFPlus::UI::Slider 964 $table->add_at (2, $row++, new CFPlus::UI::Slider
942 expand => 1, range => [$CFG->{bgm_volume}, 0, 1, 0, 1/128], 965 expand => 1, range => [$CFG->{bgm_volume}, 0, 1, 0, 1/128],
943 tooltip => "The volume of the background music. Changes are instant.", 966 tooltip => "The volume of the background music. Changes are instant.",
944 on_changed => sub { $CFG->{bgm_volume} = $_[1]; audio_music_update_volume; 0 } 967 on_changed => sub { $CFG->{bgm_volume} = $_[1]; audio_music_update_volume; 0 }
968 );
969
970 $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Frequency");
971 $table->add_at (1, $row++, new CFPlus::UI::Selector
972 c_colspan => 2, expand => 1,
973 value => $CFG->{audio_hw_frequency},
974 options => [
975 [11025, "11 kHz" , "11kHz (low quality)"],
976 [22050, "22 kHz" , "22kHz (reduced quality)"],
977 [44100, "44.1 kHz", "44.1kHz (cd quality)"],
978 [48000, "48 kHz" , "48kHz (studio quality)"],
979 ],
980 tooltip => "The sampling frequency to use. Higher sounds better, but also more cpu-intensive and might cause stuttering.",
981 on_changed => sub {
982 $CFG->{audio_hw_frequency} = $_[1];
983 audio_tab_update;
984 1
985 }
986 );
987
988 $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Channels");
989 $table->add_at (1, $row++, new CFPlus::UI::Selector
990 c_colspan => 2, expand => 1,
991 value => $CFG->{audio_hw_channels},
992 options => [
993 [1, "Mono" , "Mono (single channel, low quality)"],
994 [2, "Stereo" , "Stereo (dual channe, standard quality)"],
995 [4, "4 Ch Surround", "4 Channel Surround Sound (3d sound, high quality)"],
996 [6, "6 Ch Surround", "6 Channel Surround Sound (3d sound + center + lfe)"],
997 ],
998 tooltip => "The number of independent sound channels to use. Higher sounds better, but also more cpu-intensive and might cause stuttering.",
999 on_changed => sub {
1000 $CFG->{audio_hw_channels} = $_[1];
1001 audio_tab_update;
1002 1
1003 }
1004 );
1005
1006 $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Latency");
1007 $table->add_at (1, $row++, $AUDIO_HW_CHUNKSIZE = new CFPlus::UI::Selector
1008 c_colspan => 2, expand => 1,
1009 value => $CFG->{audio_hw_chunksize},
1010 tooltip => "The guarenteed latency. Lower is better, but also more cpu-intensive and might cause stuttering. If music playback "
1011 . "is stuttering, increase this value. Values of 50-100ms are optimal.",
1012 on_changed => sub {
1013 $CFG->{audio_hw_chunksize} = $_[1]
1014 if $_[1];
1015 audio_tab_update;
1016 1
1017 }
1018 );
1019
1020 # should really be a slider
1021 $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Mixer Voices");
1022 $table->add_at (1, $row++, new CFPlus::UI::ValSlider
1023 c_colspan => 2, expand => 1,
1024 tooltip => "The number of simultaneous sound effects possible. Higher is better, but also more cpu-intensive and might cause stuttering.",
1025 range => [$::CFG->{audio_mix_channels}, 4, 32, 0, 1],
1026 template => ">= 99",
1027 on_changed => sub {
1028 my ($slider, $value) = @_;
1029
1030 $CFG->{audio_mix_channels} = $value
1031 if $value;
1032 1;
1033 }
945 ); 1034 );
946 1035
947 $table->add_at (1, $row++, new CFPlus::UI::Button 1036 $table->add_at (1, $row++, new CFPlus::UI::Button
948 c_colspan => 2, expand => 1, align => 0, text => "Apply", 1037 c_colspan => 2, expand => 1, align => 0, text => "Apply",
949 tooltip => "Apply the audio settings", 1038 tooltip => "Apply the audio settings",
951 audio_shutdown (); 1040 audio_shutdown ();
952 audio_init (); 1041 audio_init ();
953 0 1042 0
954 } 1043 }
955 ); 1044 );
1045
1046 $vbox->add (new CFPlus::UI::FancyFrame
1047 expand => 1,
1048 label => "Audio Info",
1049 child => ($AUDIO_INFO = new CFPlus::UI::Label ellipsise => 0),
1050 );
1051
1052 audio_tab_update;
956 1053
957 $vbox 1054 $vbox
958} 1055}
959 1056
960sub set_gauge_window_fontsize { 1057sub set_gauge_window_fontsize {
2253 gauge_fontsize => 1, 2350 gauge_fontsize => 1,
2254 gauge_size => 0.35, 2351 gauge_size => 0.35,
2255 stat_fontsize => 0.7, 2352 stat_fontsize => 0.7,
2256 mapsize => 100, 2353 mapsize => 100,
2257 audio_enable => 1, 2354 audio_enable => 1,
2355 audio_hw_channels => 2,
2356 audio_hw_frequency => 22050,
2357 audio_hw_chunksize => 2048,
2358 audio_mix_channels => 8,
2258 effects_enable => 1, 2359 effects_enable => 1,
2259 effects_volume => 1, 2360 effects_volume => 1,
2260 bgm_enable => 1, 2361 bgm_enable => 1,
2261 bgm_volume => 0.5, 2362 bgm_volume => 0.5,
2262 output_sync => 1, 2363 output_sync => 1,

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines