Key Pad Musical Synthesizer Trevor Lager Brandon Gong

advertisement
Key Pad Musical Synthesizer
Trevor Lager
Brandon Gong
Overview
• Plays Notes when keypad is pressed
• Records notes for playback on SRAM
• Plays back recorded song
Schematic
Components
•
•
•
•
•
•
•
•
•
SSMI Board
10 kΩ Resistor pack
1.5 kΩ Resistor pack
Keypad
D/A converter (MCP4921 E/P)
SRAM (23LC512)
AUX Output / Speakers
Potentiometer
Resistors and Capacitors for Low Pass Filter
8 Bit Waveform
12 Bit Waveform
Pseudocode
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
function Main
Init function
Loop Forever
opMode <- Get operation mode from user
if(opMode == Record)
key <- Get user input from keyboard
playSound(key)
saveToSRAM(key)
else
address = 0
while(not end of song)
key <- getFromSRAM(address)
playSound(key)
address <- next address
End while
End if
End Loop
End Main
Pseudocode
20. function init
21.
Initialize SPI system for SRAM system
22.
- Max of 20 MHz clock
23.
- Active High clock
24.
- First SCK edge
25.
- LSB first
26.
Initialize Pin IO
27.
- Input from keyboard
28.
- Input from mode select
29.
- Output to speaker
30.
- Com with SPI
31.
Initialize Output compare system to generate notes based on
frequency
32. End init
Pseudocode
33. function playSound(key)
34.
Frequency <- Notes[key] // Get the frequency based on what key is pressed
35.
Delay <- conversion from frequency to uS
36.
For( value = 0; value < 31.4; value += 0.1)
37.
writeToDAC(digitalSin(value))
38.
Delay
39.
End Loop
40. End playSound
41. Function writeToDAC(value)
42.
Select DAC
43.
Send Write command
44.
Write value
45.
Deselect DAC
46. End writeToDAC
Pseudocode
47. function saveToSRAM(key)
48.
Send write instruction
49.
Send Address // this should start at 0 at the beginning of the
program
50.
Send key
51.
Increment Address
52. End saveToSRAM
53.
54. function getFromSRAM(address) returns char
55.
Send read instruction
56.
Send address
57.
return content of address
58. End getFromSRAM
Timing Diagram (Write)
Timing Diagram (Read)
Potential Future Improvements
•
•
•
•
Multiple tones
Implement timing for rests
Potentiometer for modulation
Be able to play and playback simultaneously
Question?
Download