0

I've got a python program that reads input from a midi device and produces text output derived from the incoming MIDI messages. As a simple example, let's say that it's simply mapping MIDI Note On events to note names e.g. note_on(60) --> 'C'. I'd like to capture the output in real time to a GVIM (actually MacVim) window without losing the ability to edit the output with a computer keyboard, i.e. I need for MacVim to read from both an external program and from the computer keyboard.

What's the cleanest general way to implement that under the assumption that the MIDI reader will never generate output while I'm trying to type and vice-versa? I'd prefer to be able to give the python script a filename and have it start MacVim with that file open, but doing it with shell commands or connecting from within MacVim would also be acceptable.

Mike Ellis
  • 1,120
  • 1
  • 12
  • 27
  • You are asking a lot. Can you show us what you have written already? Or explain why you think MacVim (a single-threaded program with no built-in asynchronous support) is the right tool for the job? – romainl Apr 19 '14 at 15:57
  • @romainl 1. I've tried using python's pty and subprocess modules. 2. vim has been my preferred editor for over 20 years -- the editing commands are pretty much hard-wired into my fingers. Moreover, I have some useful vim extensions that make it easy for me to add rhythm info to pitch names to produce LilyPond script. 3. As to asking a lot, I'm not looking for anyone to write the code for me. I just need to know if it's possible and if so, how. – Mike Ellis Apr 19 '14 at 16:21

1 Answers1

0

Based on the answers to How do I read and write repeatedly from a process in vim?, it looks like vim does not easily support 2 input sources asynchronously. I'll leave the question open in case someone happens to know an elegant solution, but for now it seems like the best approach is have my python program write to a normal file, use 'tail -f' for real-time viewing, and edit afterwards.

Community
  • 1
  • 1
Mike Ellis
  • 1,120
  • 1
  • 12
  • 27