#Purpose: This program will play a slide show of 4 slides
# The slides will appear on one large canvas one at a time,
# from left to right, with previous slides remaining in the
# picture after new ones are added.
# An appropriate narration for each slide will play after the
# slide appears
# until the time when the next slide appears.
# The narration will be blended with selected music.
import time
#This function mixes two sounds.
def makeMix(sound1, sound2, mixValue1, mixValue2):
newLength = min(getLength(sound1),getLength(sound2))
newSound = makeEmptySound(newLength)
for index in range(0,newLength):
sample1 = getSampleValueAt(sound1,index)
sample2 = getSampleValueAt(sound2,index)
newSample = mixValue1*sample1 + mixValue2*sample2
setSampleValueAt(newSound,index,newSample)
return newSound
#This function shrinks an image.
def shrink (source):
# set up target picture
target = makeEmptyPicture( getWidth(source)/2, getHeight(source)/2)
# do the actual copying
sourceX = 0
for targetX in range (0, getWidth(source)/2):
sourceY = 0
for targetY in range (0, getHeight(source)/2):
color = getColor (getPixel (source, sourceX, sourceY))
setColor (getPixel (target, targetX, targetY), color)
sourceY = sourceY + 2
sourceX = sourceX + 2
return (target)
#The main function
def slideShow():
# Create empty canvas
canvas = makeEmptyPicture(1929, 240)
#The four images
greece1 = makePicture(getMediaPath("greece.jpg"))
pic1 = shrink(greece1)
pic2 = makePicture(getMediaPath ("waikiki.jpg"))
m3 = makePicture(getMediaPath ("moon-surface.jpg"))
pic3 = shrink(m3)
pic4 = makePicture(getMediaPath ("caterpillar.jpg"))
#The four narrations
Narration1 = makeSound(getMediaPath("Clip1.wav"))
Narration2 = makeSound(getMediaPath("Clip2.wav"))
Narration3 = makeSound(getMediaPath("Clip3.wav"))
Narration4 = makeSound(getMediaPath("Clip4.wav"))
#The four background instrumentals
GreeceSound = makeSound(getMediaPath("Compatibility 30.wav"))
WaikikiSound = makeSound(getMediaPath("One Clear Moment 30.wav"))
SpaceSound = makeSound(getMediaPath("Disappearing_Acts_30.wav"))
EvilSound = makeSound(getMediaPath("Darkness Falls 30.wav"))
#The blended sounds
GreeceAudio = makeMix(GreeceSound, Narration1, .25, .75)
WaikikiAudio = makeMix(WaikikiSound, Narration2, .25, 1)
SpaceAudio = makeMix(SpaceSound, Narration3, .25, 1)
EvilAudio = makeMix(EvilSound, Narration4, .25, 1)
checkTime = false
#copying the images into the canvas
t0 = time.clock()
copyInto (pic1, canvas, 320, 20)
if (checkTime):
print time.clock() - t0, "seconds process time for copy 1"
repaint (canvas)
blockingPlay (GreeceAudio)
t0 = time.clock()
copyInto (pic2, canvas, 640, 0)
if (checkTime):
print time.clock() - t0, "seconds process time for copy 1"
repaint (canvas)
blockingPlay (WaikikiAudio)
t0 = time.clock()
copyInto (pic3, canvas, 960, 0)
if (checkTime):
print time.clock() - t0, "seconds process time for copy 1"
repaint (canvas)
blockingPlay (SpaceAudio)
t0 = time.clock()
copyInto (pic4, canvas, 1280, 45)
if (checkTime):
print time.clock() - t0, "seconds process time for copy 1"
repaint (canvas)
blockingPlay (EvilAudio)
# The slides will appear on one large canvas one at a time,
# from left to right, with previous slides remaining in the
# picture after new ones are added.
# An appropriate narration for each slide will play after the
# slide appears
# until the time when the next slide appears.
# The narration will be blended with selected music.
import time
#This function mixes two sounds.
def makeMix(sound1, sound2, mixValue1, mixValue2):
newLength = min(getLength(sound1),getLength(sound2))
newSound = makeEmptySound(newLength)
for index in range(0,newLength):
sample1 = getSampleValueAt(sound1,index)
sample2 = getSampleValueAt(sound2,index)
newSample = mixValue1*sample1 + mixValue2*sample2
setSampleValueAt(newSound,index,newSample)
return newSound
#This function shrinks an image.
def shrink (source):
# set up target picture
target = makeEmptyPicture( getWidth(source)/2, getHeight(source)/2)
# do the actual copying
sourceX = 0
for targetX in range (0, getWidth(source)/2):
sourceY = 0
for targetY in range (0, getHeight(source)/2):
color = getColor (getPixel (source, sourceX, sourceY))
setColor (getPixel (target, targetX, targetY), color)
sourceY = sourceY + 2
sourceX = sourceX + 2
return (target)
#The main function
def slideShow():
# Create empty canvas
canvas = makeEmptyPicture(1929, 240)
#The four images
greece1 = makePicture(getMediaPath("greece.jpg"))
pic1 = shrink(greece1)
pic2 = makePicture(getMediaPath ("waikiki.jpg"))
m3 = makePicture(getMediaPath ("moon-surface.jpg"))
pic3 = shrink(m3)
pic4 = makePicture(getMediaPath ("caterpillar.jpg"))
#The four narrations
Narration1 = makeSound(getMediaPath("Clip1.wav"))
Narration2 = makeSound(getMediaPath("Clip2.wav"))
Narration3 = makeSound(getMediaPath("Clip3.wav"))
Narration4 = makeSound(getMediaPath("Clip4.wav"))
#The four background instrumentals
GreeceSound = makeSound(getMediaPath("Compatibility 30.wav"))
WaikikiSound = makeSound(getMediaPath("One Clear Moment 30.wav"))
SpaceSound = makeSound(getMediaPath("Disappearing_Acts_30.wav"))
EvilSound = makeSound(getMediaPath("Darkness Falls 30.wav"))
#The blended sounds
GreeceAudio = makeMix(GreeceSound, Narration1, .25, .75)
WaikikiAudio = makeMix(WaikikiSound, Narration2, .25, 1)
SpaceAudio = makeMix(SpaceSound, Narration3, .25, 1)
EvilAudio = makeMix(EvilSound, Narration4, .25, 1)
checkTime = false
#copying the images into the canvas
t0 = time.clock()
copyInto (pic1, canvas, 320, 20)
if (checkTime):
print time.clock() - t0, "seconds process time for copy 1"
repaint (canvas)
blockingPlay (GreeceAudio)
t0 = time.clock()
copyInto (pic2, canvas, 640, 0)
if (checkTime):
print time.clock() - t0, "seconds process time for copy 1"
repaint (canvas)
blockingPlay (WaikikiAudio)
t0 = time.clock()
copyInto (pic3, canvas, 960, 0)
if (checkTime):
print time.clock() - t0, "seconds process time for copy 1"
repaint (canvas)
blockingPlay (SpaceAudio)
t0 = time.clock()
copyInto (pic4, canvas, 1280, 45)
if (checkTime):
print time.clock() - t0, "seconds process time for copy 1"
repaint (canvas)
blockingPlay (EvilAudio)