Get started with creating sounds

Here is a short example to get you started with creating sounds:

/* create a new sound with
  1 channel
  length is 88200 samples, thus 2 seconds at 44100 hz
  sampleRate is set to 44100 */
  
sound = new Sound(1,88200,44100)

// write samples
for i=0 to sound.length-1 by 1
  // sound.write
  //   channel: 0
  //   position: i
  //   value: in the range [-1 .. 1]
  sound.write(0,i,sin(i*440/44100*PI*2)*exp(-i/10000)*min(i,300)/300)
end

sound.play()

update = function()
  if mouse.press then
    // save sound as a wav file on the user's PC
    system.file.save(sound,"sound.wav")
  end
end