How to replace the windows `beep` sound

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

glenn9
Posts: 234
Joined: Wed Jan 15, 2020 10:45 pm

Re: How to replace the windows `beep` sound

Post by glenn9 » Tue Jan 07, 2025 4:46 pm

Thanks Klaus,

I think what`s confusing me is that if I double click on the mid file in windows filexplorer, the mid file will open and play with the native windows medial player.

I`ve tried some midi opensource apps, eg fluidsynth but I can`t get these to work when I call them in LC - I think its because I`m not understanding the syntax to use for the opensource midi players...

Regards,

Glenn

glenn9
Posts: 234
Joined: Wed Jan 15, 2020 10:45 pm

Re: How to replace the windows `beep` sound

Post by glenn9 » Tue Jan 07, 2025 5:11 pm

My work around so far is for LC to open fileexplorer so I can then double click on the mid file to play it...

Code: Select all

  launch url "File:C:\Users\Glenn\OneDrive\Documents\LiveCode\"
Its all of one or two extra clicks but I thought it would be much neater if I could open the mid file using LC!

Regards,
Glenn

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: How to replace the windows `beep` sound

Post by Klaus » Tue Jan 07, 2025 5:31 pm

Hi Glenn,

hm, then try either:

Code: Select all

launch document "path/to/your/midi.mid"
or

Code: Select all

launch "path/to/your/midi.mid" with "path/to/WMP.exe"
Best

Klaus

glenn9
Posts: 234
Joined: Wed Jan 15, 2020 10:45 pm

Re: How to replace the windows `beep` sound

Post by glenn9 » Wed Jan 08, 2025 9:02 am

Thanks Klaus, sadly no luck with either of those... but thank you for the suggestions.

