Jump to content
The simFlight Network Forums

Recommended Posts

Posted

Hi! I'm trying to play a short wav file "bong" to coincide with passenger sign activation/deactivation. I've determined the my sound device is #2 in the ini file, and I have the following code in my lua script, which is otherwise running fine (I'm also activating a light with Mobiflight

As per the library, I have entered the following:

            sound.path("F:\\MSFS Backup\Mobiflight")
            sound.play("bong.wav",2)

I've tripled checked the path and file name are correct.

Many thanks in advance,

Troy

Posted
44 minutes ago, vanislepilot said:

As per the library, I have entered the following:

            sound.path("F:\\MSFS Backup\Mobiflight")
            sound.play("bong.wav",2)

I've tripled checked the path and file name are correct.

As the \ is a lua escape character, you need to use \\, so try:

            sound.path("F:\\MSFS Backup\\Mobiflight")
            sound.play("bong.wav",2)

If the script is exiting after the play instruction, you may also need to add a delay, e.g.
           ipc.sleep(2000)

John

Posted
8 hours ago, vanislepilot said:

Thanks John, I've tried the "\\" and delay, as well as other sound devices; however, no luck.

While waiting for John's help,  here's a few things you could try if you haven't:

- In the Lua script, add in some additional sound.play("bong.wav",x) lines (separated with delays) but all with different sound device #s  ( none, 1, 3, 4 etc) "just in case" to see if one of them works.

- Put a copy of the sound file in the same location as your Lua script, adjust the sound path accordingly, and see if that works (I'm assuming that won't be the F drive).

- If you double click the wave file, an app should open and play it -- does that work? In other words, are you sure the wav file is good?

- If your Lua script calls different functions, etc, make sure the sound code part of the script is actually being executed.  You could make a separate Lua script just with a sound path, sound play and delay instructions and see if that works.

- try a different wav file.

Al

Posted

Are you sure the lua file is actually running? I have tested here and everything seems to be working as expected. Try logging Lua Plugins to make sure the script is being executed, with the logging console open (Log -> Open Console).

Also try those tests as mentioned by @ark1320.

Note you can also exclude the .wav extension (i.e. sound.play("bong",2)), but that shouldn't make any difference...

John

Posted

I tried all of those steps, verified the wav does work in multiple audio players. The log itself is not making mention of calls to sound.play, but the rest of the script is paired with control of a seatbelt sign and no smoking light, which is running flawlessly. Example:

function MOUSE_NOSMK_SWITCH(varname, value, userParameter)

    smkNEW = ipc.readLvar("L:switch_103_73X")

    smkLT = ipc.readUB(0x341C)    -- Read the light position
    
    
    if smkNEW == 100 then
    
        if smkLT == 0 then
            ipc.control(66718)
        end
        
    elseif smkNEW == 0 then
        
        if smkLT == 1 then        
            ipc.control(66718)
            sound.path("F:\\FSUIPC")
            sound.play("bong",2)
            -- ipc.sleep(2000)
        end
    end    
        
end

event.Lvar("switch_103_73X",100,"MOUSE_NOSMK_SWITCH")   

When I insert and remove delays, the code seems to run appropriately just no sound.

Device 2 is a USB 3.0 PreSonus Studio 192 and it's been working fine for all other MSFS related sounds.

Posted
16 minutes ago, vanislepilot said:

 The log itself is not making mention of calls to sound.play,

Suggest you create a test Lua script with just the call to the wav file and see if that works, e.g.:

 sound.path("F:\\FSUIPC")
 sound.play("bong",2)
 ipc.sleep(2000)

Al

Posted
Just now, ark1320 said:

Suggest you create a test Lua script with just the call to the wav file and see if that works, e.g.:

 sound.path("F:\\FSUIPC")
 sound.play("bong",2)
 ipc.sleep(2000)

Al

Thanks Al, also tried that as well with no luck.

Posted

First, please try just using a simple script to test if it is a problem with the sound., i.e. just
     sound.path("F:\\FSUIPC")
     sound.play("bong",2)
Also try  the other things mentioned, i.e.
    sound.path("F:\\FSUIPC\\")
    ipc.log("Playing sound on device 0...")

    sound.play("bong",0, 100)
    sleep(1000)
    ipc.log("Playing sound on device 1...")

    sound.play("bong",1, 100)
    sleep(1000)
    ipc.log("Playing sound on device 2...")

    sound.play("bong",2, 100)
   ...

