Example Code

Playing a tune using windows beep and multiple PCs.

Code and Documents

Attachment

This example plays a tune on multiple PC's through their internal speaker. To run the VI load it onto the PC's that you want to play the tune. when the VI is run on each PC a file open dialogue will pop up asking you to select the note data file. This is a custom file where each note is on it's own line. It consists of the MIDI note number and MIDI duration. A duration of 256 is equivalent to a 1/4 note. The two are separated by a colon ":".


Once you have the files loaded set the port to the same on all PCs, and set all but one to receive mode. The PC set to send will trigger all other PCs to start playing. After clicking start on all the receive PCs finally click start on the send PC. You should now hear the tune that was loaded. If none of the PCs play except the sending one make sure the UDP broadcast isn't being blocked by any routers or network switches.

I've provided an example Mario theme tune which contains 5 separate files. Distribute these files evenly across all the PC's you'll be using for best effect. It does sound a bit out of tune at some points, and the last two files are mostly silent due to the method used to convert an existing midi file. You should still be able to recognise the tune though

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Contributors