void pause_sound_if_necessary_and_play_video(const char *name, int skip, int flags)
{
    int musplaying = play.cur_music_number, i;
    int ambientWas[MAX_SOUND_CHANNELS];
    for (i = 1; i < MAX_SOUND_CHANNELS; i++)
        ambientWas[i] = ambient[i].channel;

    if ((strlen(name) > 3) && (stricmp(&name[strlen(name) - 3], "ogv") == 0))
    {
        play_theora_video(name, skip, flags);
    }
    else
    {
        char videoFilePath[MAX_PATH];
        get_install_dir_path(videoFilePath, name);

        platform->PlayVideo(videoFilePath, skip, flags);
    }

    if (flags < 10) 
    {
        update_music_volume();
        // restart the music
        if (musplaying >= 0)
            newmusic (musplaying);
        for (i = 1; i < MAX_SOUND_CHANNELS; i++) {
            if (ambientWas[i] > 0)
                PlayAmbientSound(ambientWas[i], ambient[i].num, ambient[i].vol, ambient[i].x, ambient[i].y);
        }
    }
}
Exemple #2
0
void PlayMP3File (const char *filename) {
    if (strlen(filename) >= PLAYMP3FILE_MAX_FILENAME_LEN)
        quit("!PlayMP3File: filename too long");

    debug_script_log("PlayMP3File %s", filename);

    AssetPath asset_name("", filename);

    int useChan = prepare_for_new_music ();
    bool doLoop = (play.music_repeat > 0);

    if ((channels[useChan] = my_load_static_ogg(asset_name, 150, doLoop)) != NULL) {
        channels[useChan]->play();
        current_music_type = MUS_OGG;
        play.cur_music_number = 1000;
        // save the filename (if it's not what we were supplied with)
        if (filename != &play.playmp3file_name[0])
            strcpy (play.playmp3file_name, filename);
    }
    else if ((channels[useChan] = my_load_static_mp3(asset_name, 150, doLoop)) != NULL) {
        channels[useChan]->play();
        current_music_type = MUS_MP3;
        play.cur_music_number = 1000;
        // save the filename (if it's not what we were supplied with)
        if (filename != &play.playmp3file_name[0])
            strcpy (play.playmp3file_name, filename);
    }
    else
        debug_script_warn ("PlayMP3File: file '%s' not found or cannot play", filename);

    post_new_music_check(useChan);

    update_music_volume();
}
Exemple #3
0
void SetMusicMasterVolume(int newvol) {
    const int min_volume = loaded_game_file_version < kGameVersion_330 ? 0 :
        -LegacyMusicMasterVolumeAdjustment - (kRoomVolumeMax * LegacyRoomVolumeFactor);
    if ((newvol < min_volume) | (newvol>100))
        quitprintf("!SetMusicMasterVolume: invalid volume - must be from %d to %d", min_volume, 100);
    play.music_master_volume=newvol+LegacyMusicMasterVolumeAdjustment;
    update_music_volume();
}
Exemple #4
0
void stopmusic() {

  if (crossFading > 0) {
    // stop in the middle of a new track fading in
    // Abort the new track, and let the old one finish fading out
    stop_and_destroy_channel (crossFading);
    crossFading = -1;
  }
  else if (crossFading < 0) {
    // the music is already fading out
    if (game.options[OPT_CROSSFADEMUSIC] <= 0) {
      // If they have since disabled crossfading, stop the fadeout
      stop_and_destroy_channel(SCHAN_MUSIC);
      crossFading = 0;
      crossFadeStep = 0;
      update_music_volume();
    }
  }
  else if ((game.options[OPT_CROSSFADEMUSIC] > 0)
      && (channels[SCHAN_MUSIC] != NULL)
      && (channels[SCHAN_MUSIC]->done == 0)
      && (current_music_type != 0)
      && (current_music_type != MUS_MIDI)
      && (current_music_type != MUS_MOD)) {

    crossFading = -1;
    crossFadeStep = 0;
    crossFadeVolumePerStep = game.options[OPT_CROSSFADEMUSIC];
    crossFadeVolumeAtStart = calculate_max_volume();
  }
  else
    stop_and_destroy_channel (SCHAN_MUSIC);

  play.cur_music_number = -1;
  current_music_type = 0;
}
Exemple #5
0
int play_speech(int charid,int sndid) {
    stop_and_destroy_channel (SCHAN_SPEECH);

    // don't play speech if we're skipping a cutscene
    if (play.fast_forward)
        return 0;
    if ((play.want_speech < 1) || (speech_file.IsEmpty()))
        return 0;

    SOUNDCLIP *speechmp3;
    String script_name;

    if (charid >= 0) {
        // append the first 4 characters of the script name to the filename
        if (game.chars[charid].scrname[0] == 'c')
            script_name.SetString(&game.chars[charid].scrname[1], 4);
        else
            script_name.SetString(game.chars[charid].scrname, 4);
    }
    else
        script_name = "NARR";

    // append the speech number and create voice file name
    String voice_file = String::FromFormat("%s%d", script_name.GetCStr(), sndid);

    int ii;  // Compare the base file name to the .pam file name
    curLipLine = -1;  // See if we have voice lip sync for this line
    curLipLinePhoneme = -1;
    for (ii = 0; ii < numLipLines; ii++) {
        if (stricmp(splipsync[ii].filename, voice_file) == 0) {
            curLipLine = ii;
            break;
        }
    }
    // if the lip-sync is being used for voice sync, disable
    // the text-related lipsync
    if (numLipLines > 0)
        game.options[OPT_LIPSYNCTEXT] = 0;

    voice_file.Append(".wav");
    AssetPath asset_name(speech_file, voice_file);

    speechmp3 = my_load_wave(asset_name, play.speech_volume, 0);

    if (speechmp3 == NULL) {
        voice_file.ReplaceMid(voice_file.GetLength() - 3, 3, "ogg");
        speechmp3 = my_load_ogg(asset_name, play.speech_volume);
    }

    if (speechmp3 == NULL) {
        voice_file.ReplaceMid(voice_file.GetLength() - 3, 3, "mp3");
        speechmp3 = my_load_mp3(asset_name, play.speech_volume);
    }

    if (speechmp3 != NULL) {
        if (speechmp3->play() == 0)
            speechmp3 = NULL;
    }

    if (speechmp3 == NULL) {
        voice_file.ClipRight(4); // cut the extension for debug output
        debug_script_warn("Speech load failure: '%s'", voice_file.GetCStr());
        curLipLine = -1;
        return 0;
    }

    channels[SCHAN_SPEECH] = speechmp3;
    play.music_vol_was = play.music_master_volume;

    // Negative value means set exactly; positive means drop that amount
    if (play.speech_music_drop < 0)
        play.music_master_volume = -play.speech_music_drop;
    else
        play.music_master_volume -= play.speech_music_drop;

    apply_volume_drop_modifier(true);
    update_music_volume();
    update_music_at = 0;
    mvolcounter = 0;

    update_ambient_sound_vol();

    // change Sierra w/bgrnd  to Sierra without background when voice
    // is available (for Tierra)
    if ((game.options[OPT_SPEECHTYPE] == 2) && (play.no_textbg_when_voice > 0)) {
        game.options[OPT_SPEECHTYPE] = 1;
        play.no_textbg_when_voice = 2;
    }

    return 1;
}
Exemple #6
0
void SetMusicVolume(int newvol) {
    if ((newvol < kRoomVolumeMin) || (newvol > kRoomVolumeMax))
        quitprintf("!SetMusicVolume: invalid volume number. Must be from %d to %d.", kRoomVolumeMin, kRoomVolumeMax);
    thisroom.options[ST_VOLUME]=newvol;
    update_music_volume();
}