Keyboard mania using Atmega32

INTRODUCTION

“Keyboard mania gives users an opportunity to learn and gain a unique taste of playing an electronic piano without the presence of a music teacher.”

Keyboard mania

Summary of our Project

We designed an electronic musical instrument, called keyboard mania, able to play an octave of notes with additional features. Features include a menu for user to practice a variety of pre-coded scores. The TV displays the chosen score on the screen and also outputs sounds while the user can play the chosen piano score using the computer keyboard. There is a pacer below every note in each line of the piano score guiding the tempo of the piano score which functions as a tempo indicator. Above every note in each line of the piano score, there is a check mark which informs the correctness of the piano key pressed.

Rationale and Sources of our Project Idea

In the recent decades, we are able to transform analog signals of musical instruments to digital music. With advancement in technologies, we can create, record, and edit music using a computer. As well, we can mimic the sounds of music instruments, such as electronic guitar or piano, with today’s technology. Therefore, we decide to design an electronic musical instrument, called keyboard mania. Our keyboard mania has wide applicability as it not only serves as an electronic musical instrument, but also could enable users to practice piano scores in a virtual classroom without the presence of a piano teacher. It provides users a rare opportunity to gain a unique taste of what it is like to play an electronic musical instrument. In addition, the design would save on human resource, music teachers, since users can practice on their own with video and audio results output on the TV. Last but not least, our keyboard mania is very economical, but yet provides a relatively good sound quality and a user-friendly interface. It gives students, who begin to learn piano but cannot afford a YAMAHA keyboard/piano or piano lessens, a chance to learn piano on their own.

High Level Design

Explanation of our Project

The keyboard mania displays its menu through HyperTerminal on the PC where users can first choose one piano score to practice using the computer keyboard and the welcome page on the TV screen. After the user enters his/her choice of piano score in HyperTerminal, the chosen score will be displayed on the TV screen. He or she can start to play the chosen piece of piano score by pressing the ‘s’ key, which stand for start, or to exit at any time by pressing the ‘q’ key, which stands for quit. When starting the piano score, the user has to follow the pacer, functioning as a tempo guide, below each note on the piano score and to play the correct key, such that middle C is ‘A’ on the computer keyboard and so on.  Program/Hardware Design] If the user hit the wrong key, the keyboard mania will display ‘x’ above the corresponding note on the TV screen; otherwise, the keyboard mania will display check mark above the corresponding note on the TV screen. At the same time, the user can listen to notes, which he/she plays using the computer keyboard. As a result, he/she can correct himself/herself when a wrong key is hit or when playing too fast/slow. After the user finishes the chosen piano score, the keyboard mania will display a brief evaluation report stating his/her current piano skill, his/her score, and the highest score of the chosen piece on record.

Background Math and Physics

Piano Score Generation

There are four pre-coded pieces of piano score stored as matrices in the flash memory. Each note is represented by two integers. The former integer indicates music note and the later integer represents the note’s duration.

Piano Score Drawing

The keyboard mania displays two lines on the TV screen every 1/60-second. It traverse the matrix representing the chosen piano score, takes the first integer as an offset to the base note and the second integer as the note’s duration, and displays the note on the TV screen with its correct representation.

Tone Generation (Pitch)

Our keyboard mania generates waves with specified frequencies above. We reused audio codes from Lab 4: Lunar Lander Video Game. [Reference]

Logical Structure

The HyperTerminal residing on the PC serves as the menu of the keyboard mania. It allows users to choose a piece of piano score to practice through the HyperTerminal. After the request is sent to the microcontroller, the TV will display the chosen piano score on the screen. Then the user has to enter ‘y’ to start playing or ‘q’ to quit at any time. While the user is playing, the TV will display the correctness of notes hit using the computer keyboard. After the user finishes playing the chosen piano score, the TV will display an evaluation stating the user’s score and the highest score on the record.

The keyboard mania uses the computer keyboard, the HyperTerminal on the PC, the Mega32 MCU, and the TV as its I/O devices. The interaction between these I/O devices is presented in the flow chart on the right. The HyperTerminal on the PC communicates with the serial ports on the STK500 development board. At the same time, programs are compiled using CodeVision on the PC and loaded to Mega32 MCU on the STK500 development board. Then the audio and video signals generated by the MCU are connected to analog circuits on the breadboard and output through the TV.

Hardware/Software Tradeoffs

Program Details

Hardware tradeoff

One hardware tradeoff of our keyboard mania is that the range of music notes is only one octave above the middle C because of the physical constraint of a computer keyboard. There are only 11 keys in a row on the computer keyboard; therefore, we decide to have our keyboard mania to output only one octave above middle C, 8 keys.

Software tradeoff

One software tradeoff of our keyboard mania is that the conversion calculation from input of computer keyboard to the corresponding note’s frequency. The floating-point calculation usually takes too long which cannot be finished within one frame time; therefore, we have to store it as char, but instead of float, where the conversion is done faster but the frequency accuracy is sacrificed.

Standards

RS-232

RS-232 is a standard specified by the Electronics Industry Association (EIA) for serial binary data transmission of data between a DTE (data terminal equipment) and a DCE (data communication equipment). The data terminal equipment used in our design is the PC using HyperTerminal program; the data communication equipment in our design is the STK500 development board.

For complete RS-232 standard, refer to

http://www.lammertbies.nl/comm/info/RS-232_specs.html

NTSC video

NTSC, which stand for National Television System Committee, is the analog television system used in the United States . Using the NTSC standard, frames are refreshed about every 1/30 second with interlacing technique, meaning odd and even lines are redrawn at about 60 frames per second.

For complete NTSC video standard, refer to

http://instruct1.cit.cornell.edu/courses/ee476/video/index.html

Existing Patents

With regards to intellectual property, we do not find any existing patents relative to our keyboard mania.

Program/Hardware Design

Program Details

In order to ensure completion of arithmetic calculation and drawing on the TV screen at the frame rate, we have to distribute tasks to different lines as follows:

At LineCount == 225 , the keyboard mania checks whether or not users enter request from the HyperTerminal on the PC. If a user selects a valid piano score, the keyboard mania will display the chosen score on the TV screen. If the user enters ‘y’ to start, the keyboard mania enters the PLAYING state as described on the state transition diagram on the left. When the user finishes playing the chosen piano score, the keyboard mania will print an evaluation page to inform the user his/her level of piano skill, his/her score, and the highest score so far.

For more detail: Keyboard mania


About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top