Writing a Sequencer, outputting MIDI messages?
Moderators: MattKingUSA, khz
Writing a Sequencer, outputting MIDI messages?
I'm trying to write a simple MIDI sequencer on OpenSUSE Tumbleweed, at the moment, writing in C++. To start with I was just outputting text messages to the terminal window to see that things were behaving, as I'd expect them to. Having gotten that far I decided that I'd try outputting MIDI messages that I might be able to connect to a simple synth like qsynth.
I haven't gotten to installing qsynth as yet, probably need Jack and a few things to get all that working. For the moment I found a library, RtMidi [1] which looked like a good way to simplify things. OpenSUSE Tumbleweed had a package for install, (rtmidi-devel) which got me the necessary header file to compile against, but I can't see any library, '*.so' file, to link against.
So there's a number of questions, firstly is there a better way then using RtMidi [1], which is more 'standard'? Instead of chasing a non existent library for OpenSUSE Tumbleweed I see that RtMidi is on github so I guess I can just pull that into my source tree and compile and link from there. The first question though is have I gone down the wrong route to doing this with RtMidi?
[1] http://www.music.mcgill.ca/~gary/rtmidi/
I haven't gotten to installing qsynth as yet, probably need Jack and a few things to get all that working. For the moment I found a library, RtMidi [1] which looked like a good way to simplify things. OpenSUSE Tumbleweed had a package for install, (rtmidi-devel) which got me the necessary header file to compile against, but I can't see any library, '*.so' file, to link against.
So there's a number of questions, firstly is there a better way then using RtMidi [1], which is more 'standard'? Instead of chasing a non existent library for OpenSUSE Tumbleweed I see that RtMidi is on github so I guess I can just pull that into my source tree and compile and link from there. The first question though is have I gone down the wrong route to doing this with RtMidi?
[1] http://www.music.mcgill.ca/~gary/rtmidi/
- SpotlightKid
- Established Member
- Posts: 260
- Joined: Sun Jul 02, 2017 1:24 pm
- Has thanked: 57 times
- Been thanked: 61 times
Re: Writing a Sequencer, outputting MIDI messages?
If you want cross-platform support RtMidi is a good choice. If you are only developing for Linux, using the ALSA or JACK API directly is not that hard either.
RtMidi can be used by just dropping the RtMidi.cpp and .h file into your project and compiling it in statically. Details are at the bottom of the home page.
The debian package probably just install the static library (librtmidi.a or similar). You should be able to just add that to the list of objects for your linking stage.
RtMidi can be used by just dropping the RtMidi.cpp and .h file into your project and compiling it in statically. Details are at the bottom of the home page.
The debian package probably just install the static library (librtmidi.a or similar). You should be able to just add that to the list of objects for your linking stage.
Re: Writing a Sequencer, outputting MIDI messages?
Thank you SpotlightKid.
I actually headed off and did what you suggested, pulling the two RtMidi files into my project and just compiling from there. Unfortunately when I executed the example MIDI out section of code I got the result:
MidiOutDummy: This class provides no functionality.
There are 0 MIDI output ports available.
I'm guessing that if I plugged in a USB MIDI cable that result would change, but I was hoping to have a connection appear in Jack so that I could connect that to qsynth. I guess Jack API is the way to go, so I'll do a bit of searching. Kinda answers my questions about RtMidi though.
Thanks again.
I actually headed off and did what you suggested, pulling the two RtMidi files into my project and just compiling from there. Unfortunately when I executed the example MIDI out section of code I got the result:
MidiOutDummy: This class provides no functionality.
There are 0 MIDI output ports available.
I'm guessing that if I plugged in a USB MIDI cable that result would change, but I was hoping to have a connection appear in Jack so that I could connect that to qsynth. I guess Jack API is the way to go, so I'll do a bit of searching. Kinda answers my questions about RtMidi though.
Thanks again.
- SpotlightKid
- Established Member
- Posts: 260
- Joined: Sun Jul 02, 2017 1:24 pm
- Has thanked: 57 times
- Been thanked: 61 times
Re: Writing a Sequencer, outputting MIDI messages?
You have to set the right compiler defines. Again, read the "Compiling" section at the end of the RtMidi homepage.
- SpotlightKid
- Established Member
- Posts: 260
- Joined: Sun Jul 02, 2017 1:24 pm
- Has thanked: 57 times
- Been thanked: 61 times
Re: Writing a Sequencer, outputting MIDI messages?
For that you need to compile in JACK support (see answer above) and then use the openVirtualPort method of you MidiOut instance.
- milkii
- Established Member
- Posts: 477
- Joined: Tue Jan 05, 2016 9:08 am
- Location: Edinburgh
- Has thanked: 92 times
- Been thanked: 91 times
- Contact:
Re: Writing a Sequencer, outputting MIDI messages?
A few related options on https://wiki.thingsandstuff.org/MIDI#C_.2F_C.2B.2B
they/them ta / libreav.org / wiki.thingsandstuff.org/Audio and related pages / gh
Re: Writing a Sequencer, outputting MIDI messages?
Sorry I flew though that virtual port section, of documentation, and only when you pointed it out did the penny drop. So thanks again. It works have a MIDI port showing up in qjackctl!
-
- Established Member
- Posts: 15
- Joined: Sat Nov 15, 2014 1:44 am
- Has thanked: 1 time
- Been thanked: 5 times
Re: Writing a Sequencer, outputting MIDI messages?
Maybe a stretch, but is there something of value you could learn/use from:
http://www.mikekohn.net/music/drumsplusplus.php
http://www.mikekohn.net/music/drumsplusplus.php
Re: Writing a Sequencer, outputting MIDI messages?
Here's a tutorial I wrote about the rawmidi API.
- Attachments
-
- rawmidi.zip
- (87.22 KiB) Downloaded 141 times
Author of BackupBand at https://sourceforge.net/projects/backupband/files/
My fans show their support by mentioning my name in their signature.
- digitsun
- Established Member
- Posts: 91
- Joined: Thu Mar 04, 2021 1:50 am
- Has thanked: 13 times
- Been thanked: 14 times
Re: Writing a Sequencer, outputting MIDI messages?
Congratulations for your effort @jwhitmore.
I consider that in GNU/Linux audio space lacks a good and dedicated (only) MIDI sequencer. Let me explain the actual situation.
The most important thing is keep it simple: only MIDI.
I consider that in GNU/Linux audio space lacks a good and dedicated (only) MIDI sequencer. Let me explain the actual situation.
- Ardour has a unique MIDI style: awful. But Ardour has a good performance, is stable, plugin friendly, has a lot of functionalities (for audio) and huge community.
- Qtractor follows the standard MIDI workflow, has a good performance and the plugin compatibility is not so good like Ardour. The problem is that Qtractor don't has all the possibilities of Ardour, also the development depends of only one man: Rui.
- Muse is good with MIDI and audio, but, again, Ardour is more complete (consequently has a big community and big development team)
- Zrythm is still apha.
The most important thing is keep it simple: only MIDI.
- Linuxmusician01
- Established Member
- Posts: 1542
- Joined: Mon Feb 23, 2015 2:38 pm
- Location: Holland
- Has thanked: 772 times
- Been thanked: 142 times
Re: Writing a Sequencer, outputting MIDI messages?
@digitsun: and there's good old Seq24 as well. Nowadays you need very strong reading glasses for it's interface but it does one single job without distractions: sequence Midi (notes).
- SpotlightKid
- Established Member
- Posts: 260
- Joined: Sun Jul 02, 2017 1:24 pm
- Has thanked: 57 times
- Been thanked: 61 times
- Linuxmusician01
- Established Member
- Posts: 1542
- Joined: Mon Feb 23, 2015 2:38 pm
- Location: Holland
- Has thanked: 772 times
- Been thanked: 142 times
Re: Writing a Sequencer, outputting MIDI messages?
Thanks! There's also Seq64 which is in the KXStudio repository. I think they're all the same. Maybe some of 'm have a scaling option for the interface if you've got a large screen.
Re: Writing a Sequencer, outputting MIDI messages?
So I have made progress on my sequencer and I'm outputting MIDI messages which I'm connecting with Jack, running on pipewire, to QSynth.
The next question is how to schedule these MIDI messages accurately so that it's actually music. The scheduling is doing to depend on the tempo of the music but regardless needs to be accurate, to some level. I guess I could set up a regular expiring timer and fire messages on expiration. Set a timer for 24 times per quarter note, figuring out for tempo. That seems like the most obvious method and probably a good place to start.
The next question is how to schedule these MIDI messages accurately so that it's actually music. The scheduling is doing to depend on the tempo of the music but regardless needs to be accurate, to some level. I guess I could set up a regular expiring timer and fire messages on expiration. Set a timer for 24 times per quarter note, figuring out for tempo. That seems like the most obvious method and probably a good place to start.