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. You can now test to make sure that your SoundBoard is wired up correctly using birdsong.hex . You should hear a birdsong.

Part 2

  1. 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:



  2. Note: SYNC and SCLK are the control signals used in the protocol. SCLK goes high once for every bit transmitted and SYNC goes high at the end each completed transmission, in our after 24 bits have been sent. SDIN is the output bitstream signal. Your implementation of the serial protocol must drive all three signals.
  3. 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. The "send_fm" function in Yamtest-Sample.c is the blank function for this. Note: send_fm8 can be used to transmit each single byte.  Show an OScope display matching the above to the TAs before proceeding.
  4. Sample code is provided as Yamtest-Sample.c Make any necessary changes to add your output function then compile and load it. You should hear a birdsong.
  5. Demonstrate your program to a TA.

 

Part 3

  1. Birdsong MIDI files for listening are in Birdsongs.zip; the converted versions for 15 of the songs are in birdscode.txt; the text files (including the midi you will need to convert yourself: bpwa.txt) are in birdsmidtxt.zip. Note: bpwa is different from the sample midi text given below.


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.

 

    2.   Using the above sample and hints and the yamaha data sheet information on notes, convert the note information in bpwa.txt into notes that are playable on the Yamaha chip. (Extra hint: Compare bbwa, which is the converted song in Yamtest-Sample.c with the bbwa.txt file).

   

            Question 1: If a note is in octave block 2 and the timbre uses a muliple of 2, what register values would you have to change in order to shift the note up two octaves?

 

            Question 2: Without changing individual notes, how would you double the amount of time to play a song?

 

            Question 3: The Yamaha chip uses a FIFO interrupt to tell the controller when to send more note data. How would you configure the Yamaha chip to interrupt when its FIFO is half empty?

 

 

Part 4

  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 the others provided) 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. Demonstrate your birdie to a TA.
  2. 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 2:

  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 4:

  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