A Scripting Language for Web, Linux and Windows

A Scripting Language for Web, Linux and Windows

Example: Play MIDI Sound

Demonstrates how to play sound on Windows with sound module.

<?v1
// Play MIDI (only on Windows)
dl ("sound");

deviceId 0;
voice 222;
duration 500;
volume 127;

freqList = array (
    
"c1" => 264,
    
"d1" => 297,
    
"e1" => 330,
    
"f1" => 352,
    
"g1" => 396,
    
"a1" => 440,
    
"h1" => 495,
    
"c2" => 528
);

hSound sound_create (deviceId);
if (
hSound) {
  foreach (
freqList as note => freq) {
    print (
"Play Note: "note", Voice: "voice);
    
sound_play (hSoundfreqdurationvolumevoice); 
    
sound_wait_finished (hSound); 
    
voice++;
  }
  
sound_close (hSound);
}

?>

back to Home