PSUEDOCODE ========== '---------------------------- ' Synchronia--Duet 0.0.7 ' (C)2018 Thomas R. Mahanna '---------------------------- 'CONFIGURE HARDWARE I/O (ATMEGA2560 in the Case of the Prototype) 'Configure Communication Open Serial1 For Binary As #0 'Serial Connection to PC Open Serial2 For Binary As #1 'MIDI Out / QUNexus In Open Serial3 For Binary As #2 'UNZTRUMENT I/O 'DIMESION VARIABLES 'Serial Input Variables Dim SerialInbyte As Byte Dim SerialFlag As Bit Dim QuNexusInbyte As Byte Dim QuNexusFlag As Bit Dim UntzInbyte As Byte Dim UntzFlag As Bit 'MIDI Variables Dim MIDICh as byte Dim Timbre as Byte Dim Status As Byte Dim Data1 As Byte Dim Data2 As Byte Dim StrumDelay As Byte Dim ChordArray(4) as Byte Dim ScaleArray(5) as Byte Dim Vel as Byte Dim Pedal as bit Dim Notes(5) as Byte 'Main Variables Dim I As Byte Dim ChordType As Byte Dim OldChord As Byte Dim Root As Byte Dim OldRoot As Byte Dim OldChordButton As Byte Dim OldRootButton As Byte Dim ButtonHold As Bit Dim Offset as Byte Dim Temp as byte 'DEFINE IRQ HANDLERS On Serial1 PCSerial_isr On Serial2 Qunexus_isr On Serial3 Untz_isr 'ENABLE INTERRUPTS Enable IRQ0 Enable IRQ1 Enable IRQ2 Enable Global Interrupts 'DEFINE / DECLARE SUBROUTINES Declare Sub Midiout(byval Ch As Byte , Byval Note As Byte , Byval Vel As Byte) Declare Sub Midipatch(byval Ch As Byte , Byval Patch As Byte) Declare Sub Mastervolume(byval Vol As Byte) Declare Sub Allnotesoff Declare Sub ProcessUntzButton 'MAIN ' Entering Main Loop For I = 0 To 15 SerialOut #2 , I 'All Chord Buttons Off Waitms 1 Next For I = 76 To 79 SerialOut #2 , I Waitms 1 Next For I = 92 To 95 SerialOut #2 , I Waitms 1 Next For I = 108 To 111 SerialOut #2 , I 'All Trellis Root Buttons Off Waitms 1 Next Chordtype = 0 SerialOut #2 , 140 OldChordButton = 12 Root = 0 SerialOut #2 , 204 OldRootButton = 76 Offset = 48 'Octave 4 * 12 Call ProcessUntzButton MIDICh = 1 'Set MIDI Output Channel Timbre = 0 'GM Piano [0] Vel = 96 'Velocity StrumDelay = 40 'Spread Between Notes (mS) Pedal = 1 'Pedal off SerialOut #1 , &HB0 SerialOut #1 , &H7B SerialOut #1 , &H00 'All Notes Off SerialOut #1 , 176 SerialOut #1 , 7 SerialOut #1 , 64 'Set Volume to 96 Call Mastervolume(64) 'Set Volume to 96 Call Midipatch(midich , Timbre) 'Change MIDI Intrument Timbre Do '// PROCESS UNTZTRUMENT If UntzFlag = 1 Then Select Case UntzInbyte '// Button Release Case 12 ButtonHold = 0 Case 13 ButtonHold = 0 Case 14 ButtonHold = 0 Case 15 ButtonHold = 0 Case 16 to 127 If Pedal = 0 then Call MIDIOut(MIDICh , ChordArray(1) , 0) Call MIDIOut(MIDICh , ChordArray(2) , 0) Call MIDIOut(MIDICh , ChordArray(3) , 0) Call MIDIOut(MIDICh , ChordArray(4) , 0) End If '// Chord Selection Case 140 Chordtype = 0 'Major SerialOut #2 , OldChordButton 'Turn old chordtype button off SerialOut #2 , UntzInbyte 'Turn new chordtype button on If UntzInbyte > 127 Then OldChordButton = UntzInbyte - 128 Else OldChordButton = UntzInbyte End If Buttonhold = 1 Call ProcessUntzButton Case 141 Chordtype = 1 'Minor SerialOut #2 , OldChordButton 'Turn old chordtype button off SerialOut #2 , UntzInbyte 'Turn new chordtype button on If UntzInbyte > 127 Then OldChordButton = UntzInbyte - 128 Else OldChordButton = UntzInbyte End If Buttonhold = 1 Case 142 Chordtype = 2 'Sus4 SerialOut #2 , OldChordButton 'Turn old chordtype button off SerialOut #2 , UntzInbyte 'Turn new chordtype button on If UntzInbyte > 127 Then OldChordButton = UntzInbyte - 128 Else OldChordButton = UntzInbyte End If Buttonhold = 1 Case 143 Chordtype = 3 'Dom7 SerialOut #2 , OldChordButton 'Turn old chordtype button off SerialOut #2 , UntzInbyte 'Turn new chordtype button on If UntzInbyte > 127 Then OldChordButton = UntzInbyte - 128 Else OldChordButton = UntzInbyte End If Buttonhold = 1 '// Root Selection Case 204 SerialOut #2 , OldRootButton 'Turn old root button off SerialOut #2 , UntzInbyte 'Turn new root button on Root = 0 'Root...Read more »