Can Stdin be non-blocking?

Started by Miasma, September 11, 2020, 11:02:40 AM

Previous topic - Next topic

Miasma

I've been trying to make a loop to read from Stdin, using FGetc(Stdin), but it seems to be blocking. Is there a non-blocking way I can read data from the terminal input?

I'm working on making a MIDI input (MIDI over serial) to the Vectrex so it can be used as an instrument.

Vectrex32

I'm sorry I didn't respond to this earlier. I usually get notifications when a new thread is posted. I don't know why I didn't this time. Thanks for pinging me with an e-mail.

Currently, there's no way to "peek" at whether there's a character available on stdin. But I might be able to add it as a feature. Can you tell me more about your application?

- Bob

Miasma

Thanks for the info Bob, I guessed that a notification probably hadn't gone off!

I'd like to send MIDI data via the serial connection. Pretty standard three byte groups describing note on/off, pitch and velocity. The Vectrex32 would then interpret these and instruct the AY-3 using the Sound command accordingly.

A very basic version of this could work with the existing functionality, but I'm keen to have software envelopes and an arpeggiator (and maybe even generated visuals on screen), which means I need a free running event loop to handle all this. I have this up and running so far, but just without a way to externally input sounds.

Previous people have done this and used the button inputs 1-4 on both controllers to send 8-bit values, but I haven't got this to work so far, and thought it would be great if I could just use the serial cable to the Vectrex32.