Hello Guest it is April 18, 2024, 06:17:02 PM

Author Topic: Adding sound in Mach4 m-code  (Read 1640 times)

0 Members and 1 Guest are viewing this topic.

Adding sound in Mach4 m-code
« on: June 08, 2016, 03:24:04 PM »
Been banging my head against a wall for months (only result has been a headache & a dent in the wall)...   I'm trying to get Mach4 to play a wave file when I zero an axis using my ShuttlePro. Thanks to DazTheGas's Quicky#1, I have added sounds to the zero axis buttons on the screen, but have not been able to figure out how to get a sound when I zero using the ShuttlePro. I wrote a m-code script which will zero an axis and added the nameoffile:Play() command that DazTheGas used in his Quicky. I was hoping I could assign a User Gcode to the keys on my Shuttle which would call the m-code.

function m110()
    inst = mc.mcGetInstance();
    mc.mcAxisSetPos(inst,0,0);
    notify:Play();
end

if (mc.mcInEditor() == 1) then
    m110()
end

I added the file to my sounds folder and added the "local notify = wx.wxSound('C:\\Mach4Hobby\\Sounds\\notify.wav',0)" to the end of the screen load script as per DazTheGas directions.

When I run the script the axis zeros but the sound does not play. The sound plays when zeroing the axis from the button on the screen. Anyone know why it works from a button script & not from the m-code?

Thanks in advance.
Hit the e-stop! Hit the e-stop!

Offline DazTheGas

*
  •  778 778
  • DazTheGas
    • View Profile
Re: Adding sound in Mach4 m-code
« Reply #1 on: June 08, 2016, 03:39:37 PM »
not 100% sure on this but the macros will run within a different instance than the gui so what is assigned there will not show.

DazTheGas
New For 2022 - Instagram: dazthegas