Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chooseMidiPort method from utils.hpp does not work as intended #114

Open
pissalou opened this issue Aug 21, 2024 · 8 comments
Open

chooseMidiPort method from utils.hpp does not work as intended #114

pissalou opened this issue Aug 21, 2024 · 8 comments

Comments

@pissalou
Copy link

When running examples like midiout or midiclock_out, I am prompted to choose to open a virtual port or not and later to choose which port to open. In both cases, I have to type two characters and press enter to get my input read problem like demonstrated below:

$ ./build/midiout

Would you like to open a virtual output port? [y/N] NN
Output port #0: Midi Through Port-0
Output port #1: Synth input port (60756:0)
Output port #2: input
Output port #3: input

Choose a port number: 11

Then a sound is produced by virtual port 1 (fluidsynth)

@jcelerier
Copy link
Member

jcelerier commented Aug 21, 2024

That's strange, what terminal / shell / environment is this with ? I don't see this behaviour here under linux with any terminal (ubuntu 24.04)

@jcelerier
Copy link
Member

to be honest I'd like more to have these utilities read their argument from the command line instead, what'd you think ?

@pissalou
Copy link
Author

I am using the default bash terminal in ubuntu 23.04. I can also see the same behavior when I run this snippet in an online editor (https://www.programiz.com/online-compiler/2nScotIFIm64b). I totally agree command-line arguments would be better.
midiout -a alsa_seq -p 123 would totally do it for me.

@jcelerier
Copy link
Member

jcelerier commented Aug 22, 2024

that's definitely weird, I don't have this behaviour either on the link you shared? (tried on fedora and archlinux). I had added the "cin.ignore()" because otherwise the input would be skipped.
image

@pissalou
Copy link
Author

Ok, in this example it is not so obvious but I believe the keyHit variable is empty if you type just one character. You see "y" printed on the output when you type it but for me it is the terminal acting like a passthrough (midi through is an even better analogy) If I typed a long word like "guacamole", I would see the variable is set to "uacamole", skipping the first character. I slightly modified the snippet to make it clearer what is the value of keyHit variable after calling getline: https://www.programiz.com/online-compiler/8HdmFdxe6L8ci

@jcelerier
Copy link
Member

implemented in master ; I've looked into it but it's a bit too much work to backport to 4.x though

@pissalou
Copy link
Author

I have tested the midiout example on master and can confirm it is working with command-line arguments. It could be useful to document that the value for the input/output port is the 0-based index as returned by midiprobe. In my case, "-p 1" means the 2nd output for alsa_seq:

$ midiprobe -o
Displaying ports for: ALSA (sequencer)
1 MIDI input sources:
 - [ client: 94711197311536, port: 60129542144, device: Midi Through, portname: Midi Through Port-0, display: Midi Through Port-0]
2 MIDI output sinks:
 - [ client: 94711197311536, port: 60129542144, device: Midi Through, portname: Midi Through Port-0, display: Midi Through Port-0]
 - [ client: 94711197311536, port: 549755813888, device: FLUID Synth (94690), portname: Synth input port (94690:0), display: Synth input port (94690:0)]
...

$ midiout -a alsa_seq -o 1
Opening Synth input port (94690:0)

@jcelerier
Copy link
Member

Added indexes to the midiprobe output so that it is less confusing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants