Page 2 of 3

Re: How to replace the windows `beep` sound

Posted: Tue Jan 07, 2025 4:46 pm
by glenn9
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

Re: How to replace the windows `beep` sound

Posted: Tue Jan 07, 2025 5:11 pm
by glenn9
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

Re: How to replace the windows `beep` sound

Posted: Tue Jan 07, 2025 5:31 pm
by Klaus
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

Re: How to replace the windows `beep` sound

Posted: Wed Jan 08, 2025 9:02 am
by glenn9
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

Re: How to replace the windows `beep` sound

Posted: Wed Jan 08, 2025 9:48 am
by Klaus
What does "the result" tell you?

Re: How to replace the windows `beep` sound

Posted: Wed Jan 08, 2025 11:26 am
by glenn9
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

Re: How to replace the windows `beep` sound

Posted: Wed Jan 08, 2025 11:58 am
by Klaus
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

Re: How to replace the windows `beep` sound

Posted: Wed Jan 08, 2025 2:22 pm
by glenn9
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

Re: How to replace the windows `beep` sound

Posted: Wed Jan 08, 2025 2:26 pm
by Klaus
Hi Glenn,

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

Best

Klaus

Re: How to replace the windows `beep` sound

Posted: Wed Jan 08, 2025 3:57 pm
by glenn9
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

Re: How to replace the windows `beep` sound

Posted: Wed Jan 08, 2025 4:03 pm
by Klaus
Thanks!


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

Re: How to replace the windows `beep` sound

Posted: Wed Jan 08, 2025 4:11 pm
by glenn9
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

Re: How to replace the windows `beep` sound

Posted: Thu Jan 09, 2025 9:44 pm
by bogs
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

Re: How to replace the windows `beep` sound

Posted: Thu Jan 16, 2025 11:49 am
by glenn9
Thanks Bogs, I got some useful hints and tips from the 3 videos. Glenn

Re: How to replace the windows `beep` sound

Posted: Fri Jan 17, 2025 10:10 am
by bogs
Glad it was helpful in some way glenn9 :)