Jump to content

Photo

Midi Fade


  • Please log in to reply
8 replies to this topic

#1 Mibbitable

Mibbitable

    Junior

  • Members

Posted 23 November 2017 - 03:15 PM

Is there a script that allows midis to fade other than stopping instantly?



#2 Russ

Russ

    Caelan, the Encouraging

  • Administrators
  • Location:Washington

Posted 23 November 2017 - 03:50 PM

Nope. And such a thing is impossible in 2.5. The only music controls ZScript has as of 2.5 are starting and stopping songs, and even then, there's no way to start the song from a point other than the beginning.
  • Mibbitable likes this

#3 Mibbitable

Mibbitable

    Junior

  • Members

Posted 24 November 2017 - 11:02 PM

Not even a way to change the volume of the midi going down over time by like 10 or something?



#4 Avaro

Avaro

    o_o

  • Members
  • Real Name:Robin
  • Location:Germany

Posted 24 November 2017 - 11:05 PM

Nope. xd But you could make a 2nd midi from your midi list start playing, which could be the same as the 1st one but quieter.


  • Anthus likes this

#5 Mibbitable

Mibbitable

    Junior

  • Members

Posted 24 November 2017 - 11:50 PM

That's true. I'll see into that.



#6 Anthus

Anthus

    Lord of Liquids

  • Members
  • Location:Ohio

Posted 24 November 2017 - 11:53 PM

Nope. xd But you could make a 2nd midi from your midi list start playing, which could be the same as the 1st one but quieter.

 

That is what I was thinking about, but is it possible to have the quieter MIDI begin at the exact same position? That's the only drawback I can see, but come to think of it, no one really does dynamic things with sound in quests.



#7 Avaro

Avaro

    o_o

  • Members
  • Real Name:Robin
  • Location:Germany

Posted 25 November 2017 - 11:50 AM

That is what I was thinking about, but is it possible to have the quieter MIDI begin at the exact same position? That's the only drawback I can see, but come to think of it, no one really does dynamic things with sound in quests.

 

That's because that's not possible, yeah.

 

(2.54 might have more options if that sees the light of day)


Edited by Avataro, 25 November 2017 - 03:48 PM.

  • Shane likes this

#8 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 26 November 2017 - 07:26 AM

You can now adjust the ZC system volume of MIDI, DIGI, SfX, and Enhanced Music files by script.
 
I added Audio->Volume[4] and Audio->PanStyle to ZScript in 2.54. The Audio[] array has four indices: MIDI Volume, Digi Volume, Enhanced Music Volume, and SFX Volume.
 
You're welcome.
 
I'm not adding audio file manipulation, such as seeking, to 2.54. (Possibly a later version, but not 2.54.)
 
Bear in mind that the user can override this, and you want to handle fades like this:
 
int oldaudio = FadeMidi(120, 4);
//FadeOut
int FadeMIDI(int time, int ticks_per_decrement)
{
    int oldvol = Volume[VOL_MIDI]; //Store the ore-fade setting.
    for ( int q = 0; q < fade ; ++q )
    {
        if ( !(q%ticks_per_decrement) ) --(Audio->Volume[VOL_MIDI]);
	if ( Audio->Volume[VOL_MIDI] < 1 ) return oldvol; 
        //Do not waste frames if we reach 0!
        Waitframe();
    }
    return oldvol;
}

//FadeIn to the old volume
void FadeMIDI(int time, int ticks_per_decrement, int oldsetting)
{
    int oldvol = Volume[VOL_MIDI]; //Store the ore-fade setting.
    int q;
    while( Audio->Volume[VOL_MIDI] < oldsetting ) 
    {
        if ( !(q%ticks_per_decrement) ) ++(Audio->Volume[VOL_MIDI]);
        ++q;
        Waitframe();
    }
}
You want to store the user's audio settings when doing fades, so that you can fade back in, to their original setting.

@Avataro: I'm not sure why you would not expect 2.54 to be released. I haven't spent hundreds of hours developing it, along with two other devs and however much time they have spent, for it to be shelved.

Edited by ZoriaRPG, 26 November 2017 - 07:42 AM.

  • Anthus and Jared like this

#9 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 02 December 2017 - 08:57 AM

This has been revised to:

void Audio->AdjustMusicVolume(int percent);

and

void Audio->AdjustSFXVolume(int percent);

The 'percent' parameter us an absolute, based on the user volume now.

Setting it to '25', reduced the user volume by 75%; a value of '100' sets it to the user settings, '150' would increase it by 50%.

Changes are reverted on quest exit.


1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users