Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- volume = 3.0
- speaker = peripheral.find("speaker")
- instrument = "pling"
- keyInstruments = {
- [keys.h]="harp",
- [keys.j]="pling",
- [keys.k]="chime",
- [keys.l]="iron_xylophone",
- [keys.b]="bass",
- [keys.n]="guitar",
- [keys.m]="banjo",
- [keys.comma]="didgeridoo",
- [keys.period]="bit"
- }
- keyNotes = {[keys.one]=0, [keys.q]=1, [keys.two]=2, [keys.w]=3, [keys.three]=4, [keys.e]=5, [keys.r]=6, [keys.five]=7, [keys.t]=8, [keys.six]=9, [keys.y]=10, [keys.u]=11, [keys.eight]=12, [keys.i]=13, [keys.nine]=14, [keys.o]=15, [keys.zero]=16, [keys.p]=17, [keys.z]=18, [keys.s]=19, [keys.x]=20, [keys.d]=21, [keys.c]=22, [keys.v]=23, [keys.g]=24}
- noteNames = {[0]="F#3", "G3", "G#3", "A3", "A#3", "B3", "C4", "C#4", "D4", "D#4", "E4", "F4", "F#4", "G4", "G#4", "A4", "A#4", "B4", "C5", "C#5", "D5", "D#5", "E5", "F5", "F#5"}
- shell.run("clear")
- print("Switch instrument with \"HJKLBNM,.\"")
- while true do
- local event, key, isHeld = os.pullEvent("key")
- if keyNotes[key] ~= nil then
- speaker.playNote(instrument, volume, keyNotes[key])
- print(noteNames[keyNotes[key]])
- elseif keyInstruments[key] ~= nil then
- instrument = keyInstruments[key]
- print("Instrument: "..instrument)
- print("HJKLBNM,.")
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement