jmamma / MCL

MCL firmware for the MegaCommand MIDI Controller.
BSD 2-Clause "Simplified" License
48 stars 9 forks source link

MegaCom basic framework #128

Closed yatli closed 3 years ago

yatli commented 4 years ago

Work in progress. We can build a lot of things upon this:

enum comserver_id_t {
  COMSERVER_EXTUI, // button input, ext screen etc.
  COMSERVER_FILESERVER, // simple FTP-ish protocol
  COMSERVER_EXTMIDI, // note in, CV out etc.
  COMSERVER_MAX,
  COMSERVER_DRAIN_INVALID = 0xFF
};
yatli commented 4 years ago

To eval the idea I'll implement file server and usb midi.

jmamma commented 4 years ago

it would be good if the pc side application ran as a vst.

yatli commented 4 years ago

it would be good if the pc side application ran as a vst.

Windows only?

jmamma commented 4 years ago

it would be good if the pc side application ran as a vst.

Windows only?

I hope not :grin:

yatli commented 4 years ago

Then this: https://juce.com/ ?

jmamma commented 4 years ago

Yep. that's what I was thinking.

Been a while since i've looked into vst multi platform tech.

yatli commented 4 years ago

Did your ISP just accidentally turn the "retrig" knob? :D

yatli commented 4 years ago

... or make it a VST host?

MD -> Kit Edit -> scroll down to the VST menu

yatli commented 4 years ago

finished the ack/resend/timeout transportation layer. MegaCom is half-duplex so it's easier than Tcp( will test with a hello world server tomorrow.

yatli commented 4 years ago

couldn't get UART0 RX interrupt to work... thoughts?

jmamma commented 4 years ago

The UART0 ISRs are being managed by the Arduino serial libraries.

It's how Serial.begin works.

See:

./HardwareSerial0.cpp

yatli commented 4 years ago

couldn't get UART0 RX interrupt to work... thoughts?

please disregard. it doesn't work because non of the tools I tried work at 250kbps sending hex (

The arduino serial monitor does allow me to reach the ISR, but no hex input. The other tools I tried (moserial, YAT, minicom) either doesn't have hex, or doesn't support 250kbps

yatli commented 4 years ago

image

Even works when the sequencer is running. Fully asynchronous.

yatli commented 4 years ago

Fact: running the sequencer at the grid page, file download speed = sorta 20KB/s It gets more bandwidth when opening the setting page and navigate to SYSTEM with only 2 entries displayed, or the CHROMATIC page which is lazily drawn :D :D :D

yatli commented 4 years ago

Funny. I got a steady repro of the BPM drifting problem (while transferring file):

jmamma commented 4 years ago

Sounds the like the serial ISR is hogging the cpu not allowing the MIDI or TIMER ISRS to execute. Lowering the baud will probably solve this.

yatli commented 4 years ago

It also raises tempo without file transferring. What kind of magic is this 🤔

jmamma commented 4 years ago

If you don't enable*** all ISR sei() before the sequencer ISR runs, same thing happens. The tempo increases. This is likely because the clock counters are not increasing.

So perhaps something similar is happening here?

yatli commented 4 years ago

oh ok. so it's like, something in the menu system blocked the ISR for a bit of time?

jmamma commented 4 years ago

Shouldn't be.

The only thing blocking the timer IRSs should be other ISRs or if you explicitly disable interrupts in your code.

jmamma commented 4 years ago

Is data hitting UART0 when idle?

yatli commented 4 years ago

no. ISR standing by.

jmamma commented 4 years ago

you sure?

yatli commented 4 years ago

yeah pretty sure. host is doing nothing if I don't click the UI.

jmamma commented 4 years ago

My suspicion is that one of your conditional statements is passing unexpectedly and is triggering a call to the ring buffer code that is using USE_LOCK() / SET_LOCK()

--

Or there is continuous data on the UART0 causing the isr to be triggered.

