Midi control codes 18x

piclt

Member
I have been trying sending midi from 18x to a Sparkfun VS1103 breakout board.
I started using Hippys midiuart.txt prog and all appeared to work Ok. Midiuart actually plays a tune in a loop going through all the midi sounds. Waht I want to do is switch on 18x then send program change to setup a sound then play the sound as I press pushbuttons on demand, not in aloop. I discovered the sending just one program change code followed by prognumber did not work, I needed to send at least twice before it reliably played.
Was wondering is this mormal because of the Peek and Poke etc. Does the ausart need to do something to get started ???
Any ideas, Thanks......
 

hippy

Technical Support
Staff member
I'd have expected it to work but it does suggest that the command sent ( possibly the first byte of the command ) is dropped.

I'm not sure why that should be but it may be worth setting Output Pin 5 which will be used by the UART TX high immediately after start and perhaps adding a PAUSE after that and after initialising the UART.

If this happens with every Program Change sent, not just immediately after power-on or reset it may be worth posting your code. It may be worth doing that anyway.
 

piclt

Member
------------------------------------------

PowerOnReset:

SETFREQ M8

low 7
pause 4000
GOSUB UartInit
pause 4000
MainLoop:

' Note that instrument voices may not be the same as Program Number
' so voices may not change in numerical order.

'FOR progNumber = 0 TO 127
progNumber = 57
' Select an instrument voice

char = PROG_CHANGE | CHANNEL-1 : GOSUB MidiTx ' Prog Change
char = progNumber : GOSUB MidiTx ' Prog Number
pause 4000
' Play the tune
high 7

keyIndex = 0

NextNote:

---------------------------------------
This is snippet of the code from midiuart.txt
Basically all I have done is comment out the for next loop, put a LED on pin 7 and pauses 4000 to slow it down a bit to see the LED on when the tune should be playing. I have changed the prognumber to play to 57 so as to hear the difference.
After power up, wait for pause the LED comes on, no sound or maybe the default piano notes, then LED goes off end of tune, then prog goes back to start of MainLoop, sends prognumber 57 again, LED comes on and sound 57 probably plays tune OK. sometimes it takes to the 3rd loop before the sound 57 plays.
It only happens after powerup or reset, once it starts to do the prog changes after 2 or 3 loops I can send prog changes and noteon noteoff continuously and it doesnt get mixed up

Output 5 as you suggested does not work for 18x. Pin 5 is already an output ??

thanks for your reply
 
Top