Jump to content

Help with MIDI Transfer LEDs


Gertius
 Share

Recommended Posts

Hi everyone!

Could someone please help me with setting up MIDI Monitor LEDs over DOUT Modules?

I have found the USER_MIDI_NotifyRx and Tx functions, but I am completely lost with programming Assembler. I have also searched the source codes of the SID and LTC apps to copy something from there, but the code doesn´t make sense to me at all, so I cannot simply copy/paste it. Also, I don´t have time to build a LTC Module, as my project is a universtity project and due in one week  :-\

Well if anyone could post some code for me, and tell me where to insert it I would be very very grateful!

The MIDI Leds are connected to Pin 0 (OUT) and Pin 16 (IN) of the DOUT Module, and should flicker, when MIDI  transfer is taking place.

Thanks in advance,

Best regards,

Christian

Link to comment
Share on other sites

Christian,

I think those MIDI i/o light prefs are all in the main.asm file (at least with the MB64 apps I'm always messing with). If you're not running that, you may be able to paste the necessary lines from the MB64 batch into what you're doing. Just make sure you fish around for any source lines which go with them and import those too. Thorsten or someone could probably specify what parts are required, but maybe you're working with an app which already has it all.

Hope you get it going,

George

PS- From MB64 main, in the defines area near the top of the file:

; For MIDI activity monitor: define the DOUT pins for the Rx and Tx LED
#define DEFAULT_MIDI_MONITOR_ENABLED 0  ; if 1, the Tx/Rx LEDs are enabled
#define DEFAULT_MIDI_RX_LED 0x40	; DOUT SR#9, pin D0
#define DEFAULT_MIDI_TX_LED 0x41	; DOUT SR#9, pin D1

- Here, you'd just be switching the "DEFAULT_MIDI_MONITOR_ENABLED" to enabled (change 0 to 1),

then changing those hex numbers (0x40,0x41) to whatever numbers your lights are connected to.

* Obviously, make sure you recompile afterward, so you're not just sending the same old hex dump (do that on many occasions myself ;D). 

BTW- Windows calculator (if you're on a Windows PC) will do hex (0x) to decimal conversion if you put it in "scientific" mode. (above, you're looking at numbers 64 & 65, if you didn't already know  --and they start at 0)

Link to comment
Share on other sites

Thanks for your answer, George!

It already made it clear what number to use for the LEDs!

It just occured to me, that I wasn´t exact enough in my first post, though, so let me specify my problem a little further:

we are writing a relatively complex project from scratch, but we are actually writing in C, using the C skeleton. The hooks for the USER_MIDI_NotifyRx/Tx in the mios_wrapper.asm accept Assembler code only, though. The problem is that many of the files used in assembler apps (like MB64) are missing in the C skeleton, so I don´t even know, where to copy the appropriate lines to. As an example, in the file midi_rxtx.inc, some registers have to be located to app_defines.h, which doesn´t exist in the C skeleton.

Also, the lines you posted are (understandably) nowhere to be found in the C skeleton.

Should this question rather go into C programming then?

Best regards,

Christian

Link to comment
Share on other sites

Christian,

Read the reply on the way out but didn't have time to mess with it, so I tried at the studio and brought back an edited main.asm with the Rx/Tx lights working (I usually have them shut off in stuff I'm running). Unfortunately, I've gotten comfortable with asm and still have trouble with lots of areas, so I'd rather get that straight before trying to move into C. Therefore, I don't know much about the combination when working with MIOS apps, but it sounds like you can use a little of each (?), so maybe these pieces of code can point you to some stuff you need.

This is all from the regular v1.9 assembler skeleton. There was only one minor addition outside the main file, and that was for the two (Rx/Tx) counters it uses. You'll add that in the app_defines.h file. My test file was blank "variable-wise", so it just went to the first couple free spots.

MIDI_RXTX_RX_CTR	EQU	0x010
MIDI_RXTX_TX_CTR	EQU	0x011
Next is the main. These are edited pastes from the MB64 files. It actually uses some stuff from the midi_rxtx.inc file, but I stuck the stuff directly into the places where it gets called, to keep it in one spot for clarity. Thorsten has all of the calls commented pretty well, so you should be able to see what it used to do by looking in the original MB64 files. Sorry to have hacked it up like that, but I thought it might make it easier to see what was needed for just a blank skeleton with Rx/Tx lights. These MB64 copy/pastes are also missing some conditional stuff and have some variables replaced with their actual data (in this particular app). The MB64 has lots of ways different people can set it up, and needs to act accordingly, but these edits assume that you want MIDI monitor lights, and that you'll be using the first two DOUT pins for them. I'll just paste the functions from main where I actually inserted anything:
USER_Init
	;; define number of shift registers: for 128 IOs, we need
	;; 16 registers. Btw.: thats the maximum number of supported DIN/DOUTs
	movlw	3     ; I happened to only be using 3 SR's (24 buttons/lights)
	call	MIOS_SRIO_NumberSet

	;; define the update frequency (latency) of DIN/DOUTs in mS
	movlw	1 ; ms
	call	MIOS_SRIO_UpdateFrqSet
	return 

;;------------------------------------------------------------------------------ 

USER_MIDI_NotifyTx  
	movlw	15      ; there was a MIDI_RXTX_LED_DELAY variable here (#defined as 15ms)
	SET_BSR	MIDI_RXTX_TX_CTR
	movwf	MIDI_RXTX_TX_CTR, BANKED
	return

;;------------------------------------------------------------------------------ 

USER_MIDI_NotifyRx
	movlw	15   ; LED "on time" delay -same as above
	SET_BSR	MIDI_RXTX_RX_CTR
	movwf	MIDI_RXTX_RX_CTR, BANKED
	return
Alright, then here's a piece of my junk (not edited from MB64 source). It just spits out a C note on/off when the buttons get hit (so there will be some actual MIDI going out). Also goes in the main.asm:
USER_DIN_NotifyToggle

;; first it checks to see whether the toggle was pushed or unpushed 
;; (button state is in MIOS_PARAMETER2)

	IFCLR	MIOS_PARAMETER2, 0, goto ON
OFF
        call    MIOS_MIDI_BeginStream
        movlw   0x80
        call    MIOS_MIDI_TxBufferPut
        movlw	0x3C
        call    MIOS_MIDI_TxBufferPut
        movlw   0x7F
        call    MIOS_MIDI_TxBufferPut
        call    MIOS_MIDI_EndStream
        return
ON    
        call    MIOS_MIDI_BeginStream
        movlw   0x90
        call    MIOS_MIDI_TxBufferPut
        movlw	0x3C
        call    MIOS_MIDI_TxBufferPut
        movlw   0x7F
        call    MIOS_MIDI_TxBufferPut
        call    MIOS_MIDI_EndStream
	return
Last paste into main is this. This one is where the two actual DOUT numbers (0x00 and 0x01) replaced the MIDI_RXTX_RX_LED and MIDI_RXTX_TX_LED stuff:
USER_SR_Service_Prepare
	;; Decrement Rx counter if != 0
	SET_BSR	MIDI_RXTX_RX_CTR
	movf	MIDI_RXTX_RX_CTR, W, BANKED
	skpz
	decf	MIDI_RXTX_RX_CTR, F, BANKED

	;; Decrement Tx counter if != 0
	SET_BSR	MIDI_RXTX_TX_CTR
	movf	MIDI_RXTX_TX_CTR, W, BANKED
	skpz
	decf	MIDI_RXTX_TX_CTR, F, BANKED

	;; 
	;; remove the code below if you don't want to use LEDs to
	;; indicate the counter state
	;; 

	;; set the Rx LED depending on counter state
	SET_BSR	MIDI_RXTX_RX_CTR
	movf	MIDI_RXTX_RX_CTR, W, BANKED
	skpz
	movlw	0x01
	movwf	MIOS_PARAMETER1
	movlw	0x00     ;my dout pin for MIDI receive
	call	MIOS_DOUT_PinSet

	;; set the Tx LED depending on counter state
	SET_BSR	MIDI_RXTX_TX_CTR
	movf	MIDI_RXTX_TX_CTR, W, BANKED
	skpz
	movlw	0x01
	movwf	MIOS_PARAMETER1
	movlw	0x01     ;my dout pin for MIDI transmit
	call	MIOS_DOUT_PinSet

	return

I hope some of that can help you figure out what may have been missing (and that you can use actual asm code in your skeleton 8) ). It dumped and worked OK at the studio, and on another box here.

Take Care,

George

 

Link to comment
Share on other sites

Hi George,

thanks again for your long instructions!

It was really helpful, nice and compact as it was!

I spent half a day copying/pasting lines into the c skeleton and I really managed to get the midi out led working nicely! I was amazed :-)

