Changeset 3:c4af1e9ab8d1

Show
Ignore:
Timestamp:
08/01/08 22:07:29 (4 years ago)
Author:
thib
Branch:
default
convert_revision:
svn:d0a2da98-017c-47d2-8c43-22b54484806d/trunk@4
Message:
music volume can be changed (harcorded constant atm)
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • music2/music.cc

    r0 r3  
    4444using namespace std; 
    4545 
     46#define MUSIC_VOLUME 0.2 
     47 
    4648int pcm_enable   = 0; 
    4749Mix_Chunk *play_chunk[MIX_PCM_SIZE]; 
     
    199201                } 
    200202        } 
     203         
     204        int cur_vol = MUSIC_VOLUME*SDL_MIX_MAXVOLUME; 
     205         
    201206        if (fadetime_total) { 
    202207                // ²»³Ú€òÄä»ßÃæ (fade out) 
     
    208213                } 
    209214                // int cur_vol = 256*(count_total-fadecount)/count_total; 
    210                 int cur_vol = SDL_MIX_MAXVOLUME*(count_total-fadecount)/count_total; 
    211                 char* stream_dup = new char[len]; 
    212                 memcpy(stream_dup, stream, len); 
    213                 memset(stream, 0, len); 
    214                 SDL_MixAudio(stream, (Uint8*)stream_dup, len, cur_vol); 
     215                cur_vol = cur_vol*(count_total-fadecount)/count_total; 
    215216                fadecount += len/4; 
    216217        } 
     218         
     219        char* stream_dup = new char[len]; 
     220        memcpy(stream_dup, stream, len); 
     221        memset(stream, 0, len); 
     222        SDL_MixAudio(stream, (Uint8*)stream_dup, len, cur_vol); 
     223         
    217224        return; 
    218225} 
     
    243250        fadecount = 0; 
    244251        Mix_HookMusic( &(WavChunk::callback), (void*)&wav_playing); 
    245         Mix_VolumeMusic(128); 
     252        Mix_VolumeMusic(MUSIC_VOLUME*MIX_MAX_VOLUME); 
    246253        return; 
    247254}