Introduction

For this project, you are to build a machine that plays musical chords in response to user presses on the LCD touchscreen. You will need to become familiar with the touchscreen and sound systems of the RC200E, and will need to work with table lookup techniques for generating the audio waveforms.

Project Description

The project is divided into three stages, each of which is to be implemented as a separate DK project in your course workspace.

The first project is to familiarize you with the operation of the touchscreen. In it, you will write a program that displays the coordinates of the points the user touches on the screen and develop a strategy for getting “clean” input data. For this project, you will use the PalConsole API documented in the Pal Cores manual. The PalConsole API provides a somewhat primitive way of writing text strings on the LCD.

The second stage is to introduce you to the audio output functions provided by PalAudioOut, which require you to provide sound intensity values at a defined sampling rate. You might want to work with my Audio Sampling Laboratory before starting this part of the assignment. You will need to build a sine lookup table to work with for this part of the project, which is most easily done by writing a standalone program that generates the source code for a Handel-C array of intensity values.

In the third stage, you will create a Handel-C application that combines the functionality of the first two stages: when the user presses various points on the screen, the device will generate sounds that are various mixtures of three basic frequencies to produce various chords.

Procedure

  1. Create a touchscreen input project.

    Create a new project named Touch2Console in your course workspace. Output to the console a line of text that tells the coordinates where the user is touching whenever the user is touching the touchscreen. Read from the touchscreen on every clock cycle, output the value of the touch variable to an expansion header pin, and use an oscilloscope to observe the value of this variable in real time to determine the rate at which touches repeat when the screen is pressed continuously. Observe any patterns you can about what coordinates are reported when touches begin and end, and devise a way to manage the touch data cleanly.

  2. Create an audio output project.

    The Nyquist sampling theorem says you need to sample a waveform at twice the rate of the maximum frequency component to in order to reproduce the waveform accurately. Write a program that generates a 10KHz sine wave with the sampling rate determined by a compile time constant. Try sampling rates of 2, 5, 10, and 20 KHz and see if you can hear the difference.

    Generate_PAL_Samples.java

  3. Build the chord generator

    Lay out the touchscreen so there are three zones where touches will generate tones with frequencies in a ratio of 4:5:6. You can use any base frequency you want: 440Hz is a common starting point. Touching three other places generates pairs of tones from the above set, and touching another zone generates the full chord of all three tones mixed together.