Trying to use API Sound.Play

For questions and comments on programming in general. And for any items that don't fit into the forums below.

Moderators: Benj, Mods

Post Reply
gtc
Posts: 69
Joined: Mon Mar 23, 2015 5:34 am
Has thanked: 30 times
Been thanked: 15 times
Contact:

Trying to use API Sound.Play

Post by gtc »

I wish to play a bell sound, using file bell.wav

For this API the user guide says ...
Calling in a calculation

Declare a variable 'result' of type BOOL
Add to a calculation icon:

result = ::Sound.Play("filename")
I have done that, but I get no sound played, and the result variable's value is True, even if the wav file does not exist.

Scratching my head here!

(FC6)

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Trying to use API Sound.Play

Post by Benj »

Hello,

There is an example here you can refer to but there is quite a lot going on.
viewtopic.php?f=54&t=16848&p=73371

It seems all I am doing is calling the sound.play function in the PlayMidiFile macro for the simulation sound so you can check to see if my .wav file works for you. It could be that your file is in the wrong format for the function to work correctly.

gtc
Posts: 69
Joined: Mon Mar 23, 2015 5:34 am
Has thanked: 30 times
Been thanked: 15 times
Contact:

Re: Trying to use API Sound.Play

Post by gtc »

Mine is a valid .wav file, but I tried your TETRIS.WAV as suggested and it doesn't play either.

Your code uses simulation and component macros.

The User Guide implies that all I need to use is a calculation. Is the UG incorrect, or do I simply not understand how to use API stuff?

Post Reply