| ??? 11/21/08 23:26 Modified: 11/21/08 23:31 Read: times |
#160186 - ==CODE== Responding to: ???'s previous message |
Hi again... I will post the code... as a newbie "not colleged" 8051 programmer I dont know if it is the right or best way to program what I want, so, I will be thankful with corrections, critics or sugestions. Thanks a lot!
Also, tested this same code over an USB-midi interface, my computer onboard midi interface, a Kurzeil piano keyboard and another piano keyboard but can remember the brand... all they works, just the yamaha gives the problem, but the yamaha works normal to my computer and directly to other pianos.
Note EQU 078h
MidiB EQU 079h
V0 EQU 07Ch
ORG 00H
JMP START
ORG 0023H
JMP SERI
START: MOV PCON,#0
MOV TMOD,#00100001B ;T1 8bit autoreload/T0 16bit
MOV TL1,#255 ;Set load/reload
MOV TH1,#255 ;
MOV TL0,#0
MOV TH0,#0
SETB TR1
MOV SCON,#01010000B
SETB EA
SETB ES
RUN:
JMP RUN
SERI:
PUSH ACC
JB RI,LER
JMP MidiEnd
LER:
MOV A,SBUF
MOV V0,A ;Buffers SBUF
CLR RI
ANL A,#11110000b
;=======CAUTION=========
CJNE A,#090h,$+6
LJMP PNoteOn
CJNE A,#080h,$+6
LJMP PNoteOff
JB ACC.0, MidiEnd ;END if is another midi command (ie. RT)
;a bit buggy but should work
JMP ProcessMidiData
PNoteOn: ;Process Note On Command
MOV MidiB,#1
JMP MidiEnd
PNoteOff: ;Process Note Off Command
MOV MidiB,#5
JMP MidiEnd
ProcessMidiData:
MOV A,MidiB
CJNE A,#1,$+6
LJMP PNoteOnNote
CJNE A,#2,$+6
LJMP PNoteOnVelocity
CJNE A,#5,$+6
LJMP PNoteOffNote
CJNE A,#6,$+6
LJMP PNoteOffVelocity
JMP MidiEnd ;Not Listed
PNoteOnNote:
MOV Note,V0
MOV MidiB,#2
JMP MidiEnd
PNoteOnVelocity:
MOV A,V0
JZ VELZERO
;VELOCITY NOT ZERO
;Note On Routine====
JMP PNoteOnVelocityEnd
VELZERO:;VELOCITY = ZERO (same as note off)
;;Note On Routine when velocity=zero
PNoteOnVelocityEnd:
MOV MidiB,#0
JMP MidiEnd
PNoteOffNote:
MOV Note,V0
MOV MidiB,#6
JMP MidiEnd
PNoteOffVelocity:
MOV MidiB,#0
;Note Off Routine====
JMP MidiEnd
MidiEnd:
CLR TI
CLR RI
POP ACC
RETI
END
|
| Topic | Author | Date |
| Midi trouble with Keyboard! | 01/01/70 00:00 | |
| Blame the computer? | 01/01/70 00:00 | |
| I'm lost | 01/01/70 00:00 | |
| Check for differences | 01/01/70 00:00 | |
| you are right... | 01/01/70 00:00 | |
| First check grounding | 01/01/70 00:00 | |
| ==CODE== | 01/01/70 00:00 | |
| Can I post... | 01/01/70 00:00 | |
| MIDI Trouble | 01/01/70 00:00 | |
| I can be wrong... | 01/01/70 00:00 | |
| MIDI Trouble ... | 01/01/70 00:00 | |
| Should be JB ACC.7 ... | 01/01/70 00:00 | |
| Maybe I discovered something, but have no clue to solve | 01/01/70 00:00 | |
| Midi Thru Problems... | 01/01/70 00:00 | |
| Same problem | 01/01/70 00:00 | |
| MIDI Head Scratcher .. | 01/01/70 00:00 | |
Data is arriving corrupted | 01/01/70 00:00 | |
| tried simplest way | 01/01/70 00:00 | |
| Already tried this | 01/01/70 00:00 |



