Difference between revisions of "CSC111 JES Page on Sound Processing"
(→Example 1: Playing Sound Files) |
|||
Line 15: | Line 15: | ||
* In the JES program area, type in the following main() function: | * In the JES program area, type in the following main() function: | ||
− | + | <br /> | |
<source lang="python"> | <source lang="python"> | ||
Line 24: | Line 24: | ||
</source> | </source> | ||
− | + | <br /> | |
* Save the file as '''sound1.py''' | * Save the file as '''sound1.py''' | ||
* Click on '''Load Program''' | * Click on '''Load Program''' | ||
Line 32: | Line 32: | ||
* Make sure the speakers are on, but not too loud and listen to the sentence being played. | * Make sure the speakers are on, but not too loud and listen to the sentence being played. | ||
* Try one or two other sound files. | * Try one or two other sound files. | ||
+ | <br /> | ||
+ | =Part 3: Altering a sound file= | ||
+ | |||
+ | * You will reduce the intensity of the sound by dividing all the samples by half | ||
+ | * Copy/Paste the program below in JES | ||
+ | * Read it to make sure you understand it. | ||
+ | |||
+ | <source lang="python"> | ||
+ | |||
+ | |||
+ | # select a sound file | ||
+ | file = pickAFile() | ||
+ | sound = makeSound( file ) | ||
+ | |||
+ | # play it | ||
+ | blockingPlay( sound ) | ||
+ | |||
+ | # lower its intensity by half | ||
+ | for i in range( 1, getLength( sound ) ): | ||
+ | value = getSampleValueAt( sound, i ) # get the value of the i-th sample | ||
+ | setSampleValueAt( sound, i, value / 2 ) # set the sample to half its original value | ||
+ | |||
+ | # play new waveform back | ||
+ | blockingPlay( sound ) | ||
+ | |||
+ | |||
+ | </source> |
Revision as of 20:16, 23 February 2014
--D. Thiebaut (talk) 20:12, 23 February 2014 (EST)
Contents
Reference
Installation
If you want to install JES on your personal Windows computer
If you want to install JES on your Windows laptop or computer, you can get Jes from the Google code web site. Grab the 3.2.1 version for Windows and install it on your Windows machine.
If you want to install JES on your personal Mac
Jes for the Mac is available on Google code. Get Jes 3.2.1 for the Mac, open the zip file, and move the JES 3.2.1.app to your Applications folder.
Example 1: Playing Sound Files
- In the JES program area, type in the following main() function:
file = pickAFile()
sound = makeSound( file )
blockingPlay( sound )
- Save the file as sound1.py
- Click on Load Program
- In the interactive area, type
- When prompted for a sound file, select thisisatest.wav in the Sound Files folder.
- Make sure the speakers are on, but not too loud and listen to the sentence being played.
- Try one or two other sound files.
Part 3: Altering a sound file
- You will reduce the intensity of the sound by dividing all the samples by half
- Copy/Paste the program below in JES
- Read it to make sure you understand it.
# select a sound file
file = pickAFile()
sound = makeSound( file )
# play it
blockingPlay( sound )
# lower its intensity by half
for i in range( 1, getLength( sound ) ):
value = getSampleValueAt( sound, i ) # get the value of the i-th sample
setSampleValueAt( sound, i, value / 2 ) # set the sample to half its original value
# play new waveform back
blockingPlay( sound )