Anyhow, even after hours of trying, the midi in led still had a strange behaviour as it somehow interferes with our other shift registers, that we set in C (kinda complicated to explain fully), and was on all the time. I tried thousands of variants, but still no luck...

so we decided in our project group that it is not worth the extra tryout time, ripped apart some old midi equipment (midisplitter of some sort) for the 74HC00 of the LTC Module and just build that anyway . Works fine now  :)

Anyhow, thanks again and good luck!

Christian

Link to comment
Share on other sites

Good to hear! :)

Maybe someone else could figure out what the cause of the conflict was on the input monitor for you, but it sounds like you're OK with the LTC anyway.

It would be neat to see what your app is (and what it does) when you're done. I'm still fighting with a "baby app" in MIOS/assembler per Thorsten's suggestion. I'm trying to get MIDI i/o with basic buttons and LEDs for audio mixer stuff, but starting from scratch, with no MB64 app or anything, leaves a lot to be done. :'(

George

Link to comment
Share on other sites

Hi George,

we will create a page in the wiki for our app in about a week, when the project is done. It is a university project, and it will be called Midi Box GLCD, cause it has two cores where each drives one GLCD in vertical mode. Basically it will be a programmable controller that can display parameter names beside the knob you are tweaking and is designed specially for controlling synthesizers (although it is suitable for every other app as well). It has a special menu structure for accessing 16 devices and 1024 parameters for each device. Also it should read out the edit buffer of the synths, tweak it and send it back again to change the sound program, so it will have extended sysex capabilities.

But we are having an "easy life" programming in C, and I have great respect of anyone trying to tame that Midi beast with assembler, so good luck with your app as well ;)

Well, still a lot of debugging to be done in that following week, so I better get back to work  :)

Best regards,

Christian

Link to comment
Share on other sites

Basically it will be a programmable controller that can display parameter names beside the knob you are tweaking and is designed specially for controlling synthesizers (although it is suitable for every other app as well).

Man, wasn't expecting that. :o

Sounds awesome. Like a hardware MIDI/SysEx editor? I look forward to reading about it.

Hope everything turns out perfect,

George

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...