I'm wondering if you can script to read the current midi's position so you can script to do something, personally I want it to use a sfx when it triggers.
It would be nice to use to somewhat enhance a song a bit.
Is it possible?
Trigger sfx at a midi position on a certain midi?
Started by
Lemmy Koopa
, Sep 14 2010 05:06 AM
5 replies to this topic
#1
Posted 14 September 2010 - 05:06 AM
#2
Posted 15 September 2010 - 10:43 PM
there is native allegro support for this (I've even put in FF and RW functionality in another game using allegro) however none exists in ZC yet. It's not very hard to do but would have to be written and added to the scripting engine from scratch.
#3
Posted 17 September 2010 - 12:01 AM
You mean rewriting the whole scripting engine?
#4
Posted 18 September 2010 - 10:00 AM
Huh? No, I mean it's not possible engine-wise. (unless you keep track of the seconds the midi is running yourself in a script, in which case it's fairly simple -you simply need the midi length and what SFX to play at 1/60th second intervals.)
#5
Posted 18 September 2010 - 11:32 PM
I didn't have time before, but what I meant in the last post was you could do this:
-Say you want to trigger a SFX at 1:21 in the midi, you would do this: (1:21 = 81 sec = 4860 frames)
ffc script sync_midi
{
void run()
{
int t;
for(;; Waitframe() )
{
t++;
if( t == 4860 ) Game->PlaySound(...);
if( t >= END_OF_MIDI ) t -= END_OF_MIDI;
}
}
}
Alternate method:
ffc script sync_midi
{
void run()
{
for(;; )
{
Waitframes( 4860 );
Game->PlaySound(...);
// etc...
Waitframes( END_OF_MIDI - 4860 );
}
}
}
..edit, Although if someone opens a subscreen you are screwed I guess. :\
-Say you want to trigger a SFX at 1:21 in the midi, you would do this: (1:21 = 81 sec = 4860 frames)
CODE
ffc script sync_midi
{
void run()
{
int t;
for(;; Waitframe() )
{
t++;
if( t == 4860 ) Game->PlaySound(...);
if( t >= END_OF_MIDI ) t -= END_OF_MIDI;
}
}
}
Alternate method:
CODE
ffc script sync_midi
{
void run()
{
for(;; )
{
Waitframes( 4860 );
Game->PlaySound(...);
// etc...
Waitframes( END_OF_MIDI - 4860 );
}
}
}
..edit, Although if someone opens a subscreen you are screwed I guess. :\
Edited by Gleeok, 18 September 2010 - 11:35 PM.
#6
Posted 19 September 2010 - 07:36 AM
Haha oh, subscreen pauses scripts I guess.
I was thinking of using an SFX to enhance a midi, like maybe a drum kick sfx.
Your script would probably work, but it would probably need to be redone to do it in multiple instances instead of just one place.
You know how the NES has as DPCM channel? Well it would be like that, where it would run the sound in points of the track.
You also know how in the Midi editor there was a position checker? Originally I was thinking of a script referring to that as a variable.
I'll give your method a try some time though.
I was thinking of using an SFX to enhance a midi, like maybe a drum kick sfx.
Your script would probably work, but it would probably need to be redone to do it in multiple instances instead of just one place.
You know how the NES has as DPCM channel? Well it would be like that, where it would run the sound in points of the track.
You also know how in the Midi editor there was a position checker? Originally I was thinking of a script referring to that as a variable.
I'll give your method a try some time though.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users