+ All Categories
Home > Documents > Digital Piano

Digital Piano

Date post: 04-Jan-2016
Category:
Upload: cosima
View: 33 times
Download: 0 times
Share this document with a friend
Description:
Digital Piano. By Jacob Zurasky ECE3551 – Fall 2008. Project Goals. Implement many inputs Synthesize a piano-like tone Play tones based on inputs Play a song from memory. Inputs. BF533 board only has 4 input switches 32 inputs implemented via 8x4 matrix - PowerPoint PPT Presentation
21
Digital Piano By Jacob Zurasky ECE3551 – Fall 2008
Transcript
Page 1: Digital Piano

Digital Piano

By Jacob ZuraskyECE3551 – Fall 2008

Page 2: Digital Piano

Project Goals

Implement many inputs

Synthesize a piano-like tone

Play tones based on inputs

Play a song from memory

Page 3: Digital Piano

Inputs

BF533 board only has 4 input switches

32 inputs implemented via 8x4 matrix

PIC scans matrix, sends a packet of data

BF DMA channel stores data into array

Page 4: Digital Piano
Page 5: Digital Piano

Communications

RS232, 9.6 kbps data transmission

6 bytes = 48 bits of data

Each bit represents a key on the piano

Bit is low when a key pressed

Page 6: Digital Piano

UART Configuration

UART_LCR - 8 data bits, 1 stop bit

UART_DLH/DLL - 0x16 = 352 Baud rate = SCKL / (16 * Divisor)

= 9588 kbps, with 0.1% error

UART_IER - Generate Rx Interrupt

Page 7: Digital Piano

UART DMA Channel

UART Rx Interrupt triggers a DMA write

DMA writes 6 elements to Rx_Buffer[]

Rx_Buffer[] holds the last packet sent

Page 8: Digital Piano

Tone Synthesis

Pure sine wave at a given frequency sounds very empty

Add richness to sound by adding harmonics

Analyze frequency spectrum of a piano sample

Piano C4Pure Sine C4

Page 9: Digital Piano

Pure Tone Spectrum Analysis

Page 10: Digital Piano

Piano Spectrum Analysis

Page 11: Digital Piano

Fourier Series

Use a fourier series to generate a signal with a similar frequency content

Add many harmonics of the fundamental frequency, at lower amplitudes

Composite signal has a richer sound

Page 12: Digital Piano

Fourier Series

y = a1 * sin[2 * Pi * ((1 * f) / fs) * t]

+ a2 * sin[2 * Pi * ((2 * f) / fs) * t]

+ a3 * sin[2 * Pi * ((3 * f) / fs) * t]

+ a4 * sin[2 * Pi * ((4 * f) / fs) * t]

+ …

+ an * sin[2 * Pi * ((n * f) / fs) * t]

Page 13: Digital Piano

Components of Output

Page 14: Digital Piano

Composite Output

Page 15: Digital Piano

Spectrum Analysis Comparison

Page 16: Digital Piano

Tone Synthesis

Fourier series has over 50 components

sinf() function too slow to call multiple times per sample

Implement a look-up table

Each octave of notes is stored to an array

Page 17: Digital Piano

C3 Octave Array

Page 18: Digital Piano

Tone Synthesis

Each note has three characteristicsKey_Prev_State - Previous state of noteKey_Cur_Period - Location within periodKey_Decay - Current decay rate of note

Each octave has an array of note lengths Each octave has an array of note offsets

Page 19: Digital Piano

Tone Synthesis

D3, 3rd note in C3 octave

C3_Period[2] = 327, C3_Offset[2] = 714

Notes3[714] is the first sample

Notes3[1041] is the last sample

Page 20: Digital Piano

Tone Synthesis

Linear decay while note is held

Key_Decay and Key_Cur_Period are incremented after each sample if the note is active

Summation of look-ups allows multiple tones simultaneously

Page 21: Digital Piano

Playback

Events stored on PIC similar to MIDI

Each event has a two byte frame offset

6 bytes of data for the key status


Recommended