Difference between revisions of "CSC231 Lab 6 2010"

From dftwiki3
Jump to: navigation, search
(Assemble)
(Test #1)
Line 63: Line 63:
 
=Part 2=
 
=Part 2=
  
==Test #1==
+
==Test #1: Increase intensity==
 
* Make a copy of readWavFileSkel.asm and call it '''readWavFile1.asm'''
 
* Make a copy of readWavFileSkel.asm and call it '''readWavFile1.asm'''
  
* Modify it and modify it so that you multiply the intensity of the sound by 2.
+
* Modify   it so that you multiply the intensity of the sound by 2.
  
 
* Listen to the result.  Can you still understand the message?
 
* Listen to the result.  Can you still understand the message?

Revision as of 09:53, 25 October 2010

--D. Thiebaut 13:51, 25 October 2010 (UTC)



This lab covers sound files in the WAV format, and performing various operations on a sound file using array operations.

The Format of Sound Files

Part 1

Get the code

or simply get them with getcopy
 getcopy readWaveFileSkel.asm
 getcopy wav.inc

Get sound files

 getcopy hello.wav
 getcopy goodbye.wav
(there's more at http://buggerluggs.tripod.com/ie/wav-dir184.htm )

Play the sound

  • Play the files with aplay to make sure you can hear them:
aplay goodbye.wav
Playing WAVE 'goodbye.wav' : Unsigned 8 bit, Rate 8000 Hz, Mono
  • Important: make a note of the size of the samples, in this case 8 bits, unsigned.

Assemble

  • Do not modify readWavFileSkel.asm yet. On its own it will create a new copy of the goodbye.wav under the name goodbye2.wav.


  • Assemble and link the file
nasm  -f elf readWavFileSkel.asm
ld -o readWavFileSkel readWavFileSkel.o
rm goodbye2.wav
./readWavFileSkel
  • Check that you now have a new file in your directory called goodbye2.wav
  • Play it.
 aplay goodbye2.wav
(Note: on a mac, you can use afplay from the command line instead of aplay.)
You should hear the same thing as you did when listening to the goodbye.wav file.

Part 2

Test #1: Increase intensity

  • Make a copy of readWavFileSkel.asm and call it readWavFile1.asm
  • Modify it so that you multiply the intensity of the sound by 2.
  • Listen to the result. Can you still understand the message?
  • Copy goodbye2.wav into goodbye.wav and repeat the process. Still understandable?

Test #2

  • Same thing, but this time you will divide the intensity by 2. A good way to divide by two is to shift the binary pattern to the right. When you