Sound vary according progress bar value RRS feed

  • Question

  • Locate Tag using progress bar and want to show the vary of progress bar value with the sound together. Now only using Motorola sample code to play the sound. But the sound only one beep.

     m_LocateForm.Locate_PB.Value = tagDataArray[nIndex].LocationInfo.RelativeDistance;
     m_LocateForm.lastLocatedTagTimeStamp = System.Environment.TickCount;
     if (m_LocateForm.Locate_PB.Value >0)
          if (m_isBeepingEnabled)

    Want to make it like if Tag is closer, so progress bar value is high and the sound should be like fast beeping. And so with the tag is far, then progress bar is low and sound just beep slowly.

    Is it I need to put two type of sound in order to show the vary of sound?

    Friday, October 24, 2014 4:43 AM

All replies

  • Hi brownie yeo,

    I know that you use the function MessageBeep() to make a sound. But its parameter uType is always set to MB_OK. So we can only hear the sound specified as the Windows Default Beep sound. You can check this document:

    MessageBeep function.

    As to your requirement, you want sound vary according progress bar value. I think you can consider Beep function.

    Generates simple tones on the speaker. The function is synchronous; it performs an alertable wait and does not return control to its caller until the sound finishes. It has 2 parameters.

      _In_  DWORD dwFreq,
      _In_  DWORD dwDuration
    dwFreq [in]

    The frequency of the sound, in hertz. This parameter must be in the range 37 through 32,767 (0x25 through 0x7FFF).

    dwDuration [in]

    The duration of the sound, in milliseconds.

    So we can change the sound by changing the value of dwFreq. In other words, you can set the progress bar value as dwFreg.

    You can refer to:http://msdn.microsoft.com/en-us/library/windows/desktop/ms679277(v=vs.85).aspx

    Best regards,

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, October 27, 2014 2:41 AM
  • Hi Anna,

    So I code as below:

    Reference from http://msdn.microsoft.com/en-us/library/windows/desktop/ms679277%28v=vs.85%29.aspx

    internal static extern bool Beep(uint dwFreq, uint dwDuration);
    if (m_isBeepingEnabled)
    Beep(Locate_PB.Value, 150);

    And where can I get Kernel32.dll?

    Or should I follow back the code using coredll.dll?

    But when I using coredll.dll, it shows me error can't find pinvoke dll error.

    • Edited by brownie yeo Wednesday, October 29, 2014 8:34 AM
    Wednesday, October 29, 2014 3:41 AM