Announcement

Collapse
No announcement yet.

Embedding Sound Effect

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

  • Embedding Sound Effect

    I have an efs study that, among others, draws a circle at certain points as trading signals. Here's that piece of code:

    PHP Code:
    ...
    if ((
    BuySig) && (CanclBar 0) && (A900A >= AutoStopA)) {
            if ((
    Fast2Val == 1) && (sum >= 5) && (bIsLong ) &&
            ((
    frMeanSwing && close(0) > MeanSwingVal) || (!frMeanSwing)) && (close(0) > vUpper) && (close() >= open())) {
                
    offset 1.5 atrStudy.getValue(ATRStudy.ATR);
                
    drawShapeRelative(0low(0) - offsetShape.CIRCLEnull Color.blue Shape.BOTTOM Shape.ONTOP Shape.RIGHT);
                
    BuySig false;
            }
    ... 
    What I would like to ad is a simultaneous sound effect. I tried just inserting locally something simple like:

    Alert.playSound("New.wav");

    but it didn't work correctly. Perhaps I messed up with the right number of brackets or parentheses, or I failed to define the sound function up above, or...

    Can someone suggest the correct and complete code to add? I would appreciate any help you guys can provide. TIA

    John
    Last edited by JKK; 08-22-2006, 11:46 AM.

  • #2
    Hello John,

    Alert.playSound("New.wav");

    This is the correct syntax. Some things to consider.

    1 - Was this code placed inside the same if statement as the drawShape... call?
    2 - Verify that the New.wav file exists inside \eSignal\Sounds\ folder.
    3 - Check to make sure that your sound files root is set to ....\eSignal\Sounds\. You can verify this by going to Tools --> EFS --> Settings.



    4 - If all of the above check out ok, check to see if the volume on your PC is off.

    5 - Navigate to the sounds folder and play the wav file with another application, such as Windows Media Player, if you have one.

    6 - If still no sound, you may have a hardware conflict.

    If you want to post a working example of the formula I would be happy to test it on my end. It's possible that there may be something in the code logic that is preventing the alert from playing.
    Jason K.
    Project Manager
    eSignal - an Interactive Data company

    EFS KnowledgeBase
    JavaScript for EFS Video Series
    EFS Beginner Tutorial Series
    EFS Glossary
    Custom EFS Development Policy

    New User Orientation

    Comment


    • #3
      Thanks Jason. I followed your instructions and now it's at a point where I get a single "pop" of a sound, not the sound effects I was expecting. What could be the cause of that? The sound-files work fine when I doubleclick on them but not when called in this program. strange.

      here is the piece of code that seems to be giving me trouble. If you need the whole efs study, let me know.

      John

      ------------------------

      if ((BuySig) && (CanclBar > 0) && (A900A >= AutoStopA)) {
      if ((Fast3Val == 1) && (sum >= 5) && (bIsLong ) &&
      ((frMeanSwing && close(0) > MeanSwingVal) || (!frMeanSwing)) && (close(0) > vUpper) && (close() >= open()))
      {
      offset = 1.5 * atrStudy.getValue(ATRStudy.ATR);
      Alert.playSound("c:\program files\eSignal\Sounds\New.wav");
      drawShapeRelative(0, low(0) - offset, Shape.CIRCLE, null , Color.blue , Shape.BOTTOM | Shape.ONTOP | Shape.RIGHT);
      Alert.playSound( "c:\program files\eSignal\Sounds\sp_pt_buy_level1.wav" );
      BuySig = false;
      }
      else if ((BuySig) && ((CanclBar <= 0) || (A900A < AutoStopA))) {
      BuySig = false;
      }
      } else BuySig = false;


      if ((SellSig) && (CanclBar > 0) && (A900A <= AutoStopA)) {
      if ((Fast3Val == -1) && (sum <= -5) && (bIsShort ) &&
      ((frMeanSwing && close(0) <MeanSwingVal) || (!frMeanSwing)) && (close(0) < vLower) && (close() <= open())) {
      offset = 1.5 * atrStudy.getValue(ATRStudy.ATR);
      Alert.playSound("c:\program files\eSignal\Sounds\New.wav");
      drawShapeRelative(0, high(0) + offset, Shape.CIRCLE, null , Color.red, Shape.TOP | Shape.ONTOP | Shape.RIGHT);
      Alert.playSound( "c:\program files\eSignal\Sounds\sp_pt_sell_level1.wav" );
      SellSig = false;
      }
      else if ((SellSig) && ((CanclBar <= 0) || (A900A > AutoStopA))) {
      SellSig = false;
      }
      } else SellSig = false;

      Comment


      • #4
        Hello John,

        That sound you are hearing is a default sound that plays when the specified wav file cannot be found.

        If "c:\Program Files\eSignal\Sounds\" is set as the sound files root in your EFS settings, then the following should work.

        Alert.playSound("New.wav");
        or
        Alert.playSound("sp_pt_buy_level1.wav");


        You can still specify the full path if you want. However, you should use the following.

        Alert.playSound("c:\\Program Files\\eSignal\\Sounds\\New.wav");
        or
        Alert.playSound("c:\\Program Files\\eSignal\\Sounds\\sp_pt_buy_level1.wav");

        One more thing to note here is that depending on what type of sound card you have, if you try to play two sounds within the same condition, you will probably only hear the last one called. New.wav in your example. I recommend using only one sound alert per condition.
        Jason K.
        Project Manager
        eSignal - an Interactive Data company

        EFS KnowledgeBase
        JavaScript for EFS Video Series
        EFS Beginner Tutorial Series
        EFS Glossary
        Custom EFS Development Policy

        New User Orientation

        Comment


        • #5
          Thanks Jason,

          This worked fine - I appreciate your help.

          John

          Comment


          • #6
            You're most welcome.
            Jason K.
            Project Manager
            eSignal - an Interactive Data company

            EFS KnowledgeBase
            JavaScript for EFS Video Series
            EFS Beginner Tutorial Series
            EFS Glossary
            Custom EFS Development Policy

            New User Orientation

            Comment

            Working...
            X