CSE466 Lab Assignment 5

In this lab you will learn how to interface with the sound board we will be using to create the Flock project. The goal of this lab is for you to gain an understanding of how to generate sound using the Yamaha chip.

This is a 3 part lab. In it, you will:

  1. Program a communication interface to the SoundBoard Yamaha chip.
  2. Explore some basic FM sounds.
  3. Parse MIDI-derived birdsongs, and play the birdsongs through the SoundBoard.

Part 1

  1. Connect a 10-pin header to your protoboard where you will plug in JP3 on your SoundBoard. (Don't plug in the SoundBoard yet.)
  2. Here is the schematic of the SoundBoard. Wire up the 10 pin connector as follows:

    Name JP3 Pin
    Connects through
    Connected To
    GND pin 1 >> -- >> GND
    YCOE pin 2 >> 1K resistor >> ATmega16 pin 33 (PA7)
    YRST pin 3 >> 1K resistor >> ATmega16 pin 35 (PA5)
    SDIN pin 4 >> 1K resistor >> ATmega16 pin 17 (PD3)
    SYNC pin 5 >> 1K resistor >> ATmega16 pin 20 (PD6)
    ExtV pin 6 >> -- >> +5Volts
    SCLK pin 7 >> 1K resistor >> ATmega16 pin 18 (PD4)
    IRQ pin 8 >> -- >> ATmega16 pin 16 (PD2)
    MPWM pin 9


    not connected
    GND pin 10 >> -- >> GND

    We use 1K resistors to isolate the 3.3V SoundBoard from the 5 volt lines from our ATmega16. You will have to remove a few existing component from your board to make these connections.
  3. Page 34 of the Yamaha datasheet (the very last datasheet in your coursepak) shows the serial protocol for talking to the FM chip. Refer to Page 8 for descriptions of the internal Yamaha chip registers. Here is a scope dump of what your serial protocal code should look like:




  4. Without the SoundBoard plugged in, write a function that accepts an 8-bit address and a 16 bit data word, and sends them to the connector. Show this to the TAs before proceeding.
  5. Sample code is provided as Yamtest.c Make any necessary changes to add your output function then compile and load it. You should hear a birdsong.
  6. Demonstrate your program to a TA.

Part 2

  1. Find three interesting voices by experimenting with settings in the Timbre data $10- $2F. Include changes in ADSR envelope settings. These don't have to be specific instrumental sounds-- they can be different, but should be pleasing. Experiment!
  2. Here is a short paper with some examples that may give you some ideas.

  3. Turn in your timbres, and play them for the TAs.

Part 3

  1. Birdsong MIDI files for listening are in Birdsongs.zip; the text versions are in birdsmidtxt.zip for adapting to your program.


Here is a sample birdsong in text format:

// \Birdsongs\btwa.mid

mthd

  version 0 // single multichanneltrack

  // 1 track

  unit 100 // is 1/4

end mthd

 

mtrk(1)  // track 1

 /* U0 */  /* 0ms */   trackname "BTWA.MID"

 /* U0 */  /* 0ms */   text "created from WAV file by WAV2MID (C) Tanager Productions"

 /* U0 */  /* 0ms */   beats 120.00000 /* 500000 microsec/beat */

 /* U0 */  /* 0ms */   program ChoirPd

  96; /* U96 */  /* 480ms */ +f#7 $64;

  6; /* U102 */  /* 510ms */ -f#7 $00;

  27; /* U129 */  /* 645ms */ +f#7 $64;

  17; /* U146 */  /* 730ms */ -f#7 $00;

  24; /* U170 */  /* 850ms */ +f#7 $64;

  31; /* U201 */  /* 1005ms */ -f#7 $00;

  38; /* U239 */  /* 1195ms */ +f#7 $64;

  27; /* U266 */  /* 1330ms */ -f#7 $00;

 /* U266 */  /* 1330ms */   +f7 $64;

  4; /* U270 */  /* 1350ms */ -f7 $00;

 /* U270 */  /* 1350ms */   +d#7 $64;

  10; /* U280 */  /* 1400ms */ -d#7 $00;

 /* U280 */  /* 1400ms */   +d7 $64;

  17; /* U297 */  /* 1485ms */ -d7 $00;

 /* U297 */  /* 1485ms */   +d#7 $64;

  7; /* U304 */  /* 1520ms */ -d#7 $00;

 /* U304 */  /* 1520ms */   +f#7 $64;

  10; /* U314 */  /* 1570ms */ -f#7 $00;

 /* U314 */  /* 1570ms */   +g7 $64;

  4; /* U318 */  /* 1590ms */ -g7 $00;

 /* U318 */  /* 1590ms */   +f#7 $64;

  3; /* U321 */  /* 1605ms */ -f#7 $00;

 /* U321 */  /* 1605ms */   +g7 $64;

  4; /* U325 */  /* 1625ms */ -g7 $00;

 /* U325 */  /* 1625ms */   -c-1 $00;

 /* U325 */  /* 1625ms */

end mtrk

 

MIDI unit position and time position are shown in comments before each command:

/* U7765 */ /* 34085ms */

Comments are inside /* ... */ or start with // till end of line.

 

Pauses are shown before commands either in MIDI units ( 47; )or musical notation ( 536/4; ).

MIDI notes consists of pairs of commands: Note on is displayed as + and Note off is displayed as -

MIDI channel are displayed in mtrk(channel number) or as [channel number] inside a track before a command.

Values are shown decimal (0-127) or hexadecimal ($00 - $7F).

 

Hint—use the lines with – notes (note off events); the first value is the number of milliseconds of duration of the event, in 5 millisecond steps.

 

Standard MIDI file format is here.

  1. Construct a new program based on your code from Part 1, with the following characteristics: NOTE: you will need to add any additional hardware necessary to meet these requirements.

·        Each song is stored separately.

·        You should be able to play the 16 birdsongs (from your MIDI conversion above) and select them by a button

·        One button selects which birdsong (displayed as 1-16 in hex). If a song is currently playing and this button is pressed, you do not need to be able to interrupt the song being played change to the new song (but the next song you play should be the new song).

·        One button is start/stop. You should use the Decimal Point on hex LED display to display when your birdie is in running mode. It should be on when running, off when stopped.

·        The displayed song will continually play until the stop button is pressed or the song to play is changed.

  1. Compare bbwa in Yamtest-Sample.c with the .txt files for hints.
  2. Demonstrate your birdie to a TA.
  3. Turn in a hard copy of your code.

Deliverables

For all files turned in, the comments at the top of the file should contain:

Be prepared to answer questions about the Yamaha sound chip and interface during grading.

Part 1:

  1. Demonstrate your program and circuit to a TA. You can either do this during this lab, or during the first 1/2 hour of the next lab.

Part 2:

  1. Demonstrate your timbre generator to a TA. You can either do this during this lab, or during the first 1/2 hour of the next lab.
  2. Turn in your timbre settings.

Part 3:

  1. Demonstrate your birdie to a TA. You can either do this during this lab, or during the first 1/2 hour of the next lab.
  2. Turn in hardcopy of your commented C code.

End