yatli commented 4 years ago

Let me try this on the dev branch.

yatli commented 4 years ago

That's a repro. dev branch. :p

jmamma commented 4 years ago

That's a repro. dev branch. :p

You seeing tempo drift in dev branch?

yatli commented 4 years ago

Yeah. Just do a few rounds of the menu thing.

jmamma commented 4 years ago

Yeah. Just do a few rounds of the menu thing.

do what now?

jmamma commented 4 years ago

Just flashed dev branch. I'm not seeing any tempo drift. (from grid page tempo display)

yatli commented 4 years ago
jmamma commented 4 years ago

When MENU -> MD settings are changed. Global settings are sent back to the MD. This includes tempo.

I think there is an edge case where the global settings tempo, is not up to date, so the MD tempo gets shifted to an older value... instead of current.

yatli commented 4 years ago

Not likely. Why does it keep increasing?

jmamma commented 4 years ago

I'm not seeing the increase you're reporting then.

yatli commented 4 years ago

A simpler repro without involving the GridPage init/cleanup:

jmamma commented 4 years ago

Not showing up for me.

Justins-MacBook-Pro-4:megacommand jmammarella$ md5 main.hex
MD5 (main.hex) = bc67731518f844109024bbdf1be6a3c0
Justins-MacBook-Pro-4:megacommand jmammarella$ git status . | head -n 20
On branch dev
Untracked files:
Justins-MacBook-Pro-4:megacommand jmammarella$ git log | head -n 20
commit cf7b6e5ca351760162b5e785b4dc34a2b6e5e5e2
Merge: 4408431 73dd675
Author: jmamma <jmamma@gmail.com>
Date:   Tue Aug 11 12:36:09 2020 +1000

    Merge pull request #125 from jmamma/size_reduce_2

    Size reduce attempt 2
yatli commented 4 years ago

Alright. Same as the last time I opened the case. We can discard the issue here I guess.

jmamma commented 4 years ago

What happened last time ?

Bad compile ?

yatli commented 4 years ago

The timeline:

  1. https://github.com/jmamma/MIDICtrl20_MegaCommand/issues/4
  2. https://github.com/jmamma/MIDICtrl20_MegaCommand/pull/47#issuecomment-546681967
  3. https://github.com/jmamma/MIDICtrl20_MegaCommand/pull/47#issuecomment-546684139
  4. https://github.com/jmamma/MIDICtrl20_MegaCommand/issues/65

So, just some weird states going on in my MD. Maybe related to other issues (last time it was https://github.com/jmamma/MIDICtrl20_MegaCommand/issues/98)

yatli commented 4 years ago

Porting https://github.com/v-yadli/paw-01 over to test realtime messages.

jmamma commented 4 years ago

What is/was paw-01?

yatli commented 4 years ago

Oh that.

image

image

yatli commented 4 years ago

image

A synth that browses the internet(

jmamma commented 4 years ago

Is that a DAW or a 💣?

yatli commented 4 years ago

which red wire again?

yatli commented 4 years ago

Took me quite a while to make it stable and not dropping frames, but here it is, a 1x2 midi bridge.

Host: https://github.com/yatli/Camelotia/tree/main/src/MegaCom.MidiHost

Requires two virtual midi devices, "MegaCommandPort1" and "MegaCommandPort2"

yatli commented 4 years ago

Also, debug messages are framed into one kind of message. So the debugging capabilities can be retained (or even improved)

yatli commented 4 years ago

With megacom framed debug (and custom formatter): Sketch uses 221460 bytes (87%) of program storage space. Maximum is 253952 bytes.

With standard Serial.print, upstream dev branch: Sketch uses 218962 bytes (86%) of program storage space. Maximum is 253952 bytes.

(Cannot compile megacom-enabled debug version with Serial because of uart0 conflicts)

yatli commented 4 years ago

Hook up the midi host and debug:

image