LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Generate a beep sound via PC speaker

Solved!
Go to solution

Hello Friends,

 

I like to add a beep sound to my VI, I tried two methods, one is to use Kernel32 Dll beep, another is to use beep.vi, however, none of them worked on labview 2015. I used both of them on older labview version prior to 2010. I do not know why they do not work on 2015.

 

Could someone help me with the issue? see attached vi.

 

Thanks.

Gu

 

 

0 Kudos
Message 1 of 12
(7,380 Views)
Solution
Accepted by topic author edmonton

It works fine on my computer. Note that it plays the beep through the computer speakers, not an internal speaker, at least on my laptop.

 

Did you try it on yours with "use system alert?" set to True? From the help on Beep.vi:

 

"This VI might not work correctly if use system alert? is FALSE."

 

EDIT: By "works fine" I mean my computer starts making noise. The VI actually locked up for a while when I first ran it, screeching a high pitched tone out of my headphones 🙂

 

I'd add a Wait in there or something, as it basically locked up the environment. I also removed the dll call and was just using Beep.vi- I'm just trying to get my computer to beep.

0 Kudos
Message 2 of 12
(7,354 Views)

Hi BertMcMahan,

 

Thanks for your reply. 

I did try "use system alert" and set to True before my posting. It did not work either.

 

Which LabVIEW version are you using? My is 2015. It might be just related to my computer issue, I will try it on another computer later.

 

Regards,

Gu 

0 Kudos
Message 3 of 12
(7,279 Views)

I tried it in LV2018 32-bit.

 

Is the beep sound maybe coming out of a speaker system that's turned off?

0 Kudos
Message 4 of 12
(7,275 Views)

I don't even know if modern operating systems even support PC speaker any more.  If I remember correctly, you had to send a square wave directly to that port (whatever it is).


Edit: LOL, I was thinking the OP was talking about the little speaker sometimes included with a PC desktop case.

 

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 5 of 12
(7,271 Views)

@billko wrote:

 LOL, I was thinking the OP was talking about the little speaker sometimes included with a PC desktop case.

 


Beep.vi used to make that little speaker beep, at least back in 8.2. I don't think it does anymore, but IIRC that was a Windows change, not a LabVIEW one.

Message 6 of 12
(7,259 Views)

I created a VI using Windows 10 and LabVIEW 2016 that consisted of just the Beep.vi function.  When I ran it (without specifying any parameters), I got my system "alert" tone, "bdddring".  I then added some parameters -- 440 (A above middle C, the pitch used to "tune" an orchestra; 500, half a second; F (don't use System Alert).  When I ran it, I got half a second of A440.

 

I repeated this opening the VI in LabVIEW 2019.  Same results.  It works fine in Windows 10 with the last four versions of LabVIEW (OK, I didn't test it with 2017 and 2018, but I could, they're on this PC, but I'm too lazy ...).

Beep Demo.png

 

Bob Schor

 

0 Kudos
Message 7 of 12
(7,206 Views)

Hi Everyone,

 

Thank you for all your efforts to address the sound issue.

 

I could not make beep.vi working in LabVIEW 2015 on my laptop, I checked the laptop's speaker and it works normal when playing YouTube videos and music files . 

 

I solved the beep sound issue in LabVIEW by playing a wav sound file instead. Attached is the VI.

 

Regards,

Gu

0 Kudos
Message 8 of 12
(6,821 Views)

I wouldn't really call it "solved".  The issue remains that it isn't working correctly; you just found a workaround.

 

It's kind of like saying "driving around a pothole" is the solution to fixing the pothole when really the solution is to fill it in...

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 9 of 12
(6,650 Views)

What happened when you tried (on your system) to run the one-function VI I posted?  I'm pretty sure it should have worked ...  Now, if it didn't make the kind of sound you wanted (i.e. if you wanted a different "beep" sound), then you stated the "problem" incorrectly, and your solution ("I wanted a particular .wav file to be played, but I didn't want to change the Windows setting for the "beep", so I simply played the .wav file that I wanted instead") is correct.  

 

I hope you learned something about the "Beep" function, namely that in its Default setting, it plays a defined Windows sound, but you can make it play a tone instead.

 

Bob Schor

0 Kudos
Message 10 of 12
(6,616 Views)