Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

sound files

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    sound files

    is there a way to concatenate to wav files to play as one sound with PlaySound()

    #2
    Hello FCatan,

    Are you trying to play multiple sounds at the same time? If so, this will need to be done in separate PlaySound() calls.

    Are you trying to concatenate a string that provides the location of one sound file? Yes, you can do this just like any other string.

    @"C:\Program Files(x86)\"+ folderVariable + "\sounds\mySound.Wav"
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      yes, I'm trying to play multiple sounds at the same time. the first sound file identifies the instrument and the second the condition. So, for example, the first sound file will say "ES" and the second "MA Crossover". Effectively, I want is to sound like "ES MA Crossover". To do that I have 2 PlaySound() calls back to back, but they are executed so fast that only the second one is heard.

      Comment


        #4
        Hello,

        Thank you for the reply.

        What is happening is the way NinjaTrader plays sounds, only 1 sound can be played at once although the method that calls the sound can be called over and over again.

        When you submit multiple PlaySound() methods the last sound submitted would be heard if they are all happening at the same time.

        To hear these separately, there has to be a delay between the calls to PlaySound(). This can be accomplished using various logic such as a bool variable that gets toggled and the next OnBarUpdate the next PlaySound can happen and so on. This is really the only want to get sounds to play in succession from a single call to OnBarUpdate.

        Otherwise you would need to use a third party software for audio editing to combine the multiple sounds into one wav file that can be called on one time in NinjaTrader. I don't have any specific recommendations on software for this, but I am sure google would be a good resource on finding something that can do this.

        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          Originally posted by FCatan View Post
          yes, I'm trying to play multiple sounds at the same time. the first sound file identifies the instrument and the second the condition. So, for example, the first sound file will say "ES" and the second "MA Crossover". Effectively, I want is to sound like "ES MA Crossover". To do that I have 2 PlaySound() calls back to back, but they are executed so fast that only the second one is heard.
          Have you thought about recording a separate alert message for each possibility?

          There are a few 'text-to-speech' sites out there that will allow you to type in the words you want and out comes the speech. They can be downloaded as wav files (compatible with Ninja). Go here:



          Type in "E.S. M.A. Crossover", select the voice you want and if you're happy, download it.

          Comment


            #6
            Originally posted by arbuthnot View Post
            Have you thought about recording a separate alert message for each possibility?

            There are a few 'text-to-speech' sites out there that will allow you to type in the words you want and out comes the speech. They can be downloaded as wav files (compatible with Ninja). Go here:



            Type in "E.S. M.A. Crossover", select the voice you want and if you're happy, download it.
            It seems that the AT&T text-to-speech program (http://www2.research.att.com/~ttsweb/tts/demo.php) already doesn´t work. Do you know some another similar program for free?
            Thank you.

            Comment


              #7
              Originally posted by emuns View Post
              It seems that the AT&T text-to-speech program (http://www2.research.att.com/~ttsweb/tts/demo.php) already doesn´t work. Do you know some another similar program for free?
              Thank you.
              Yup - I'd noticed that AT&T site had disappeared!

              But, using a two-stage process, you can get text to speech (free) that works a treat. I've used it and the sound alerts work fine in NT7.

              Firstly, go here:

              Free web based Text To Speech (TTS) service. Convert online any English text into MP3 audio file.


              Experiment with

              - Select language

              - Select voice (I've found the 'Heather' voice is very clear)

              - Select speed

              You end up downloading MP3s.

              You need to convert these to WAV format, and this can be done, again free, here:



              This certainly works. Sometimes the sites can take a few moments (or more) to do the 'recording'.
              Last edited by arbuthnot; 08-26-2015, 06:56 AM.

              Comment


                #8
                Hello,

                A simple way to speak using NinjaScript would be to use the System.Speech namespace with C#.



                You would need to add a reference to the following file, this should be available on any PC with .net.

                C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.0\System.Speech. dll

                Next you would need to add the using statement to your script:

                using System.Speech.Synthesis;

                Finally a simple test:
                Code:
                private SpeechSynthesizer synth;
                
                protected override void OnStartUp()
                {
                	synth = new SpeechSynthesizer();
                	synth.SetOutputToDefaultAudioDevice();
                }
                protected override void OnBarUpdate()
                {
                	if(!Historical && Close[0] > Open[0])
                	{
                		synth.Speak(Instrument.FullName + " Close is greater than open");
                	}
                }
                I have included an export and the speech assembly in case anyone is unable to find it on their system.

                One note with this method, this does take priority so a long message happening over and over would "lock" the UI thread, so this would not work good for alerts that happen frequently. For alerts that happen frequently I would suggest the wav files as described by the other members.

                I look forward to being of further assistance.
                Attached Files
                Last edited by NinjaTrader_Jesse; 08-26-2015, 08:55 AM.
                JesseNinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by judysamnt7, 03-13-2023, 09:11 AM
                4 responses
                59 views
                0 likes
                Last Post DynamicTest  
                Started by ScottWalsh, Today, 06:52 PM
                4 responses
                36 views
                0 likes
                Last Post ScottWalsh  
                Started by olisav57, Today, 07:39 PM
                0 responses
                7 views
                0 likes
                Last Post olisav57  
                Started by trilliantrader, Today, 03:01 PM
                2 responses
                22 views
                0 likes
                Last Post helpwanted  
                Started by cre8able, Today, 07:24 PM
                0 responses
                10 views
                0 likes
                Last Post cre8able  
                Working...
                X