etc

 

12 minutes ago, vanislepilot said:

function MOUSE_NOSMK_SWITCH(varname, value, userParameter)

    smkNEW = ipc.readLvar("L:switch_103_73X")

You don't need to read the lvar as you can use the value variable, or change to
   function MOUSE_NOSMK_SWITCH(varname, smkNEW, userParameter)

Posted
1 minute ago, vanislepilot said:
2 minutes ago, ark1320 said:

Suggest you create a test Lua script with just the call to the wav file and see if that works, e.g.:

 sound.path("F:\\FSUIPC")
 sound.play("bong",2)
 ipc.sleep(2000)

Al

Thanks Al, also tried that as well with no luck.

Can you please do this with Log -> Lua Plugins set, and show me both the lua script and your FSUIPC7.log file after the test. Also try with other devices (0,1,3,4,5,6,7,8) and with also setting the volume parameter to 100.

Posted

I always put the sound.path instruction at the top of my scripts as part of the general script setup rather than just before the soundlplay call. Wonder if in this script a small delay is needed between the sound.path and sound.play instructions?

Al

Posted
2 minutes ago, ark1320 said:

Any chance a small delay is needed between the sound.path and sound.play instructions?

No.

Also please add logging for sound by setting a Log->Custom value of x20.

Posted
2 hours ago, vanislepilot said:

Thanks Al, also tried that as well with no luck.

Any chance sound.path("F:\\FSUIPC") should be sound.path("F:\\FSUIPC7") ?

Posted
2 hours ago, John Dowson said:

Can you please do this with Log -> Lua Plugins set, and show me both the lua script and your FSUIPC7.log file after the test. Also try with other devices (0,1,3,4,5,6,7,8) and with also setting the volume parameter to 100.

Tried all 16 audio devices (even though some of them are haptic feedback), and didn't hear the sound but it looks like the simple script is running.

wavTest.lua wavTest.log

Edit:   Updated to include x20 log.

FSUIPC7.ini FSUIPC7.log

Posted

It would have been better to NOT Log Lua Separately, so that the lua log and sound logging can be seen together, but looking at your files it looks as though it is trying to play the sound file,  but something strange is going on,... This is my lof extract from a similar test:

Quote

    68188 LUA.3: Playing gear_down from local folder
    68188 Sound: Id 1, PlayNow("gear_down")
    68203 Sound: Id 1, PlayTheSound("gear_down.wav")
    72938 Sound: Id 1 DeActivate: sound not playing now ...
    72938 Sound: Id 1 EndPlay: releasing buffer
    72938 Sound: Id 0 EndPlay: all done!
    73360 LUA.3: Playing crash on device 0
    73360 Sound: Id 1, PlayNow("F:\Sounds\crash_ground")
    73360 Sound: Id 1, PlayTheSound("F:\Sounds\crash_ground.wav")
    77375 LUA.3: Playing crash on device 1
    77375 Sound: Id 2, PlayNow("F:\Sounds\crash_ground")
    77375 Sound: Id 2, PlayTheSound("F:\Sounds\crash_ground.wav")
    77391 Sound: EnumDevice=Primary Sound Driver
    80375 Sound: Id 1 DeActivate: sound not playing now ...
    80375 Sound: Id 1 EndPlay: releasing buffer
    80375 Sound: Id 0 EndPlay: all done!
    81407 LUA.3: Playing crash on device 2
    81407 Sound: Id 3, PlayNow("F:\Sounds\crash_ground")
    81407 Sound: Id 3, PlayTheSound("F:\Sounds\crash_ground.wav")
    81407 Sound: EnumDevice=Primary Sound Driver
    81407 Sound: EnumDevice=Speakers (3- Razer Nommo Pro)
    84438 Sound: Id 2 DeActivate: sound not playing now ...
    84438 Sound: Id 2 EndPlay: releasing buffer
    84438 Sound: Id 0 EndPlay: all done!
    85516 LUA.3: Playing crash on device 3
...

Note that the id is changing (yours is always 1) and the DeActivate and EndPlay messages, which are missing from your log.

Apart from this issue, is your audio working ok?

Could you check the windows Event viewer, to see if there are any events logged relating to audio.

