Jump to content
Sign in to follow this  
BlackbirdSD

Question about sound files and music

Recommended Posts

I added this to the description.ext

class CfgSounds
{
 sounds[] = {};
 class sicmusic
 {
 name = "sicmusic";
 sound[] = {"\sounds\sicmusic.wav",500,1};
 titles[] = {0,""};
 };
};
and this works to play music.  My question is,

1. how do you get the music to loop and playback once the song is over? 

2.If creating a stereo playing the radio, how do you get another song to play after the first?

3.For multiplayer, will the other guy be able to hear the music in game or do they need to get the sound file separate?

 

Thanks

Share this post


Link to post
Share on other sites

Configure it as CfgMusic and use music related Event Handlers

 

in MP you will have to global execute it

Share this post


Link to post
Share on other sites
2 hours ago, killzone_kid said:

Configure it as CfgMusic and use music related Event Handlers

 

in MP you will have to global execute it

Can you explain in detail what you mean?  I'm still new to much of this.

Thanks

Share this post


Link to post
Share on other sites

@BlackbirdSD
Well, there are many ways to achieve what you want.

I'll explain Killzone_kid version first :

  1. In the description.ext, you can define "sound file" in as two "types", as cfgSounds (as you did), or as cfgMusic as Killzone_kid advice you to do.
    The way you define your "sound file" will classify the file as either sound or music for the Arma engine, and determine what kind of commands you can use to play your "sound file".
    In fact, defining your file as a cfgMusic (will classify the file as music) and allow you to use playMusic to play your file.
    Now the cool thing with that command, is that it triggers  music Event Handlers, as defined in the biki :
    Quote

    An event handler (abbreviated to EH) allows you to automatically monitor and then execute custom code upon particular events being triggered.

    In our case, we are interested in using the musicStop event handler, who triggers when a cfgMusic sound is done playing.
    That way, you should be able to "know" when your song is done playing, and play it again. Here's a ready to use code snippet :
    playMusic "myMusic"; //To start the music
    ehID = addMusicEventHandler ["MusicStop", {playMusic "myMusic";}]; //EH that handles the loop
    
    //Code to stop the music, uncomment to use
    /*
    removeMusicEventHandler ["MusicStop", ehID];
    playMusic "";
    */
    This code however is not MP friendly, as it will only work on the machine the code is run into, you'll have to make sure it is run on all machine if you want all the players too hear the music, and there are many ways to do so. For reference, one of them is to global execute it with remoteExec, and do something in this fashion :
    {
    	playMusic "myMusic"; //To start the music
    	ehID = addMusicEventHandler ["MusicStop", {playMusic "myMusic";}]; //EH that handles the loop
    } remoteExec ["bis_fnc_call", 0]; 
    The main limitation of this method however, is that playSound isn't 3D. Which mean, the music will not fade out the further you get from your stereo and will always play at the same volume.
     
  2.  Another approach to get the 3D sound capability is to define your song as cfgSound, and use say3D.
    However since the song is now cfgSound and not cfgMusic, you won't be able to use the musicStop event handler anymore.
    A workaround is to put your say3D in a loop with a sleep which is as long as the song duration.
    Note that this is not MP friendly, so you'll have to use the remoteExec trick as well.
     
  3. To get native MP compatibility (so you don't need to remoteExec), you can use playSound3D.
    Note that you don't need to define your "sound file" in the description.ext to use playSound3D, as you only have to give the path to your song file.
    Unfortunately, here again you won't be able to use the musicStop event handler, so you'll have to use the sleep trick again.
    Just note that you'll have to use another trick to get the MP friendly sound file path in MP, just check Jacmac comment in the playSound3D page for a "ready to use" code.

 

I hope that helps !
(I got too lazy to explain methods 2 and 3 in detail, but I'm sure you get the idea 🙂 )

Share this post


Link to post
Share on other sites
4 hours ago, Tova said:

@BlackbirdSD
Well, there are many ways to achieve what you want.

I'll explain Killzone_kid version first :

  1. In the description.ext, you can define "sound file" in as two "types", as cfgSounds (as you did), or as cfgMusic as Killzone_kid advice you to do.
    The way you define your "sound file" will classify the file as either sound or music for the Arma engine, and determine what kind of commands you can use to play your "sound file".
    In fact, defining your file as a cfgMusic (will classify the file as music) and allow you to use playMusic to play your file.
    Now the cool thing with that command, is that it triggers  music Event Handlers, as defined in the biki : In our case, we are interested in using the musicStop event handler, who triggers when a cfgMusic sound is done playing.
    That way, you should be able to "know" when your song is done playing, and play it again. Here's a ready to use code snippet :
    
    playMusic "myMusic"; //To start the music
    ehID = addMusicEventHandler ["MusicStop", {playMusic "myMusic";}]; //EH that handles the loop
    
    //Code to stop the music, uncomment to use
    /*
    removeMusicEventHandler ["MusicStop", ehID];
    playMusic "";
    */
    This code however is not MP friendly, as it will only work on the machine the code is run into, you'll have to make sure it is run on all machine if you want all the players too hear the music, and there are many ways to do so. For reference, one of them is to global execute it with remoteExec, and do something in this fashion :
    
    {
    	playMusic "myMusic"; //To start the music
    	ehID = addMusicEventHandler ["MusicStop", {playMusic "myMusic";}]; //EH that handles the loop
    } remoteExec ["bis_fnc_call", 0]; 
    The main limitation of this method however, is that playSound isn't 3D. Which mean, the music will not fade out the further you get from your stereo and will always play at the same volume.
     
  2.  Another approach to get the 3D sound capability is to define your song as cfgSound, and use say3D.
    However since the song is now cfgSound and not cfgMusic, you won't be able to use the musicStop event handler anymore.
    A workaround is to put your say3D in a loop with a sleep which is as long as the song duration.
    Note that this is not MP friendly, so you'll have to use the remoteExec trick as well.
     
  3. To get native MP compatibility (so you don't need to remoteExec), you can use playSound3D.
    Note that you don't need to define your "sound file" in the description.ext to use playSound3D, as you only have to give the path to your song file.
    Unfortunately, here again you won't be able to use the musicStop event handler, so you'll have to use the sleep trick again.
    Just note that you'll have to use another trick to get the MP friendly sound file path in MP, just check Jacmac comment in the playSound3D page for a "ready to use" code.

 

I hope that helps !
(I got too lazy to explain methods 2 and 3 in detail, but I'm sure you get the idea 🙂 )

Thank you for the detailed explanation.  Some of which Im still unclear on but I can confirm that the music worked for me with my friend and he heard it also using my script I mentioned above.  What is the max volume you can set?

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×