Results 1 to 18 of 18

Thread: Script for play a .wav sound

  1. #1
    Ace 1lokos's Avatar
    Join Date
    Jan 2012
    Posts
    5,323
    Post Thanks / Like
    Total Downloaded
    1.04 GB

    Script for play a .wav sound

    No, I won't ask again.

    Code:
    using System;
    using System.Media;
    using maddox.game;
    using maddox.game.world;
    using System.Collections.Generic;
    using maddox.GP;
    
    public class Mission : AMission
    {
           public override void OnBattleStarted()
    	   {
                GamePlay.gpHUDLogCenter("Mission started");
      	   }
               public override void OnTrigger(int missionNumber, string shortName, bool active)
    	   {
                  base.OnTrigger(missionNumber, shortName, active);
                  if ("t1".Equals(shortName) && active)		      
                 {
    		 GamePlay.gpHUDLogCenter("Trigger 1");
                     System.Media.SoundPlayer player = new System.Media.SoundPlayer(@"D:\Sing.wav");
                     player.Play();
    	         }
    	   }	 
    }
    This work nice, based on timer trigger.

    HUD messages are not need, I put just for show that trigger are working, before hear the sound - what cost "39" atempts, script by "reverse engineering" is time consuming.
    Last edited by 1lokos; Oct-13-2020 at 12:21.

  2. Likes TWC_Fatal_Error liked this post
  3. #2
    Manual Creation Group fenbeiduo's Avatar
    Join Date
    May 2013
    Posts
    70
    Post Thanks / Like
    Total Downloaded
    282.61 MB

    Re: Script for play a .wav sound



    Marked

    Thanks for sharing!

  4. #3
    Novice Pilot ITAF_Airone1989's Avatar
    Join Date
    Aug 2020
    Posts
    95
    Post Thanks / Like
    Total Downloaded
    812.8 KB

    Re: Script for play a .wav sound

    Quote Originally Posted by 1lokos View Post
    No, i won't ask again.

    Code:
    using System;
    using System.Media;
    using maddox.game;
    using maddox.game.world;
    using System.Collections.Generic;
    using maddox.GP;
    
    public class Mission : AMission
    {
           public override void OnBattleStarted()
    	   {
                GamePlay.gpHUDLogCenter("Mission started");
      	   }
               public override void OnTrigger(int missionNumber, string shortName, bool active)
    	   {
                  base.OnTrigger(missionNumber, shortName, active);
                  if ("t1".Equals(shortName) && active)		      
                 {
    		 GamePlay.gpHUDLogCenter("Trigger 1");
                     System.Media.SoundPlayer player = new System.Media.SoundPlayer(@"D:\Sing.wav");
                     player.Play();
    	         }
    	   }	 
    }
    This work nice, based on timer trigger.

    HUD messages are not need, I put just for show that trigger are working, before hear the sound - what cost "39" atempts, script by "reverse engineering" is time consuming.
    Great job Sokol!!!!
    Just a question: what is the folder where I have to install the audio file?

  5. #4
    Ace 1lokos's Avatar
    Join Date
    Jan 2012
    Posts
    5,323
    Post Thanks / Like
    Total Downloaded
    1.04 GB

    Re: Script for play a .wav sound

    I test with sound file in root of D:\ for simplify the (many) attempts.

    But you can call from mission folder:

    Code:
    (@"D:\Documents\1C SoftClub\il-2 sturmovik cliffs of dover\missions\Single\mission_folder\audio_sample.wav");
    I think there's a way to short this with ..\\..\\ but don't look at this.

  6. #5
    Novice Pilot ITAF_Airone1989's Avatar
    Join Date
    Aug 2020
    Posts
    95
    Post Thanks / Like
    Total Downloaded
    812.8 KB

    Re: Script for play a .wav sound

    A question:
    Is it possible to send the audio message just to one faction during a multiplayer game using something similar to this script?

    HTML Code:
    private void sendScreenMessageTo(int army, string msg, object[] parms)
        {
            List<Player> Players = new List<Player>();
    
            //Singleplayer or Dedi Server
            if (GamePlay.gpPlayer() != null)
            {
                if (GamePlay.gpPlayer().Army() == army || army == -1)
                    Players.Add(GamePlay.gpPlayer());
            } // Multiplayer
            if (GamePlay.gpRemotePlayers() != null || GamePlay.gpRemotePlayers().Length > 0)
            {
                foreach (Player p in GamePlay.gpRemotePlayers())
                {
                    if (p.Army() == army || army == -1)
                        Players.Add(p);
                }
            }
            if (Players != null && Players.Count > 0)
                GamePlay.gpHUDLogCenter(Players.ToArray(), msg, parms);
        }
    
    
        private void sendChatMessageTo(int army, string msg, object[] parms)
        {
            List<Player> Players = new List<Player>();
    
            //Singleplayer or Dedi Server
            if (GamePlay.gpPlayer() != null)
            {
                if (GamePlay.gpPlayer().Army() == army || army == -1)
                    Players.Add(GamePlay.gpPlayer());
            } // Multiplayer
            if (GamePlay.gpRemotePlayers() != null || GamePlay.gpRemotePlayers().Length > 0)
            {
                foreach (Player p in GamePlay.gpRemotePlayers())
                {
                    if (p.Army() == army || army == -1)
                        Players.Add(p);
                }
            }
            if (Players != null && Players.Count > 0)
                GamePlay.gpLogServer(Players.ToArray(), msg, parms);
        }
    		
     
    		if ("missionstartW".Equals(shortName) && missionstartWsTriggerToggle == false)
                {
    				Timeout(3, () => sendScreenMessageTo(2, "Hello RED FLIGHT, Saffer speaking.", null));
    				GamePlay.gpGetTrigger(shortName).Enable = false;
                    missionstartWsTriggerToggle = true;
                    return;
                }
    
    		}

  7. #6
    Ace 1lokos's Avatar
    Join Date
    Jan 2012
    Posts
    5,323
    Post Thanks / Like
    Total Downloaded
    1.04 GB

    Re: Script for play a .wav sound

    The "SoundPlayer" has a limitation, you can use only one stance at time.

    May should use "SayToGroup" playing "Samples" files if your intention is send various sound calls.

  8. #7
    ATAG Member ATAG_Oskar's Avatar
    Join Date
    Nov 2017
    Location
    Canada
    Posts
    986
    Post Thanks / Like
    Total Downloaded
    908.31 MB

    Re: Script for play a .wav sound

    private void playSoundToOneArmy(int army) {

    Player player = GamePlay.gpPlayer();
    if (army == player.Army())
    // play sound
    }
    }

  9. #8
    varrattu
    Guest

    Re: Script for play a .wav sound

    What are you doing? Please review.

    ~V~


    Quote Originally Posted by ATAG_Oskar View Post
    private void playSoundToOneArmy(int army) {

    Player player = GamePlay.gpPlayer();
    if (army == player.Army())
    // play sound
    }
    }
    Last edited by varrattu; Oct-13-2020 at 08:36.

  10. #9
    Combat pilot Veteran66's Avatar
    Join Date
    Jan 2013
    Posts
    114
    Post Thanks / Like
    Total Downloaded
    206.20 MB

    Re: Script for play a .wav sound

    Quote Originally Posted by 1lokos View Post
    I test with sound file in root of D:\ for simplify the (many) attempts.

    But you can call from mission folder:

    Code:
    (@"D:\Documents\1C SoftClub\il-2 sturmovik cliffs of dover\missions\Single\mission_folder\audio_sample.wav");
    I think there's a way to short this with ..\\..\\ but don't look at this.

    (@"C:\Users\XXX\OneDrive\Dokumente\1C SoftClub\il-2 sturmovik cliffs of dover\missions\Single\mission_folder\audio_sample. wav");

    I try to short this way to:

    (@"C:\..\\..\\..\\..\\..\\il-2 sturmovik cliffs of dover\missions\Single\mission_folder\audio_sample. wav");

    don`t work

    I Like this "play a wav sound" script, but the full way is not user friendly

  11. #10
    ATAG Member ATAG_Oskar's Avatar
    Join Date
    Nov 2017
    Location
    Canada
    Posts
    986
    Post Thanks / Like
    Total Downloaded
    908.31 MB

    Re: Script for play a .wav sound

    Check the next release. You will be able to play sounds like this:

    System.Media.SoundPlayer player = new System.Media.SoundPlayer(BaseMissionPath + "Sing.wav");

  12. Likes TWC_Flug liked this post
  13. #11
    Combat pilot Veteran66's Avatar
    Join Date
    Jan 2013
    Posts
    114
    Post Thanks / Like
    Total Downloaded
    206.20 MB

    Re: Script for play a .wav sound

    Quote Originally Posted by ATAG_Oskar View Post
    Check the next release. You will be able to play sounds like this:

    System.Media.SoundPlayer player = new System.Media.SoundPlayer(BaseMissionPath + "Sing.wav");
    oh nice

  14. #12
    Supporting Member Baffin's Avatar
    Join Date
    Apr 2013
    Location
    Northwestern Virginia, USA
    Posts
    1,980
    Post Thanks / Like
    Total Downloaded
    127.26 MB

    Re: Script for play a .wav sound

    Another method is to use the Freeware "VoiceAttack". While this is primarily for controlling your system using spoken english, It can play sound files in response to a voice command. Anyway, the price is right and it works as advertised.

    VAC (Voice Activated Controls) also does this, but costs a few dollars...
    Last edited by Baffin; Jul-28-2022 at 09:15.
    Windows 11 Pro, ASUS ROG Maximus Z790 Dark Hero, 2 TB Samsung M.2 SSD 990PRO. Intel Core i9 14900KF using TPUII BIOS feature. Air Cooling with Thermalright Peerless Assassin 120 SE CPU Cooler w/ 2 fans. Crucial 96GB DDR 5 RAM at 5600 MT/s. LG 55" 4K OLEDC7P TV, NVIDIA GeForce RTX 4090 Gaming X Trio 24G. Realtek High Definition Audio, Sony Surround amp w/ optical cable for 5.1 speakers, Ear Buds from Motherboard for Discord/TeamSpeak3. TrackIR5, Buttkicker Gamer 2, Thrustmaster Warthog, 2x Saitek X-52 (Buttons & Gear), Gear-Falcon Trim Box, Thrustmaster TPR Pendular Rudder Pedals. Voice Activated Controls.

  15. #13
    Combat pilot Veteran66's Avatar
    Join Date
    Jan 2013
    Posts
    114
    Post Thanks / Like
    Total Downloaded
    206.20 MB

    Re: Script for play a .wav sound

    Quote Originally Posted by Baffin View Post
    Another method is to use the Freeware "VoiceAttack". While this is primarily for controlling your system using spoken english, It can play sound files in response to a voice command. Anyway, the price is right and it works as advertised.

    VAC (Voice Activated Controls) also does this, but costs a few dollars...
    This script:
    System.Media.SoundPlayer player = new System.Media.SoundPlayer(BaseMissionPath + "Sing.wav");
    will be good for missionsdesigner

  16. #14
    Supporting Member
    Join Date
    Dec 2019
    Posts
    473
    Post Thanks / Like
    Total Downloaded
    22.61 MB

    Re: Script for play a .wav sound

    Quote Originally Posted by ATAG_Oskar View Post
    Check the next release. You will be able to play sounds like this:

    System.Media.SoundPlayer player = new System.Media.SoundPlayer(BaseMissionPath + "Sing.wav");
    Is this released yet please?
    I am Yo-Yo not YoYo (that's someone else)

  17. #15
    Supporting Member
    Join Date
    Dec 2019
    Posts
    473
    Post Thanks / Like
    Total Downloaded
    22.61 MB

    Re: Script for play a .wav sound

    Ooo, it seems it is, how delightful.
    I am Yo-Yo not YoYo (that's someone else)

  18. #16
    Combat pilot
    Join Date
    Aug 2020
    Posts
    181
    Post Thanks / Like
    Total Downloaded
    121.31 MB

    Re: Script for play a .wav sound

    Quote Originally Posted by ATAG_Oskar View Post
    private void playSoundToOneArmy(int army) {

    Player player = GamePlay.gpPlayer();
    if (army == player.Army())
    // play sound
    }
    }
    Oskar can you do this with a Trigger for specific AirGroup or AirArmy RED or Blue fly through?

    Example: Sub Mission loads and in flying over Canterbury Airfield Tower at Airfield says bomber group over Canterbury. Giving Towers separate abilities for their airspace. Or Enemy approaching Dover- these could load when the submission loads and run one time. Or like Dover airspace tower reporting Stukas height and directions from dover.

    Just Brain storming ideas...
    Last edited by BlacKnight; Mar-29-2023 at 07:58.

  19. #17
    ATAG Member ATAG_Oskar's Avatar
    Join Date
    Nov 2017
    Location
    Canada
    Posts
    986
    Post Thanks / Like
    Total Downloaded
    908.31 MB

    Re: Script for play a .wav sound

    Quote Originally Posted by BlacKnight View Post
    Oskar can you do this with a Trigger for specific AirGroup or AirArmy RED or Blue fly through?

    Example: Sub Mission loads and in flying over Canterbury Airfield Tower at Airfield says bomber group over Canterbury. Giving Towers separate abilities for their airspace. Or Enemy approaching Dover- these could load when the submission loads and run one time. Or like Dover airspace tower reporting Stukas height and directions from dover.

    Just Brain storming ideas...
    That code looks fine, but only in SP. In that scenario the sim loads the audio file from your local hard drive. In MP you would need every player to download the audio. Like this:


    System.Media.SoundPlayer player = new System.Media.SoundPlayer();
    player.Open(new URI("http://somehost.com/path/AudioFileOne.wav"));
    player.Play();

  20. #18
    Combat pilot
    Join Date
    Aug 2020
    Posts
    181
    Post Thanks / Like
    Total Downloaded
    121.31 MB

    Re: Script for play a .wav sound

    Was looking at this:

    using System;
    using System.Media;
    using maddox.game;
    using maddox.game.world;
    using System.Collections.Generic;
    using maddox.GP;

    public class Mission : AMission
    {
    public override void OnTrigger(int missionNumber, string shortName, bool active)
    {
    base.OnTrigger(missionNumber, shortName, active);
    if ("SlipIndicator".Equals(shortName) && active)
    {
    player.SayToArmy(new "You_need_to_keep_the_slip_indicator_centered.ogg" );
    player.Play();
    }
    }
    }

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •