def triangularPictureSound():

  size = 320 #size of the empty picture

  pic = makeEmptyPicture(size,size) #empty picture
  snd = makeEmptySound(5) #empty sound

  samplesPerCycle = 1.0*size #sound samples per cycle

  # We need to switch every half-cycle
  samplesPerHalfCycle = int(samplesPerCycle / 2)

  # Value to add for each subsequent sample: Must be integer
  increment = int(2*32768/samplesPerHalfCycle) 

  pos = 1 # Starting sample position in the sound
  sampleVal = -32768 # Staring sample value for the sound
  i = 1 # Half-cycle counter
  for p in getPixels(pic):
    # if end of a half-cycle
    if (i > samplesPerHalfCycle):
      # Reverse the amplitude
      increment = increment * -1
      # And reinitialise the half-cycle counter
      i = 0
    #Set the sound sample value
    sampleVal = sampleVal + increment
    setSampleValueAt(snd, pos, sampleVal)
    #Set the pixel color
    colorVal = int(sampleVal*0.008)
    setRed(p, colorVal)
    setGreen(p, colorVal)
    setBlue(p, colorVal)

    i = i + 1 #increment the half-cycle counter
    pos = pos + 1 #increment the sample position in the sound

  return (pic, snd)
