Пример #1
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();
}
Пример #2
0
bool pass_fire::set_background(const char * background)
{
    std::string asset_name(background);
    asset_texture asset = assets_storage::instance().read<asset_texture>(asset_name);

    if(asset.pixels())
    {
        texture_background_.set_data(asset.pixels(), asset.size(), asset.format());
        return true;
    }
    return false;
}
Пример #3
0
bool pass_positions::initialize()
{
    std::string asset_name("textures/noise.png");
    asset_texture asset = assets_storage::instance().read<asset_texture>(asset_name);

    if(!asset.pixels())
        return false;

    texture_displacement_.set_data(asset.pixels(), asset.size(), asset.format());

    return rendering::load_program("shaders/experiments/light/positions_product_reset.prog",
                                   program_reset_) &&
           rendering::load_program("shaders/experiments/light/positions_product_process.prog",
                                   program_process_);
}
Пример #4
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;
}