Precision in sequential sounds

Started by alkis21, Fri 15/09/2006 23:07:05

Previous topic - Next topic

alkis21

Hello again.

My composer sent me a theme that I intend to use in the main menu of my game. However, he believes that for the best result to be achieved, the theme must be divided in two parts: the first part needs to be played in the beginning, and the second one needs to begin immediately after the first one ends. The second part must be the one that loops repeatedly, giving a much more elegant and flawless sound.

The problem with that idea is that I can't seem to get it to work correctly. What I did was:

-make the first part a sound effect (sound1.ogg)
-make the second part a musical score (music3.ogg)
-added the following code:

Player enters room (after fadein): PlaySound(1); 
Repeatedly execute: if (IsSoundPlaying()==0) PlayMusic(3);

Although the code works, there is a quite noticeable fraction of a second between the two sounds, which kind of ruins it.

Can you think of a more precide way of making the two sounds play consecutively with no delay?

nihilyst

As far as I know, you can just have one music file and use the GetMP3PosMillis and SeekMP3PosMillis commands. So if, for example, the second part starts after 10 seconds and the entire file was 1 minute long, you could use this in the rep_ex:

if (GetMP3PosMillis() > 100000)  //when the music reaches 01:00
SeekMP3PosMillis(10000);  //go to 00:10

Should work, but I don't know, if there is any audible break.

cheers
nihilyst

alkis21

Thanks for the suggestion, but none of the files is an MP3; they're both OGGs. I'm using the MP3-less version of AGS to avoid the violation of copyright issues.

nihilyst

According to the handbook, those commands should work with OGGs, too.

strazer

Have you tried:

Code: ags

  SetMusicRepeat(0);
  PlayMusic(1); // sound1.ogg -> music1.ogg
  SetMusicRepeat(1); 
  PlayMusicQueued(2);

alkis21

Strazer, that's the first thing I tried... the change is even more noticeable than the method I use in my first post.
Nihilyst's suggestion looks like it might work... I'll experiment.

Ashen

If not, could you use the 'Crossfade music tracks' option? If you can figure out how long the crossfade takes and split the sound files accordingly, it might give a seemless transition.
I know what you're thinking ... Don't think that.

alkis21

I tried everything, I simply can't get it right...

ciborium

You may be able to fake it, but your music file will be enlarged.
But judging by the rest of your game, I don't think one large sound file will kill the game.

Open your complete music file in an audio editor and copy and paste the part you want to loop to the end ten times or so and then make another file with just your repeated portion. There will be a break in the middle but unless someone stays on that screen for too long they'll never notice. (How many times did you actually watch all of the opening credits to Monkey Island?)

If "A" is the first protion of your song,
And "B" is the second portion,
Then edit the song so it is "ABBBBBBBBBBBBBBB"
Save it as one file and "B" as another file.

Then play the manually looped vesion followed by the automatically looped "B"

I know this is the dirty method and there is probably an elegant scripted method that will keep your music files as-is, but you might give it a try.

SMF spam blocked by CleanTalk