Пример #1
0
void IAGSEngine::PlaySoundChannel (int32 channel, int32 soundType, int32 volume, int32 loop, const char *filename) {
  stop_and_destroy_channel (channel);
  SOUNDCLIP *newcha = NULL;

  if (((soundType == PSND_MP3STREAM) || (soundType == PSND_OGGSTREAM)) 
    && (loop != 0))
    quit("IAGSEngine::PlaySoundChannel: streamed samples cannot loop");

  if (soundType == PSND_WAVE)
    newcha = my_load_wave (filename, volume, loop);
  else if (soundType == PSND_MP3STREAM)
    newcha = my_load_mp3 (filename, volume);
  else if (soundType == PSND_OGGSTREAM)
    newcha = my_load_ogg (filename, volume);
  else if (soundType == PSND_MP3STATIC)
    newcha = my_load_static_mp3 (filename, volume, (loop != 0));
  else if (soundType == PSND_OGGSTATIC)
    newcha = my_load_static_ogg (filename, volume, (loop != 0));
  else if (soundType == PSND_MIDI) {
    if (midi_pos >= 0)
      quit("!IAGSEngine::PlaySoundChannel: MIDI already in use");
    newcha = my_load_midi (filename, loop);
    newcha->set_volume (volume);
  }
  else if (soundType == PSND_MOD) {
    newcha = my_load_mod (filename, loop);
    newcha->set_volume (volume);
  }
  else
    quit("!IAGSEngine::PlaySoundChannel: unknown sound type");

  channels[channel] = newcha;
}
Пример #2
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;
}