You could try updating your VC++ redistributables to see if this is an issue (see the Installation and Registration guide for details). Other than that, I don't understand why this isn't working.  I will look at the code tomorrow to see what could be causing the id not to increment and why those log messages are missing.

Could you also attach the bong.wav file so I can test with that to exclude that being the issue - and maybe try with another sound file.

 

Posted
21 minutes ago, John Dowson said:

It would have been better to NOT Log Lua Separately, so that the lua log and sound logging can be seen together, but looking at your files it looks as though it is trying to play the sound file,  but something strange is going on,... This is my lof extract from a similar test:

Note that the id is changing (yours is always 1) and the DeActivate and EndPlay messages, which are missing from your log.

Apart from this issue, is your audio working ok?

Could you check the windows Event viewer, to see if there are any events logged relating to audio.

You could try updating your VC++ redistributables to see if this is an issue (see the Installation and Registration guide for details). Other than that, I don't understand why this isn't working.  I will look at the code tomorrow to see what could be causing the id not to increment and why those log messages are missing.

Could you also attach the bong.wav file so I can test with that to exclude that being the issue - and maybe try with another sound file.

 

The audio is working just fine, even when playing the wav by itself. I will update the redistributables and see if that does the trick. Thanks for working on this! Wav file attached.

Posted

I just combined the logging as you suggested, and saw several "*** mmioOpen Failed, Error 0" lines after each attempt at playing. Hopefully that means something to you! Many thanks again.

FSUIPC7.log

 

Update: this same error occurred after uninstalling and reinstalling the latest distributables. I have also renamed the FSUIPC folder FSUIPC7.

Posted
7 hours ago, vanislepilot said:

I just combined the logging as you suggested, and saw several "*** mmioOpen Failed, Error 0" lines after each attempt at playing. Hopefully that means something to you! Many thanks again.

FSUIPC7.log 35.94 kB · 1 download

 

Update: this same error occurred after uninstalling and reinstalling the latest distributables. I have also renamed the FSUIPC folder FSUIPC7.

Seems to be a Windows file handling error of some kind (e.g., maybe couldn't find or open the sound file):   https://learn.microsoft.com/en-us/windows/win32/api/mmiscapi/nf-mmiscapi-mmioopen

Is the install of FSUIPC7 and the sound file both on the F drive?

Al

 

Posted

The error indicates that the bong.wav couldn't be found/opened. Are you sure its called bong.wav? The ones you attached were called:
    bong.wav.0645ec9f6c9d603625c03bbececf9f2f.wav
    bong.wav.6131c136275a2d1df950f9af7a19cf17.wav
Have  you tried with a different .wav file?

11 hours ago, vanislepilot said:

I have also renamed the FSUIPC folder FSUIPC7.

Did you update the sound.path call in your test script for this as well? Looks like its still referencing the old folder name:
     19766 Sound: Id 1, PlayNow("F:\FSUIPC\bong")
     19766 Sound: Id 1, PlayTheSound("F:\FSUIPC\bong.wav")

That is probably the cause if the current "mmioOpen Failed" error.

Posted (edited)

It looks to be that bomg.wav file. I tried using that file here and get the same issue. I have added extra logging and it looks like it cannot read (or convert) the format of that wav file.
Looking at that wav file, it could be one or all of the following:
    - is using a bits_per_sample value of 24, the ones I am using use 16
    - is using 2 channels, the ones I am using use 1
    - the bit rate is 2304000, the ones I am using use 705600
    - sample rate is 48000, the ones I am using use 44100

...or something else.

I could look into adding code to handle/convert this format, but I am no expert on wav file formats so this may take a while.

I converted that bong.wav using this online tool and this plays as expected, so please try this: 

John

Later: I think its the bits_per_sample value of 24 that is the issue....

Edited by John Dowson
Later added
Posted
7 hours ago, John Dowson said:

Did you update the sound.path call in your test script for this as well? Looks like its still referencing the old folder name:
     19766 Sound: Id 1, PlayNow("F:\FSUIPC\bong")
     19766 Sound: Id 1, PlayTheSound("F:\FSUIPC\bong.wav")

That is probably the cause if the current "mmioOpen Failed" error.

You are quite right John, I think I missed that. Thanks.

I will give the new file a try when I get home later today. I really appreciate your assistance in this! I will make sure I have 16 bit files from now on.

Cheers

Troy

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.