I guess I`ll just have to live with the few extra clicks to play the mid file from file explorer!

Regards,

Glenn

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: How to replace the windows `beep` sound

Post by Klaus » Wed Jan 08, 2025 9:48 am

What does "the result" tell you?

glenn9
Posts: 234
Joined: Wed Jan 15, 2020 10:45 pm

Re: How to replace the windows `beep` sound

Post by glenn9 » Wed Jan 08, 2025 11:26 am

LC just seems to ignore the commands, ie no error messages etc, it just continues with the rest of the code as if the calls to the mid files were not there...!

have tried the following permutations:

Code: Select all

launch document "File:C:\Users\Glenn\OneDrive\Documents\LiveCode\" & tName & "test.mid"

Code: Select all

launch document "C:\Users\Glenn\OneDrive\Documents\LiveCode\" & tName & "test.mid"

Code: Select all

launch "File:C:\Users\Glenn\OneDrive\Documents\LiveCode\" with "path/to/WMP.exe"

Code: Select all

launch "C:\Users\Glenn\OneDrive\Documents\LiveCode\" with "path/to/WMP.exe"
Regards,
Glenn

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: How to replace the windows `beep` sound

Post by Klaus » Wed Jan 08, 2025 11:58 am

Hi Glenn,

please ALWAYS use parens when concatenating filenames (and names of LC objects) and check the result!

Code: Select all

...
## "launch document..." WITHOUT "file:..."!
launch document ("C:\Users\Glenn\OneDrive\Documents\LiveCode\" & tName & "test.mid")
if the result <> EMPTY then
  answer the result
end if
...
"the result" may show why this does not work.

And please try with the correct path and application name of the Windows Media Player, I'm on a Mac so I don't know the exact path.
"path/to/WMP.exe" was just an example. 8)
Corrext syntax is: launch DOCUMENT xyz with app.exe (Sorry forgot DOCUMENT in my example.)
And of course you need to supply the FILENAME of your MIDI file:

Code: Select all

...
launch document "C:\Users\Glenn\OneDrive\Documents\LiveCode\name of your MIDI file.mid" with "CORRECT path/on your/machine to/WMP.exe"
if the result <> EMPTY then
  answer the result
end if
...
Best

Klaus

glenn9
Posts: 234
Joined: Wed Jan 15, 2020 10:45 pm

Re: How to replace the windows `beep` sound

Post by glenn9 » Wed Jan 08, 2025 2:22 pm

Klaus,

Bingo! Your code has worked, LC now triggers the playing of the midi file! - thank you so much!
(I`d be embarrassed to disclose how many hours I`ve spent trying to get this to work previously!)

Best regards and Happy New Year.
Glenn

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: How to replace the windows `beep` sound

Post by Klaus » Wed Jan 08, 2025 2:26 pm

Hi Glenn,

which code did the trick?
The first one "launch document..." or the second one "launch document xyz WITH app.exe"?

Best

Klaus

glenn9
Posts: 234
Joined: Wed Jan 15, 2020 10:45 pm

Re: How to replace the windows `beep` sound

Post by glenn9 » Wed Jan 08, 2025 3:57 pm

Hi Klaus,

it was the first one that did the trick.

Code: Select all

...
## "launch document..." WITHOUT "file:..."!
launch document ("C:\Users\Glenn\OneDrive\Documents\LiveCode\" & tName & "test.mid")
if the result <> EMPTY then
  answer the result
end if
...
Regards,

Glenn

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: How to replace the windows `beep` sound

Post by Klaus » Wed Jan 08, 2025 4:03 pm

Thanks!


Your message contains 7 characters.
You need to enter at least 10 characters.

glenn9
Posts: 234
Joined: Wed Jan 15, 2020 10:45 pm

Re: How to replace the windows `beep` sound

Post by glenn9 » Wed Jan 08, 2025 4:11 pm

Just in case its of interest to anyone this LC works for me in generating a Lilypond score

Code: Select all

on generateLilyPond   
   
   -- Lilypond is case sensitive 
   put toLower(gKey) into gKey
   set the hideConsoleWindows to true
   
   -- this is the basic syntax for Lilypond to generate a score
   put "\version" && quote & "2.24.2" & quote & CR & CR into tLilyPondContent
   put "\score {" & CR after tLilyPondContent 
   put "\relative {" & CR after tLilyPondContent
   put "\time" && gTime after tLilyPondcontent
   put "\key" && gKey && "\major" after tLilyPondcontent
   
   put "\tempo 4 =" && tTempo after tLilyPondcontent
   
   -- this enters the notes (as variables of course) that Lilypond should create a PDF score/midi from
   put "" & tN1 & "'" && tN2 && tN3 && tN4 && tN5 && tN6 && tN7 && tN8 && tN9 && tN10 && tN11 && tN12 && "}" & CR after tLilyPondContent
   
   -- pdf Lilypond code
   if gPDf is "True" then
      put " \layout { }" & CR after tLilyPondContent 
   end if
   
   -- midi Lilypond code
   put "\midi { }"  & CR after tLilyPondContent 
   put "}"  & CR after tLilyPondContent 
   
end generateLilyPond
Regards,

Glenn

bogs
Posts: 5480
Joined: Sat Feb 25, 2017 10:45 pm

Re: How to replace the windows `beep` sound

Post by bogs » Thu Jan 09, 2025 9:44 pm

This doesn't replace the windows 'beep' sound, and I'm sure it isn't as spectacular as midi, but this YT playlist may be of interest to someone trying to create a similar app (musical).

https://www.youtube.com/watch?v=0xm6U96 ... GQyg_l3r3C
Image

glenn9
Posts: 234
Joined: Wed Jan 15, 2020 10:45 pm

Re: How to replace the windows `beep` sound

Post by glenn9 » Thu Jan 16, 2025 11:49 am

Thanks Bogs, I got some useful hints and tips from the 3 videos. Glenn

bogs
Posts: 5480
Joined: Sat Feb 25, 2017 10:45 pm

Re: How to replace the windows `beep` sound

Post by bogs » Fri Jan 17, 2025 10:10 am

Glad it was helpful in some way glenn9 :)
Image

Post Reply