设为首页收藏本站同能贴吧 切换语言 繁体中文
开启辅助访问 切换到窄版
扫描二维码关注官方公众号
返回列表
+ 发新帖
查看: 118|回复: 0

[转载发布] Cross Fade Audio Script

[复制链接]
累计送礼:
0 个
累计收礼:
1 个
  • TA的每日心情
    开心
    2026-7-12 04:10
  • 签到天数: 209 天

    连续签到: 2 天

    [LV.7]常住居民III

    9071

    主题

    864

    回帖

    6万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    VIP
    7
    卡币
    58883
    OK点
    16
    推广点
    0
    同能卷
    50
    积分
    68848

    灌水之王

    发表于 2026-8-1 21:15:14 | 显示全部楼层 |阅读模式
    Cross Fade Audio V1.0





    Created by Neon Black



    What is it?

    This is a script which allows you fade out one audio into another audio at the same spot.  Sounds easy enough to do already I'm sure, however it works a little differently than you might imagine and actually requires a bit of modification and tweaking to work properly.  Also note the "cross" part of "cross fade".  This means that the old audio file continues playing while the new file begins (at least somewhat).  Note that this script is not "perfect" but it's about as good as you're going to get without someone doing some serious modifications.  I will also explain the issues with this script below.

    How can I use it?

    Place this script anywhere in the materials section above main.  If you notice incompatibility with another script, place this script above that script.  If you still experience incompatibility issues, please post what scripts you are using as well as what kind of error you are getting.  This script is easy enough to use and just requires you to enable a single variable to begin using cross fade, however there are a few limitations you can use while actually using cross fade.


    • Turn the switch on and music will always cross fade.  This means that while the switch is on, the music ending will fade out and the music starting will fade in, and attempt to be at the same spot in the song, even if the two musics are different.  If you want to change music without a fade in effect, you must turn the switch off.
    • Playing a music effect (ME) will disable cross fade.  Due to an issue related to how the script works, playing a ME will disable cross fade as well as revert background music and background sound to normal if they are currently "abnormal".  This can actually be a good way to "repair" the music after using cross fade for a little while.
    • You cannot use background sounds (BGS) while cross fade is enabled.  This script works by alternating music between background music and background sound.  For this reason, while cross fade is enabled you will not be able to use BGS.  Sorry.  BGS should work while this is disabled.
    • Music to cross fade must be .OGG or .WAV.  Not my rule.  This is enterbrain's.  MP3s do not work with positions.  While the fade in and fade out will most likely work with .MP3s, the whole "starting at the same spot" thing will not.  In my opinion .OGGs are better to work with due to being smaller and being able to loop.  (Should I make a .OGG looping tutorial or is there already one?)

    As I mentioned there are also certain issues with the script which I am unable to resolve (and most likely never will).  The issues are as follows.


    • Stereo tracks do not properly work with track offset.  To explain a little, the track does not quite play at the same position as the old track, so a "track offset" had to be added to have the new track play closer to the current position of the old track.  For some reason stereo tracks like having a slight bit of static at the end of their track while they are the BGS if you have defined an offset.  For those of you who still want to use stereo tracks with this, I have not yet tested how this problem works with looping tracks, so that might be a solution!
    • The tracks do not always fade in at the proper place.  I was having a rather ridiculous problem with tracks not wanting to properly fade in without losing or gaining some of the beat, so I decided to write a quick script that would calculate the position of a track every frame to help me determine the best offset.  The results were actually quite surprising and informative.  The Audio module does not update the position every frame, or when you call the position check or anything like that.  Rather it only updates every 8~12 frames (not sure what the variance is about).  This means it is possible to have some variance in the position of the track by about 150~180 milliseconds.  There's not a whole lot I can do about this, but it's not really that noticeable anyway.  Sorry.

    What does it work with?

    It should work with most other scripts.  It modifies the Audio module, so unless someone else decided to edit the audio module, you should be good.

    Alias - Audio: bgm_play, bgm_stop, bgm_fade, bgm_pos, bgs_play, bgs_stop, bgs_fade, bgs_pos, me_play

    New Objects - Audio: check_fades, stop_fades, cross_bgm, cross_bgs

    How can I get the code?

    Version 1.0 (base script, 6.4.2012) is available from my pastebin account here or from the demo on my mediafire account here.

    I would like to use this code.



    This work is licensed under a Creative Commons Attribution-NonCommercial 3.0 Unported License.

    Permissions beyond the scope of this license may be available at http://cphouseset.wo...d-terms-of-use/.

    Author's Disclaimer:

    A while back Raven Blue approached me to create a script like this for VX.  Sadly my meager Ruby skills are not enough to really do anything extraordinary, so I wasn't able to do it.  Now with certain new things I am able to create the desired script with Ace.  Also, I probably need some music credits.  Windhollow Cavern was composed by Raven Blue for use with this script.  Might be a good idea to track him down and ask him if you can use it before you do.  Megaboss was composed by amkrogh89 and can be obtained from his thread here.  Rigid Paradise was composed by ZUN and was used in Touhou Project.  It was just the music I was testing with, so I don't really recommend stealing it, even though I kinda did "borrow" it....


    本贴来自国际rpgmaker官方论坛作者:Neon Black处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/cross-fade-audio-script.2472/

    本帖子中包含更多资源

    您需要 登录 才可以下载或查看,没有账号?立即注册

    x
    天天去同能,天天有童年!
    回复 送礼论坛版权

    使用道具 举报

    文明发言,和谐互动
    文明发言,和谐互动
    高级模式
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    简体中文
    繁體中文
    English(英语)
    日本語(日语)
    Deutsch(德语)
    Русский язык(俄语)
    بالعربية(阿拉伯语)
    Türkçe(土耳其语)
    Português(葡萄牙语)
    ภาษาไทย(泰国语)
    한어(朝鲜语/韩语)
    Français(法语)
    关闭

    幸运抽奖

    社区每日抽奖来袭,快来试试你是欧皇还是非酋~

    立即查看

    聊天机器人
    Loading...

    QQ|Archiver|手机版|小黑屋|同能RPG制作大师 ( 沪ICP备12027754号-3 )

    GMT+8, 2026-8-17 14:32 , Processed in 0.122616 second(s), 55 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

    快速回复 返回顶部 返回列表