50 likes | 59 Views
Learn about sampling audio waves and how to play them back with examples and notes.
E N D
Session 18 CPSC 231 Tu#02
Table of content Audio Object Types Examples
Audio Notes are a sin wave that oscillates with different frequencies
Audio (cont’d) Waves are analog, but our systems are digital We have to sample the wave The more samples, the more accurate For note A: sin(2πt ×440)
Audio (cont’d) • stdaudio, accepts an array of samples • For t seconds, we need t * sampling-rate samples • t = 1: 44,100 samples SPS = 44100 # samples per secondhz = 440.0 # concert Aduration = 1.0 # one secondn = int(SPS * duration)a = stdarray.create1D(n+1)for i in range(n+1): a[i] = math.sin(2.0 * math.pi * i * hz / SPS)stdaudio.playSamples(a)stdaudio.wait()