Trouble with midi.tx - any way to test?
tuffstuff
Posts: 24
I'm having some trouble sending midi messages. I think my midi send circuit isn't correct but I'm having trouble testing it. I have come up with a way to test if the midi messages are outputting to the midi jack, but its isn't working that well. I have set up a couple of cogs, one reads the midi messages the other sends and prints what is being read to the terminal. Here is my code:
There are two cogs running one sends midi messages the other reads them and prints them to the terminal. The circuit is a midi in midi out circuit. I have tried a few on this forum to no avail.
What's wierd about the code above that when I comment out the midi.rx lines in the second cog and un-comment out "pst.str(string("|"))". It will flood the terminal with pipes like you might expect. When I un-comment the midi.rx the pipes stop. Is the second cog freezing? Does that term apply?
Can anyone suggest a better way of testing the midi out to read what it is outputting?
Thanks!
CON _clkmode = xtal1+pll16x _xinfreq = 5_000_000 OBJ pst : "Parallax Serial Terminal" midi : "FullDuplexSerial" VAR LONG stack[500] PUB Play | Index pst.Start(115200) midi.start(0, 5, %0000, 31250) cognew(Read, @stack) repeat repeat Index from 0 to 3 midi.tx($90) midi.tx(midimessage[Index]) pst.str(string("|")) waitcnt(clkfreq + cnt) PUB Read | a,b,c pst.Start(115200) midi.start( 0, 5, %0000, 31250 ) repeat 'pst.str(string("|")) a := midi.rx b := midi.rx c := midi.rx pst.hex(a,2) pst.hex(b,2) pst.hex(c,2) DAT midimessage WORD $3755, $3700, $4055, $4000
There are two cogs running one sends midi messages the other reads them and prints them to the terminal. The circuit is a midi in midi out circuit. I have tried a few on this forum to no avail.
What's wierd about the code above that when I comment out the midi.rx lines in the second cog and un-comment out "pst.str(string("|"))". It will flood the terminal with pipes like you might expect. When I un-comment the midi.rx the pipes stop. Is the second cog freezing? Does that term apply?
Can anyone suggest a better way of testing the midi out to read what it is outputting?
Thanks!
Comments
Andy
Andy, I see that you initialized two "FullDuplexSerial" objects, one for printing to the terminal and the other for reading and writing midi messages. I didn't know you could use FDS for writing to the terminal. I will need to learn more about these serial objects. My question is why did you use two objects for this? Why can't we print to the terminal with the same object that we are reading and writing midi data with?
Kuroneko, you used square brackets in an interesting way. Can you explain what their functions are? Are you initializing two object also in a sort of short hand way?
Thanks again for the help!
Using two times the same object spares also a lot of RAM because the same object exists only one time in hub-ram, only the VAR sections of the two FDS objects need their own memory.
You need two serial objects because one handles serial in and out on pin 0 and 5 with 31250 baud, and the other serial in and out on pin 30 and 31 with 115.2 kBaud. The FDS object provides only one in and one out channel with the same baudrate. And you can not switch the pin and baudrate without stopping and restarting the object.
Andy
By using code example to write my code I overlooked the two distinct baud rates in my two serial objects. Why do we use 115200 for writing to the terminal and 31250 for reading/writing pins?
Thanks again,
Common Bauds these days: 9600, 19200, 38400, 57600, 115200. Still used occasionally: 1200, 2400, 4800.
The penalty is that every instance of the FDS object needs its own cog, a few variables and two 16 byte buffers one for receive, one for transmit.
Also if you could use the same baudrate you need two transmitters (MIDI and Terminal) and one receiver (MIDI). One FDS object can handle only one trnsmitter.
There is also a 4 port serial object, which could handle all 3 serial channels with one cog.
Andy